Hi,
i'm experiencing an unusual issue with a script, don't know if really related to timer, for sure is related to time.
I have a script that checks if a monster is dead and then spawn a blocker. Problem is that it take from 1 to 3 seconds to spawn that blocker after monster is dead. More weird is that with same timer and similar script (check if a monster is hit then change his position) it works perfectly.
Anyone knows a reason why this happens?
PS: i need this to prevent monsters to move freely but i need them to fire arrows freely. So if there is a way to achieve that i appreciate any solution (tryed to modify a blocker object with no results).
slow timer issue [SOLVED]
slow timer issue [SOLVED]
Last edited by Granamir on Mon Mar 16, 2015 12:14 pm, edited 1 time in total.
Re: slow timer issue
Without seeing your script, I can't think of anything off the top of my head.
However, you can disable a monster's movement by unchecking the "move" box and it will do everything else as normal. Not sure if this is exactly what you're trying to do...
However, you can disable a monster's movement by unchecking the "move" box and it will do everything else as normal. Not sure if this is exactly what you're trying to do...
Re: slow timer issue
Yep i disabled movement for first row, archers, but behind them there is a melee row and those need to move.
Btw here is my code:
a timer, set to 0.001, is linked to that function
... if i link same timer to this code:
it works perfectly.
Btw here is my code:
Code: Select all
function blockerScale()
for i=1, 3 do
local m = findEntity("archer_" .. i)
if not m then
local b = findEntity("bloccaScale_" .. i)
if not b then
spawn("blocker", 6, 4, i+27, 3, 0, "bloccaScale_" .. i)
print("blocco " .. i .. "fuori")
end
end
end
end... if i link same timer to this code:
Code: Select all
function mostriGradino()
for i=1, 4 do
local m = findEntity("mostro_" .. i)
if m ~= nil then
local x, y = m:getPosition()
if (x == 13 or x == 14) and (y == 14 or y == 15) then
m:setWorldPositionY(1.3)
else
end
else
end
end
endRe: slow timer issue
Hmmm, it looks like a monster's entity isn't destroyed immediately upon it's death. This is probably necessary for onDie hooks to work correctly (using one of those would be one potential solution).
You can use m.monster:isAlive() to check in your script with minimal changes though - probably the easiest solution.
You can use m.monster:isAlive() to check in your script with minimal changes though - probably the easiest solution.
Re: slow timer issue
I'm pretty sure it's not necessary for onDie hooks but it is the best way to handle the visual effects on death (particles and light, probably the 3D sound source too).
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: slow timer issue
I did something similar, where I needed to check the status of pressure plates in a room when a Monster Boss died. If they are not depressed then the Boss respawns, otherwise other fun stuff happens.
If your blockers are always in a set series of locations, then Spawning them isn't necessary, simply Enable or Disable as needed. If the Blockers location is truly dynamic, then your code looks perfect.
The OnDie Hook is best for checking the logic in this situation.
Below is a code snippet from my Monster Boss battle, hope it helps:
If your blockers are always in a set series of locations, then Spawning them isn't necessary, simply Enable or Disable as needed. If the Blockers location is truly dynamic, then your code looks perfect.
The OnDie Hook is best for checking the logic in this situation.
Below is a code snippet from my Monster Boss battle, hope it helps:
Code: Select all
function NewFireBoss()
local fireBoss;
do fireBoss = spawn("uggardian", party.level, 11, 15, 1, 0);
fireBoss.monster:addConnector("onDie", "script_entity_18","FireBossDeath")
fireBoss.monster:setLevel(3);
fireBoss.monster:setMaxHealth(600);
boss_fight_1.bossfight:addMonster(fireBoss.monster);
end
end
function FireBossDeath()
-- Check for conditions and respond to Boss Death
end
Re: slow timer issue
Thank you guys.
i'll try first easier solution ^_^
EDIT: ...and it works great. Again thank you guys.
i'll try first easier solution ^_^
EDIT: ...and it works great. Again thank you guys.