generated from Jaysyn/ModuleTemplate
88 lines
2.8 KiB
Plaintext
88 lines
2.8 KiB
Plaintext
/*
|
|
Rune Puzzle
|
|
Jirtan, Inc.
|
|
|
|
The rune puzzle script is used on the onused event of "rune" palceables.
|
|
The palceables' tags should be as follows...
|
|
|
|
rune1_keyresref
|
|
rune2_keyresref
|
|
rune3_keyresref
|
|
rune4_keyresref
|
|
rune5_keyresref
|
|
rune6_keyresref
|
|
etc
|
|
|
|
"keyresref" is the resref for the key you want to be created.
|
|
The number is the order in which it goes, so putting them in a
|
|
row of 1, 2, 3, 4, 5, 6, etc, would be way too easy. Mix them up a bit.
|
|
|
|
Set the integer "LAST_RUNE" equal to 1 on the last rune. It would look like:
|
|
"LAST_RUNE" int 1
|
|
in the toolest, in the last rune's advanced tab, in the variables window.
|
|
|
|
The order of them is stored on the PC as temporary integer.
|
|
|
|
If the PC doesn't follow the order, it is reset.
|
|
|
|
*/
|
|
|
|
void main()
|
|
{
|
|
object oRune = OBJECT_SELF;
|
|
object oPC = GetLastUsedBy();
|
|
|
|
string sRuneTag = GetTag(oRune);
|
|
string sKeyResref = GetStringRight(sRuneTag, GetStringLength(sRuneTag) - 6);
|
|
|
|
int nNumber = StringToInt(GetSubString(sRuneTag, 4, 1));
|
|
int nLastRuneUsed = GetLocalInt(oPC, "RUNE_" + sKeyResref);
|
|
int nIsFinalRune = GetLocalInt(oRune, "LAST_RUNE");
|
|
|
|
//Debugger - Safegaurd
|
|
if ((oRune == OBJECT_INVALID) || (oPC == OBJECT_INVALID) || (nNumber == 0))
|
|
{
|
|
SpeakString("Error! Rune tag is set incorrectly, or Rune or PC do not exist.");
|
|
return;
|
|
}
|
|
|
|
//The correct rune was used...
|
|
else if (nLastRuneUsed + 1 == nNumber)
|
|
{
|
|
effect eComplete = EffectVisualEffect(VFX_DUR_GLOW_YELLOW);
|
|
effect eCorrect = EffectVisualEffect(VFX_DUR_GLOW_LIGHT_YELLOW);
|
|
|
|
//Completed the puzzle...
|
|
if (nIsFinalRune != 0)
|
|
{
|
|
DeleteLocalInt(oPC, "RUNE_" + sKeyResref);
|
|
CreateItemOnObject(sKeyResref, oPC);
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eComplete, oRune, 2.0);
|
|
}
|
|
|
|
//Not done, but picked the right rune..
|
|
else
|
|
{
|
|
SetLocalInt(oPC, "RUNE_" + sKeyResref, nNumber);
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eCorrect, oRune, 2.0);
|
|
}
|
|
}
|
|
|
|
//The wrong rune was used...
|
|
else
|
|
{
|
|
effect eWrong = EffectVisualEffect(VFX_DUR_GLOW_GREEN);
|
|
effect ePenalize = EffectLinkEffects(EffectDamage(d3(), DAMAGE_TYPE_ACID, DAMAGE_POWER_PLUS_ONE), EffectVisualEffect(VFX_FNF_GAS_EXPLOSION_ACID));
|
|
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eWrong, oRune, 2.0);
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, ePenalize, oPC);
|
|
|
|
DeleteLocalInt(oPC, "RUNE_" + sKeyResref);
|
|
}
|
|
|
|
|
|
//: This is just for Debug purposes!
|
|
//SpeakString("Debug! Last Rune Used: " + IntToString(nLastRuneUsed) + ", Current Rune: " + IntToString(nNumber) + ", Key Resref: " + sKeyResref + ", Rune Tag: " + sRuneTag + ".");
|
|
//: Everything below is needed, however.
|
|
}
|