View previous topic :: View next topic |
Author |
Message |
sotrain515
Joined: 17 May 2010 Posts: 39 Location: Connecticut
|
Posted: Mon Jan 14, 2013 7:43 am Post subject: Drawing NPCs on the map |
|
|
Is there any rhyme or reason to how NPCs are drawn when more than one exists in the same space? I'm guessing it's "higher-numbered NPC IDs are always drawn over lower-numbered"?
Would it be possible to have a bitset (either game-wide or map-wide) in the future that could modify that behavior? I would actually like it to be, for instance, "lower-numbered NPC IDs are always drawn over higher-numbered"?
Of course, what I really, really want is each NPC in a map to have some kind of "priority" value, with higher priorities always getting drawn above lower (and equal priorities could just mimic whatever the current behavior is, doesn't really matter). That's my pipe dream at least. |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Wed Jan 16, 2013 5:54 pm Post subject: |
|
|
It depends on the map's "Walkabout Layering" option.
If it is set to "Heroes above NPCs" (which is the default in old games) or "NPCs above heroes", then layering is according to NPC references (not IDs at all). An NPC reference is a number from -1 to -300. -1 is on the bottom, and -300 is topmost. The reference number actually depends on the order in which the NPCs are placed in the map editor or created with 'createnpc'. When you place an NPC in the map editor it gets the highest unused reference number (so first -1 then -2...). createnpc works in the opposite way; it starts from -300.
However, if the walkabout layering is "Together" (the new default), all the heroes and NPCs are sorted according to their Y position and drawn in that order, as you would want if any of your walkabout sprites are more than 20 pixels tall.
Now anyway, walkabout layering is actually implemented using slice sorting (like the 'sortchildren' command). So it would be easy to let people set their own draw order just by disabling the the default sort values. So I If I added new layering options "Custom" and you wrote a script to assign sort order manually (using 'setsortorder') you would be happy? Actually I suppose I would want to add "Scripted (Together)", "Scripted (Heroes above NPCs)" and "Scripted (NPCs above Heroes)". _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
sotrain515
Joined: 17 May 2010 Posts: 39 Location: Connecticut
|
Posted: Thu Jan 17, 2013 10:58 am Post subject: |
|
|
Hmm, actually, I think just knowing the behavior might be enough for my purposes. So, you say that every NPC put on the map in the editor gets ordered from -1 to -300, while every NPC created using createnpc command in plotscripting gets ordered from -300 to -1, and the engine actually draws them with -1 at the bottom and -300 at the top, is that right?
For my purposes, I basically have about four NPCs that should appear above every other NPC (they shouldn't really conflict with each other; or maybe they would, but for simplicity let's just say they won't). If I, at the beginning of any map they appear on, destroy them and then recreate them (remembering their position, direction, npc extras, etc.), they would then be the topmost NPCs drawn, right? That's something that I could do easily at the beginning of each new map (along with other stuff, such as my backdrop loading and so forth).
If that would work, then I don't think I would need any special new bitsets / scripting commands. (oh and my maps use the "Heroes above NPCs" setting for an unrelated reason.. that I actually can't remember off the top of my head).
On second thought, yes, a set sort order on npc-sprites is what I'm looking for. As always, I'm in no rush and appreciate the responses. Thanks.
Last edited by sotrain515 on Sat Jan 19, 2013 5:27 pm; edited 1 time in total |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sat Jan 19, 2013 4:20 am Post subject: |
|
|
OK. On second thoughts there only needs to be one "Scripted layering" option, you can script heroes above or below NPCs yourself.
You can use strikethrough like so:
as well as some other HTML. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
sotrain515
Joined: 17 May 2010 Posts: 39 Location: Connecticut
|
Posted: Sat Jan 19, 2013 5:34 pm Post subject: |
|
|
Ah, much better. I tried "[s][/s]" and it did nothing (then I gave up).
Quote: | you can script heroes above or below NPCs yourself. |
...and NPCs above / below each other, yes? |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sat Jan 19, 2013 8:30 pm Post subject: |
|
|
Naturally. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
sotrain515
Joined: 17 May 2010 Posts: 39 Location: Connecticut
|
Posted: Thu Feb 28, 2013 2:12 pm Post subject: |
|
|
It occurred to me recently that what I want is more or less like the "hero z" and "set hero z" functions.
Not sure if it's any easier, but basically a hypothetical "npc z" and "set npc z". |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Fri Mar 01, 2013 9:01 am Post subject: |
|
|
Actually we were planning on adding those commands since it would not be much work to do so.
But are you sure that's what you want? To make an NPC appear above all other NPCs using Z values, you would place it at the bottom of the map (so that according to its Y value it appears on top), and that set its Z value to (Map height * 20 - Desired Y). _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
sotrain515
Joined: 17 May 2010 Posts: 39 Location: Connecticut
|
Posted: Tue Mar 05, 2013 8:17 am Post subject: |
|
|
I think so..
I guess I'll just come right out and describe what I'm trying to do. I have a script where npcs kind of "jump" from one tile to another. To simulate this, I use the npc pixel commands to move an npc up about 20 pixels (I think, maybe it's 40), then I switch them out for an identical sprite and move that (along with a shadow sprite that is parented below them on the tile they are "above") to the destination. Then I swap back in the npc, pixel it back down and destroy the shadow sprite.
This looks good for the most part, particularly since map layering is maintained while the npc is lifting up but then the npc is over the entire map when it is actually moving, only to have layer-primacy (or whatever) be restored when it is being put back down. I think it looks pretty nifty.
The only problem is that as the npc is pixel'd up or down, it tends to draw behind npcs that are above it along the y-axis.
I'm thinking that using a z-modification in place of pixel-modification would do the trick...
Sorry, I know that's a lot of words to slog through, but I don't think I can describe it any more succinctly. |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Tue Mar 05, 2013 10:28 pm Post subject: |
|
|
Ah yes, that is exactly what npc z values would be used for. Maybe it could also draw the shadow below the NPC automatically. (Right now only vehicles (with non-zero z values) have shadows, which is also the only time an npc ever has a non-zero z value.) But the shadow would have to be optional.
I guess I'll add the npc z value commands instead of the Scripted Walkabout Layering option, because I am doubtful about anyone ever using that (if anyone wants to speak up...) _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
|