Moving npc stopping to move upon map re-enter

Sirren67

Look, Ma! Two Heads!
Apparently giving info to others brings me bad luck, so back to the basics.
I'm making a npc which becomes visible under a given condition. At this point it walks across my map and desappears.
My trouble is: if I exit the map before it reaches its final destination then my critter won't move anymore.
I started to have it moving via timed event
Code:
procedure timed_event_p_proc begin
if( self_visible ) then
 if (((critter_state(self_obj) bwand DAM_KNOCKED_DOWN) == FALSE)
    and (not(combat_is_initialized)))and (fixed_param == 1) then begin
    
         if (tile_num(self_obj) == 25902) then begin 
         animate_move_to_tile(25324);
         end
         else if (tile_num(self_obj) == 25324) then begin
         animate_move_to_tile(22131);
         end 
         else if (tile_num(self_obj) == 22131) then begin
         animate_move_to_tile(15529);
         end 
         else if (tile_num(self_obj) == 15529) then begin
          animate_move_to_tile(9129);
         end
end
add_timer_event(self_obj,game_ticks(6),1);
end

So far I tried to have my critter move via procedure critter, map enter, map update... I also tried to call timed event via map enter/update... Nothing. What am I doing wrong?
 
Well your logic is flawed because it depends on the critter reaching a specific tile before moving to the next location. If you want to animate multiple moves or sequences, it is probably best to use some kind of sequence numbering. Take a look at how they scripted the horrigan encounter ECBDYGRD.SSL. They use a sequence number as follows:

Code:
if (sequence == 5) then begin
   float_msg(farmer, mstr(106), FLOAT_MSG_YELLOW);
   sequence += 1;
   add_timer_event(self_obj, game_ticks(3), TIMER_SEQUENCE);
end else if (sequence == 6) then begin
   float_msg(self_obj, mstr(107), FLOAT_MSG_RED);
   sequence += 1;
   add_timer_event(self_obj, game_ticks(1), TIMER_SEQUENCE);

Another possibility is rather than checking if the critter is at a specific tile, you could check which tile it is closest to. I used this approach for those lizards fishing near the water. There are some 20 tiles along the water edge, but I wanted the lizard to run to the nearest water edge tile. So I made a routine that does this kind of thing:

Code:
target_distance := tile_distance(self_tile, 19117);
if (target_distance < closest_distance) then begin
   target_tile := 19117;
   closest_distance := target_distance;
end
target_distance := tile_distance(self_tile, 19317);
if (target_distance < closest_distance) then begin
    target_tile := 19317;
    closest_distance := target_distance;
end

reg_anim_clear(self_obj);
animate_run_to_tile(target_tile);
flush_add_timer_event(self_obj,game_ticks(1),2);
 
Mowing/animating critters is one of hardest things to do in fallout so if You are at that then You're high level scripter now ;).

I have my own way of creating moving critters:

Create a local variable by name LVAR_current_waypoint.
And add that code to the map_update_p_proc

Code:
if (local_var(LVAR_current_waypoint) != 0) then 
begin 
      reg_anim_clear(self_obj); 
      reg_anim_begin(); 
      animate_move_to_tile(local_var(LVAR_current_waypoint)); 
      reg_anim_end(); 
end

Now when you want that critter to move to some tile put that tile in LVAR_current_waypoint (and call map_update...) in your timed_event_p_proc.
 
jargo said:
Mowing/animating critters is one of hardest things to do in fallout

Yeah, you will spend much more time testing than coding, and half of that time you'll be thinking ... what the heck is it doing? :lol:
 
O.k. folks, I'll try this stuff. Jargo, if I go into ego tripping I won't be able to script for some time ;)). Thanks to you both. Bye
 
We all know that i don't know but... :)

Whay not try combinatingwith MVAR or LVAR HEREBEFOR.

He moves-> you exit->(he stops)->you re-enter (herbefore != 0) hi's gone...
is that posible?
Sorry if my giving stupid ideas!
 
He moves-> you exit->(he stops)->you re-enter (herbefore != 0) hi's gone...
is that posible?
Sorry if my giving stupid ideas!
Yea that can be done even shorter:

He moves->you exit (hi's gone) :)
 
The (really) more easy way I think is this:

Code:
procedure timed_event_p_proc begin 
if( self_visible ) then 
 if (((critter_state(self_obj) bwand DAM_KNOCKED_DOWN) == FALSE) 
    and (not(combat_is_initialized)))and (fixed_param == 1) then begin 
    
         if (tile_num(self_obj) == 25902) then begin 
         animate_move_to_tile(25324); 
         end 
         else if (tile_num(self_obj) == 25324) then begin 
         animate_move_to_tile(22131); 
         end 
         else if (tile_num(self_obj) == 22131) then begin 
         animate_move_to_tile(15529); 
         end 
         else if (tile_num(self_obj) == 15529) then begin 
          animate_move_to_tile(9129); 
         end 
     //new
         else begin 
         animate_move_to_tile(25902); 
         end 
end 
add_timer_event(self_obj,game_ticks(6),1); 
end

Now the npc moves his way. If he stops or the add_timer_event time is over, he moves back to tile "25902". But you must check out the time, because if the moving way is to long, he moves back to the home tile "25902".
 
I decided to shelve the "moving thing" for now, the situation scripting didn't really needed my critter to cross all the map...
I made another script instead:
It's a guard linked to a door. If you temper with the door he runs towards you shouting. If you leave the door alone he waits, tells something and then comes back to his original tile. At this point he keeps an eye on you (he rotates to face you).... Don't jump on your seats, it's just copy paste :wink:
The point is this part of the code:
Code:
if (fixed_param == 1) then begin
         if (tile_num(self_obj) == 20853) then begin
            add_timer_event(self_obj, game_ticks(3), TIMER_WAIT);
            float_msg(Self_obj,"Moron...",FLOAT_MSG_RED);
            add_timer_event(self_obj, game_ticks(3), TIMER_WAIT);
            animate_move_to_tile(local_var(LVAR_Home_Tile));
         end
end
It works as intended only the first time you temper with the door, from the second time on the critter doesn't wait, he performs all his script in a row... It gives a feeling of sloppiness. Does anybody know how to fix this? Bye
 
You showed us very small amount of code. In this fragment only one thing is weird:
add_timer_event(self_obj, game_ticks(3), TIMER_WAIT);
float_msg(Self_obj,"Moron...",FLOAT_MSG_RED);
add_timer_event(self_obj, game_ticks(3), TIMER_WAIT);

Why use two times the very same timer event call?
 
O.k., some more code:
Code:
procedure timed_event_p_proc begin
   if fixed_param == 6 then begin 
      if local_var(LVAR_Door_Tempered) < 3 then begin
         //Run_Next_To_Obj_And_Face(dude_obj);
         animate_run_to_tile(20853);
         add_timer_event(self_obj, game_ticks(5), TIMER_SEQUENCE);  
         float_msg(Self_obj," HEY!! KEEP AWAY FROM THAT DOOR!!",FLOAT_MSG_RED); 
         set_local_var(LVAR_Door_Tempered,local_var(LVAR_Door_Tempered) + 1); 
      end    
      else begin 
         set_local_var(LVAR_Hostile,2); 
         attack(dude_obj);
      end        
  end
      
      if (fixed_param == TIMER_LOOK) then begin
      if (not combat_is_initialized) then begin
         if (not anim_busy(self_obj) and obj_on_screen(self_obj)) then begin
            if (obj_can_see_obj(self_obj, dude_obj)) then begin
               reg_anim_begin();
               animate_rotation(rotation_to_tile(self_tile, dude_tile));
               reg_anim_end();
            end
         end
      end

      add_timer_event(self_obj, ONE_GAME_SECOND, TIMER_LOOK);
   end
end
Probably a flow in the general script layout, I think...
 
Back
Top