So, I've been having trouble with a series of scripts of mine. Basically, I have set a trigger to pick a random number from 1 to 4, which should change other triggers to do different things. I have 4 manual traps set up. If their number is called by the initial trigger, then the manual trap opens the door out of the area. If not, then it casts a spell at the player.
Here is my code:
OnEnter Script for trigger CHEST_CODE: (The first trigger of the 5)
void main()
{
SetLocalInt(GetObjectByTag("CHEST_CODE"), "nChestCode",d4());
}
The other 4 triggers are set up around rune plates, which the player is supposed to step on. Their code is like this.
void main()
{
object oPC = GetFirstPC();
if (GetLocalInt(GetObjectByTag("CHEST_CODE"), "nChestCode") == 1)
{
SetLocked(GetObjectByTag("CRYPT_DOOR"),FALSE);
AssignCommand(GetObjectByTag("PLATE01"),ActionSpeakString("You hear the sound of turning gears indicating that the door to the crypt has unlocked.")); }
else {
AssignCommand(GetObjectByTag("PLATE01"),ActionCastSpellAtObject(115, oPC,0,TRUE,1,1,TRUE));
}
}
This is the script for trigger PLATETRAP01, and the scripts for the other triggers are the same, they just use the numbers 2, 3, or 4 in their conditional.
The random number is working fine, and the correct trigger always unlocks the door, but the SpeakString never fires, and the trap never fires for any of the other plates.
Modifié par treetrunker, 29 juillet 2010 - 09:15 .