View previous topic :: View next topic |
Author |
Message |
RedMaverickZero Three pointed, red disaster! Halloween 2006 Creativity Winner


Joined: 12 Jul 2003 Posts: 1459
|
Posted: Sat Sep 08, 2007 1:50 pm Post subject: Making NPCs move... differently |
|
|
Hey, I'm trying to set this part up in my game where the player sneaks around. I want to make an NPC that, when looking in the players direction a certain number of spaces away from him that he'll do something.
Is there a way to do this easily? _________________ ---------------Projects----
Mr.Triangle's Maze: 70%
Takoyaki Surprise: 70% |
|
Back to top |
|
 |
JSH357

Joined: 02 Feb 2003 Posts: 1705
|
Posted: Sat Sep 08, 2007 2:18 pm Post subject: |
|
|
Welcome to the hairy world of AI programming. This doesn't sound all TOO difficult, but it will probably require some thought...
Actually I have to go, but I'll try and post some advice later on. |
|
Back to top |
|
 |
RedMaverickZero Three pointed, red disaster! Halloween 2006 Creativity Winner


Joined: 12 Jul 2003 Posts: 1459
|
Posted: Sat Sep 08, 2007 2:45 pm Post subject: |
|
|
I've seen this done before a long time ago. Sew made a game called "Once Upon A Ninja" where it did this. I just have no clue how it's done... _________________ ---------------Projects----
Mr.Triangle's Maze: 70%
Takoyaki Surprise: 70% |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Sat Sep 08, 2007 3:09 pm Post subject: |
|
|
I helped Surlaw with this problem recently. He probably still has the script. I don't remember where I put it and I'm too lazy to find out or rewrite it right now. _________________
|
|
Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Sat Sep 08, 2007 4:55 pm Post subject: |
|
|
Do you want the NPC to only detect characters directly in front of him (a line of sight) or do you want him to detect characters in a 'sight cone' in front of him (for example, if the player is two steps in front of him and one step to the side, and there are no walls in the way, is it fair to say that the NPC 'sees' him?). Obviously, the line of sight method is MUCH easier. _________________ 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 |
|
 |
RedMaverickZero Three pointed, red disaster! Halloween 2006 Creativity Winner


Joined: 12 Jul 2003 Posts: 1459
|
Posted: Sat Sep 08, 2007 5:13 pm Post subject: |
|
|
My original idea was for it to be sorta like in Pokemon how a trainer spots you if he looks at you and then walks up to you. _________________ ---------------Projects----
Mr.Triangle's Maze: 70%
Takoyaki Surprise: 70% |
|
Back to top |
|
 |
JSH357

Joined: 02 Feb 2003 Posts: 1705
|
Posted: Sat Sep 08, 2007 5:40 pm Post subject: |
|
|
Is the NPC stationary or moving? If it's stationary, then there are several easy methods. Otherwise, it is definitely more complicated. |
|
Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Sat Sep 08, 2007 5:47 pm Post subject: |
|
|
I'm sorry, I really don't remember how Pokemon worked (I played it a long time ago, but I never owned it and never got interested enough in it to get very far). The important questions from a plotscripting standpoint are (as it seems to me):
1. Will you go with a straight line of sight, or a 'cone', as in my previous post?
2. Will the player still be in control and able to 'escape' (difficult), or will being sighted freeze the player and ensure a certain course of action (easier)?
3. Does the seeking NPC move? How so?
I have a (slightly wonky) script for straight line detection that freezes the player using invisible step-on NPCs to check for walls and/or other npcs blocking the seeker's view. It was of questionable reliability, but I think that together with some of the experts here it could be put into good working order for a fairly near-sighted NPC... _________________ 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 |
|
 |
Newbie_Power

Joined: 04 Sep 2006 Posts: 1762
|
Posted: Sat Sep 08, 2007 6:11 pm Post subject: |
|
|
Here is my idea, although I don't know how the plot script would be written.
1. The area of sight would be step on NPCs
2. Four different types of NPCs for each direction, and multiple instances for the line of sight.
3. Only one type of NPC appears at a time depending on the direction. _________________
TheGiz> Am I the only one who likes to imagine that Elijah Wood's character in Back to the Future 2, the kid at the Wild Gunman machine in the Cafe 80's, is some future descendant of the AVGN? |
|
Back to top |
|
 |
RedMaverickZero Three pointed, red disaster! Halloween 2006 Creativity Winner


Joined: 12 Jul 2003 Posts: 1459
|
Posted: Sat Sep 08, 2007 6:14 pm Post subject: |
|
|
JSH357 wrote: | Is the NPC stationary or moving? If it's stationary, then there are several easy methods. Otherwise, it is definitely more complicated. |
I was going to have them not move, but maybe change direction to help make the sneaking around a lil more interesting. But definitely not moving. _________________ ---------------Projects----
Mr.Triangle's Maze: 70%
Takoyaki Surprise: 70% |
|
Back to top |
|
 |
JSH357

Joined: 02 Feb 2003 Posts: 1705
|
Posted: Sat Sep 08, 2007 6:43 pm Post subject: |
|
|
If they aren't moving and aren't changing directions: Your weapon of choice is the step-on invisible NPC. But that should be obvious I hope.
If they aren't moving and ARE changing directions, here's a potential method off the top of my head:
Put invisible npcs in all 4 directions and have them activate a script that checks the "Watching" NPC's face direction (ie, facing up, left, right, or down). If the NPC is facing the hero (You would determine this by checking the X and Y positions of the hero, I assume), then continue on with the script. Otherwise, the script ends.
The only caveat is that the NPC can shift direction while the player is sitting there, and honestly I'm not sure how to rig it up so the script will still activate, so in hindsight this is probably not a very good idea.
Another option that's possible is to have a script always running on the map that randomly changes the NPC's direction, and if the hero is in the right place the script could continue. That sounds messy to me, though, and I'm not sure if it would slow Game.exe down or not.
In summary, someone else could probably help you better than I could here, but I'm just throwing some thoughts out. |
|
Back to top |
|
 |
Sajim of EVOS
Joined: 25 Jun 2007 Posts: 13
|
Posted: Sun Mar 09, 2008 7:51 pm Post subject: |
|
|
In "Stenmele Osmium", we made a script similar to a "zelda 64" style...where there are a few npcs that walk back and forth, and if you walk in their line of sight they see you and you restart..i had 2 scripts to do this. I can send you what i wrote if you still need it. Of course i'll explain what i did throughout the script _________________ Writer.Plotscripter for the team "EVOS Creations" |
|
Back to top |
|
 |
no_shot Surpasses you in poetical prowess

Joined: 28 Apr 2003 Posts: 300 Location: On the road to perfection.
|
Posted: Tue Mar 11, 2008 6:32 pm Post subject: |
|
|
I'm pretty sure I included the raw script file in Game w/o A Name (I'm not trying to trick you into downloading it) which includes a script that does roughly what you want to do. Just to prove I'm not trying to trick you into downloading my game, I've included an altered version to use as an example. What it does is set a horizontal "danger" zone that continues indefinitely along the x axis. If this wording confuses you, it makes an area that goes forever left to right, and is only 2 tiles tall, that serves as the "spotlight" aka where the npc is able to see the player. This particular script was the map's autorun, but can be triggered some other way if you want. Also, the numbers and conditions are game specific, and can be changed to suit.
Code: | plotscript, sentry, begin
while (current map == 3) do,
(
if ((hero y (me) >> 12), and, (hero y (me) << 15)) then,
(
if (((npc x (2) << hero x (me)), and, (NPC direction (2) == east)),
or, ((npc x (2) >> hero x (me)), and, (NPC direction (2) == west))) then,
begin
[do the stuff that happens when you're seen]
end
)
wait(1) # <-- this needs to be in here for some damn reason or it'll
freeze. don't ask me why
)
end |
I hope this gives you the jist of it. I'll answer any questions you have except ones concerning black genitalia. _________________ Play Horrible Fantasy NOW! |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Fri Mar 14, 2008 1:11 am Post subject: |
|
|
For the sake of completeness: Guards in Eldardeen have a cone of view, with the range of their sight varying by angle; decreasing due to obstructions, which are marked by bits on the passmap and behind which you might be only partially hidden; light levels, if they are implemented; your disguise; and the guard's alertness. The obstruction checking is complicated, working on the pixel position of the player and guard, and 20x10 size 'obstruction map tiles'.
So in summary, you don't want to see my scripts. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
|