#include "da_includefile_1"
#include "x2_inc_switches"
#include "sha_subr_methds"
// If your module's OnActivateItem has custom scripting, just paste the following into it.
// Be sure to include the file "da_includefile_1" at the very top, as it is here, above the void main().
void main()
{
{
object oItem = GetItemActivated();
// * Generic Item Script Execution Code
// * If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
// * it will execute a script that has the same name as the item's tag
// * inside this script you can manage scripts for all events by checking against
// * GetUserDefinedItemEventNumber(). See x2_it_example.nss
if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
{
SetUserDefinedItemEventNumber(X2_ITEM_EVENT_ACTIVATE);
int nRet = ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
if (nRet == X2_EXECUTE_SCRIPT_END)
{
return;
}
}
}
object oDA_ITEM = GetItemActivated();
string sDA_ITEM = GetTag(oDA_ITEM);
string sDA_DETECTOR = "da_gladetecto";
string sDA_ENFORCER = "da_enforcerke";
string sDA_ITEMLEFT13 = GetStringLeft(sDA_ITEM, 13);
object oDA_ACTIVATOR = GetItemActivator();
object oDA_TARGET = GetItemActivatedTarget();
string sDA_TARGET = GetTag(oDA_TARGET);
string sDA_TARGETLEFT12 = GetStringLeft(sDA_TARGET, 12);
string sDA_CONTAINER = "da_jailcrate";
if (sDA_ITEMLEFT13 == sDA_ENFORCER) //The lines for the Enforcer Key.
{
int iENFORCER = GetIsEnforcer(oDA_ACTIVATOR);
int iEXEMPT = GetIsExempt(oDA_TARGET);
if (iENFORCER == FALSE)
{
DestroyObject(oDA_ITEM); //Make sure only authorized enforcers can activate this item.
FloatingTextStringOnCreature("Only authorized enforcers may use that key.", oDA_ACTIVATOR, FALSE);
}
else if (GetIsPC(oDA_TARGET))
{
SetLocalObject(oDA_ACTIVATOR, "da_mytarget", oDA_TARGET); //If the target if a player, start a conversation for more options.
AssignCommand(oDA_ACTIVATOR, ActionStartConversation(oDA_ACTIVATOR, "da_cnv_enforcrky", TRUE));
}
else if (sDA_TARGETLEFT12 == sDA_CONTAINER)
{
effect eKNOCK = EffectVisualEffect(VFX_IMP_KNOCK);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eKNOCK, oDA_TARGET);
SetLocked(oDA_TARGET, FALSE); //Unlock the Confiscated Item Crate, if that's the target.
AssignCommand(oDA_TARGET, SpeakString("**unlocks temporarily**"));
FloatingTextStringOnCreature("This container will be unlocked for the next twenty seconds, or until someone opens it.", oDA_ACTIVATOR, FALSE);
float fDELAY = 20.0;
DelayCommand(fDELAY, SetLocked(oDA_TARGET, TRUE));
}
else FloatingTextStringOnCreature("The key is inert.", oDA_ACTIVATOR, FALSE);
}
if (sDA_ITEMLEFT13 == sDA_DETECTOR) //The lines for the Gladi-Detector.
{
if (GetIsPC(oDA_TARGET))
{
int iTEAM = GetLocalInt(oDA_TARGET, "da_Team");
string sTARGETNAME = GetName(oDA_TARGET);
switch (iTEAM) //Inform the activator what color Gladiator, if any, the target is.
{
case 1:
FloatingTextStringOnCreature(sTARGETNAME + " glows red.", oDA_ACTIVATOR, FALSE);
break;
case 2:
FloatingTextStringOnCreature(sTARGETNAME + " glows blue.", oDA_ACTIVATOR, FALSE);
break;
case 3:
FloatingTextStringOnCreature(sTARGETNAME + " glows green.", oDA_ACTIVATOR, FALSE);
break;
default:
FloatingTextStringOnCreature(sTARGETNAME + " does not glow.", oDA_ACTIVATOR, FALSE);
break;
}
DelayCommand(1.5, AssignCommand(oDA_ACTIVATOR, SpeakString("** examines " + sTARGETNAME + " with a Gla-Detector **"))); //Announce to the examination action to all.
}
else FloatingTextStringOnCreature("The detector is inert.", oDA_ACTIVATOR, FALSE); //Do nothing if the target is not a player.
}
// Paste the above lines into your module properties' OnActivateItem script to enable the Enforcer Key and Token Detector.
{
object oItem = GetModuleItemAcquired();
// * Generic Item Script Execution Code
// * If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
// * it will execute a script that has the same name as the item's tag
// * inside this script you can manage scripts for all events by checking against
// * GetUserDefinedItemEventNumber(). See x2_it_example.nss
if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
{
SetUserDefinedItemEventNumber(X2_ITEM_EVENT_ACQUIRE);
int nRet = ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
if (nRet == X2_EXECUTE_SCRIPT_END)
{
return;
}
}
}
}