I made this script, but as a beginning lua scripter I still find it hard to get some stuff working.
I tent to look at other scripts how they work and then try and create my script.
This is an example but I am clearly doing stuff wrong.
In this script I try and create a bit more interaction with a creature.
One of the problems you would perhaps know is that if you have a very long spell (wich has 10 seconds of animation or something) and then when he dies, your server will report a shitload of errors.
I tried to fix that also by approaching it like this.
I would like to someone to explaine me what is wrong and why.
Thanks in advance.
Regards,
Pasibun
I tent to look at other scripts how they work and then try and create my script.
This is an example but I am clearly doing stuff wrong.
In this script I try and create a bit more interaction with a creature.
One of the problems you would perhaps know is that if you have a very long spell (wich has 10 seconds of animation or something) and then when he dies, your server will report a shitload of errors.
I tried to fix that also by approaching it like this.
I would like to someone to explaine me what is wrong and why.
Thanks in advance.
Regards,
Pasibun
Lua:
function onStatsChange(cid, attacker, type, combat, value)
local t = {
["Raijin"] = {pos1 = { x = 884, y = 423, z = 9 , stackpos = 1 }},
["Raijin"] = {pos2 = { x = 881, y = 423, z = 9 , stackpos = 1 }},
["Minor Entity"] = {pos3 = { x = 884, y = 422, z = 9 , stackpos = 1 }},
["Minor Entity"] = {pos4 = { x = 884, y = 423, z = 9 , stackpos = 1 }},
["Minor Entity"] = {pos5 = { x = 884, y = 424, z = 9 , stackpos = 1 }},
["Minor Entity"] = {pos6 = { x = 884, y = 425, z = 9 , stackpos = 1 }}
}
local percentage = 1
local monsterHP = getCreatureHealth(cid)
local cidName = getCreatureName(cid)
local monsterHP = percentage / 100
if(monsterHP <= 80*percentage) and getCreatureStorage ~= 19200 then
doTeleportThing(cid, t[cidName].pos1)
doCreatureSetStorage(cid, 19200)
doCreateMonster(t[cidName].pos3)
doCreateMonster(t[cidName].pos4)
doCreateMonster(t[cidName].pos5)
doCreateMonster(t[cidName].pos6)
doSendMagicEffect(CONST_ME_MAGIC_BLUE)
end
if(monsterHP <= 70*percentage) and getCreatureStorage ~= 19201 then
doTeleportThing(cid, t[cidName].pos2)
doCreatureSetStorage(cid, 19201)
doSendMagicEffect(CONST_ME_MAGIC_BLUE)
end
if(monsterHP <= 60*percentage) and getCreatureStorage ~= 19202 then
doCreatureSetStorage(cid, 19202)
doSendMagicEffect(CONST_ME_MAGIC_BLUE)
end
if(monsterHP <= 50*percentage) and getCreatureStorage ~= 19203 then
doSendMagicEffect(CONST_ME_MAGIC_BLUE)
doCreatureSetStorage(cid, 19203)
end
if(monsterHP <= 40*percentage) and getCreatureStorage ~= 19204 then
doTeleportThing(cid, t[cidName].pos1)
doCreatureSetStorage(cid, 19204)
doCreateMonster(t[cidName].pos3)
doCreateMonster(t[cidName].pos4)
doCreateMonster(t[cidName].pos5)
doCreateMonster(t[cidName].pos6)
doSendMagicEffect(CONST_ME_MAGIC_BLUE)
doCreatureAddHealth(cidName, 20000)
end
if(monsterHP <= 30*percentage) and getCreatureStorage ~= 19205 then
doTeleportThing(cid, t[cidName].pos2)
doCreatureSetStorage(cid, 19205)
doSendMagicEffect(CONST_ME_MAGIC_BLUE)
end
if(monsterHP <= 20*percentage) and getCreatureStorage ~= 19206 then
doCreatureSetStorage(cid, 19206)
doSendMagicEffect(CONST_ME_MAGIC_BLUE)
end
if(monsterHP <= 10*percentage) and getCreatureStorage ~= 19207 then
doCreatureSetStorage(cid, 19207)
doSendMagicEffect(CONST_ME_MAGIC_BLUE)
end
if(monsterHP == 0) then
doSendMagicEffect(CONST_ME_MAGIC_BLUE)
end
end