• 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!

Change monster looktype if HP is lower than

BugaS

Donżuan
Joined
Mar 12, 2009
Messages
1,219
Reaction score
9
Location
NYC
Hey!

I hope, that anyone can help me. I've got a monster and I want to add that when the monster will have 50% he change the looktype. Is it possible? TFS 0.4
 
I guess it can be done by monster spells, however I'm not sure how to store the original outfit, which means you will have to use two scripts and change it back manually.

Script 1:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

function onCastSpell(cid, var)
 
    local outfit = {lookType = 128, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0}
 
    if getCreatureHealth(cid) < getCreatureMaxHealth(cid) * 0.5 then
        doCreatureChangeOutfit(cid, outfit)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
    end
 
    return doCombat(cid, combat, var)
end
Script 2:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

function onCastSpell(cid, var)

    local min, max = 50, 100
    local outfit = {lookType = 130, lookHead = 100, lookBody = 100, lookLegs = 100, lookFeet = 100}
 
    if doCreatureAddHealth(cid, math.floor(math.random(min, max))) ~= 0 then
        if getCreatureHealth(cid) >= getCreatureMaxHealth(cid) * 0.5 then
            doCreatureChangeOutfit(cid, outfit)
        end
    end
 
    return doCombat(cid, combat, var)
end


Declare in yourmonster.xml
Code:
<!-- sort of onThink -->
<defense name="spell_one" interval="1000" chance="99"/>
<!-- Scripted heal -->
<defense name="spell_two" interval="5000" chance="15"/>


And in spells.xml
Code:
<instant name="spell_one"             words="###1" aggressive="0" blockwalls="0" selftarget="1" needlearn="1" script="test/script_one.lua"/>
<instant name="spell_two"             words="###2" aggressive="0" blockwalls="0" selftarget="1" needlearn="1" script="test/script_two.lua"/>
 
Last edited:
I guess it can be done by monster spells, however I'm not sure how to store the original outfit, which means you will have to use two scripts and change it back manually.

Script 1:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

function onCastSpell(cid, var)
 
    local outfit = {lookType = 127, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0}
 
    if getCreatureHealth(cid) < getCreatureMaxHealth(cid) / 2 then
        doCreatureChangeOutfit(cid, outfit)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
    end
 
     return doCombat(cid, combat, var)
end
Script 2:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

function onCastSpell(cid, var)

    local min, max = 50, 100
    local outfit = {lookType = 130, lookHead = 100, lookBody = 100, lookLegs = 100, lookFeet = 100}
 
    if doCreatureAddHealth(cid, math.floor(math.random(min, max))) then
        if getCreatureHealth(cid) >= getCreatureMaxHealth(cid) / 2 then
            doCreatureChangeOutfit(cid, outfit)
        end
    end
 
     return doCombat(cid, combat, var)
end


Declare in yourmonster.xml
Code:
<!-- sort of onThink -->
<defense name="spell_one" interval="1000" chance="99"/>
<!-- Scripted heal -->
<defense name="spell_two" interval="5000" chance="15"/>


And in spells.xml
Code:
<instant name="spell_one"          words="###1"  aggressive="0" needlearn="1" script="monster/script_one.lua"/>
<instant name="spell_two"          words="###2"  aggressive="0" needlearn="1" script="monster/script_two.lua"/>
Not work
 
Back
Top