ATSRTRPA.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.

\*/

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

   Filename: SprTrp0.ssl

   Purpose: This script is a spatial/scenery script for a spear

            trap. Basically, trap will be hidden until the player

            makes a successful stat roll (vs. Perception). Once

            Found, the trap will become visible and the player

            will have to try to disarm it.

   Created: December 18, 1997 RWH2

   Updated:

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

/\* Include Files \*/

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

#define NAME SCRIPT\_SPRTRP0

#define CUR\_SCRIPT SCRIPT\_ATSRTRPA

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

#include "..\headers\arcaves.h"

#define TRAP\_BONUS (0)

#define PERCEPTION\_BONUS (0)

#define AGILITY\_BONUS (0)

#define DIST\_BONUS (2)

#define TRAP\_EXP EXP\_TRAPS\_NORMAL

#define TRAP\_TIME (0) // In Seconds

#define MIN\_DMG (1)

#define MAX\_DMG (4)

#define INITIAL\_TILE (25708) // Tile num spear is fired from

#define PROJECTILE\_ROF (500)

#define TRAP\_MVAR MVAR\_Arroyo\_Trial\_Spear14

procedure start;

procedure spatial\_p\_proc;

procedure use\_skill\_on\_p\_proc;

procedure look\_at\_p\_proc;

procedure description\_p\_proc;

procedure timed\_event\_p\_proc;

procedure Missile\_Fired;

procedure Check\_Hit;

#define LVAR\_Trap\_Found (0)

#define LVAR\_Trap\_Exploded (1)

#define LVAR\_Gave\_Exp (2)

#define LVAR\_Got\_Perception\_Roll (3)

#define LVAR\_Extended\_Look (4)

variable Projectile;

variable Final\_Hex;

variable Projectile\_Dir;

procedure start begin

end

procedure spatial\_p\_proc begin

   variable Range;

   variable Range\_Mod;

   variable Detection\_Roll;

   variable Trap;

   if (obj\_type(source\_obj) == 1) then begin

       Range:=get\_critter\_stat(source\_obj,STAT\_pe) + PERCEPTION\_BONUS;

       Range\_Mod:=Range - (tile\_distance\_objs(self\_obj,source\_obj)\*DIST\_BONUS);

       if ((tile\_distance\_objs(self\_obj,source\_obj) <= Range) and

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

           if (Range\_Mod > PERCEPTION\_BONUS) then

               Range\_Mod:= PERCEPTION\_BONUS;

           Detection\_Roll:=do\_check(source\_obj,STAT\_pe,Range\_Mod);

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

               if (not(dude\_is\_running)) then begin

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

                   reg\_anim\_clear(source\_obj);

                   Trap:=create\_object\_sid(PID\_CAVE\_FLOOR\_TRAP\_VISIBLE,tile\_num(self\_obj),elevation(self\_obj),CUR\_SCRIPT);

               end

               if (is\_critical(Detection\_Roll)) then begin

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

                       display\_msg(mstr(100));

                   else if ((proto\_data(obj\_pid(source\_obj),cr\_body\_type) == CR\_BODY\_BIPED) and (obj\_can\_see\_obj(source\_obj,dude\_obj))) then

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

               end

               else begin

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

                       display\_msg(mstr(102));

                   else if ((proto\_data(obj\_pid(source\_obj),cr\_body\_type) == CR\_BODY\_BIPED) and (obj\_can\_see\_obj(source\_obj,dude\_obj))) then

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

               end

           end

       end

       if ((tile\_distance\_objs(self\_obj,source\_obj) == 0) and

           (local\_var(LVAR\_Trap\_Exploded) == 0) and (map\_var(TRAP\_MVAR) == 0)) then begin

           game\_ui\_disable;

           debug\_msg("Set off the Trap!");

           Projectile:=create\_object(PID\_FLYING\_SPEAR,INITIAL\_TILE,elevation(self\_obj));

           Face\_Critter(source\_obj,Projectile);

           if (tile\_contains\_obj\_pid(tile\_num(self\_obj),elevation(self\_obj),PID\_CAVE\_FLOOR\_TRAP\_VISIBLE)) then begin

               debug\_msg("Destroying Visible Trap");

               destroy\_object(tile\_contains\_pid\_obj(tile\_num(self\_obj),elevation(self\_obj),PID\_CAVE\_FLOOR\_TRAP\_VISIBLE));

               debug\_msg("Destroyed Visible Trap");

           end

           Trap:=create\_object(PID\_CAVE\_FLOOR\_TRAP\_DEPRESSED,tile\_num(self\_obj),elevation(self\_obj));

           call Check\_Hit;

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

           set\_map\_var(TRAP\_MVAR,1);

       end

   end

end

procedure use\_skill\_on\_p\_proc begin

   variable Traps\_Roll;

   variable Trap;

   if ((local\_var(LVAR\_Trap\_Exploded) == 0) and (map\_var(TRAP\_MVAR) == 0) and (action\_being\_used == SKILL\_TRAPS)) then begin

       script\_overrides;

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

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

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

               Trap:=create\_object\_sid(PID\_CAVE\_FLOOR\_TRAP\_DISARMED,tile\_num(self\_obj),elevation(self\_obj),CUR\_SCRIPT);

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

               set\_map\_var(TRAP\_MVAR,1);

               display\_msg(message\_str(SCRIPT\_GENERIC,102));

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

                   set\_local\_var(LVAR\_Gave\_Exp,1);

                   give\_xp(TRAP\_EXP);

               end

           end

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

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

               set\_map\_var(TRAP\_MVAR,1);

               display\_msg(message\_str(SCRIPT\_GENERIC,104));

               if (tile\_contains\_obj\_pid(tile\_num(self\_obj),elevation(self\_obj),PID\_CAVE\_FLOOR\_TRAP\_VISIBLE)) then begin

                   debug\_msg("Destroying Visible Trap");

                   destroy\_object(tile\_contains\_pid\_obj(tile\_num(self\_obj),elevation(self\_obj),PID\_CAVE\_FLOOR\_TRAP\_VISIBLE));

                   debug\_msg("Destroyed Visible Trap");

               end

               Trap:=create\_object\_sid(PID\_CAVE\_FLOOR\_TRAP\_DEPRESSED,tile\_num(self\_obj),elevation(self\_obj),CUR\_SCRIPT);

               call Check\_Hit;

           end

           else begin

               display\_msg(message\_str(SCRIPT\_GENERIC,103));

           end

       end

       else begin

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

               Trap:=create\_object\_sid(PID\_CAVE\_FLOOR\_TRAP\_DISARMED,tile\_num(self\_obj),elevation(self\_obj),CUR\_SCRIPT);

               set\_map\_var(TRAP\_MVAR,1);

               display\_msg(obj\_name(source\_obj)+message\_str(SCRIPT\_GENERIC,105));

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

                   set\_local\_var(LVAR\_Gave\_Exp,1);

                   give\_xp(TRAP\_EXP);

               end

           end

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

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

               set\_map\_var(TRAP\_MVAR,1);

               display\_msg(obj\_name(source\_obj)+message\_str(SCRIPT\_GENERIC,107));

               if (tile\_contains\_obj\_pid(tile\_num(self\_obj),elevation(self\_obj),PID\_CAVE\_FLOOR\_TRAP\_VISIBLE)) then begin

                   debug\_msg("Destroying Visible Trap");

                   destroy\_object(tile\_contains\_pid\_obj(tile\_num(self\_obj),elevation(self\_obj),PID\_CAVE\_FLOOR\_TRAP\_VISIBLE));

                   debug\_msg("Destroyed Visible Trap");

               end

               Trap:=create\_object\_sid(PID\_CAVE\_FLOOR\_TRAP\_DEPRESSED,tile\_num(self\_obj),elevation(self\_obj),CUR\_SCRIPT);

               call Check\_Hit;

           end

           else begin

               display\_msg(obj\_name(source\_obj)+message\_str(SCRIPT\_GENERIC,106));

           end

       end

   end

end

procedure look\_at\_p\_proc begin

   script\_overrides;

   display\_msg(mstr(102));

   debug\_msg("Looking At the Trap");

end

procedure description\_p\_proc begin

   variable Perception\_Roll;

   script\_overrides;

   if (local\_var(LVAR\_Got\_Perception\_Roll) == 0) then begin

       set\_local\_var(LVAR\_Got\_Perception\_Roll,1);

       Perception\_Roll:=do\_check(dude\_obj,STAT\_pe,PERCEPTION\_BONUS);

       set\_local\_var(LVAR\_Extended\_Look,Perception\_Roll);

   end

   if (is\_critical(local\_var(LVAR\_Extended\_Look))) then begin

       if (is\_success(local\_var(LVAR\_Extended\_Look))) then

           display\_msg(mstr(100));

       else

           display\_msg(mstr(106));

   end

   else begin

       display\_msg(mstr(102));

   end

end

procedure timed\_event\_p\_proc begin

   if (fixed\_param == 1) then begin

       destroy\_object(Projectile);

       Projectile:=create\_object(PID\_SHARPENED\_POLE,Final\_Hex,elevation(self\_obj));

// Face\_Critter(source\_obj,Projectile);

// anim(Projectile,ANIMATE\_ROTATION,Projectile\_Dir);

       anim(Projectile,ANIMATE\_ROTATION,rotation\_to\_tile(INITIAL\_TILE,Final\_Hex));

       game\_ui\_enable;

   end

end

procedure Check\_Hit begin

   variable Agility\_Roll;

   Agility\_Roll:=do\_check(source\_obj,STAT\_ag,AGILITY\_BONUS);

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

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

           display\_msg(mstr(104));

       else

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

       Final\_Hex:=tile\_num\_in\_direction(tile\_num(source\_obj),rotation\_to\_tile(INITIAL\_TILE,tile\_num(source\_obj)),3);

       call Missile\_Fired;

   end

   else begin

       critter\_dmg(source\_obj,random(MIN\_DMG,MAX\_DMG),(DMG\_normal\_dam BWOR DMG\_BYPASS\_ARMOR BWOR DMG\_NOANIMATE));

       Final\_Hex:=tile\_num(source\_obj);

       call Missile\_Fired;

   end

   add\_timer\_event(self\_obj,game\_ticks(TRAP\_TIME),1);

end

procedure Missile\_Fired begin

   variable Cur\_Tile\_Num;

   variable Counter:=0;

   set\_map\_var(TRAP\_MVAR,1);

   play\_sfx("sprtrap");

   while (tile\_num(Projectile) != Final\_Hex) do begin

       if ((Counter % PROJECTILE\_ROF) == 0) then begin

           Cur\_Tile\_Num:=tile\_num\_in\_direction(tile\_num(Projectile),rotation\_to\_tile(tile\_num(Projectile),Final\_Hex),1);

           move\_to(Projectile,Cur\_Tile\_Num,elevation(self\_obj));

           if (Final\_Hex == tile\_num(source\_obj)) then begin

               anim(source\_obj,ANIM\_hit\_from\_back,ANIMATE\_FORWARD);

           end

           else begin

               anim(source\_obj,ANIM\_dodge\_anim,ANIMATE\_FORWARD);

           end

           debug\_msg("Projectile == "+tile\_num(Projectile)+". Final\_Hex == "+Final\_Hex);

       end

       Counter+=1;

   end

end