I have a script that makes a boulder fall on your head when you trigger a step on NPC. The boulder is always situated 6 squares above the step on NPC that triggers the script. There are 4 instances of the same NPC for "boulder", which happens to be NPC 5 in the list. Therefore, the 4 boulders are NPC 5,0 5,1 5,2 & 5,3. The step on NPCs that trigger the script sends an argument to the script based on the instance number of the boulder that I wish to fall. Here is what the scripts look like:
Code: Select all
script, hurtplayer, amount, begin
variable (damage)
damage := amount
#will hurt the player without killing them, reducing them to a minimum of 1 hp
if ( (get hero stat (me, stat:life, current stat) ) <= damage) #if players health is already less than the amount of damage to be dealt, reduce player's health to 1
then (
set hero stat(find hero (0), stat:life, (get hero stat (find hero (0), stat:life, current stat) -- (get hero stat (find hero (0), stat:life, current stat) -- 1) ) , current stat)
)
else (
#subtract damage amount of life from player
set hero stat(find hero (0), stat:life, (get hero stat (find hero (0), stat:life, current stat)--(damage) ), current stat)
)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
plotscript, rockfall, arg, begin
#variable (npcinstance)
#npcinstance := arg
suspend player
suspend NPCs
set NPC ignores walls (NPC reference (5, arg), true)
set NPC obstructs (NPC reference (5, arg), false)
#stop everything moving, allow the rock to fall through walls/other npcs/the hero
play sound (22, false, false)
walk npc (NPC reference (5, arg), down, 3)
wait for npc (NPC reference (5, arg) )
#do the check to see if you avoid the falling rock when it is halfway down
if (get hero stat (me,stat:agility, current stat) <= random (1,25) )
then (
walk hero (me, right, 1)
walk npc (NPC reference (5, arg), down, 3)
wait for npc (NPC reference (5, arg) )
play sound (21, false, false)
delete npc (NPC reference (5, arg) )
show text box (331)
wait for textbox
resume player
resume NPCs
)
else (
walk npc (NPC reference (5, arg), down, 3)
wait for npc (NPC reference (5, arg) )
play sound (23, false, false)
delete npc (NPC reference (5, arg) )
show text box (332)
wait for textbox
hurtplayer (10)
resume player
resume NPCs
)
end
Any help muchly appreciated!