@andgalf requested help with some GUIs that were originally uploaded by Little Baron, which can be found here: Lockpicking & Trap Disarming UI's | The Neverwinter Vault
NB: The images for the GUI are required from the above Vault download.
The thread has grown quite long, and rather than people potentially missing what is now available, I thought I would post the scripts here for any others interested. These three new scripts are only for the Disable Trap GUI, as this is the one I concentrated on. The Lock Picking GUI I have also fixed, but the code is tightly woven into my own campaign code and not something easily shared. (If you want to see the Lock Picking GUI in action, check out The Scroll.)
Little Baron’s original work uses more scripts and a different XML to what I provide here, so keep that in mind if you consider using this. My own version also allows a player to toggle on or off usage of any Thieves Tools so they are not automatically used if the player does not wish to use them here. This version also prevents PCs without any training (or points) in the DISABLE DEVICE skill from being able to disable trap components or recover the trap. (They may still be able to find components of the trap, but cannot interact with them.)
If you decide to use this, then please report any issues in this thread for my attention, and I will try to address them as soon as possible. My thanks to @andgalf for encouraging me to pull my finger out and fix this. It’s only been around six years.
NB: TRIGGER TRAP: Use a basic “empty” non-trap trigger to determine where the trap is to be. i.e. DO NOT USE a TRAP Trigger. DO NOT mark it as trapped! Although you can manually set DCs and trap types and they will be used.
NB: If you leave the default trap as a Minor Spike Trap Type (*), then a random trap type is generated based upon the PC level. If a DC is left at zero, then a random one will be generated, based on the PC level for DISARM and on the DISARM setting for DETECTION.
(*) To force a Minor Spike Trap, set an integer on the trap within “TRAPTYPE” to -1 (minus one). You MUST then manually add DETECT DC and DISABLE DC values.
UPDATED: These scripts also work with VFX fix!
NB: OBSERVE SCRIPT NAMES.
alb_open_trappicking: Goes on a placeable (OnUsed), a door’s (OnFailToOpen) and a triggers (OnEntered): -
/////////////////////////////////////////////////////////////////////////////////
// LittleBaron 10/08 (UPDATED & FIXED. INC COMPANION SUPPORT BY LANCE BOTELLE 07/03/22)
// NB: OBJECT_SELF IS THE TRAPPED OBJECT THAT IS TRIGGERED CALLING THIS SCRIPT.
// DISPLAYS THE TRAP GUI IF DETECTED (OR SETS OFF TRAP IF NOT)-OR RECALLS LAST STATE.
// THE GUI OPENED WITH THIS SCRIPT IS CALLED LB_trappicker.xml
// THE XML USES ONLY ONE CALLBACK SCRIPT: gui_trappicking
/////////////////////////////////////////////////////////////////////////////////
//#include "alb_functions_core"
#include "x0_i0_position"
///////////////////////////////////////////////////////////////////////////////////////
// RETURN A RANDOM NUMBER FROM THOSE THAT REMAIN IN DESIGNATED SERIES (14 OF 0-13)
///////////////////////////////////////////////////////////////////////////////////////
int GetRandomNumber(object oTrap, string sPickFromInitial = "ABCDEFGHIJKLMN");
int GetRandomNumber(object oTrap, string sPickFromInitial = "ABCDEFGHIJKLMN")
{
// VALUE TO RETURN
int iNumber;
string sPickFrom = GetLocalString(oTrap, "XLettersRemain");
// INITIAL SPECTRUM
if(sPickFrom == ""){sPickFrom = sPickFromInitial;}
int iLettersRemain = GetStringLength(sPickFrom); // E.g. 11 in this case
int ThisLetter = Random(iLettersRemain); // E.g. 0-10 possible here.
string sLetter = GetSubString(sPickFrom, ThisLetter, 1); // E.g. 0 would return "A"
// CREATE & STORE REMAINING ALPHABET STRING
int nRightCount = iLettersRemain - ThisLetter - 1; // E.g. 11 - 0 - 1 = 10 (-1 is GetSubString 0 correction)
int nLeftCount = iLettersRemain - nRightCount - 1; // E.g. 11 - 10 - 1 = 0 (-1 is for this allocation)
string sRHRemain = GetStringRight(sPickFrom, nRightCount); // E.g. "BCDEFGHIJK" in this case
string sLHRemain = GetStringLeft(sPickFrom, nLeftCount); // E.g. Nothing to return in this case.
string sRemainingLetters = sLHRemain + sRHRemain;
SetLocalString(oTrap, "XLettersRemain", sRemainingLetters); // Now stores "BCDEFGHIJK" as possible remianing letters to choose from.
// SECONDARY PREF CAN USE 5-15
if(sLetter == "A"){iNumber = 0;}
else if(sLetter == "B"){iNumber = 1;}
else if(sLetter == "C"){iNumber = 2;}
else if(sLetter == "D"){iNumber = 3;}
else if(sLetter == "E"){iNumber = 4;}
else if(sLetter == "F"){iNumber = 5;}
else if(sLetter == "G"){iNumber = 6;}
else if(sLetter == "H"){iNumber = 7;}
else if(sLetter == "I"){iNumber = 8;}
else if(sLetter == "J"){iNumber = 9;}
else if(sLetter == "K"){iNumber = 10;}
else if(sLetter == "L"){iNumber = 11;}
else if(sLetter == "M"){iNumber = 12;}
else if(sLetter == "N"){iNumber = 13;}
return iNumber; // E.g. Returns 1
}
///////////////////////////////////////////////////////////////////////////////////////
// RETURN A RANDOM PREFIX STRING FROM THOSE THAT REMAIN IN DESIGNATED SERIES (11)
///////////////////////////////////////////////////////////////////////////////////////
string GetRandomSecPref(object oTrap, string sPickFromInitial = "ABCDEFGHIJK");
string GetRandomSecPref(object oTrap, string sPickFromInitial = "ABCDEFGHIJK")
{
// VALUE TO RETURN
string sSECPREF;
string sPickFrom = GetLocalString(oTrap, "LettersRemain");
// INITIAL SPECTRUM
if(sPickFrom == ""){sPickFrom = sPickFromInitial;}
int iLettersRemain = GetStringLength(sPickFrom); // E.g. 11 in this case
int ThisLetter = Random(iLettersRemain); // E.g. 0-10 possible here.
string sLetter = GetSubString(sPickFrom, ThisLetter, 1); // E.g. 0 would return "A"
// CREATE & STORE REMAINING ALPHABET STRING
int nRightCount = iLettersRemain - ThisLetter - 1; // E.g. 11 - 0 - 1 = 10 (-1 is GetSubString 0 correction)
int nLeftCount = iLettersRemain - nRightCount - 1; // E.g. 11 - 10 - 1 = 0 (-1 is for this allocation)
string sRHRemain = GetStringRight(sPickFrom, nRightCount); // E.g. "BCDEFGHIJK" in this case
string sLHRemain = GetStringLeft(sPickFrom, nLeftCount); // E.g. Nothing to return in this case.
string sRemainingLetters = sLHRemain + sRHRemain;
SetLocalString(oTrap, "LettersRemain", sRemainingLetters); // Now stores "BCDEFGHIJK" as possible remianing letters to choose from.
// SECONDARY PREF CAN USE 5-15
if(sLetter == "A"){sSECPREF = "dd5_";}
else if(sLetter == "B"){sSECPREF = "dd6_";}
else if(sLetter == "C"){sSECPREF = "dd7_";}
else if(sLetter == "D"){sSECPREF = "dd8_";}
else if(sLetter == "E"){sSECPREF = "dd9_";}
else if(sLetter == "F"){sSECPREF = "dd10_";}
else if(sLetter == "G"){sSECPREF = "dd11_";}
else if(sLetter == "H"){sSECPREF = "dd12_";}
else if(sLetter == "I"){sSECPREF = "dd13_";}
else if(sLetter == "J"){sSECPREF = "dd14_";}
else if(sLetter == "K"){sSECPREF = "dd15_";}
return sSECPREF; // E.g. Returns "dd5_"
}
////////////////////////////////////////////////////////////////////////////////////////////
// RELOCK THE DOOR AFTER TRAP
////////////////////////////////////////////////////////////////////////////////////////////
void CheckReLock(object oTRAP);
void CheckReLock(object oTRAP)
{
if(!GetIsTrapped(oTRAP))
{
// FOR COMPATIBILITY
if(GetLocalInt(oTRAP, "lockedalso") == 0)
{
SetLocked(oTRAP, FALSE);
SetLockKeyRequired(oTRAP, FALSE);
}
else
{
SetLocked(oTRAP, TRUE);
AssignCommand(oTRAP, ActionCloseDoor(oTRAP));
}
}
else
{
DelayCommand(0.2, CheckReLock(oTRAP));
}
}
////////////////////////////////////////////////////////////////////////////////////////////
// DISPLAY THE TRAP GUI (FIRST TIME EMPTY)
////////////////////////////////////////////////////////////////////////////////////////////
void LBDisplayTrapGUI(object oPC, object oTRAP, int iFIRSTTIME);
void LBDisplayTrapGUI(object oPC, object oTRAP, int iFIRSTTIME)
{
// MAIN GUI DISLAY
DisplayGuiScreen(oPC, "SCREEN_TRAPPICKER", FALSE, "LB_trappicker.xml");
// DISABLE RECOVERY ON INITIAL STARTUP
//SetGUIObjectDisabled(oPC, "SCREEN_TRAPPICKER", "RecoveryButton", !GetTrapRecoverable(oTRAP));
SetGUIObjectHidden(oPC, "SCREEN_TRAPPICKER", "LBRecover", TRUE);
// KNOWN OR NOT
string sTRAPNAME = GetLocalString(oTRAP, "TRAPNAMEKNOWN");
string sTRAPIMAGE = GetLocalString(oTRAP,"TRAPIMAGE");
// UNKNOWN ON FIRST RUN
if(iFIRSTTIME || sTRAPNAME == ""){sTRAPNAME = "Trap Type Unkown"; sTRAPIMAGE = "temp0.tga";}
SetGUITexture(oPC, "SCREEN_TRAPPICKER", "TRAP_TOP", sTRAPIMAGE);
SetGUIObjectText(oPC, "SCREEN_TRAPPICKER", "TRAP_FEEDBACK", -1, sTRAPNAME);
// THE NUMBER OF SECONDARY COMPONENTS REQUIRED FOR DEACTIVATION
int iSECQTY = GetLocalInt(oTRAP, "SECONDARY");
// RESTORE PROGRESS BARS TO DATE
int x;
int iSECDONE;
while(x < 14)
{
if(GetLocalInt(oTRAP, "PICK_" + IntToString(x) + "FOUND") == 2)
{
iSECDONE ++;
}
x++;
}
float fSECFULL = IntToFloat(iSECQTY);
float fSECDONE = IntToFloat(iSECDONE);
float fPercent = fSECDONE/fSECFULL;
//SendMessageToPC(GetFirstPC(FALSE), " FOUND >>> " + FloatToString(fSECDONE) + " TOTAL >>> " + FloatToString(fSECFULL));
//SendMessageToPC(GetFirstPC(FALSE), " GOOD BAR >>> " + FloatToString(fPercent));
SetGUIProgressBarPosition(oPC, "SCREEN_TRAPPICKER", "TRAP_PROG_GOOD", fPercent);
int iWORSE = GetLocalInt(oTRAP, "FAILLEVEL");
float fNewFail = IntToFloat(iWORSE)/100.0;
//SendMessageToPC(GetFirstPC(FALSE), " WORSE INT >>> " + IntToString(iWORSE));
//SendMessageToPC(GetFirstPC(FALSE), " BAD BAR >>> " + FloatToString(fNewFail));
SetGUIProgressBarPosition(oPC, "SCREEN_TRAPPICKER", "TRAP_PROG_BAD", fNewFail);
///////////////////////////////////////////////////////////////////////////////////////
// RESET ALL IDENTIFIED ITEMS WITHIN THE TRAP
// IF "FOUND" == 1: BUTTON FOUND BUT NOT PRESSED
// IF "FOUND" == 2: BUTTON FOUND AND ALREADY PRESSED
///////////////////////////////////////////////////////////////////////////////////////
x = 0;
while (x < 14)
{
string sBUTTON = "PICK_" + IntToString(x);
if (GetLocalInt(oTRAP, sBUTTON + "FOUND") > 0)
{
string sTGAPREF = GetLocalString(oTRAP, sBUTTON + "TGA");
int iSTATE = GetLocalInt(oTRAP, sBUTTON + "FOUND");
if(iSTATE == 1)
{
SetGUITexture(oPC,"SCREEN_TRAPPICKER", sBUTTON, sTGAPREF + "idle.tga");
SetGUIObjectDisabled(oPC, "SCREEN_TRAPPICKER", sBUTTON, FALSE);
}
else if(iSTATE == 2)
{
SetGUITexture(oPC,"SCREEN_TRAPPICKER", sBUTTON, sTGAPREF + "press.tga");
SetGUIObjectDisabled(oPC, "SCREEN_TRAPPICKER", sBUTTON, TRUE);
}
else
{
SetGUITexture(oPC, "SCREEN_TRAPPICKER", sBUTTON, "sigil_slot.tga");
}
}
x++;
}
///////////////////////////////////////////////////////////////////////////////////////
// PICK USAGE BUTTON
///////////////////////////////////////////////////////////////////////////////////////
int iPICKSTATE = GetLocalInt(oTRAP, "PICKUSE");
// NOT BEING USED (DEFAULT STATE)
string sTexture = "b_s0_normal.tga";
if(iPICKSTATE == 0)
{
// SHOW IMAGE AS ACTIVELY USING
sTexture = "b_s0_hover_pressed.tga";
SetLocalInt(oTRAP, "PICKUSE", 1);
}
else
{
DeleteLocalInt(oTRAP, "PICKUSE");
}
SetGUITexture(oPC, "SCREEN_TRAPPICKER", "LBPickUse", sTexture);
}
////////////////////////////////////////////////////////////////////////////////////////////////
// PC CLICKS ON PLACEABLE, DOOR OR ENTERS TRIGGER
////////////////////////////////////////////////////////////////////////////////////////////////
void main()
{
////////////////////////////////////////////////////////////////////////////////////////////
// TRAP CURRENT STATE (RE-DISPLAY IF ALREADY UNDERWAY)
// NB: TRIGGERS CANNOT BE RE-DISPLAYED! (ONLY PLACEABLE AND DOORS)
////////////////////////////////////////////////////////////////////////////////////////////
object oTRAP = OBJECT_SELF;
int iOBJTYPE = GetObjectType(oTRAP);
// REASON NOT TO FIRE (ALSO USED FOR TRAP COMPLETED AS WELL AS JAMMED)
if(GetLocalInt(oTRAP, "TRAPSTUCK")){return;}
////////////////////////////////////////////////////////////////////////////////////////////
// CURRENT PC LEVEL & SKILLS (TRAP DETECTION ROLLS)
////////////////////////////////////////////////////////////////////////////////////////////
object oPC = GetLastUsedBy();
if(!GetIsObjectValid(oPC)){oPC = GetEnteringObject();}
int iPCLevel = GetTotalLevels(oPC, FALSE);
int iPCSpot = GetSkillRank(SKILL_SPOT,oPC,FALSE);
int iPCSearch = GetSkillRank(SKILL_SEARCH,oPC,FALSE);
int iSEARCHING = GetDetectMode(oPC);
int iROLL; int iHIGHEST; int x;
// THREE ROLLS TO EMULATE THE APPROACH
while (x < 3)
{
iROLL = d20() + iPCSpot;
if (iHIGHEST < iROLL){iHIGHEST = iROLL;}
x++;
}
x = 0;
// ALSO THREE SEARCH ROLLS IF WAS IN SEARCH MODE
while (x < 3 && iSEARCHING == DETECT_MODE_ACTIVE)
{
iROLL = d20() + iPCSearch;
if (iHIGHEST < iROLL){iHIGHEST = iROLL;}
x++;
}
// HIGHEST DIE ROLL FROM THOSE MADE
iROLL = iHIGHEST;
////////////////////////////////////////////////////////////////////////////////////////////
// GET TRAP TYPE BASED ON VAR. (NB: MINOR SPIKE REQUIRES "TRAPTYPE" TO -1 AT BUILD TIME)
// IF "TRAPTYPE" NOT SET, THEN IT WILL DETERMINE A TRAP BASED ON TRAP TYPE SET, UNLESS ...
// IF MINOR SPIKE LEFT AS DEFAULT WITHOUT "TRAPTYPE" TO -1, THEN RANDOM TYPE & LEVEL SET.
// EPIC VERSIONS NOT SUPPORTED.
////////////////////////////////////////////////////////////////////////////////////////////
int iTYPE = GetLocalInt(oTRAP, "TRAPTYPE");
// FORCE MINOR SPIKE TRAP WITH NO RANDOMNESS
if (iTYPE == -1){iTYPE = 0;}
// TRAP SET BASED ON OBJECT SETTING (OR RANDOM) - BASED ON PC LEVEL
else if(iTYPE == 0)
{
// IF STILL MINOR SPIKE, THEN RANDOMIZE TYPE
iTYPE = GetTrapBaseType(oTRAP);
if (iTYPE == 0)
{
// 0-10
iTYPE = Random(11);
// AND ADJUST FOR PC LEVEL (0-4)
int level = (iPCLevel/4);
if (level > 4){level = 4;}
iTYPE = iTYPE * 4;
iTYPE = iTYPE + level;
}
}
////////////////////////////////////////////////////////////////////////////////////////////
// TRIGGER - CREATE REAL TRAP NOW
////////////////////////////////////////////////////////////////////////////////////////////
if(iOBJTYPE == OBJECT_TYPE_TRIGGER && GetTag(oTRAP) != "NEWTRAP")
{
SetTag(OBJECT_SELF, "NEWTRAP");
location loc = GetAheadLocation(oPC, 2.75);
oTRAP = CreateTrapAtLocation(iTYPE, loc, 2.5, "NEWTRAP", STANDARD_FACTION_HOSTILE);
DelayCommand(1.0, DestroyObject(OBJECT_SELF));
}
////////////////////////////////////////////////////////////////////////////////////////////
// INITIALIZE THE TRAP
////////////////////////////////////////////////////////////////////////////////////////////
int iFIRSTTIME = 0; int DDC;
if(!GetLocalInt(oTRAP, "INITIALIZED"))
{
iFIRSTTIME = 1;
////////////////////////////////////////////////////////////////////////////////////////////
// ELSE INITIALIZE THE TRAP NOW! PREPARES TRAP DCS AND TYPE! DISPLAY GUI IF SPOTTED!
////////////////////////////////////////////////////////////////////////////////////////////
SetLocalInt(oTRAP, "INITIALIZED", 1);
SetLocalInt(oTRAP, "ACTIVATED", 1);
////////////////////////////////////////////////////////////////////////////////////////////
// PREPARE TRAP DCS
////////////////////////////////////////////////////////////////////////////////////////////
// TRAP DISARM DC
int DC = GetTrapDisarmDC(oTRAP);
if (DC == 0)
{
DC = 14 + (iPCLevel + Random(iPCLevel/2));
SetTrapDisarmDC(oTRAP, DC);
}
// TRAP DETECT DC
DDC = GetTrapDetectDC(oTRAP);
if (DDC == 0)
{
DDC = (DC/2) + Random(DC/2);
SetTrapDetectDC(oTRAP, DDC);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// INITIALIZE THE TRAP BASED ON TYPE
///////////////////////////////////////////////////////////////////////////////////////////////////////
// NAME AND IMAGE
string sTRAPNAME; string sTRAPIMAGE;
// STRING PREFIX FOR PRIME COMPONENT
string sPRIMEPREF;
// INT SUFFIX FIX FOR TRAP RECOVERED (NEG AND ACID FIX)
int iRecover;
// IMAGES FOR PRIME COMPNENT USE PREF: 0, 1, 2, 3, 4, 16 and 17
if(iTYPE < 4)//spike trap
{
sTRAPNAME = "Spike Trap";
sTRAPIMAGE = "it_kit_spiketrap.tga";
sPRIMEPREF = "dd16_";
}
else if(iTYPE < 8)//holy trap
{
sTRAPNAME = "Holy Energy Trap";
sTRAPIMAGE = "it_kit_holytrap.tga";
sPRIMEPREF = "dd4y_";
}
else if(iTYPE < 12)//tangle trap
{
sTRAPNAME = "Tangle Trap";
sTRAPIMAGE = "it_kit_tangletrap.tga";
sPRIMEPREF = "dd17_";
}
else if(iTYPE < 16)//acid trap
{
sTRAPNAME = "Acid Blob Trap";
sTRAPIMAGE = "it_kit_acidblobtrap.tga";
sPRIMEPREF = "dd4g_";
}
else if(iTYPE < 20)//fire trap
{
sTRAPNAME = "Fire Trap";
sTRAPIMAGE = "it_kit_firetrap.tga";
sPRIMEPREF = "dd1_";
}
else if(iTYPE < 24)//electrical trap
{
sTRAPNAME = "Electric Trap";
sTRAPIMAGE = "it_kit_electricaltrap.tga";
sPRIMEPREF = "dd0_";
}
else if (iTYPE < 28)//gas trap
{
sTRAPNAME = "Gas Trap";
sTRAPIMAGE = "it_kit_gastrap.tga";
sPRIMEPREF = "dd3_";
}
else if(iTYPE < 32)//frost trap
{
sTRAPNAME = "Frost Trap";
sTRAPIMAGE = "it_kit_frosttrap.tga";
sPRIMEPREF = "dd2_";
}
else if(iTYPE < 36)//Neg trap
{
sTRAPNAME = "Negative Energy Trap";
sTRAPIMAGE = "it_kit_negativetrap.tga";
sPRIMEPREF = "dd4r_";
// BASE ITEM TO RESREF REF FIX
iRecover = 8;
}
else if(iTYPE < 40)//Sonic trap
{
sTRAPNAME = "Sonic Trap";
sTRAPIMAGE = "it_kit_sonictrap.tga";
sPRIMEPREF = "dd2_";
}
else if(iTYPE < 44)//acid splash trap
{
sTRAPNAME = "Acid Splash Trap";
sTRAPIMAGE = "it_kit_acidsplashtrap.tga";
sPRIMEPREF = "dd4g_";
// BASE ITEM TO RESREF REF FIX
iRecover = -8;
}
// STORE TRAP DETAILS
SetLocalString(oTRAP, "TRAPNAME", sTRAPNAME);
SetLocalString(oTRAP, "TRAPIMAGE", sTRAPIMAGE);
SetLocalInt(oTRAP, "TRAPTYPE", iTYPE);
// STORE TRAP RECOVERY SUFFIX
iRecover = iRecover + iTYPE + 1;
string sRecover = IntToString(iRecover);
if(iRecover < 10){sRecover = "0" + sRecover;}
SetLocalString(oTRAP, "TRAPRECOVER", "nw_it_trap0" + sRecover);
////////////////////////////////////////////////////////////////////////////////
// RANDMISE A PRIMARY COMPONENT BUTTON (IMAGE AND DC + 5)
////////////////////////////////////////////////////////////////////////////////
// RETURNS RANDOM 0-13
int iPRIMEBUTTON = GetRandomNumber(oTRAP);
// STORE PRIME BUTTON TGA PREFIX
string sBUTTON = "PICK_" + IntToString(iPRIMEBUTTON);
SetLocalString(oTRAP, sBUTTON + "TGA", sPRIMEPREF);
SetLocalInt(oTRAP, sBUTTON + "PRIME", 1);
// PRIMARY BUTTON DC
SetLocalInt(oTRAP, sBUTTON + "DC", DDC + 5);
////////////////////////////////////////////////////////////////////////////////
// NOW RANDOMISE 1-13 SECONDARY BUTTONS AVAILABLE (BASED ON TRAP ORIGINAL DC)
////////////////////////////////////////////////////////////////////////////////
int iSEC = DC/5; if(iSEC < 1){iSEC = 1;} else if(iSEC > 13){iSEC = 13;}
SetLocalInt(oTRAP, "SECONDARY", iSEC);
// DEBUG FEEDBACK
/*SendMessageToPC(GetFirstPC(FALSE), "<color=CornFlowerBlue>TRAP TYPE >>> " + IntToString(iTYPE)
+ "\nBASE DC TO FIND >>> " + IntToString(DC)
+ "\nPRIME (MAX) DC TO FIND (SECONDARIES LOWER) >>> " + IntToString(DDC+5)
+ "\nSECONDARY STORED >>> " + IntToString(iSEC) + "</c>");*/
// SendMessageToPC(GetFirstPC(FALSE), " STORING SECONDS >>> " + IntToString(iSEC));
while (iSEC > 0)
{
// 13 BUTTONS REMAIN RANDOMIZATION (NEVER RETURNS NUMBER ALREADY USED)
int iSECBUTTON = GetRandomNumber(oTRAP);
sBUTTON = "PICK_" + IntToString(iSECBUTTON);
// MUST USE 11 VALUES OF 5 - 15 (NOT ANY OF THE PRIMES USED)
string sSECONDPREF = GetRandomSecPref(oTRAP);
SetLocalString(oTRAP, sBUTTON + "TGA", sSECONDPREF);
// AND GIVE EACH BUTTON A DC VALUE TOO
int iHALFDC = DDC/2; int iRoll = Random(iHALFDC) + iHALFDC;
SetLocalInt(oTRAP, sBUTTON + "DC", iRoll);
iSEC = iSEC - 1;
}
SetTrapDisarmable(oTRAP, FALSE);
SetTrapRecoverable(oTRAP, FALSE);
}
////////////////////////////////////////////////////////////////////////////////////////////
// TRAP NOW DETECTED! ONLY DISARM VIA GUI! CANNOT BE RECOVERED UNTIL DISABLED!
////////////////////////////////////////////////////////////////////////////////////////////
if(iROLL < DDC)
{
// SET TRAP STATES
SetTrapActive(oTRAP, TRUE);
SetTrapDetectable(oTRAP, TRUE);
SetTrapDetectedBy(oTRAP, oPC);
AssignCommand(oPC,SpeakString("TRAP!"));
// PLACE TRAP ON DOOR OR PLACEABLE NOW. (TRIGGER TRAP HAS ALREADY BEEN SETUP ABOVE.)
if(iOBJTYPE != OBJECT_TYPE_TRIGGER)
{
CreateTrapOnObject(iTYPE, oTRAP, STANDARD_FACTION_HOSTILE, "", "");
}
if(iOBJTYPE == OBJECT_TYPE_PLACEABLE)
{
AssignCommand(oPC,ClearAllActions());
DelayCommand(0.1, AssignCommand(oPC, ActionInteractObject(oTRAP)));
// FOR COMPATIBILITY
if(GetLocalInt(oTRAP, "lockedalso") == 0)
{
SetLocked(oTRAP, FALSE);
SetLockKeyRequired(oTRAP, FALSE);
}
}
else if(iOBJTYPE == OBJECT_TYPE_DOOR)
{
SetLocked(oTRAP, FALSE);
AssignCommand(oPC,ClearAllActions());
AssignCommand(oPC, ActionOpenDoor(oTRAP));
DelayCommand(0.2, CheckReLock(oTRAP));
}
SetLocalInt(oTRAP, "TRAPSTUCK", 1);
return;
}
////////////////////////////////////////////////////////////////////////////////////////////
// PC SPOTS THE TRAP (STOP!) DISPLAY GUI FOR THE FIRST TIME!
////////////////////////////////////////////////////////////////////////////////////////////
// ALTHEA CAMPAIGN
//SetLocalObject(GetMainPC(oPC), "TRAP", oTRAP);
// OTHER CAMPAIGNS (SP ONLY)
SetLocalObject(GetModule(), "TRAP", oTRAP);
AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, SpeakString("I've found a trap!"));
PlayCustomAnimation(OBJECT_SELF, "search" , TRUE, 3.0);
DelayCommand(0.1, LBDisplayTrapGUI(oPC, oTRAP, iFIRSTTIME));
}
LB_trappicker.xml: The NEW XML for trap picking: -
<?xml version="1.0" encoding="NWN2UI"?>
<!-- SCREEN DEFINITIONS -->
<UIScene name="SCREEN_TRAPPICKER" x=ALIGN_CENTER y=ALIGN_CENTER width=400 height=400 modal=true idleexpiretime="0.1"
fadeout="0.3" fadein="0.3" draggable=true backoutkey=true scriptloadable=true priority="SCENE_SCRIPT" OnRemove=UIObject_Misc_ExecuteServerScript("gui_trappicking","EXIT","")/>
<!-- Close Button -->
<UIButton name="CloseButton" x=355 y=45 style="STYLE_CLOSE_BUTTON" OnLeftClick=UIButton_Input_ScreenClose()> </UIButton>
<UIButton name="LBPickUse" x=13 y=45 width=27 height=27 MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","LP","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","LP") OnToolTip='UIObject_Tooltip_DisplayTooltipString("Toggle Pick Usage - If Available","OBJECT_X","OBJECT_Y","SCREEN_TOOLTIP_2")'>
<UIFrame state="base" fill="b_s0_normal.tga" />
<!UIFrame state=up fill="b_s0_normal.tga" />
<UIFrame state=hilited fill="b_s0_hover.tga" />
</UIButton>
<UIButton name="LBRecover" x=170 y=168 width=60 height=60 fill="sigil_slot.tga" MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","R","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","R") OnToolTip='UIObject_Tooltip_DisplayTooltipString("Click To Recover Trap","OBJECT_X","OBJECT_Y","SCREEN_TOOLTIP_2")'>
<UIFrame state=up fill="recover_normal.tga" />
<UIFrame state=down fill="recover_pressed.tga" />
<UIFrame state=focused fill="recover_hover.tga" />
<UIFrame state=hilited fill="recover_hover_pressed.tga" />
<UIFrame state=hifocus fill="recover_hover_pressed.tga" />
<UIFrame state=disabled fill="recover_hover_pressed.tga" />
</UIButton>
<!-- Button1 (On left click fires script) -->
<UIButton name="PICK_0" x=340 y=80 width=40 height=40 MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","0","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","0")>
<UIFrame state=base fill="sigil_slot.tga" />
</UIButton>
<UIButton name="PICK_1" x=17 y=80 width=40 height=40 MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","1","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","1")>
<UIFrame state=base fill="sigil_slot.tga" />
</UIButton>
<UIButton name="PICK_2" x=178 y=80 width=40 height=40 MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","2","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","2")>
<UIFrame state=base fill="sigil_slot.tga" />
</UIButton>
<UIButton name="PICK_3" x=97 y=80 width=40 height=40 MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","3","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","3")>
<UIFrame state=base fill="sigil_slot.tga" />
</UIButton>
<UIButton name="PICK_4" x=258 y=80 width=40 height=40 MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","4","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","4")>
<UIFrame state=base fill="sigil_slot.tga" />
</UIButton>
<UIButton name="PICK_5" x=340 y=270 width=40 height=40 MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","5","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","5")>
<UIFrame state=base fill="sigil_slot.tga" />
</UIButton>
<UIButton name="PICK_6" x=17 y=270 width=40 height=40 MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","6","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","6")>
<UIFrame state=base fill="sigil_slot.tga" />
</UIButton>
<UIButton name="PICK_7" x=178 y=270 width=40 height=40 MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","7","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","7")>
<UIFrame state=base fill="sigil_slot.tga" />
</UIButton>
<UIButton name="PICK_8" x=97 y=270 width=40 height=40 MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","8","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","8")>
<UIFrame state=base fill="sigil_slot.tga" />
</UIButton>
<UIButton name="PICK_9" x=258 y=270 width=40 height=40 MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","9","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","9")>
<UIFrame state=base fill="sigil_slot.tga" />
</UIButton>
<UIButton name="PICK_10" x=340 y=143 width=40 height=40 MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","10","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","10")>
<UIFrame state=base fill="sigil_slot.tga" />
</UIButton>
<UIButton name="PICK_11" x=340 y=207 width=40 height=40 MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","11","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","11")>
<UIFrame state=base fill="sigil_slot.tga" />
</UIButton>
<UIButton name="PICK_12" x=17 y=143 width=40 height=40 MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","12","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","12")>
<UIFrame state=base fill="sigil_slot.tga" />
</UIButton>
<UIButton name="PICK_13" x=17 y=207 width=40 height=40 MouseDownSFX="gui_select" OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","13","") OnLeftClick=UIObject_Misc_ExecuteServerScript("gui_trappicking","","13")>
<UIFrame state=base fill="sigil_slot.tga" />
</UIButton>
<UIText name="TRAP_FEEDBACK" x=77 y=49 width=240 height=20 align=center valign=center color="white" fontfamily="Title_Font" text="Trap" />
<UIFrame name="TRAP_TOP" x=170 y=168 width=60 height=60 fill="sigil_slot.tga" OnToolTip='UIObject_Tooltip_DisplayTooltipString("Disable Trap To Recover It","OBJECT_X","OBJECT_Y","SCREEN_TOOLTIP_2")' OnMouseEnter=UIObject_Misc_ExecuteServerScript("gui_trappicking","R","") />
<UIProgressBar name="TRAP_PROG_GOOD" x=118 y=178 width=18 height=68 vertical=true img="trap_prog_good.tga" />
<UIProgressBar name="TRAP_PROG_BAD" x=265 y=178 width=18 height=68 vertical=true img="trap_prog_bad.tga" />
<UIFrame name="Bar_1" x=112 y=170 width=30 height=85 fill="trap_prog_overbar2.tga"/>
<UIFrame name="Bar_2" x=259 y=170 width=30 height=85 fill="trap_prog_overbar.tga"/>
<!-- Background Image -->
<UIIcon name="TRAP_BACKGROUND" img="TrapBack.tga" x=0 y=0 width=400 height=400 />
<UIFrame x=0 y=0 width=PARENT_WIDTH height=PARENT_HEIGHT border=32 />
FINAL SCRIPT IN NEXT POST (TOO LARGE FOR HERE)