Jump to content
HerrSvensson

Is it possible to make Detected or ReceivedOrder triggers to work?

Recommended Posts

Is it possible to make Detected or ReceivedOrder triggers to work?

 

I want to disarm traps only after the traps have been detected. Problem is Detected doesn't work, and I prefer to not use timers. The trigger Disarmed works though.

 

I also want to give someone an order, for example, if inventory is full, drop some items and give an order for someone to pick them up. The problem is that either GiveOrder or ReceivedOrder doesn't work.

 

Or has anyone had any success with these two triggers?

Share this post


Link to post

It turns out that GiveOrder and ReceivedOrder does in fact work:

 

...
IF
!Global("FullInv", "LOCALS", 1)
ActionListEmpty()
ReceivedOrder([PC], 1)
THEN
RESPONSE #100
SetInterrupt(TRUE)
DisplayStringHead(Myself, 16102) // "Very well, I will assist you"
MoveToObject(LastCommandedBy())
SetInterrupt(FALSE)
END

IF
ActionListEmpty()
Global("FullInv", "LOCALS", 1)
THEN
RESPONSE #100
 DisplayStringHead(Myself, 71376) // "Come to me."
 GiveOrder([PC.0.0.MAGE_ALL],1)
 MoveToObject([PC.0.0.MAGE_ALL])  
 GiveItem("SCRL75",[PC.0.0.MAGE_ALL]) // Identify
 SetGlobal("FullInv", "LOCALS", 0)
END

 

I didn't have any success with Detected() though, once a trap has been detected.

Share this post


Link to post

I solved this problem.

 

Apparently the functions Detected, Unlocked or Disarmed only works on the actual objects you interact with.

 

Example 1: edit the trap file, GDARTS, which "Picture 1" is using. Whenever one of the triggers above is activated, simply add a global variable. A thief will can then check for this global variable.

 

GDARTS.BAF:

IF
OnCreation()
THEN
RESPONSE #100
 SetGlobal("EllRoomTrap5Trap","AR0602",2)
 SetGlobal("Picture1Trap","AR0602",2)
 SetGlobal("Picture1Lock","AR0602",1)
END
// ---- The old script ------
IF
OR(2)
 Entered([ANYONE])
 Opened([ANYONE])
THEN
RESPONSE #100
 DisplayString(LastTrigger,14381) // Trap Sprung
 ForceSpell(LastTrigger,TRAP_DARTS)
END
// ---------------------------
IF
Detected([ANYONE])
AreaCheck("AR0602")
Name("Ell Room Trap 5",Myself)
!Global("EllRoomTrap5Trap","AR0602",1)  // Is not detected?
THEN
RESPONSE #100
 SetGlobal("EllRoomTrap5Trap","AR0602",1)
 DisplayStringHead(Myself,16488)  // "You have detected a trap."
END
IF
Detected([ANYONE])
 AreaCheck("AR0602")
 Name("Picture 1",Myself)
 !Global("Picture1Trap","AR0602",1)  // Is not detected?
THEN
RESPONSE #100
 SetGlobal("Picture1Trap","AR0602",1)
 DisplayStringHead(Myself,16488)  // "You have detected a trap."
END
IF
 Disarmed([ANYONE])
 AreaCheck("AR0602")
 Name("Ell Room Trap 5",Myself)
 GlobalGT("EllRoomTrap5Trap","AR0602",0)  // Is trapped?
THEN
RESPONSE #100
 SetGlobal("EllRoomTrap5Trap","AR0602",0)
 DisplayStringHead(Myself,16520)  // "Trap Disarmed"
END
IF
Disarmed([ANYONE])
AreaCheck("AR0602")
Name("Picture 1",Myself)
GlobalGT("Picture1Trap","AR0602",0)  // Is trapped?
THEN
RESPONSE #100
 SetGlobal("Picture1Trap","AR0602",0)
 DisplayStringHead(Myself,16520)  // "Trap Disarmed"
END
IF
Unlocked([ANYONE])
AreaCheck("AR0602")
Name("Picture 1",Myself)
Global("Picture1Lock","AR0602",1)  // Is locked?
THEN
RESPONSE #100
 DisplayStringHead(Myself,16517)  // "Lock Pick Succeeded"
 SetGlobal("Picture1Lock","AR0602",0)
END

 

 

Example 2: Locked objects without traps were more tedious. I first created a new "lock script" and loaded an object with it using ChangeAIScript in an ARxxxx.baf file.

 

AR0602.BAF

IF
OnCreation()
Global("NewGame","AR0602",0)
THEN
RESPONSE #100
 HideGUI()
 FadeToColor([1.0],0)
 SetGlobal("NewGame","AR0602",1)
 ActionOverride("Chest 6",ChangeAIScript("LOCKTEST",AREA)) // <-- Added this
 Continue()
END
IF
Global("RielevDisable","AR0602",0)
THEN
RESPONSE #100
 SetGlobal("RielevDisable","AR0602",1)
 TriggerActivation("Rielevdeadtrigger",FALSE)
END
IF
Global(...

 

LOCKTEST.BAF:

IF
OnCreation()
THEN
RESPONSE #100
 SetGlobal("Chest6Lock","AR0602",1)
END
IF
Unlocked([ANYONE])
AreaCheck("AR0602")
Name("Chest 6",Myself)
Global("Chest6Lock","AR0602",1)  // Is locked?
THEN
RESPONSE #100
 DisplayStringHead(Myself,16517)  // "Lock Pick Succeeded"
 SetGlobal("Chest6Lock","AR0602",0)
END

 

The last solution in example 2 works, but it feels a bit too much like a hack. I don't think it works to load a "lock script" for an object in one area only so with this approach you'd have to load the script in all areas where the object exists. Of course, you still need to use different global variables for lock checking depending on which area you are in otherwise if a lock is unlocked in one area, the same object in another area might think its unlocked when its not.

 

 

Here is a script I used for my thief:

//*Thief toggle*
// Toggle disarm activity ON:
IF
ActionListEmpty()
Class(Myself,THIEF_ALL)
Global("THIEF_SEARCH","LOCALS",0)						  // Toggle: Off
Hotkey(D)
THEN
RESPONSE #100
 DisplayString(Myself,17596)						   // "THIEF SCOUT:"
 DisplayStringHead(Myself,14669)					   // "AI On"
 SetGlobal("THIEF_SEARCH","LOCALS",1)
END
// Toggle disarm activity OFF:
IF
Class(Myself,THIEF_ALL)
Global("THIEF_SEARCH","LOCALS",1)						  // Toggle: On
Hotkey(D)
THEN
RESPONSE #100
 DisplayString(Myself,17596)						   // "THIEF SCOUT:"
 DisplayStringHead(Myself,14671)					   // "AI Off"
 SetGlobal("THIEF_SEARCH","LOCALS",0)
END
// *Detect traps*
// Find traps
IF
ActionListEmpty()
!GlobalTimerNotExpired("LOOT_TIMER","LOCALS")
Global("THIEF_SEARCH","LOCALS",1)						  // Toggle: On
!ModalState(DETECTTRAPS)								  
!GlobalTimerNotExpired("FIND_TRAP_TIMER","LOCALS")		 // Is Find traps off?
THEN
RESPONSE #100
 SetGlobalTimer("FIND_TRAP_TIMER","LOCALS",5)
 FindTraps()
END
// Very close to "Ell Room Trap 5"
IF
Class(Myself,THIEF_ALL)
Range("Ell Room Trap 5",10)
!ModalState(DETECTTRAPS)								  
!GlobalTimerNotExpired("FIND_TRAP_TIMER","LOCALS")		 // Is Find traps off?
Global("EllRoomTrap5Trap","AR0602",2)					  // Is trapped but not detected?
THEN
RESPONSE #100
 DisplayString(Myself,52376)						   // "There is something here.. just let me - Hold! It moves!"
 ClearActions(Myself)
 SetGlobalTimer("FIND_TRAP_TIMER","LOCALS",5)
 FindTraps()
END
// Thief toggle ON: "Ell Room Trap 5" trap detected (detect skill: 10)
IF
Range("Ell Room Trap 5",10)
!GlobalTimerNotExpired("LOOT_TIMER","LOCALS")
Global("THIEF_SEARCH","LOCALS",1)						  // Toggle: On
Global("EllRoomTrap5Trap","AR0602",1)					  // Is detected?
Class(Myself,THIEF_ALL)
CheckStatGT(Myself,69,TRAPS)							   // Can disarm?
THEN
RESPONSE #100
 ClearActions(Myself)
 SetInterrupt(FALSE)
 RemoveTraps("Ell Room Trap 5")
 SetInterrupt(TRUE)
 Continue()
END
// Very close to "Picture 1"
IF
Class(Myself,THIEF_ALL)
Range("Picture 1",10)
!ModalState(DETECTTRAPS)								  
!GlobalTimerNotExpired("FIND_TRAP_TIMER","LOCALS")		
Global("Picture1Trap","AR0602",2)						  // Is trapped but not detected?
THEN
RESPONSE #100
 DisplayString(Myself,52376)						   // "There is something here.. just let me - Hold! It moves!"
 ClearActions(Myself)
 SetGlobalTimer("FIND_TRAP_TIMER","LOCALS",5)
 FindTraps()
END
// Thief toggle ON: "Picture 1" trap detected (detect skill: 50)
IF
Range("Picture 1",10)
!GlobalTimerNotExpired("LOOT_TIMER","LOCALS")
Global("THIEF_SEARCH","LOCALS",1)						  // Toggle: On
Global("Picture1Trap","AR0602",1)						  // Is detected?
Class(Myself,THIEF_ALL)
CheckStatGT(Myself,39,TRAPS)							   // Can disarm?
THEN
RESPONSE #100
 ClearActions(Myself)
 SetInterrupt(FALSE)
 RemoveTraps("Picture 1")
 PickLock("Picture 1")
 SetInterrupt(TRUE)
 Continue()
END
// Thief toggle ON: "Chest 6" is locked (lock skill: 20)
IF
ActionListEmpty()
!See([ENEMY])
Range("Chest 6",10)
Global("Chest6Lock","AR0602",1)						    // Is locked?
!GlobalTimerNotExpired("LOOT_TIMER","LOCALS")
Global("THIEF_SEARCH","LOCALS",1)						  // Toggle: On
Class(Myself,THIEF_ALL)
CheckStatGT(Myself,19,LOCKPICKING)
THEN
RESPONSE #100
 SetInterrupt(FALSE)
 PickLock("Chest 6")
 SetInterrupt(TRUE)
 Continue()
END

Edited by HerrSvensson

Share this post


Link to post
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.


×
×
  • Create New...