• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ [TFS 1.3] How to Change Monster's Spell In-Game?

Yan18

Member
Joined
Jun 14, 2014
Messages
104
Solutions
3
Reaction score
17
Hello guys!

Is there any event or function to change monster's spells in-game (real time, after loading distro)? Is it possible?

For example, a Lava-Golem has Fireball spell and a player click in a lever in a quest, and after that, the Lava-Golem at the area lose the Fireball spell.
 
You can add a spell that checks for global storage, then place special lava golems there, the lever will just set the global storage.
 
Cool, but how could I add Spell in a monster except monster.xml?

Attack names link to spells, etc:
massive_energy_elemental.xml
XML:
		<attack name="massive energy elemental electrify" interval="2000" chance="20">
			<attribute key="areaEffect" value="yellowspark" />
		</attack>

Links to: (through monster attack name -> spell instant name)
spells.xml
XML:
<instant name="massive energy elemental electrify" words="###4" aggressive="1" blockwalls="1" needtarget="0" needlearn="1" script="monster/massive_energy_elemental_electrify.lua" />

Which links to Lua file:
massive_energy_elemental_electrify.lua
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BLOCKHIT)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

function onCastSpell(creature, variant)
	for _, target in ipairs(combat:getTargets(creature, variant)) do
		creature:addDamageCondition(target, CONDITION_ENERGY, DAMAGELIST_VARYING_PERIOD, 25, {10, 12}, 10)
	end
	return true
end

Where you can modify onCastSpell to only cast the spell if a global variable is set, which you can configure by toggling a lever in-game.

In the same fashion, you can create the spell in revscriptsys, and link to it using the attacks table, etc:
Lua:
monster.attacks = {
	{name = "melee", attack = 130, skill = 70, effect = CONST_ME_DRAWBLOOD, interval = 2*1000},
	{name = "massive energy elemental electrify", chance = 20, interval = 2*1000, effect = CONST_ME_YELLOW_RINGS}
}
 
Attack names link to spells, etc:
massive_energy_elemental.xml
XML:
        <attack name="massive energy elemental electrify" interval="2000" chance="20">
            <attribute key="areaEffect" value="yellowspark" />
        </attack>

Links to: (through monster attack name -> spell instant name)
spells.xml
XML:
<instant name="massive energy elemental electrify" words="###4" aggressive="1" blockwalls="1" needtarget="0" needlearn="1" script="monster/massive_energy_elemental_electrify.lua" />

Which links to Lua file:
massive_energy_elemental_electrify.lua
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BLOCKHIT)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

function onCastSpell(creature, variant)
    for _, target in ipairs(combat:getTargets(creature, variant)) do
        creature:addDamageCondition(target, CONDITION_ENERGY, DAMAGELIST_VARYING_PERIOD, 25, {10, 12}, 10)
    end
    return true
end

Where you can modify onCastSpell to only cast the spell if a global variable is set, which you can configure by toggling a lever in-game.

In the same fashion, you can create the spell in revscriptsys, and link to it using the attacks table, etc:
Lua:
monster.attacks = {
    {name = "melee", attack = 130, skill = 70, effect = CONST_ME_DRAWBLOOD, interval = 2*1000},
    {name = "massive energy elemental electrify", chance = 20, interval = 2*1000, effect = CONST_ME_YELLOW_RINGS}
}
Thanks for explanation!

I don't know if I didn't explain my doubt right, but, I wanna now if is possible to add an existing spell to a monster by a different way from monster.xml.

For example, I have a global storage, and in the event onSpawn in Data/Events/Monster.lua I add an existing spell in monsters spawning.
 
Thanks for explanation!

I don't know if I didn't explain my doubt right, but, I wanna now if is possible to add an existing spell to a monster by a different way from monster.xml.

For example, I have a global storage, and in the event onSpawn in Data/Events/Monster.lua I add an existing spell in monsters spawning.
We've been over this already. Why did you create a new thread for essentially the same question?
 
We've been over this already. Why did you create a new thread for essentially the same question?
Both topics looks like similar, but the topics aren't equals, the another topic I had a doubt about how to add spell in MonsterType and this topic my doubt is how to add spell in a monster in any event, but when I created this topic I didn't understand if was possible add spell in a different way by monster.xml, then I created the another topic.
 
Back
Top