Jump to content

Scripting for Evading a Trap


David Brasher

Recommended Posts

I have a locked chest that casts a powerful fireball on whoever tries to open it, but I would like to make it so it won't cast it's fireball if the opener has the key to the chest.

 

 

Scn (Scriptname)

 

Begin OnActivate

 

Cast (Ranged Fireball 350 Damage) Player

Activate

 

End

 

 

I used to program Commodore 64s in BASIC, and I have to admit that this Oblivion scripting language is tearing me up. I constantly find myself wanting to use IF THEN and GOTO statements, but I am using the wrong computer language.

 

Does anyone have any advice on what commands to use and how to arrange them to do what I am trying to do?

Link to comment
Share on other sites

Hmm. I think the script should look something like this:

 

Scn (Scriptname)

Begin OnActivate

If Player.GetItemCount (Key's ItemID) >= 1
Activate
Else
Cast (Ranged Fireball 350 Damage) Player
Activate
EndIf

End

 

...that casts a powerful fireball on whoever tries to open it...

 

This script won't cast spells at whoever activates it, it will cast a spell at the player even when a NPC activates it. To fix this:

 

Scn (Scriptname)

Ref Target

Begin OnActivate

Set Target to GetActionRef

If Target.GetItemCount (Key's ItemID) >= 1
Activate
Else
Cast (Ranged Fireball 350 Damage) Target
Activate
EndIf

End

 

After the player (or NPC) activates the chest, the script will use the 'GetActionRef' function to determine who activated it. It saves that data in the 'Target' reference variable, so it can be used in the rest of the script as well. Then we use 'GetItemCount' to check for the key in the activator's inventory. If he has one, the chest will be activated as normally. If he doesn't have one, the chest will cast the spell, and then it will be activated.

 

Good luck with your mod!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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