Seasoned Roamer Dyng Posted July 21, 2004 Share Posted July 21, 2004 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? Link to comment Share on other sites More sharing options...
Curious Artila Eldritch_Cadillac Posted July 21, 2004 Share Posted July 21, 2004 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. Link to comment Share on other sites More sharing options...
Curious Artila Eldritch_Cadillac Posted July 21, 2004 Share Posted July 21, 2004 Duplicate. Sorry. ------------ Grrr those splitters, or whatever the proper term is, they bug me Link to comment Share on other sites More sharing options...
Well-Actually War Trall Fort Posted July 21, 2004 Share Posted July 21, 2004 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. Code: // 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 setbegincreaturescript;variables;short i,target; // Standard variables, not used in this basic scriptbody;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; Link to comment Share on other sites More sharing options...
Well-Actually War Trall Khoth Posted July 21, 2004 Share Posted July 21, 2004 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. Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted July 21, 2004 Share Posted July 21, 2004 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. Link to comment Share on other sites More sharing options...
Well-Actually War Trall Fort Posted July 21, 2004 Share Posted July 21, 2004 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. Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted July 21, 2004 Share Posted July 21, 2004 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. Link to comment Share on other sites More sharing options...
Well-Actually War Trall Fort Posted July 21, 2004 Share Posted July 21, 2004 I was worried the creature might not run its script until 8 turns later, so I just made it immediate just in case. Link to comment Share on other sites More sharing options...
Magnificent Ornk Donald Hebb Posted July 21, 2004 Share Posted July 21, 2004 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. >_< Link to comment Share on other sites More sharing options...
Recommended Posts