 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
bmp
Joined: 10 Aug 2012 Posts: 4
|
Posted: Fri Aug 10, 2012 1:50 am Post subject: Help please I want the looping sparkles on my map |
|
|
I'm a complete newb at any kind of scripting... So any help would be appreciated!
I think this would probably be a VERY easy problem to solve with a bit more knowledge!
What I want to do is have perhaps multiple animations that loop on a map - like little sparkle animations. They would disappear when the player interacts with them if they've completed the tutorial, otherwise they would continue to loop.
So far:
I have several NPCs on the map (the sparkles) and a four frame walkabout animation of a sparkle. I can get NPCs to animate (although not looping) when they are interacted with but not on their own accord.
I thought it might be do-able with animated tiles, but I had no idea how to get rid of the sparkle tiles after the player interacted with them...
I've done the basic Plotscripting tutorial but trying to work out how the while loop works (and what to do with it!) has been the cause of frustration.
Here's what I have:
Code: | include, plotscr.hsd
plotscript, Spin, who=0, while true, do, begin
set NPC frame (who, 0)
wait (2)
set NPC frame (who, 1)
wait (2)
set NPC direction (who, right)
set NPC frame (who, 0)
wait (2)
set NPC frame (who, 1)
wait (2)
end |
|
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Fri Aug 10, 2012 5:39 am Post subject: |
|
|
Hi!
You write a while loop like this:
Code: | plotscript, Spin, who=0, begin
while (true) do, begin
set NPC direction (who, up)
set NPC frame (who, 0)
wait (2)
set NPC frame (who, 1)
wait (2)
set NPC direction (who, right)
set NPC frame (who, 0)
wait (2)
set NPC frame (who, 1)
wait (2)
end
end |
(You can write '(' and ')' instead of 'begin' and 'end', that's just a stylistic choice.)
But this script won't really work very well: if you leave the map, then it'll continue running, animating NPCs on the new map! You can change "while(true)" to "while(current map == 4)" (for example), but notice that it'll finish a loop before checking whether the map changes. Of course in this case that won't matter.
Also, only have copy of the script can run at a time. Unfortunately, these are things that plotscripting is quite bad at... You can still do this using a more complicated script; just ask if you don't like the other options:
I'll note that the classical way to create a four frame animation without any scripting is to draw the frames in the up, right, down, left directions of a walkabout and create an NPC with the movetype "always make right turns", then surround the npc on all sides by walls (or use a zone) to make it spin in place.
---
To get rid of an animated tile, overwrite it with a normal tile using the 'write map block command'. For example, if the animating tile is at x=12, y=25 on layer 1, and you want to overwrite it with the blank tile 0, you could run the following script from a textbox:
Code: | plotscript, remove sparklie 2, begin
write map block(12, 25, 0, 1)
end |
If you want to use a different tile, you can see the tile numbers in the 'tile picker' in the map editor, tilemap mode (press Enter).
However, unfortunately the effect of "write map block" isn't preserved in saved games. By default it's not saved when you leave the map either (to make it save, go to "Edit general map data" and set "Tile Data: Remember state when leaving". If you want to save the changes in saved games then you would have to set a tag and create a map autorun script which checks the tag and if so deletes the animation.
Using NPCs has the advantage that you can hide the NPC permanently by setting a tag, or using one-time-use NPCs. However, if place multiple copies of the NPC then all of them will disappear at once. You would need to create multiple nearly-duplicate NPC Definitions to get around that. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Fri Aug 10, 2012 6:22 am Post subject: |
|
|
The sparkles are just NPCs, and you want them to disappear when the hero talks to them, right? I think that could be done with no scripting.
Use the "Walk In Place" NPC walk type to keep them sparkling without moving around.
...unless I am misunderstanding what you intend. |
|
Back to top |
|
 |
bmp
Joined: 10 Aug 2012 Posts: 4
|
Posted: Fri Aug 10, 2012 6:51 am Post subject: |
|
|
Thank you very much for your helps!
I've solved the problem without any scripting! For some reason using zones to restrict the movement of the NPC turning did not occur to me... But this way I can have my non-moving NPCs with four animation frames.
The animation is a little bit too fast and reducing the speed seems to apply only to the walk speed more than the turning speed. But this is nitpicking and for now it suits my purposes.
To get it perfect, I'd really need to use complicated scripts. And if I start to try an use complicated scripts this early without fully understanding plotscripting I will probably end up tying myself in knots. I will not script for mere sparkles. Not yet anyway. But one day...
Also, thanks for the while loop explanation TMC. It's a lot clearer now. |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|