AICAVDOR.SSL

*This image comes from* Fallout Mod *or from websites created and owned by Game publisher or Game developer, who hold the copyright of* Fallout Mod*. All trademarks and registered trademarks present in the image are proprietary to Game publisher.
The use of images to illustrate articles concerning the subject of the images in question is believed to qualify as **fair use** under United States copyright law, as such display does not significantly impede the right of the copyright holder to sell the copyrighted material.*

Template:Scriptfile

Template:Scriptbox

File:Transcript.png
/\*

        Copyright 1998-2003 Interplay Entertainment Corp. All rights reserved.

\*/

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

        Item: Wood Door

        Locked: NO

        Trapped: NO

        Closing: YES

        Description: This is a generic locked and trapped wooden door.

        Log:

           Please note any changes that have been made to the file in Updated. Then comment

           the code which you have changed/altered/commented out. Please, do not delete any

           code which was written.

           Created: September 26, 1997

           Updated:

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

/\* Include Files \*/

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

#define NAME SCRIPT\_DOOR

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

/\* Defines and Macros \*/

/\* Door States \*/

#define STATE\_ACTIVE (0)

#define STATE\_INACTIVE (1)

#define STATE\_WOOD (0)

#define STATE\_METAL (1)

#define STATE\_NON\_DESTROY (2)

#define STATE\_STANDARD\_LOCK (0)

#define STATE\_ELECTRIC\_LOCK (1)

#define STATE\_DOOR\_CLOSE (1)

#define STATE\_DOOR\_NOCLOSE (0)

/\* Sets whether the door is locked or trapped or closing \*/

#define LOCKED\_STATUS STATE\_ACTIVE

#define TRAPPED\_STATUS STATE\_INACTIVE

#define DOOR\_STATUS STATE\_METAL

#define LOCK\_STATUS STATE\_STANDARD\_LOCK

#define CLOSE\_STATUS STATE\_DOOR\_NOCLOSE

/\* Penalties for Lock difficulty based on whether or not you are using lockpicks. \*/

#define Lock\_Bonus (0)

#define Lockpick\_Bonus (Lock\_Bonus+20)

#define Exd\_Lockpick\_Bonus (Lock\_Bonus+40)

/\* Penalties for disarming the trap \*/

#define Trap\_Bonus (0)

#define Trap\_Set\_Bonus (Trap\_Bonus-10)

/\* Penalties for forcing the door open using strength \*/

#define Crowbar\_Bonus (0)

/\* Max and Min damage for the trap \*/

#define DOOR\_STRENGTH (2)

#define MIN\_DAMAGE (10)

#define MAX\_DAMAGE (20)

#define Crowbar\_Strain (2)

/\* Experience Points for Skills \*/

#define Lockpick\_Exp EXP\_LOCKPICK\_NORMAL

#define Traps\_Exp EXP\_TRAPS\_NORMAL

/\* Door close distance \*/

#define DOOR\_CLOSE\_DIST (2)

/\* How far do you want the last object that used the door to get away before it closes \*/

/\* Timer id's \*/

#define TIMER\_CLOSE (1)

/\* Standard Script Procedures \*/

procedure start;

procedure use\_p\_proc;

procedure look\_at\_p\_proc;

procedure description\_p\_proc;

procedure use\_skill\_on\_p\_proc;

procedure use\_obj\_on\_p\_proc;

procedure damage\_p\_proc;

procedure map\_enter\_p\_proc;

procedure map\_update\_p\_proc;

/\* Script Specific Procedure Calls \*/

procedure Look\_Traps\_And\_Locks;

procedure Look\_Traps;

procedure Look\_Locks;

procedure Skill\_Disarm\_Traps;

procedure Disarm\_Traps;

procedure Unlock\_Lock;

procedure Lockpick\_Lock;

procedure Lockpick\_Door;

procedure Super\_Lockpick\_Lock;

procedure Lock\_Door;

procedure Set\_Lock;

procedure Set\_Lockpick\_Lock;

procedure Super\_Set\_Lockpick\_Lock;

procedure Set\_Trap;

procedure Pry\_Door;

procedure Damage\_Critter;

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   Local Variables which are saved. All Local Variables need to be

   prepended by LVAR\_

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

#define LVAR\_Locked (0)

#define LVAR\_Trapped (1)

#define LVAR\_Found\_Trap (2)

#define LVAR\_Set\_Door\_Status (3)

#define LVAR\_Explosion\_Attempts (4)

#define LVAR\_Gave\_Locks\_XP (5)

#define LVAR\_Gave\_Traps\_XP (6)

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   Imported variables from the Map scripts. These should only be

   pointers and variables that need not be saved. If a variable

   Needs to be saved, make it a map variable (MVAR\_)

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   Local variables which do not need to be saved between map changes.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

variable Locks\_Roll;

variable Traps\_Roll;

variable last\_source\_obj;

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

\*\*\*\*\*\*\* PROCEDURES \*\*\*\*\*\*\*

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   The start procedure is the first procedure called when the map is

   first entered. Any initial information that needs to be set up

   should be placed in here.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure start begin

end

procedure timed\_event\_p\_proc begin

   if (obj\_is\_open(self\_obj)) then begin

      if not combat\_is\_initialized then begin

         if (tile\_distance\_objs(self\_obj, last\_source\_obj) < DOOR\_CLOSE\_DIST and critter\_state(last\_source\_obj) != CRITTER\_IS\_DEAD) then

            add\_timer\_event(self\_obj, 10, TIMER\_CLOSE);

         else

            obj\_close(self\_obj);

      end else

         add\_timer\_event(self\_obj, 10, TIMER\_CLOSE);

   end

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   Any time that a critter tries to use this door will call this

   procedure. it will check to see if the door is trapped and locked.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure use\_p\_proc begin

/\* Trap\_Roll is a global variable to this script, defined at the beginning

   of the script. \*/

   Traps\_Roll:=roll\_vs\_skill(source\_obj,SKILL\_TRAPS,Trap\_Bonus);

   if (local\_var(LVAR\_Trapped) == STATE\_ACTIVE) then begin

       if (is\_success(Traps\_Roll)) then begin

           script\_overrides;

           set\_local\_var(LVAR\_Found\_Trap,1);

           reg\_anim\_clear(source\_obj);

           if (source\_obj == dude\_obj) then begin

               display\_msg(mstr(204));

           end

           else begin

               display\_msg(mstr(205));

           end

       end

       else begin

           if (obj\_is\_locked(self\_obj)) then begin

               script\_overrides;

               display\_msg(mstr(203));

               call Damage\_Critter;

           end

           else begin

               call Damage\_Critter;

           end

       end

   end

   else if (obj\_is\_locked(self\_obj)) then begin

       script\_overrides;

       display\_msg(mstr(203));

   end

   if (CLOSE\_STATUS == STATE\_DOOR\_CLOSE) then begin

      last\_source\_obj := source\_obj;

      add\_timer\_event(self\_obj, 10, TIMER\_CLOSE);

   end

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This is cursory glance description that the player will receive should

   he just pass the Action Cursor over. Examines which give more information

   need to be in the description\_p\_proc procedure.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure look\_at\_p\_proc begin

   script\_overrides;

   if (DOOR\_STATUS == STATE\_WOOD) then begin

       display\_msg(mstr(100));

   end

   else begin

       display\_msg(mstr(101));

   end

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   Should the player examine the door closely, then he should be allowed a lockpick

   roll, a traps roll and a perception roll. Depending on which rolls are made will

   determine how much information about the door will be given.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure description\_p\_proc begin

   script\_overrides;

   if ((local\_var(LVAR\_Locked) == STATE\_ACTIVE) and (local\_var(LVAR\_Trapped) == STATE\_ACTIVE)) then begin

       call Look\_Traps\_And\_Locks;

   end

   else if (local\_var(LVAR\_Trapped) == STATE\_ACTIVE) then begin

       call Look\_Traps;

   end

   else if (local\_var(LVAR\_Locked) == STATE\_ACTIVE) then begin

       call Look\_Locks;

   end

   else if (DOOR\_STATUS == STATE\_WOOD) then begin

       display\_msg(mstr(100));

   end

   else begin

       display\_msg(mstr(101));

   end

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   Should the player try using a skill on the door, here are where the skill rolls

   will be made. The ones which need to be in here are: Lockpick and Traps. Science

   and Repair can be added to this list to give more information about the door.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure use\_skill\_on\_p\_proc begin

   variable Skill\_Used;

   Skill\_Used:=action\_being\_used;

   if (Skill\_Used == SKILL\_LOCKPICK) then begin

       if (local\_var(LVAR\_Locked) == STATE\_ACTIVE) then begin

           call Unlock\_Lock;

       end

       else begin

           call Set\_Lock;

       end

   end // End of Skill\_Lockpick

   else if (Skill\_Used == SKILL\_TRAPS) then begin

       if (local\_var(LVAR\_Trapped) == STATE\_ACTIVE) then begin

           call Skill\_Disarm\_Traps;

       end

       else begin

           if (source\_obj == dude\_obj) then begin

               display\_msg(mstr(195));

           end

           else begin

               display\_msg(obj\_name(source\_obj)+mstr(200));

           end

       end

   end // End of Skill\_Traps

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This is called when the player is using an object on the door. When the check is

   made to find out what is being used, obj\_pid(obj\_being\_used\_with) will need to

   be checked against a prototype.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure use\_obj\_on\_p\_proc begin

   variable Tool;

   Tool:=obj\_pid(obj\_being\_used\_with);

   if (LOCK\_STATUS == STATE\_STANDARD\_LOCK) then begin

       if (Tool == PID\_LOCKPICKS) then begin

           if (local\_var(LVAR\_Locked) == STATE\_ACTIVE) then begin

               call Lockpick\_Lock;

           end

           else begin

               call Set\_Lockpick\_Lock;

           end

       end

       else if (Tool == PID\_EXP\_LOCKPICK\_SET) then begin

           if (local\_var(LVAR\_Locked) == STATE\_ACTIVE) then begin

               call Super\_Lockpick\_Lock;

           end

           else begin

               call Super\_Set\_Lockpick\_Lock;

           end

       end

   end

   else if (LOCK\_STATUS == STATE\_ELECTRIC\_LOCK) then begin

       if (Tool == PID\_ELECTRONIC\_LOCKPICKS) then begin

           if (local\_var(LVAR\_Locked) == STATE\_ACTIVE) then begin

               call Lockpick\_Lock;

           end

           else begin

               call Set\_Lockpick\_Lock;

           end

       end

       else if (Tool == PID\_ELEC\_LOCKPICK\_MKII) then begin

           if (local\_var(LVAR\_Locked) == STATE\_ACTIVE) then begin

               call Super\_Lockpick\_Lock;

           end

           else begin

               call Super\_Set\_Lockpick\_Lock;

           end

       end

   end

   else if (Tool == PID\_CROWBAR) then begin

       call Pry\_Door;

   end

   else if ((Tool == PID\_DYNAMITE) or (Tool == PID\_PLASTIC\_EXPLOSIVES)) then begin

       call Set\_Trap;

   end

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   Should the door sustain damage from anything (ie, dynamite, plastic explosives, rockets,

   or any other forms of damage), this procedure will be called to destroy the door and

   free up the space.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure damage\_p\_proc begin

   variable Trap\_Damage;

  /\*\*\*\*\*\*\*\*\*\*\*\* Wood Door \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

 if (weapon\_dmg\_type(target\_obj) == DMG\_explosion) then begin

   if (DOOR\_STATUS == STATE\_WOOD) then begin

       if (local\_var(LVAR\_Trapped) == STATE\_ACTIVE) then begin

           set\_local\_var(LVAR\_Trapped, STATE\_INACTIVE);

           set\_local\_var(LVAR\_Locked, STATE\_INACTIVE);

           Trap\_Damage:=random(MIN\_DAMAGE,MAX\_DAMAGE);

           explosion(tile\_num(self\_obj), elevation(self\_obj), Trap\_Damage);

           destroy\_object(self\_obj);

       end

       else begin

           set\_local\_var(LVAR\_Trapped, STATE\_INACTIVE);

           set\_local\_var(LVAR\_Locked, STATE\_INACTIVE);

           destroy\_object(self\_obj);

       end

   end

  /\*\*\*\*\*\*\*\*\*\*\*\* Metal Door \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

   else if (DOOR\_STATUS == STATE\_METAL) then begin

       set\_local\_var(LVAR\_Explosion\_Attempts,local\_var(LVAR\_Explosion\_Attempts)+1);

       if (local\_var(LVAR\_Trapped) == STATE\_ACTIVE) then begin

           set\_local\_var(LVAR\_Locked, STATE\_INACTIVE);

           Trap\_Damage:=random(MIN\_DAMAGE,MAX\_DAMAGE);

           explosion(tile\_num(self\_obj), elevation(self\_obj), Trap\_Damage);

       end

       else if (local\_var(LVAR\_Explosion\_Attempts) > DOOR\_STRENGTH) then begin

           set\_local\_var(LVAR\_Trapped, STATE\_INACTIVE);

           set\_local\_var(LVAR\_Locked,STATE\_INACTIVE);

           destroy\_object(self\_obj);

       end

   end

end

   else begin

       display\_msg(mstr(193));

   end

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   Whenever the map is first entered, this procedure will be called. The main purpose of

   this procedure is to lock the door from the outset, rather than having to worry about

   it through Mapper. After the door has been unlocked, it will remain as such, unless

   the player locks it once more.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure map\_enter\_p\_proc begin

/\* Set up the door state when the player first enters the map \*/

   if (local\_var(LVAR\_Set\_Door\_Status) == 0) then begin

       set\_local\_var(LVAR\_Set\_Door\_Status,1);

       set\_local\_var(LVAR\_Locked,LOCKED\_STATUS);

       set\_local\_var(LVAR\_Trapped,TRAPPED\_STATUS);

   end

   if (local\_var(LVAR\_Locked) == STATE\_ACTIVE) then begin

       obj\_lock(self\_obj);

   end

   else begin

       obj\_unlock(self\_obj);

   end

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This procedure gets called roughly every 30 seconds of real time. It is used to make

   sure that the door does not lock on it's own and that the player will be able to get

   through once he has unlocked the door. Once more, this is so that locking and

   unlocking do not need to be done in Mapper.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure map\_update\_p\_proc begin

   if (local\_var(LVAR\_Locked) == STATE\_ACTIVE) then begin

       obj\_lock(self\_obj);

   end

   else begin

       obj\_unlock(self\_obj);

   end

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This is the set of conditions for when you look at a locked and trapped door, based

   on your lockpick and traps skills and perception to notice things.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure Look\_Traps\_And\_Locks begin

   variable Perception\_Check;

   variable Traps\_Check;

   variable Locks\_Check;

   Perception\_Check:=do\_check(dude\_obj,STAT\_pe,0);

   Traps\_Check:=roll\_vs\_skill(dude\_obj,SKILL\_TRAPS,0);

   Locks\_Check:=roll\_vs\_skill(dude\_obj,SKILL\_LOCKPICK,0);

   if (is\_success(Perception\_Check)) then begin

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

      /\* Critical Success of a Perception Check (Start)\*/

       if (is\_critical(Perception\_Check)) then begin

           if (is\_success(Traps\_Check)) then begin

               set\_local\_var(LVAR\_Found\_Trap,1); // player has found the trap

      /\* Critical Success of a Traps Check (Start)\*/

               if (is\_critical(Traps\_Check)) then begin

                   if (is\_success(Locks\_Check)) then begin

                       if (is\_critical(Locks\_Check)) then begin

                           display\_msg(mstr(102));

                       end // critical success (Locks)

                       else begin

                           display\_msg(mstr(103));

                       end // regular success (Locks)

                   end

                   else if (is\_critical(Locks\_Check)) then begin

                       display\_msg(mstr(104));

                   end // critical Failure (Locks)

                   else begin

                       display\_msg(mstr(105));

                   end // end of regular failure (Locks)

               end // critical success (Traps)

      /\* Success of a Traps Check (Start)\*/

               else begin

                   if (is\_success(Locks\_Check)) then begin

                       if (is\_critical(Locks\_Check)) then begin

                           display\_msg(mstr(106));

                       end // critical success (Locks)

                       else begin

                           display\_msg(mstr(107));

                       end // regular success (Locks)

                   end

                   else if (is\_critical(Locks\_Check)) then begin

                       display\_msg(mstr(108));

                   end // critical Failure (Locks)

                   else begin

                       display\_msg(mstr(109));

                   end // end of regular failure (Locks)

               end // regular success (Traps)

           end

      /\* Critical Failure of a Traps Check (Start)\*/

           else if (is\_critical(Traps\_Check)) then begin

               if (is\_success(Locks\_Check)) then begin

                   if (is\_critical(Locks\_Check)) then begin

                       display\_msg(mstr(110));

                   end // critical success (Locks)

                   else begin

                       display\_msg(mstr(111));

                   end // regular success (Locks)

               end

               else if (is\_critical(Locks\_Check)) then begin

                   display\_msg(mstr(112));

               end // critical Failure (Locks)

               else begin

                   display\_msg(mstr(113));

               end // end of regular failure (Locks)

          end // critical Failure (Traps)

      /\* Failure of a Traps Check (Start)\*/

           else begin

               if (is\_success(Locks\_Check)) then begin

                   if (is\_critical(Locks\_Check)) then begin

                       display\_msg(mstr(114));

                   end // critical success (Locks)

                   else begin

                       display\_msg(mstr(115));

                   end // regular success (Locks)

               end

               else if (is\_critical(Locks\_Check)) then begin

                   display\_msg(mstr(116));

               end // critical Failure (Locks)

               else begin

                   display\_msg(mstr(117));

               end // end of regular failure (Locks)

           end // regular failure (Traps)

       end // critical success (Stat\_Pe)

      /\* Critical Success of a Perception Check (Finish)\*/

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

      /\* Success of a Perception Check (Start)\*/

       else begin

           if (is\_success(Traps\_Check)) then begin

               set\_local\_var(LVAR\_Found\_Trap,1); // player has found the trap

      /\* Critical Success of a Traps Check (Start)\*/

               if (is\_critical(Traps\_Check)) then begin

                   if (is\_success(Locks\_Check)) then begin

                       if (is\_critical(Locks\_Check)) then begin

                           display\_msg(mstr(118));

                       end // critical success (Locks)

                       else begin

                           display\_msg(mstr(119));

                       end // regular success (Locks)

                   end

                   else if (is\_critical(Locks\_Check)) then begin

                       display\_msg(mstr(120));

                   end // critical Failure (Locks)

                   else begin

                       display\_msg(mstr(121));

                   end // end of regular failure (Locks)

               end // critical success (Traps)

      /\* Success of a Traps Check (Start)\*/

               else begin

                   if (is\_success(Locks\_Check)) then begin

                       if (is\_critical(Locks\_Check)) then begin

                           display\_msg(mstr(122));

                       end // critical success (Locks)

                       else begin

                           display\_msg(mstr(123));

                       end // regular success (Locks)

                   end

                   else if (is\_critical(Locks\_Check)) then begin

                       display\_msg(mstr(124));

                   end // critical Failure (Locks)

                   else begin

                       display\_msg(mstr(125));

                   end // end of regular failure (Locks)

               end // regular success (Traps)

           end

      /\* Critical Failure of a Traps Check (Start)\*/

           else if (is\_critical(Traps\_Check)) then begin

               if (is\_success(Locks\_Check)) then begin

                   if (is\_critical(Locks\_Check)) then begin

                       display\_msg(mstr(126));

                   end // critical success (Locks)

                   else begin

                       display\_msg(mstr(127));

                   end // regular success (Locks)

               end

               else if (is\_critical(Locks\_Check)) then begin

                   display\_msg(mstr(128));

               end // critical Failure (Locks)

               else begin

                   display\_msg(mstr(129));

               end // end of regular failure (Locks)

           end // critical Failure (Traps)

      /\* Failure of a Traps Check (Start)\*/

           else begin

               if (is\_success(Locks\_Check)) then begin

                   if (is\_critical(Locks\_Check)) then begin

                       display\_msg(mstr(130));

                   end // critical success (Locks)

                   else begin

                       display\_msg(mstr(131));

                   end // regular success (Locks)

               end

               else if (is\_critical(Locks\_Check)) then begin

                   display\_msg(mstr(132));

               end // critical Failure (Locks)

               else begin

                   display\_msg(mstr(133));

               end // end of regular failure (Locks)

           end // regular failure (Traps)

       end // regular success (Stat\_pe)

   end

      /\* Success of a Perception Check (Finish)\*/

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

      /\* Critical Failure of a Perception Check (Start)\*/

   else if (is\_critical(Perception\_Check)) then begin

       if (is\_success(Traps\_Check)) then begin

           set\_local\_var(LVAR\_Found\_Trap,1); // player has found the trap

      /\* Critical Success of a Traps Check (Start)\*/

           if (is\_critical(Traps\_Check)) then begin

               if (is\_success(Locks\_Check)) then begin

                   if (is\_critical(Locks\_Check)) then begin

                       display\_msg(mstr(134));

                   end // critical success (Locks)

                   else begin

                       display\_msg(mstr(135));

                   end // regular success (Locks)

               end

               else if (is\_critical(Locks\_Check)) then begin

                   display\_msg(mstr(136));

               end // critical Failure (Locks)

               else begin

                   display\_msg(mstr(137));

               end // end of regular failure (Locks)

           end // critical success (Traps)

      /\* Success of a Traps Check (Start)\*/

           else begin

               if (is\_success(Locks\_Check)) then begin

                   if (is\_critical(Locks\_Check)) then begin

                       display\_msg(mstr(138));

                   end // critical success (Locks)

                   else begin

                       display\_msg(mstr(139));

                   end // regular success (Locks)

               end

               else if (is\_critical(Locks\_Check)) then begin

                   display\_msg(mstr(140));

               end // critical Failure (Locks)

               else begin

                   display\_msg(mstr(141));

               end // end of regular failure (Locks)

           end // regular success (Traps)

       end

      /\* Critical Failure of a Traps Check (Start)\*/

       else if (is\_critical(Traps\_Check)) then begin

           if (is\_success(Locks\_Check)) then begin

               if (is\_critical(Locks\_Check)) then begin

                   display\_msg(mstr(142));

               end // critical success (Locks)

               else begin

                   display\_msg(mstr(143));

               end // regular success (Locks)

           end

           else if (is\_critical(Locks\_Check)) then begin

               display\_msg(mstr(144));

           end // critical Failure (Locks)

           else begin

               display\_msg(mstr(145));

           end // end of regular failure (Locks)

       end // critical Failure (Traps)

      /\* Failure of a Traps Check (Start)\*/

       else begin

           if (is\_success(Locks\_Check)) then begin

               if (is\_critical(Locks\_Check)) then begin

                   display\_msg(mstr(146));

               end // critical success (Locks)

               else begin

                   display\_msg(mstr(147));

               end // regular success (Locks)

           end

           else if (is\_critical(Locks\_Check)) then begin

               display\_msg(mstr(148));

           end // critical Failure (Locks)

           else begin

               display\_msg(mstr(149));

           end // end of regular failure (Locks)

       end // regular failure (Traps)

   end // Critical Failure (Stat\_pe)

      /\* Critical Failure of a Perception Check (Finish)\*/

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

      /\* Failure of a Perception Check (Start)\*/

   else begin

       if (is\_success(Traps\_Check)) then begin

           set\_local\_var(LVAR\_Found\_Trap,1); // player has found the trap

      /\* Critical Success of a Traps Check (Start)\*/

           if (is\_critical(Traps\_Check)) then begin

               if (is\_success(Locks\_Check)) then begin

                   if (is\_critical(Locks\_Check)) then begin

                       display\_msg(mstr(150));

                   end // critical success (Locks)

                   else begin

                       display\_msg(mstr(151));

                   end // regular success (Locks)

               end

               else if (is\_critical(Locks\_Check)) then begin

                   display\_msg(mstr(152));

               end // critical Failure (Locks)

               else begin

                   display\_msg(mstr(153));

               end // end of regular failure (Locks)

           end // critical success (Traps)

      /\* Success of a Traps Check (Start)\*/

           else begin

               if (is\_success(Locks\_Check)) then begin

                   if (is\_critical(Locks\_Check)) then begin

                       display\_msg(mstr(154));

                   end // critical success (Locks)

                   else begin

                       display\_msg(mstr(155));

                   end // regular success (Locks)

               end

               else if (is\_critical(Locks\_Check)) then begin

                   display\_msg(mstr(156));

               end // critical Failure (Locks)

               else begin

                   display\_msg(mstr(157));

               end // end of regular failure (Locks)

           end // regular success (Traps)

       end

      /\* Critical Failure of a Traps Check (Start)\*/

       else if (is\_critical(Traps\_Check)) then begin

           if (is\_success(Locks\_Check)) then begin

               if (is\_critical(Locks\_Check)) then begin

                   display\_msg(mstr(158));

               end // critical success (Locks)

               else begin

                   display\_msg(mstr(159));

               end // regular success (Locks)

           end

           else if (is\_critical(Locks\_Check)) then begin

               display\_msg(mstr(160));

           end // critical Failure (Locks)

           else begin

               display\_msg(mstr(161));

           end // end of regular failure (Locks)

       end // critical Failure (Traps)

      /\* Failure of a Traps Check (Start)\*/

       else begin

           if (is\_success(Locks\_Check)) then begin

               if (is\_critical(Locks\_Check)) then begin

                   display\_msg(mstr(162));

               end // critical success (Locks)

               else begin

                   display\_msg(mstr(163));

               end // regular success (Locks)

           end

           else if (is\_critical(Locks\_Check)) then begin

               display\_msg(mstr(164));

           end // critical Failure (Locks)

           else begin

               display\_msg(mstr(165));

           end // end of regular failure (Locks)

       end // regular failure (Traps)

   end // Regular Failure (Stat\_pe)

      /\* Failure of a Perception Check (Finish)\*/

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This is the set of conditions for when you look at a trapped door, based on your

   traps skill and perception to notice the trap.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure Look\_Traps begin

   variable Perception\_Check;

   variable Traps\_Check;

   Perception\_Check:=do\_check(dude\_obj,STAT\_pe,0);

   Traps\_Check:=roll\_vs\_skill(dude\_obj,SKILL\_TRAPS,0);

   if (is\_success(Perception\_Check)) then begin

       if (is\_critical(Perception\_Check)) then begin

           if (is\_success(Traps\_Check)) then begin

               if (is\_critical(Traps\_Check)) then begin

                   display\_msg(mstr(104));

               end // Critical Success (traps)

               else begin

                   display\_msg(mstr(108));

               end // Regular Success (Traps)

           end

           else if (is\_critical(Traps\_Check)) then begin

               display\_msg(mstr(112));

           end // Critical Failure (Traps)

           else begin

               display\_msg(mstr(116));

           end // Regular Failure (Traps)

       end // Critical Success (Stat\_Pe)

       else begin

           if (is\_success(Traps\_Check)) then begin

               if (is\_critical(Traps\_Check)) then begin

                   display\_msg(mstr(120));

               end // Critical Success (traps)

               else begin

                   display\_msg(mstr(124));

               end // Regular Success (Traps)

           end

           else if (is\_critical(Traps\_Check)) then begin

               display\_msg(mstr(128));

           end // Critical Failure (Traps)

           else begin

               display\_msg(mstr(132));

           end // Regular Failure (Traps)

       end // Regular Success (Stat\_pe)

   end

   else if (is\_critical(Perception\_Check)) then begin

       if (is\_success(Traps\_Check)) then begin

           if (is\_critical(Traps\_Check)) then begin

               display\_msg(mstr(136));

           end // Critical Success (traps)

           else begin

               display\_msg(mstr(140));

           end // Regular Success (Traps)

       end

       else if (is\_critical(Traps\_Check)) then begin

           display\_msg(mstr(144));

       end // Critical Failure (Traps)

       else begin

           display\_msg(mstr(148));

       end // Regular Failure (Traps)

   end // Critical Failure (Stat\_pe)

   else begin

       if (is\_success(Traps\_Check)) then begin

           if (is\_critical(Traps\_Check)) then begin

               display\_msg(mstr(152));

           end // Critical Success (traps)

           else begin

               display\_msg(mstr(156));

           end // Regular Success (Traps)

       end

       else if (is\_critical(Traps\_Check)) then begin

           display\_msg(mstr(160));

       end // Critical Failure (Traps)

       else begin

           display\_msg(mstr(164));

       end // Regular Failure (Traps)

   end // Regular Failure (Stat\_Pe)

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This is the set of conditions for when you look at a locked door, based on your

   lockpick skill and perception to notice the lock.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure Look\_Locks begin

   variable Perception\_Check;

   variable Locks\_Check;

   Perception\_Check:=do\_check(dude\_obj,STAT\_pe,0);

   Locks\_Check:=roll\_vs\_skill(dude\_obj,SKILL\_LOCKPICK,0);

   if (is\_success(Perception\_Check)) then begin

       if (is\_critical(Perception\_Check)) then begin

           if (is\_success(Locks\_Check)) then begin

               if (is\_critical(Locks\_Check)) then begin

                   display\_msg(mstr(114));

               end // Critical Success (Locks)

               else begin

                   display\_msg(mstr(115));

               end // Regular Success (Locks)

           end

           else if (is\_critical(Locks\_Check)) then begin

               display\_msg(mstr(116));

           end // Critical Failure (Locks)

           else begin

               display\_msg(mstr(117));

           end // Regular Failure (Locks)

       end // Critical Success (Stat\_Pe)

       else begin

           if (is\_success(Locks\_Check)) then begin

               if (is\_critical(Locks\_Check)) then begin

                   display\_msg(mstr(130));

               end // Critical Success (Locks)

               else begin

                   display\_msg(mstr(131));

               end // Regular Success (Locks)

           end

           else if (is\_critical(Locks\_Check)) then begin

               display\_msg(mstr(132));

           end // Critical Failure (Locks)

           else begin

               display\_msg(mstr(133));

           end // Regular Failure (Locks)

       end // Regular Success (Stat\_pe)

   end

   else if (is\_critical(Perception\_Check)) then begin

       if (is\_success(Locks\_Check)) then begin

           if (is\_critical(Locks\_Check)) then begin

               display\_msg(mstr(146));

           end // Critical Success (Locks)

           else begin

               display\_msg(mstr(147));

           end // Regular Success (Locks)

       end

       else if (is\_critical(Locks\_Check)) then begin

           display\_msg(mstr(148));

       end // Critical Failure (Locks)

       else begin

           display\_msg(mstr(149));

       end // Regular Failure (Locks)

   end // Critical Failure (Stat\_pe)

   else begin

       if (is\_success(Locks\_Check)) then begin

           if (is\_critical(Locks\_Check)) then begin

               display\_msg(mstr(162));

           end // Critical Success (Locks)

           else begin

               display\_msg(mstr(163));

           end // Regular Success (Locks)

       end

       else if (is\_critical(Locks\_Check)) then begin

           display\_msg(mstr(164));

       end // Critical Failure (Locks)

       else begin

           display\_msg(mstr(165));

       end // Regular Failure (Locks)

   end // Regular Failure (Stat\_Pe)

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This procedure will do a standard Traps roll to see if the player can

   find and remove traps from the door.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure Skill\_Disarm\_Traps begin

/\* Trap\_Roll is a global variable to this script, defined at the beginning

   of the script. \*/

   Traps\_Roll:=roll\_vs\_skill(source\_obj,SKILL\_TRAPS,Trap\_Bonus);

   call Disarm\_Traps;

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This procedure will allow the player to set traps on doors behind him. The door

   will need to be closed, as all traps are set to go off if the door is openned.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure Set\_Trap begin

   variable Explosive;

   variable Removal\_Counter;

/\* Trap\_Roll is a global variable to this script, defined at the beginning

   of the script. \*/

   Traps\_Roll:=roll\_vs\_skill(source\_obj,SKILL\_TRAPS,Trap\_Set\_Bonus);

   Explosive:=obj\_being\_used\_with;

   if (obj\_is\_open(self\_obj)) then begin

       script\_overrides;

       if (source\_obj == dude\_obj) then begin

           display\_msg(mstr(206));

       end

       else begin

           display\_msg(obj\_name(source\_obj)+mstr(207));

       end

   end

   else begin

       script\_overrides;

       Removal\_Counter:=rm\_mult\_objs\_from\_inven(source\_obj,Explosive,1);

       if (is\_success(Traps\_Roll)) then begin

           set\_local\_var(LVAR\_Trapped,STATE\_ACTIVE);

           if (source\_obj == dude\_obj) then begin

               display\_msg(mstr(208));

           end

           else begin

               display\_msg(obj\_name(source\_obj)+mstr(210));

           end

       end

       else if (is\_critical(Traps\_Roll)) then begin

           call Damage\_Critter;

       end

       else begin

           if (source\_obj == dude\_obj) then begin

               display\_msg(mstr(209));

           end

           else begin

               display\_msg(obj\_name(source\_obj)+mstr(211));

           end

       end

   end

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This procedure will do a skill check vs traps to determine if the player

   or NPC finds the trap. If the trap is found, then it will check to see if

   the player or NPC set off the trap or disarms it.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure Disarm\_Traps begin

   if (is\_success(Traps\_Roll)) then begin

       if (local\_var(LVAR\_Found\_Trap) == 0) then begin

           set\_local\_var(LVAR\_Found\_Trap,1);

           if (source\_obj == dude\_obj) then begin

               display\_msg(mstr(194));

           end

           else begin

               display\_msg(mstr(199));

           end

           if (local\_var(LVAR\_Gave\_Traps\_XP) == 0) then begin

               set\_local\_var(LVAR\_Gave\_Traps\_XP,1);

               give\_xp(Traps\_Exp);

           end

       end

       else begin

           set\_local\_var(LVAR\_Trapped,STATE\_INACTIVE);

           if (source\_obj == dude\_obj) then begin

               display\_msg(mstr(196));

           end

           else begin

               display\_msg(obj\_name(source\_obj)+mstr(201));

           end

       end

   end

   else if (is\_critical(Traps\_Roll)) then begin

       call Damage\_Critter;

   end

   else begin

       if (local\_var(LVAR\_Found\_Trap) == 0) then begin

           if (source\_obj == dude\_obj) then begin

               display\_msg(mstr(195));

           end

           else begin

               display\_msg(obj\_name(source\_obj)+mstr(200));

           end

       end

       else begin

           display\_msg(obj\_name(source\_obj)+mstr(202));

       end

   end

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This procedure will just do a standard lockpick roll to see if the player

   can lockpick the door

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure Unlock\_Lock begin

/\* Locks\_Roll is a global variable to this script, defined at the beginning

   of the script. \*/

   Locks\_Roll:=roll\_vs\_skill(source\_obj,SKILL\_LOCKPICK,Lock\_Bonus);

   call Lockpick\_Door;

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This procedure will do a lockpick roll if the player or NPC uses lockpick

   on the door. There will be a modifer from the standard roll, because the

   player will have proper tools.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure Lockpick\_Lock begin

/\* Locks\_Roll is a global variable to this script, defined at the beginning

   of the script. \*/

   Locks\_Roll:=roll\_vs\_skill(source\_obj,SKILL\_LOCKPICK,Lockpick\_Bonus);

   call Lockpick\_Door;

end

procedure Super\_Lockpick\_Lock begin

/\* Locks\_Roll is a global variable to this script, defined at the beginning

   of the script. \*/

   Locks\_Roll:=roll\_vs\_skill(source\_obj,SKILL\_LOCKPICK,Exd\_Lockpick\_Bonus);

   call Lockpick\_Door;

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This procedure will check against the roll\_vs\_lockpick to see if the

   source\_object will unlock the door and display the appropriate messages

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure Lockpick\_Door begin

   if (is\_success(Locks\_Roll)) then begin

       set\_local\_var(LVAR\_Locked, STATE\_INACTIVE); // Door is unlocked

       obj\_unlock(self\_obj); // engine unlock door

       if (source\_obj == dude\_obj) then begin

           display\_msg(mstr(170));

       end

       else begin

           display\_msg(obj\_name(source\_obj)+mstr(173));

       end

       if (local\_var(LVAR\_Gave\_Locks\_XP) == 0) then begin

           set\_local\_var(LVAR\_Gave\_Locks\_XP,1);

           give\_xp(Lockpick\_Exp);

       end

   end

   else if (is\_critical(Locks\_Roll)) then begin

       jam\_lock(self\_obj);

       if (source\_obj == dude\_obj) then begin

           display\_msg(mstr(171));

       end

       else begin

           display\_msg(obj\_name(source\_obj)+mstr(174));

       end

   end

   else begin

       if (source\_obj == dude\_obj) then begin

           display\_msg(mstr(172));

       end

       else begin

           display\_msg(obj\_name(source\_obj)+mstr(175));

       end

   end

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This procedure will allow the source\_obj to lock the door that he had

   just unlocked.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure Set\_Lock begin

/\* Locks\_Roll is a global variable to this script, defined at the beginning

   of the script. \*/

   Locks\_Roll:=roll\_vs\_skill(source\_obj,SKILL\_LOCKPICK,Lock\_Bonus);

   call Lock\_Door;

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This procedure will allow the source\_obj to lock the door that he had

   just unlocked using its lockpicks to accomplish this deed.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure Set\_Lockpick\_Lock begin

/\* Locks\_Roll is a global variable to this script, defined at the beginning

   of the script. \*/

   Locks\_Roll:=roll\_vs\_skill(source\_obj,SKILL\_LOCKPICK,Lockpick\_Bonus);

   call Lock\_Door;

end

procedure Super\_Set\_Lockpick\_Lock begin

/\* Locks\_Roll is a global variable to this script, defined at the beginning

   of the script. \*/

   Locks\_Roll:=roll\_vs\_skill(source\_obj,SKILL\_LOCKPICK,Exd\_Lockpick\_Bonus);

   call Lock\_Door;

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This procedure will actively set the lock on the door and set all of

   the coresponding varaibles for it.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure Lock\_Door begin

   if (is\_success(Locks\_Roll)) then begin

       set\_local\_var(LVAR\_Locked, STATE\_ACTIVE); // Door is unlocked

       obj\_lock(self\_obj); // engine unlock door

       if (source\_obj == dude\_obj) then begin

           display\_msg(mstr(189));

       end

       else begin

           display\_msg(obj\_name(source\_obj)+mstr(191));

       end

       if (local\_var(LVAR\_Gave\_Locks\_XP) == 0) then begin

           set\_local\_var(LVAR\_Gave\_Locks\_XP,1);

           give\_xp(Lockpick\_Exp);

       end

   end

   else begin

       if (source\_obj == dude\_obj) then begin

           display\_msg(mstr(190));

       end

       else begin

           display\_msg(obj\_name(source\_obj)+mstr(192));

       end

   end

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   This procedure is used should the player try to pry the door open using a

   crowbar or some similar instrument.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure Pry\_Door begin

   variable Stat\_Roll;

   Stat\_Roll:=do\_check(source\_obj,STAT\_st,Crowbar\_Bonus);

   if (is\_success(Stat\_Roll)) then begin

       set\_local\_var(LVAR\_Locked, STATE\_INACTIVE);

       obj\_unlock(self\_obj);

       if (source\_obj == dude\_obj) then begin

           display\_msg(mstr(176));

       end

       else begin

           display\_msg(mstr(181));

       end

   end

   else if (is\_critical(Stat\_Roll)) then begin

       critter\_dmg(source\_obj,Crowbar\_Strain,(DMG\_normal\_dam BWOR DMG\_BYPASS\_ARMOR));

       if (source\_obj == dude\_obj) then begin

           if (Crowbar\_Strain == 1) then begin

               display\_msg(mstr(177));

           end

           else begin

               display\_msg(mstr(178)+Crowbar\_Strain+mstr(179));

           end

       end

       else begin

           if (get\_critter\_stat(source\_obj,STAT\_gender) == GENDER\_MALE) then begin

               if (Crowbar\_Strain == 1) then begin

                   display\_msg(mstr(182));

               end

               else begin

                   display\_msg(mstr(183)+Crowbar\_Strain+mstr(184));

               end

           end

           else begin

               if (Crowbar\_Strain == 1) then begin

                   display\_msg(mstr(186));

               end

               else begin

                   display\_msg(mstr(187)+Crowbar\_Strain+mstr(188));

               end

           end

       end

   end

   else begin

       if (source\_obj == dude\_obj) then begin

           display\_msg(mstr(180));

       end

       else begin

           display\_msg(mstr(185));

       end

   end

end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

   Should the trap go off for any reason by critter influence, then this procedure will

   be called to deal damage to the critter, display a message stating how much damage

   was taken, and remove the trap.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

procedure Damage\_Critter begin

   variable Trap\_Damage;

   Trap\_Damage:=random(MIN\_DAMAGE,MAX\_DAMAGE);

   if (source\_obj == dude\_obj) then begin

       critter\_dmg(dude\_obj,Trap\_Damage,(DMG\_explosion BWOR DMG\_BYPASS\_ARMOR));

/\* display\_msg("You set off the trap and were hit for "+Trap\_Damage+" points of damage.); \*/

       display\_msg(mstr(166)+Trap\_Damage+mstr(167));

   end

   else begin

       critter\_dmg(source\_obj,Trap\_Damage,(DMG\_explosion BWOR DMG\_BYPASS\_ARMOR));

/\* display\_msg(Critter\_Name+" set off the trap was hit for "+Trap\_Damage+" points of damage"); \*/

       display\_msg(obj\_name(source\_obj)+mstr(168)+Trap\_Damage+mstr(169));

   end

/\* The trap is now disarmed and should never go off again. \*/

   set\_local\_var(LVAR\_Trapped, STATE\_INACTIVE);

end