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

Weird creatureEvent crashes

Deathaak

New Member
Joined
Jun 9, 2008
Messages
102
Reaction score
0
IncendiusDamaged.lua
Lua:
local spawn = {x = 648, y = 514, z = 7}
local curStorage = getStorage(35013)
local monster = "Essence of Incendius"

function onStatsChange(cid, attacker, type, combat, value)
	
	local hp = math.floor((getCreatureHealth(cid)/100000)*100)	
	
        if hp <90 then doCreateMonster(monster,spawn) end
	
	return true
end

I used to have more elaborate with spawns depending on the creatures health and storage value to not make it spawn more than 1.. but I've stripped it down quite a bit to stop it from crashing. (It doesn't matter what monster im trying to spawn it always crashes) But I'll paste it anyway:

essence of incendius.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Essence of Incendius" nameDescription="an essence of incendius" race="fire" experience="0" speed="200" manacost="0">
	<health now="1" max="1"/>
	<look type="49"/>
	<targetchange interval="5000" chance="8"/>
	<strategy attack="100" defense="0"/>
	<flags>
		<flag summonable="0"/>
		<flag attackable="0"/>
		<flag hostile="1"/>
		<flag illusionable="1"/>
		<flag convinceable="1"/>
		<flag pushable="0"/>
		<flag canpushitems="1"/>
		<flag canpushcreatures="0"/>
		<flag targetdistance="1"/>
		<flag staticattack="60"/>
		<flag runonhealth="0"/>
	</flags>
	<attacks>
	</attacks>
	<defenses armor="18" defense="20"/>
</monster>

It works to summon fine with /m essence of incendius

There must be something improper with doing doCreateMonster() from a statschange script or something..

Thankful for help
 
Ok. I fixed it by changing it to;

IncendiusDamaged.lua
Lua:
local spawn = {x = 648, y = 514, z = 7}
local curStorage = getStorage(35013)
local monster = "Essence of Incendius"
local hp = 0

function addMonster()
	doCreateMonster(monster,spawn)	
	return true
end

function onStatsChange(cid, attacker, type, combat, value)
	hp = math.floor((getCreatureHealth(cid)/100000)*100)      
        
	if (hp <90 and curStorage <1 ) then
		doSetStorage(35013, "1")
		addEvent(addMonster,1000*1)
	elseif (hp < 60 and curStorage == 1) then
		doSetStorage(35013, "2")
		addEvent(addMonster,1000*1)
	elseif (hp < 30 and curStorage == 2) then
		doSetStorage(35013, "3")
		addEvent(addMonster,1000*1)
	end
	return true
end

Did it crash cause of dataflood? Don't know much about this to be honest, any decent answer to why it crashed is still wanted.
 
Ok. The storage values are going apeshit to be honest.

The game just reload updated storagevalues when I use the TFS clients reload Creature Events option, why? Is it meant to be this way?

Lua:
local spawn = {x = 648, y = 514, z = 7}
local curStorage = getStorage(35013)
local monster = "Essence of Incendius"
local hp = 0

function addMonster(storage)
	doCreateMonster(monster,spawn)
	return true
end

function onStatsChange(cid, attacker, type, combat, value)
	hp = math.floor((getCreatureHealth(cid)/100000)*100)      
      doBroadcastMessage("Current storageValue: "..curStorage..", health: "..hp.."%")
	if (hp <90 and curStorage <1 ) then
		doCreatureSay(cid, "Argh, I'll let lose the essence of me to destroy you!", TALKTYPE_MONSTER)
		doSetStorage(35013, "1")
		addEvent(addMonster,1000*2,1)
	elseif (hp < 60 and curStorage == 1) then
		doCreatureSay(cid, "Do not fail me, Essence!", TALKTYPE_MONSTER)
		doSetStorage(35013, "2")
		addEvent(addMonster,1000*2)
	elseif (hp < 30 and curStorage == 2) then
		doCreatureSay(cid, "Destroy them!", TALKTYPE_MONSTER)
		doSetStorage(35013, "3")
		addEvent(addMonster,1000*2)
	end
	return true
end

Code:
[08/01/2010 15:11:02] Reloaded actions.
[08/01/2010 15:11:04] Reloaded creature events.
[08/01/2010 15:11:14] > Broadcasted message: "Current storageValue: 0, health: 100%".
[08/01/2010 15:11:21] > Broadcasted message: "Current storageValue: 0, health: 98%".
[08/01/2010 15:11:23] > Broadcasted message: "Current storageValue: 0, health: 96%".
[08/01/2010 15:11:25] > Broadcasted message: "Current storageValue: 0, health: 94%".
[08/01/2010 15:11:27] > Broadcasted message: "Current storageValue: 0, health: 93%".
[08/01/2010 15:11:29] > Broadcasted message: "Current storageValue: 0, health: 91%".
[08/01/2010 15:11:31] > Broadcasted message: "Current storageValue: 0, health: 90%".
[08/01/2010 15:11:33] > Broadcasted message: "Current storageValue: 0, health: 88%".
[08/01/2010 15:11:35] > Broadcasted message: "Current storageValue: 0, health: 87%".
[08/01/2010 15:11:37] > Broadcasted message: "Current storageValue: 0, health: 85%".
[08/01/2010 15:11:39] > Broadcasted message: "Current storageValue: 0, health: 84%".
[08/01/2010 15:11:41] > Broadcasted message: "Current storageValue: 0, health: 83%".

At this point he's spamming Argh, I'll let lose the essence of me to destroy you! since storagevalue dont want to update.. so I do a Reload -> Creature Events.


Code:
[08/01/2010 15:11:39] > Broadcasted message: "Current storageValue: 0, health: 84%".
[08/01/2010 15:11:41] > Broadcasted message: "Current storageValue: 0, health: 83%".
[08/01/2010 15:13:31] Reloaded creature events.
[08/01/2010 15:13:33] > Broadcasted message: "Current storageValue: 1, health: 80%".
[08/01/2010 15:13:35] > Broadcasted message: "Current storageValue: 1, health: 80%".

Voila, storagevalue updated.. but totally useless for an in-game counter. So is there any other way I can go about with this? I want him to summon 3 monsters each at specific healths. No more, no less.

Thankful for help.
 
Last edited:
Code:
local spawn, monster, storage = {x = 648, y = 514, z = 7}, "Essence of Incendius", 35013

function addMonster(storage)
	doCreateMonster(monster,spawn)
end

function onStatsChange(cid, attacker, type, combat, value)
	local hp, curStorage = math.floor(getCreatureHealth(cid) / 100000 * 100), getGlobalStorageValue(storage)
	doBroadcastMessage("Current storageValue: "..curStorage..", health: "..hp.."%")
	if (hp < 90 and curStorage < 1 ) then
		doCreatureSay(cid, "Argh, I'll let lose the essence of me to destroy you!", TALKTYPE_MONSTER)
		setGlobalStorageValue(storage, 1)
		addEvent(addMonster,1000*2,1)
	elseif (hp < 60 and curStorage == 1) then
		doCreatureSay(cid, "Do not fail me, Essence!", TALKTYPE_MONSTER)
		setGlobalStorageValue(storage, 2)
		addEvent(addMonster,1000*2)
	elseif (hp < 30 and curStorage == 2) then
		doCreatureSay(cid, "Destroy them!", TALKTYPE_MONSTER)
		setGlobalStorageValue(storage, 3)
		addEvent(addMonster,1000*2)
	end
	return true
end
 
Of course..... Function doesn't reload new local values outside the function when the script is called? .... I'll remember to only declare static variables outside of the function

Thanks alot! (Also thanks for new way of declaring multiple variables! :eek:)
 
Back
Top