Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Trying to make sense of vanilla trap script


ThomasKaira
 Share

Recommended Posts

I am attempting to modify a vanilla script for use in a new trap for a dungeon.

The trap I'm making is similar to the Ayleid poison gas trap (though at the same time a bit different) so a lot is relying on my understanding of this script:

short init

float timer

short next

ref mySelf

ref myParent


float fTrapDamage

float fLevelledDamage

float fTrapPushBack

float fTrapMinVelocity

short bTrapContinuous


begin onActivate


	if init == 0

		set mySelf to getSelf

		set myParent to getParentRef

		set init to 1

	endif


	if isActionRef player == 0 && isActionRef mySelf == 0


		set init to 2


		; set up the damage values

		set fTrapDamage to 10

		set fTrapPushBack to 0

		set fLevelledDamage to 0.125

		set fTrapMinVelocity to 20

		set bTrapContinuous to 1


		set timer to 8

		set next to 1

		playgroup forward 1


	endif


end


begin gameMode


	;daisy-chain

	if next == 1 && timer <= 7

		set next to 0

		myParent.activate mySelf 1

	endif


	if timer <= 0 && init == 2


		playgroup forward 1

		set timer to 10


	endif


	if timer > 0

		set timer to timer - getSecondsPassed

	endif


end

The basics I do know: when the player enters the parented trigger zone, a gas particle begins to animate that damages the player when he walks into it.

There are a few things that I do not understand, so if anyone could translate the following segments into English, that would be great.

I do not understand this line:

"if isActionRef player == 0 && isActionRef mySelf == 0"

And I also need a bit of assistance with deciphering the script after the daisy-chain comment (only the first block after, though, the rest I know).

Edited by ThomasKaira
Link to comment
Share on other sites

I'll try to help a little myself

-----------------

if isActionRef player == 0 && isActionRef mySelf == 0

ActionRef player, means that the Reference Action is caused by the Player... basically saying... is the Action caused by the Player? if so, continue to the next part....

&& basically means that .... this AND this must happen.. or I don't work

isActionRef mySelf == 0 I'm not 100% sure about this so I'll leave it be.... (though I think this is calling for the Trap itself...)

---------

Daisy Chain portion:

if next == 1 && timer <= 7

set next to 0

myParent.activate mySelf 1

this is calling for the "Next" item in the chain.... so if you have 4 traps set, the first will fire, then the next one will, and so on until all traps have fired.

set next to 0 is telling the game to stop calling on this portion as all stuff has been completed. (Hence in the first line == 1 (the one says, I'm good to go, fire the trap)

myParent.activate mySelf .... is telling the next device in the chain to activate itself and run until finished....

----

I'm fairly confident that I've explained this in an okay way, but I have been wrong before. I have done the same thing you are doing, trying to learn what is what in scripts, and from my learning, what I've wrote above should be fairly accurate. Someone else might make a correction on something I've said wrong

Good luck :thumbup:

Link to comment
Share on other sites

if isActionRef player == 0 && isActionRef mySelf == 0

This is saying "if what activated it is not the player and not myself (the trap)".

Basically that block will only fire when the parented object is the one activating it. In this case, the trigger zone attached to it. The trigger zone object likely has a block that will only allow the trap to be triggered once instead of repeatedly, otherwise this block would continuously reset the trap which isn't desired.

Link to comment
Share on other sites

Well, that helps somewhat, but implementation is still a problem, as I can't really figure out how I want to do this.

What I want to happen is this: every five seconds a cloud of steam is emitted. If an actor passes through that steam cloud, they get damaged, but it is safe to pass if the steam cloud is not being emitted.

So far: I do have the steam cloud toggling itself every five seconds, but I have absolutely no clue how to set up the trap portion. Given the model I'm using, I am fairly certain I will have to use a trigger zone, but that's about it at this point.

EDIT: I know now that the daisy-chain portion won't be needed, since I'm not going to be daisy-chaining any of these steam traps together.

On the upside, though, I've got my shock traps working the way I want them. :D

Edited by ThomasKaira
Link to comment
Share on other sites


                set fTrapDamage to 10 <--- This setting is for how much damage per second is done.

                set fTrapPushBack to 0 <---- this would cause the player/npc to be pushed back... not used on this trap.

                set fLevelledDamage to 0.125 <---- Damage multiplier.

                set fTrapMinVelocity to 20 <---- I'm not sure what this does.

That is your damage portion there.

I think you would have to use an "Elseif" statement along with the timer and your script that controls the cloud toggling.

as far as setting up a script for it, I'm not sure about it, so I will not attempt it.

Link to comment
Share on other sites

I got it.

Here's the script:

scn TKSteamDamageTimedScript


;this scripted trap will damage the player in a five-second on, five-second off cycle.

;be sure to match properly with steam cloud emmision script.

;will trigger automatically


short enablestate

float timer


float fTrapDamage

float fLevelledDamage

float fTrapPushBack

float fTrapMinVelocity

short bTrapContinuous



begin gameMode


	;generic script timer

	if timer > 0

		set timer to timer - GetSecondsPassed

	else


		;five second cycle for enable status to match steam cloud emission

		if enablestate == 0

			set timer to 5

			set enablestate to 1

		elseif enablestate == 1

			set timer to 5

			set enablestate to 0

		endif

	endif


	; set up the damage values for steam cloud emmision

	if enablestate == 1

		set fTrapDamage to 5

		set fTrapPushBack to 0

		set fLevelledDamage to 0.5

		set fTrapMinVelocity to 0

		set bTrapContinuous to 1


	;remove trap damage values for when steam stops	

	elseif enablestate == 0

		set fTrapDamage to 0

		set fTrapPushBack to 0

		set fLevelledDamage to 0

		set fTrapMinVelocity to 0

		set bTrapContinuous to 0


	else

		TrapUpdate

	endif


end

It gets attached to a trigger zone that will be placed alongside the steam cloud emitter. Both will be switched on and off every five seconds.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...