 |
Castle Paradox
|
| View previous topic :: View next topic |
| Author |
Message |
TwinHamster ♫ Furious souls, burn eternally! ♫

Joined: 07 Mar 2004 Posts: 1352
|
Posted: Mon Mar 16, 2009 12:38 pm Post subject: |
|
|
So I'm trying to place a small explosion on top of dead enemies.
The goomba case in process enemies currently looks like:
| Code: |
case(enemy:goomba) do (
# Make our goomba walk
set npc frame(npc, enemy anim / 2)
if (npc direction(npc) == left) then (
put npc(npc, npc pixel x(npc) -- goomba walk speed, npc pixel y(npc))
if (npc can left(npc) == false) then (set npc direction(npc, right))
) else (
if (npc direction(npc) == right) then (
put npc(npc, npc pixel x(npc) + goomba walk speed, npc pixel y(npc))
if (npc can right(npc) == false) then (set npc direction(npc, left))
) else (
# Run down the time until we delete the enemy
set npc extra(npc, extra 1, npc extra(npc, extra 1) -- 1)
show value (npc extra (npc, extra 1))
if (npc extra(npc, extra 1) == 0) then (
destroy npc (small pop)
destroy npc(npc)
exit returning(0) # Quit out of this script
)
)
)
put npc(npc, npc pixel x(npc), npc pixel y(npc) + npc extra(npc, extra 2) / 10)
if (npc can fall(npc)) then (
set npc extra(npc, extra 2, npc extra(npc, extra 2) + gravity)
if (npc extra(npc, extra 2) >> hero-max-vy) then (set npc extra(npc, extra 2, hero-max-vy))
) else (
set npc extra(npc, extra 2, 0)
)
# Check for hero collisions
if(hero hurting == 0)
then(
if ((hero-x / 10) -- npc pixel x(npc) << 20 &&
npc pixel x(npc) -- (hero-x / 10) << 20 &&
(hero-y / 10) -- npc pixel y(npc) << 20 &&
npc pixel y(npc) -- (hero-y / 10) << 20 &&
npc direction(npc) <> down)
then (
# Collision! Check if hero fell onto goomba.
hurt hero
)
)
#Check for SPEARS
if (((npc pixel y(npc) -- npc pixel y (lance))>> -10) && (10 >> npc pixel y(npc) -- npc pixel y (lance)) && ( (20 >> (npc pixel x (99) -- npc pixel x (npc))) && ((npc pixel x (99) -- npc pixel x (npc)) >> -20)) )
then (
# Goomba dies
create npc (small pop, npcx(npc), npcy(npc))
put npc (small pop, npcpixelx(npc), npcpixely(npc))
set npc direction (npc, down)
set npc extra(npc, extra 1, corpse time)
#Hey refer
)
) |
When an enemy dies, npc 'small pop', defined as the constant 96, is placed on top of the enemy npc which faces down (an empty frame).
I'm letting the enemy stay on the map to employ its 'extra 1' data for the decay of the explosion.
After testing this a couple of times, it seems that once the enemy's [extra 1] decays to 0, the code:
| Code: |
if (npc extra(npc, extra 1) == 0) then (
destroy npc (small pop)
destroy npc(npc)
exit returning(0) # Quit out of this script
)
) |
is only partially obeyed.
The 'npc' will be destroyed, but 'small pop' stays.
I don't think I've ever seen an instance when [destroy npc] outright failed.
As always, any help would be appreciated. Thanks |
|
| Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Mon Mar 16, 2009 1:31 pm Post subject: |
|
|
How are you defining small pop? I'm guessing it's a constant.
You might consider making small pop a separate enemy type that doesn't do anything except decay. Right now, you're looking at problems if there are two small pops onscreen at the same time. _________________
|
|
| Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Mon Mar 16, 2009 1:36 pm Post subject: |
|
|
Can there be more than one copy of the NPC ID 96 on the map? If so, then
| Code: | | destroy npc (small pop) |
is only going to destroy the first one.
Even if you only see one pop, is it possible that the code which checks for goomba-death is actually triggering more than once as the spear passes through? That could cause several pops to be created for a single death, and if "destroy npc" is only removing the first one, how would you notice? |
|
| Back to top |
|
 |
Spoon Weaver

Joined: 18 Nov 2008 Posts: 421 Location: @home
|
Posted: Mon Mar 16, 2009 1:44 pm Post subject: |
|
|
| I suggest just turning the goomba into a small pop then have something that destroys small pops. That's what I did. Seems easier. Also I thought you were going to use the npc extra thing to count as HP for each npc. Seemed like a good idea. |
|
| Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Mon Mar 16, 2009 2:47 pm Post subject: |
|
|
| James Paige wrote: | | Even if you only see one pop, is it possible that the code which checks for goomba-death is actually triggering more than once as the spear passes through? That could cause several pops to be created for a single death, and if "destroy npc" is only removing the first one, how would you notice? |
This seems very likely.
I still stand by making small pop an enemy type, which would solve all your problems. _________________
|
|
| Back to top |
|
 |
TwinHamster ♫ Furious souls, burn eternally! ♫

Joined: 07 Mar 2004 Posts: 1352
|
Posted: Mon Mar 16, 2009 2:56 pm Post subject: |
|
|
| Spoon Weaver wrote: | | I suggest just turning the goomba into a small pop then have something that destroys small pops. That's what I did. Seems easier. Also I thought you were going to use the npc extra thing to count as HP for each npc. Seemed like a good idea. |
Looking through the Plotscripting Dictionary, it looks like each npc can hold 4 extra values (0-3).
So far, there are two that are being used (enemy directions and decay time, I believe).
So it looks like making them their own enemy types might be the best solution.
[Edit]
Works great!
Haven't tested killing a cluster of enemies at once, but I'm not anticipating any problems with that.
There's actually a bug where touching the explosion of enemy type 2 before it decays away will hurt the hero as if the enemy were still there; however, as enemy type 2 is a hovering flaming skull, I'm okay with that. |
|
| Back to top |
|
 |
Pepsi Ranger Reality TV Host

Joined: 05 Feb 2003 Posts: 493 Location: South Florida
|
Posted: Mon Mar 16, 2009 6:18 pm Post subject: |
|
|
Actually, since you guys are talking about NPC Extras, I've been curious for awhile about how they're used. Is it like using a timer? I think Twin or Moogle was talking about using it for enemy HP in some other thread somewhere. Is it basically like turning an NPC into a variable? _________________ Progress Report:
The Adventures of Powerstick Man: Extended Edition
Currently Updating: General sweep of the game world and dialogue boxes. Adding extended maps.
Tightfloss Maiden
Currently Updating: Chapter 2 |
|
| Back to top |
|
 |
Spoon Weaver

Joined: 18 Nov 2008 Posts: 421 Location: @home
|
Posted: Mon Mar 16, 2009 6:23 pm Post subject: |
|
|
it's basically just another variable that defines each npc, theres the type (up to 99), count ( up to ...999?), x and y location, and so on. Extras are just another number and appearantly theres four of them.
as for the small pop hurting you. I'd suspect that all npcs would hurt you seeing how you have things set up. If thats the case I'm guess you'll need to change the collision script. I suggest using the Id # instead of the reference "NPC". |
|
| Back to top |
|
 |
Pepsi Ranger Reality TV Host

Joined: 05 Feb 2003 Posts: 493 Location: South Florida
|
Posted: Mon Mar 16, 2009 7:33 pm Post subject: |
|
|
| Quote: | | it's basically just another variable that defines each npc, theres the type (up to 99), count ( up to ...999?), x and y location, and so on. Extras are just another number and appearantly theres four of them. |
Well, yeah, I gathered that from the plotscript dictionary. That's like saying an appendix is just another piece of the long intestine.
I should be clearer: How do you actually use them? It sounds like they can be used to convert an NPC into a variable, but even then I'm not sure how that would work. I found the reference I was talking about a couple posts ago. It was Twinhamster in his sidescroller journal. He talks about using NPC extra for enemy HP. How exactly is that done? What other things can it be used for?
I think menus have a similar argument, and I've never been clear how to use it there, either. But I must say that I am intrigued by the possibilities they offer if they can be used for anything.
(And Twin, your game looks awesome, btw.) _________________ Progress Report:
The Adventures of Powerstick Man: Extended Edition
Currently Updating: General sweep of the game world and dialogue boxes. Adding extended maps.
Tightfloss Maiden
Currently Updating: Chapter 2 |
|
| Back to top |
|
 |
TwinHamster ♫ Furious souls, burn eternally! ♫

Joined: 07 Mar 2004 Posts: 1352
|
Posted: Mon Mar 16, 2009 7:59 pm Post subject: |
|
|
| Quote: | | as for the small pop hurting you. I'd suspect that all npcs would hurt you seeing how you have things set up. If thats the case I'm guess you'll need to change the collision script. I suggest using the Id # instead of the reference "NPC". |
Well, everything else is colliding just fine, so I'd rather not mess with something that's not totally broken.
| Pepsi Ranger wrote: | | Quote: | | it's basically just another variable that defines each npc, theres the type (up to 99), count ( up to ...999?), x and y location, and so on. Extras are just another number and appearantly theres four of them. |
Well, yeah, I gathered that from the plotscript dictionary. That's like saying an appendix is just another piece of the long intestine.
I should be clearer: How do you actually use them? It sounds like they can be used to convert an NPC into a variable, but even then I'm not sure how that would work. I found the reference I was talking about a couple posts ago. It was Twinhamster in his sidescroller journal. He talks about using NPC extra for enemy HP. How exactly is that done? What other things can it be used for? |
It's actually a lot cooler than just 4 extra variables per NPC.
Moogle1's Side-Scroller 101 articles from Hamsterspeak demonstrate that they can be used to give each instance of an NPC ID has its own personal copy of extra data 0 through 3.
The article itself uses 1 and 2.
[NPC Extra 1] is used to store either 0 or 1, for whether an instance of an NPC is active (On the screen) at the moment while [NPC Extra 2] is used to store...uh, I think the direction that an NPC should be facing.
But yeah, they're really neat.
I still haven't hammered out the process for using them, but I'm working on it.
| Quote: | | I think menus have a similar argument, and I've never been clear how to use it there, either. But I must say that I am intrigued by the possibilities they offer if they can be used for anything. |
If you're talking about the extra data that each menu option has, I would imagine that they work as variables...
But I would also like to hear from somebody else who actually uses them.
| Quote: | | (And Twin, your game looks awesome, btw.) |
It plays great too! ;) |
|
| Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Tue Mar 17, 2009 1:38 am Post subject: |
|
|
(I haven't read this thread or SS101 too closely, so I skipped over a lot of other complaints/questions)
| TwinHamster wrote: |
Looking through the Plotscripting Dictionary, it looks like each npc can hold 4 extra values (0-3).
So far, there are two that are being used (enemy directions and decay time, I believe).
|
What? Where did you get that idea. There are two NPC extra data fields, 0 or 2 (extra2) and 1 (extra1) (numbering of extra data fields is a bit screwed up, currently discussing solutions on the mailinglist).
However, by coincidence I added a 3rd NPC extra field over the weekend.
Eventually you will be able to store arrays (or 'objects'?) in NPC extra data, so there will be no limit to the amount of per-NPC data you will be able to store, and in fact having more than one NPC extra data field will be unnecessary (and kind of inelegant).
Returning to the present, NPC extra data fields are a very sparse commodity. I often try to cram multiple pieces of data into a single integer (eg setnpcextra(npc, 0, a + 1000*b + 1000000*c)). I haven't followed the SS101 scripts too closely, but I think using up both (available at time) extra data fields is an annoying waste. If I used the scripts, I would modify them to free up at least one of those.
| Pepsi Ranger wrote: | | I should be clearer: How do you actually use them? It sounds like they can be used to convert an NPC into a variable, but even then I'm not sure how that would work. I found the reference I was talking about a couple posts ago. It was Twinhamster in his sidescroller journal. He talks about using NPC extra for enemy HP. How exactly is that done? What other things can it be used for? |
NPC extra data is used to give an NPC more state. For example, you could give NPCs the abilities to pick up items and store the items they're carrying, record hit points or a value indicating what they are currently doing (eg. going towards destination 4). I often use them to store an ID into a fake array that contains a whole lot of additional data for the NPC.
| Pepsi Ranger wrote: | | I think menus have a similar argument, and I've never been clear how to use it there, either. But I must say that I am intrigued by the possibilities they offer if they can be used for anything. |
Menu items are somewhat different, because you can also set their extra data from within Custom. You would normally use it like script arguments for NPC activation or map autorun scripts. But you can do anything you want with it. For example, you could give each menu item an image (such as an image of a sack of coffee beans), and put the ID number of the image in one of the extra data fields (probably in Custom). A script could continuous check the currently selected menu item, and display the associated image specified by the extra data.
They might also be useful for building dynamic menus with scripts, to indicate what a menu item should actually do. _________________ "It is so great it is insanely great." |
|
| Back to top |
|
 |
TwinHamster ♫ Furious souls, burn eternally! ♫

Joined: 07 Mar 2004 Posts: 1352
|
Posted: Tue Mar 17, 2009 4:45 am Post subject: |
|
|
| Quote: | | What? Where did you get that idea. There are two NPC extra data fields, 0 or 2 (extra2) and 1 (extra1) (numbering of extra data fields is a bit screwed up, currently discussing solutions on the mailinglist). |
Oh. I saw 0 and I saw the 3 of 'extra 3' and imagined that I could use extras 0-3
| Quote: | | However, by coincidence I added a 3rd NPC extra field over the weekend. |
Whew! |
|
| Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Tue Mar 17, 2009 7:58 am Post subject: |
|
|
Just a thought-- If you wanted to attach a whole ton of data into NPC extra, and you were not patient enough to wait for arrays to be implemented, you would store the slice handle of a container slice that you had set invisible.
An invisible container handle will never be drawn on the screen, so it doesn't even matter where it is or what size it is, but you can fill it with a long list of child containers (which would also be invisible because their parent is invisible), and you could use their "extra" data like a fake array. |
|
| Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Tue Mar 17, 2009 8:29 am Post subject: |
|
|
Linked lists, OHR style!
But that's really messy. Fortunately, garbage collection is as easy as switching to another map. _________________
|
|
| Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Tue Mar 17, 2009 9:59 am Post subject: |
|
|
| Moogle1 wrote: | Linked lists, OHR style!
But that's really messy. Fortunately, garbage collection is as easy as switching to another map. |
Yes, definitely messy.
..but possibly less messy than trying to cram in the same functionality using read global/write global.
Especially if you wrapped it up in some helper scripts that could be converted to use real arrays later when they are available. |
|
| 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
|