Question about opening lockers

clercqer

Senator oTO
Orderite
As you might have guessed, I am new to this whole modding thing, so bear with me and my silly questions if you please.
I looked through the forums already, read the FAQs, stickies and guides but haven't found an answer to my question.

The situation is like this: I want a critter to walk over to a locker, open it, close it, and make the critter walk back.
Now I've already succeeded in making the critter walk over there, turn in the right direction and do it's 'use' animation, but I can't seem to figure out how I can make the locker's door swing open...

So my question is: how can I make a critter open a locker? (and close it afterwards, but I'm thinking that's the same principle)

Thank you.
 
Im not really sure, but you could try to look in other scripts where something opens/closes by its self. Try the door scripts to Roses place.

But if you look in the Horrigan encounter, the men arent really shooting the farmer and his family, their animations are just synchronizing together.

I have a question, is input possible while its going on?
 
Xavierblazer said:
I have a question, is input possible while its going on?
If you mean keyboard/mouse input then the answer is - no. At least in 1.02d version of the script.
 
The Broken Hills radscorpion opens a footlocker, check that.
 
Per said:
The Broken Hills radscorpion opens a footlocker, check that.
Thanks, I totally forgot about that. At first glance it seems to be in the Professor's script. This would be where it's at, right?

Code:
else if( Agility_State == 3 ) then begin
      // Play Scorpion's "Magic fingers" animation.
      reg_anim_clear( scorpion_obj );
      reg_anim_begin();
      reg_anim_animate( scorpion_obj,ANIM_stand,-1 );
      reg_anim_end();
      Agility_State += 1;
      add_timer_event( self_obj, game_ticks(1), 0 );
   end
   else if( Agility_State == 4 ) then begin
      obj_unlock( Professor_Box2 );
      obj_open( Professor_Box2 );
      inc_local_var( LVAR_Scorpion_Score );

      float_scorp(204);
      Agility_State += 1;
      add_timer_event( self_obj, game_ticks(2), 0 );
   end
I'll have to study it some more because there're some things I don't get (yet).

Thanks everyone.
 
Depending on how you do it, it could be very simple(three scripts and one map variable, make the critter in his script walk over to the locker, and when he gets in front of it to do his open animation, then only do one map variable where the critter reports that hes done with his open animation and run the locker opening animation.)

or you could do pointers and such(two exports to the map script then run everything from the map script, harder to do but more reliable I think)
 
Ok, here's how I did it. Though it works, I'm not sure I did it as efficiently as possible, so please comment.

There's an export variable in the map script: Jay_Locker

Here's the Locker's script (pretty much the same as the box in Broken Hills).
Code:
#include "..\headers\define.h"

#define NAME                    SCRIPT_TIJYLCKR

#include "..\headers\command.h"

procedure start;
procedure map_update_p_proc;
procedure map_enter_p_proc;

import variable Jay_Locker;

procedure start begin
   Jay_Locker := self_obj;
end

procedure map_update_p_proc begin
   Jay_Locker := self_obj;
end

procedure map_enter_p_proc begin
   Jay_Locker := self_obj;
end

And here's the critter (the part that matters):

Code:
import variable Jay_Locker;

variable Only_Once:=0;

procedure timed_event_p_proc begin
   if (fixed_param == 1) then begin
      obj_open(Jay_Locker);
   end
end

procedure critter_p_proc begin
   if (game_time_hour == 1200) then begin
      animate_move_obj_to_tile(self_obj,21924,0);
   end
   
   if (tile_num(self_obj) == 21924) and (Only_Once == 0) then begin
      call open_locker;
      Only_Once:= 1;
   end
end

procedure open_locker begin
   anim(self_obj,ANIM_magic_hands_middle,5);
   add_timer_event(self_obj,game_ticks(1),1);
end

Like I said, all pointers are welcome.
 
Yep, that's how I would have done it, too. When animating several things at once, it's usually easiest to control everything from one single script. To do that you'll need pointers to the objects that are animated, and usually you'll need imported/exported variables to handle that (unless you created the things that will be animated in the script).
 
Thanks for the input. However, I still have a question. When making the script for the locker, (and this is quite stupid) I just made it exactly like the footlocker script in Broken Hills, without really understanding it. And I was wondering why the Jay_Locker == self_obj command is in all those procedures. Wouldn't it also work if it was just in the start procedure or the map_enter_p_proc procedure? Oh and also: what's the difference between those two procedures? From what I can figure out, they both are called when the map is entered...

Thanks for bearing with my silly questions.
 
clercqer said:
Jay_Locker == self_obj command is in all those procedures
What script do you refer to?
Wouldn't it also work if it was just in the start procedure or the map_enter_p_proc procedure? Oh and also: what's the difference between those two procedures?
I could give you a straight answer, but I won't. The answer is in "Fallout_Editor.doc" file which comes with the map editor, pages 27 & 28!
 
lisac2k said:
clercqer said:
Jay_Locker == self_obj command is in all those procedures
What script do you refer to?
To the TIJYLCKR script I posted above.
lisac2k said:
Wouldn't it also work if it was just in the start procedure or the map_enter_p_proc procedure? Oh and also: what's the difference between those two procedures?
I could give you a straight answer, but I won't. The answer is in "Fallout_Editor.doc" file which comes with the map editor, pages 27 & 28!
Right, how did I miss that? Note to self: search first next time.

As to my first question: I tried it with this script attached to the locker (so with a lot less stuff in it when compared to the one I posted above):

Code:
/* Include Files */

#include "..\headers\define.h"

#define NAME                    SCRIPT_TIJYLCKR

#include "..\headers\command.h"

procedure map_enter_p_proc;

import variable Jay_Locker;

procedure map_enter_p_proc begin
   Jay_Locker := self_obj;
end

And it worked fine. Is this version better than the one above? Was there a lot of unnecessary junk in the first TIJYLCKR script (which was more or less a copy of the script for the scorpion's locker in Broken Hills)?
 
Well, the first script (with junk) can be better, but doesn't have to... It's hard to explain. Probably the scripters from BIS wanted to be sure their locker variable is defined properly and OFTEN as self_obj. Why did they want it that way? I can't be 100% sure, but they might have problems with just one definition (like you did it in the map_enter_p_proc) later, when stuff gets complicated. Or it's a part of redundant (junk) code, but was never erased. Or...

IMO, I think just one definition (in map_enter_p_proc) is enough for most things you want to do. However, don't forget that Murphy is one merciless son of a *itch...
 
Back
Top