Moving Along a Specified Path?

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: Moving Along a Specified Path?
Warrior
Member # 3905
Profile #0
Ok, I'm trying to make a scenario (to be released november 2024 if ever). However I'm still not quite familiar with the editor nor scripting.

How would you go about if you want a character (NPC) to move to a specified spot. I want a character to walk away (to another part of town) after having been talked to. Any suggestions on how you could pull this off?
Posts: 56 | Registered: Tuesday, January 20 2004 08:00
Apprentice
Member # 4119
Profile #1
Newbie too, but waypoint sounds promising. I haven't looked at it yet, but that was my plan for implementing this when the time came.
Posts: 23 | Registered: Thursday, March 18 2004 08:00
Apprentice
Member # 4119
Profile #2
Duplicate. Sorry.

------------

Grrr those splitters, or whatever the proper term is, they bug me

[ Wednesday, July 21, 2004 08:32: Message edited by: Eldritch_Cadillac ]
Posts: 23 | Registered: Thursday, March 18 2004 08:00
Agent
Member # 2820
Profile #3
Use a really simple, modified basicnpc script. In the TALKING_STATE, check to see if the flag has been set, then set it if it hasn't. Then tell the monster to either move_to_loc_x_y() or approach_waypoint(). The waypoint must be set in the editor. I'll post an edited script in a minute.

// basicnpc.txt
// A very simple, naive text. Creature attacks anything it hates nearby.
// Once it has won, it returns to its home.
// Memory Cells:
// Cell 0 - How creature moves.
// 0 - If 0, wander randomly around my starting position.
// 1 - Stands still until a target appears and go back to my starting position when I move away.
// 2 - Completely immobile, even if target appears.
// Cell 1,2 - Stuff done flag. If both 0, nothing. Otherwise when this
// is killed, set to 1. (Example: If cell 1 is 3 and cell 2 is 5, when
// creature is killed, sets SDF(3,5) to 1.)
// Cell 3 - Dialogue node to start with if talked to. if left at 0, this
// character doesn't talk.
// Cell 4,5 - Stuff Done Flag to be set when character is talked to.
// Cell 6 - Waypoint to move to when SDF(Cell 4, Cell 5) is set

begincreaturescript;

variables;

short i,target; // Standard variables, not used in this basic script

body;

beginstate INIT_STATE; // Only called once when creature comes into existence
if (get_memory_cell(0) == 2)
set_mobility(ME,0);
break;

beginstate DEAD_STATE;
// Set the appropriate stuff done flag for this character being dead
if ((get_memory_cell(1) != 0) || (get_memory_cell(2) != 0))
set_flag(get_memory_cell(1),get_memory_cell(2),1);
break;

beginstate START_STATE;
// if I have a target for some reason, go attack it. Note that
// initially, there will be no target, but sometimes the script
// loops back up here when there might be one
if (target_ok()) { // Make sure target is still alive
if (dist_to_char(get_target()) <= 16) // Make sure target isn't too far away
set_state(3); // See the note for state 3 below
else set_target(ME,-1); // If the target was too far away, I have no target anymore
}

// Look for a target, attack it if visible
if (select_target(ME,8,0)) { // this call both looks for a target (within 8 spaces) and returns TRUE if it was successful
do_attack();
set_state(3);
}

// Have I been hit? Strike back! Only gets here if I was hit by someone who was too far away or unseen
if (who_hit_me() >= 0) {
set_target(ME,who_hit_me());
do_attack();
set_state(3);
}

// Otherwise, just peacefully move around. Go back to start, if I'm too far from where I
// started. Remember that if I was attacking, I'd be in state 3 now, not here.
if (get_sdf(get_memory_cell(4),get_memory_cell(5)) > 0) { // approach waypoint if flag set
if (approach_waypoint(ME,get_memory_cell(6),1))
if (get_memory_cell(0) == 0)
fidget(ME,25);
}
else {
if ((my_dist_from_start() >= 6) || ((my_dist_from_start() > 0) && (get_memory_cell(0) > 0))) {
if (get_ran(1,1,100) < 40)
return_to_start(ME,1);
}
else if (get_memory_cell(0) == 0) {
fidget(ME,25);
}
}
// if we're in combat and the above didn't give me anything to do, just
// stop now. Otherwise, game will keep running script, and that eats up CPU time.
if (am_i_doing_action() == FALSE)
end_combat_turn();
break;

beginstate 3;
// Referred here only when a state has given me a target. I will keep starting
// in this state when it is my turn until the next command sets me somewhere else.
// The whole point of this state is for me to keep attacking the same target until it's dead.
if (target_ok() == FALSE) // If the target died, then go back because this state is only good for attacking
set_state(START_STATE);
do_attack();
break;

beginstate TALKING_STATE; // Triggered when someone talks to me
if (get_memory_cell(3) == 0) {
print_str("Talking: It doesn't respond.");
end();
}
if ((get_memory_cell(4) != 0) || (get_memory_cell(5) != 0)) {
if (get_sdf(get_memory_cell(4),get_memory_cell(5)) == 0)
set_flag(get_memory_cell(4),get_memory_cell(5),1);
approach_waypoint(ME,get_memory_cell(6),1);
}
begin_talk_mode(get_memory_cell(3));
break;


[ Wednesday, July 21, 2004 09:22: Message edited by: Keep ]

--------------------
Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are.
====
Alorael: War and violence would end if we all had each other's babies!
====
Drakefyre: Those are hideous mangos.
Posts: 1415 | Registered: Thursday, March 27 2003 08:00
Post Navel Trauma ^_^
Member # 67
Profile Homepage #4
I do this in Babysitting. Have a look at Father Crilly's creature script. He uses several waypoints though, because he goes a long way and I wanted the pathfinding to be easy.

--------------------
Barcoorah: I even did it to a big dorset ram.

New Mac BoE
Posts: 1798 | Registered: Thursday, October 4 2001 07:00
Off With Their Heads
Member # 4045
Profile Homepage #5
I believe Keep's script won't do what you want, too. The TALKING_STATE is only called when you actively talk to the character. Keep's script will look really bloody weird. The character will take one step every time you attempt to talk to it.

Khoth's script is the way to go.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Agent
Member # 2820
Profile #6
What do you mean my script won't work? I just tested it and it worked fine. The second parameter in approach_waypoint() determines how close to go to the place. But you will need to tweak it to suit your needs, of course.

--------------------
Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are.
====
Alorael: War and violence would end if we all had each other's babies!
====
Drakefyre: Those are hideous mangos.
Posts: 1415 | Registered: Thursday, March 27 2003 08:00
Off With Their Heads
Member # 4045
Profile Homepage #7
If you tested it and it does in fact work, then I take that back. I don't understand how it could possibly work -- creatures are not supposed to stay in TALKING_STATE after you've talked to them, nor are they supposed to enter it without you talking to them -- but if it does, then clearly there's something here that I don't understand.

Oh. Wait. It is in the START_STATE, too. Never mind. My apologies. The clutter in the TALKING_STATE is unnecessary, but the code in the START_STATE will work.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Agent
Member # 2820
Profile #8
I was worried the creature might not run its script until 8 turns later, so I just made it immediate just in case.

--------------------
Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are.
====
Alorael: War and violence would end if we all had each other's babies!
====
Drakefyre: Those are hideous mangos.
Posts: 1415 | Registered: Thursday, March 27 2003 08:00
BANNED
Member # 4
Profile Homepage #9
God, I have one of these on my site.

http://geocities.com/terrorsmartyr/BladesofAvernum/talkparty.txt

You people sure don't know how to look. >_<

--------------------
*
Posts: 6936 | Registered: Tuesday, September 18 2001 07:00