Jump to content

CS script analysis thread


DarkSpyda04

Recommended Posts

I'll post this thread so we can look at scripts and learn what they do. This includes OBSE scripts. I just took a look at the script that runs when you step into fire and I'll post it in code brackets:

 

scn GenericFireDamageMedium01SCRIPT

;This script causes the player to burn when stepping in fire
;First we initialize variables

float fireTimer 
short activated
ref ImOnFire

begin onTrigger Player ;immediate events of the trigger when player steps in fire

     if activated == 0 ;Make sure trigger can be activated
         cast TRAPGenericFireDamageMedium01 player ;place fire spell on player
         set activated to 1 ;stop trigger from being re-activated
         set fireTimer to 3 ;set countdown timer to 3 seconds
     endif
end

begin gameMode ;script that always runs regardless

     if activated == 1 ;make sure the fire has been triggered
          if fireTimer > 0 ;make sure the timer has been set
               set fireTimer to fireTimer - getSecondsPassed ;decrement timer
          endif

          if fireTimer <= 0 ;when the timer has finished counting down
               set activated to 0 ;reset trigger so it can be re-activated
          endif

     endif
end
Edited by DarkSpyda04
Link to comment
Share on other sites

  • 2 weeks later...

More hawtness as I just recently took a look at the player warp script that happens when you leave the boundaries in Cameron's Paradise. This script calls "Player.moveto" on-trigger of the trigger volume "MQ15TrigZonePLAYERwarp01" and teliports the player to the x-marker "CPHilltopTeleporterSpot", an XMarkerHeading. This script executes once per-trigger to avoid a very bad glitch that makes it difficult just to exit the game, nevermind make the game impossible to play.

 

This script could be used to maybe create a walk-in teliporter (rather than one you activate) or teliportation zones or maybe some other cool things.

 

scn MQ15TrigZonePLAYERwarp01SCRIPT
 
; warps player to CPHilltopTeleporterSpot xmarker
 
float timer
short activated
 
begin onTrigger player
 
if activated == 0
set activated to 1
set timer to 1
playsound SPLAlterationCast ;play sound
TriggerHitShader ;play screen blur effect
player.moveto CPHilltopTeleporterSpotREF ;teliport player to location
 
endif
 
end
 
begin gamemode
if activated == 1 && timer <= 0
set activated to 0
 
endif
 
if timer > 0
set timer to timer - getsecondspassed
endif
 
end

 

In particular, the script checks to make sure that "activated" equals "0" before continuing on with the rest of the script, setting the timer, setting activated to "1", and teliporting the player. Once activated equals "1", the timer continually ticks down until it hits zero. When it does hit zero, activated is set to "0" and the script stops. An effective doOnce.

 

On a sort of related note, I'm picking up on some color-coding between all the different types of volumes. Invisible walls are yellow and the warp points were green. I didn't look too much into all the different colors of different volumes but this is just an observation.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...