How do I make an NPC look like it's jumping?
From OHRRPGCE-Wiki
[edit] Bobbing
You can make an npc jump or hop to show that they are speaking by moving an npc up a few pixels and back down again. It's really simple, all you have to do is use a line of script like this:
put npc (npc, npc pixel x (npc), npc pixel y (npc) -- pixels)
So take the above script and change a few things. Let's say I wanted to make NPC #2 (that's an NPC type ID, you can of course use npc references) jump up 3 pixels. I'd use this:
put npc (2, npc pixel x (2), npc pixel y (2) -- 3)
But this isn't all! That just moves the NPC up three pixels. Now we have to move him down again:
put npc (2, npc pixel x (2), npc pixel y (2) + 3)
Just remember to put a wait command between the two (I would recommend about 2 or 3 ticks).
So with the commands all together, the script looks like this:
put npc (2, npc pixel x (2), npc pixel y (2) -- 3) wait (2) put npc (2, npc pixel x (2), npc pixel y (2) + 3)
Of course, all this applies to heroes too.
[edit] Jumping
But what if I want an npc to jump around rather than just blip to show that they are speaking? This is quite a different question. Firstly, if we want an npc to jump 20 pixels up and back down smoothly, we need to use a couple of for loops.
variable (i) for (i, 1, 10) do, begin #rise 20 pixels in 10 smalls steps put npc (2, npc pixel x (2), npc pixel y (2) -- 2) wait (1) end wait (2) #stop at the top for (i, 1, 10) do, begin #go back down 10 smalls steps put npc (2, npc pixel x (2), npc pixel y (2) + 2) wait (1) end
However, this npc still ends up where it started. If you want to jump one tile forward, you need to move the npc a little in the correct direction each step by adding to the x and y components. Warning: using walknpc for this purpose could have undesired results.
You may have seen in the plotscript dictionary that there is a command set hero Z (hero, Z) and might ask what about trying to set npc Z. It would appear to be simpler.
Well the main problem is that "set npc Z" does't exist because individual npcs don't have a Z value. So you have to use the above method. You can of course use set hero Z for making heroes jump.
