Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

Drawing NPCs on the map

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
sotrain515




Joined: 17 May 2010
Posts: 39
Location: Connecticut

PostPosted: Mon Jan 14, 2013 7:43 am    Post subject: Drawing NPCs on the map Reply with quote

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
View user's profile Send private message Send e-mail
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Wed Jan 16, 2013 5:54 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
sotrain515




Joined: 17 May 2010
Posts: 39
Location: Connecticut

PostPosted: Thu Jan 17, 2013 10:58 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sat Jan 19, 2013 4:20 am    Post subject: Reply with quote

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:
Code:
<s>incorrect</s>

as well as some other HTML.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
sotrain515




Joined: 17 May 2010
Posts: 39
Location: Connecticut

PostPosted: Sat Jan 19, 2013 5:34 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sat Jan 19, 2013 8:30 pm    Post subject: Reply with quote

Naturally.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
sotrain515




Joined: 17 May 2010
Posts: 39
Location: Connecticut

PostPosted: Thu Feb 28, 2013 2:12 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Fri Mar 01, 2013 9:01 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
sotrain515




Joined: 17 May 2010
Posts: 39
Location: Connecticut

PostPosted: Tue Mar 05, 2013 8:17 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Tue Mar 05, 2013 10:28 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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