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

NPC activation through walls

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> The Arcade
View previous topic :: View next topic  
Author Message
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Thu Aug 23, 2007 7:41 pm    Post subject: NPC activation through walls Reply with quote

Is there any easy way to make it so that NPCs cannot be activated if there
is a passability wall between the hero and the NPC? If not, I think that this would be an extremely beautiful general bitset to have. If this bitset would be too complicated to implement for Ubersetzung, then I would like to beg that the useNPC bug (bug 439) be fixed before the next stable release, as this is preventing me from creating this functionality via plotscripting.
_________________
My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161

This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com
Back to top
View user's profile Send private message Visit poster's website
Jack
the fool




Joined: 30 Jul 2004
Posts: 773

PostPosted: Thu Aug 23, 2007 8:58 pm    Post subject: Re: NPC activation through walls Reply with quote

msw188 wrote:
Is there any easy way to make it so that NPCs cannot be activated if there
is a passability wall between the hero and the NPC?


I think a way to do this would be to place another NPC (one with no text/walkabout) facing whatever direction the wall is, over the initial NPC (I think by holding down an arrow, and spawning the NPC). If I'm correct, the player will activate that NPC instead, and if it has no text, will just do nothing.
_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Fri Aug 24, 2007 4:47 am    Post subject: Reply with quote

Oh, Jack's right. An NPC on the same tile with lower reference will block any others, even if it's totally unusable. I fixed the usenpc bug though.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Fri Aug 24, 2007 11:08 am    Post subject: Reply with quote

Thanks TMC. Oh and Jack, I need for NPCs to be triggerable if you are on the correct side of the wall, AND they are free to move as they please, so that solution would not work.

EDIT: For what it's worth, James' and Adam's suggestions on Bugzilla also would not have worked. Adam's suggestion would not have prevented the hero from facing the wrong direction, and James' would have failed if the NPC did anything but call a text box (outside of doing nothing).

Might as well convert this over to a question on implementation. I was originally planning on having a keypress script check for the spacebar, and then use an npc accordingly, but now I realize that a keypress script does not stop the spacebar from using npcs anyway, so that wouldn't have worked.

The new plan is to have all triggerable NPCs who have a chance of being on a wall set to not face the hero, and call a script that checks for a wall between them. The NPC could send an argument to call a textbox, but what to do about NPCs that I would have wanted to call a script? I would have gone with negative arguments, but scripts no longer have ID numbers. What to do... I guess I will have to have separate scripts for each such NPC. Maybe I will reserve negative arguments for fighting enemy formations. Does anyone have any suggestions? Is there a much simpler way of doing this that I am not seeing? (I do not have enough NPCs to 'double-up' each NPC with a triggering partner, as a matter of fact, I already use the same NPC IDs for different things based on where you are on the map).
_________________
My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161

This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com
Back to top
View user's profile Send private message Visit poster's website
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Fri Aug 24, 2007 12:26 pm    Post subject: Reply with quote

If I'm not mistaken, someone fixed the facing problem.

If you want to extract NPC behavior, an easyish way is to check what script is associated with that NPC and call it from your main script. At least I *think* there are commands to do all that.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Fri Aug 24, 2007 2:48 pm    Post subject: Reply with quote

The problem is that I cannot allow the NPC to have its activation set, because otherwise I cannot stop the player from being able to activate it through a wall.

In any case, I think I have found the best possible system. If anyone is interested, here is the setup:

1. Have a "No Wall Ahead" script that returns true if there is no wall directly in front of a character.

2. Have all NPCs set to not face player, also no NPC can call a text box or battle.

3. Have all NPCs that would trigger text boxes instead trigger a script that uses the No Wall Ahead check before actually calling the text box. This text box is indicated by the NPC's script argument; if the argument is positive, the NPC faces the hero if the No Wall Ahead check passes; if the argument is negative, the NPC does not face the hero. This script does a bunch of other stuff that custom usually does, like freezing the NPC in question (via alter npc move type), and remembering the NPC's original direction to be reset after the text box is gone (no support for changing an NPC's direction permanently with this).

4. Have all scripts that would be run from NPCs include a No Wall Ahead check and do the 'bunch of other stuff' themselves. This is the worst part; due to the ordering of commands, I have not been able to find a way around carefully copying and pasting the various 'other stuff' code throughout any NPC triggered-script, without knowing the NPC's move-type beforehand.

It seems to work okay. The only problem (and I think I'm willing to let it slide) is that you can force moving NPCs on the other side of a wall to move back to the tile in front of you that they were just on by 'triggering' them. They don't say anything (which is good), but it is funny that you can stand outside the wall and effectively keep them from moving.

I have to admit that I am a little proud of putting such a general system together. I don't know what is considered too simple or too complex for a Plotscript of the Month, but I might be interested in trying to make this one for you guys if you like (actually it will be several plotscripts, but isn't that the fun of it?). Of course, if someone has a better solution then I'd be pretty interested to hear it.
_________________
My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161

This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com
Back to top
View user's profile Send private message Visit poster's website
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Fri Aug 24, 2007 6:40 pm    Post subject: Reply with quote

I think that's overly complex. How about this:

1. Have a "No Wall Ahead" script that returns true if there is no wall directly in front of a character.

2. Set all NPCs up as normally

3. Use the following script as onkeypress script:
Code:
plotscript, keypress, begin
  if (key is pressed (key:space) || key is pressed (key:ctrl) || key is pressed (key:enter)) then (
    if (not (No Wall Ahead)) then (
      suspend player
      wait (1)
      resume player
    )
  )
end

Which ought to block the use keys when facing a wall.

Don't throw your solution away, maybe I'm missing something else you want to do. Oh right, it won't stop on-touch NPCs from triggering from the other side of a wall.


Also, there's nothing to stop you from assigning ID numbers to script if you need them. You may see some weird things (like scripts listed twice in the script menu) if you give an id number to a plotscript, but I think it should be ok. (Or you could just assign an ID greater than 16383)
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Sat Aug 25, 2007 8:04 am    Post subject: Reply with quote

Wait, so a keypress script runs BEFORE the action assigned to the key itself? I was fairly certain it was the other way around (I cannot remember why, but I feel like I've had to use this fact before...). It's true that this will not fix touch NPC's, but I think I'd much rather have to make special cases for them than do what I am doing right now. If what you say is true Sir Cacti, I will be simultaneously humiliated, frustrated at the waste of all that work, and relieved at having a simple solution from here on out.

I also wanted to ask if that "not" command works properly, or if you were just putting that in for shorthand of something like NoWallAhead==false.

Actually, it may be simpler just to go in and reverse everything about NoWallAhead and make it a Wall Ahead script to return true if there is a wall.

EDIT: Well, I just put it together and it works great. Thanks so much The Mad Cacti. I don't know why I thought the whole keypress thing worked the other way around.
_________________
My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161

This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com
Back to top
View user's profile Send private message Visit poster's website
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sat Aug 25, 2007 10:36 pm    Post subject: Reply with quote

Glad to help. Prehaps we could do with a command to block specific keypresses (there might be cases where you want to block one but not something else pressed simultaneously).
Not works fine. Normally I would write if (something) else (something) (miniscule speed increase!) but I plan to eventually have it automatically optimise to that anyway.
_________________
"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 -> The Arcade All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot 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