Aantioch_Infernum/_module/nss/hls_wandlab.nss
Jaysyn904 22947ad4b6 Initial Upload
Initial Upload
2023-08-08 16:22:17 -04:00

167 lines
6.5 KiB
Plaintext

//hahnsoo's wand creation system
//Credits: HCR by Archaegeo
//Potion/Scroll creation system by Pothole (The inspiration and base code of this system)
//Various wands by Syrsuro
//Hunger Thirst Fatigue system by Edward Beck
//
//To use: Place in the OnSpellCastAt event of a placeable, and make sure the
//placeable can have an inventory. Place a Wand item (any wand item) and an
//amount of items of any kind with a total value greater than the base cost
//of the wand (Spell level * Caster level * 375). Cast a spell of 0 - 4 levels
//that targets the placeable, and your wand will be created in the
//placeable object. Variables are set in hls_defaults.
//Note: This is meant to be used with Syrsuro's Treasure Generation system, as
//there are several wands in that system that are used to avoid redundancy. If
//you wish to use this without Syrsuro's Treasure Generation system, create the
//wands that are missing... the list is in hls_inc_convert, with the original
//Tag/resref names and what they are converted to in the file. Create the wand
//with the listed spell in the comments, and set the tag and the resref to the
//original tag/resref listed.
#include "hls_defaults"
#include "hls_inc_spell"
#include "hls_inc_convert"
void MakePlayerFatigued(object oPC, string message = "")
{
if (!GetIsPC(oPC)) return;
int bFatigued = GetLocalInt(oPC, "bFatigued");
int bExhausted = GetLocalInt(oPC, "bExhausted");
if (bFatigued || bExhausted) return;
AssignCommand(oPC, ApplyEffectToObject(DURATION_TYPE_PERMANENT, ExtraordinaryEffect(EffectCurse(2, 2, 0, 0, 0, 0)), oPC));
AssignCommand(oPC, ApplyEffectToObject(DURATION_TYPE_PERMANENT, ExtraordinaryEffect(EffectMovementSpeedDecrease(60)), oPC));
if (message!="") FloatingTextStringOnCreature(message, oPC, FALSE);
SetLocalInt(oPC,"bFatigued",TRUE);
}
void MakePlayerExhausted(object oPC, string message = "")
{
if (!GetIsPC(oPC)) return;
int bFatigued = GetLocalInt(oPC, "bFatigued");
int bExhausted = GetLocalInt(oPC, "bExhausted");
if (bExhausted) return;
if (bFatigued) {
RemoveEffect(oPC,ExtraordinaryEffect(EffectCurse(2, 2, 0, 0, 0, 0)));
RemoveEffect(oPC,ExtraordinaryEffect(EffectMovementSpeedDecrease(60)));
SetLocalInt(oPC,"bFatigued",FALSE);
}
AssignCommand(oPC, ApplyEffectToObject(DURATION_TYPE_PERMANENT, ExtraordinaryEffect(EffectCurse(6, 6, 0, 0, 0, 0)), oPC));
AssignCommand(oPC, ApplyEffectToObject(DURATION_TYPE_PERMANENT, ExtraordinaryEffect(EffectMovementSpeedDecrease(80)), oPC));
if (message!="") FloatingTextStringOnCreature(message, oPC, FALSE);
SetLocalInt(oPC,"bExhausted",TRUE);
}
void main()
{
float iCantrip = 1.0f;
int iSpellID = GetLastSpell();
string sSpellID = IntToString(iSpellID);
if (GetStringLength(sSpellID) == 2)
sSpellID = "0" + sSpellID;
if (GetStringLength(sSpellID) == 1)
sSpellID = "00" + sSpellID;
object oPlayer = GetLastSpellCaster();
int bFatigued = GetLocalInt(oPlayer, "bFatigued");
int bExhausted = GetLocalInt(oPlayer, "bExhausted");
int iCost;
int nXP = GetXP(oPlayer);
int nXPCost;
int iSpellLevel = ReturnSpellLevel(iSpellID);
int iCastLevel = ReturnCasterLevel(iSpellID, GetCasterLevel(oPlayer));
string sCastLevel;
int nTime;
string sWandTag;
int iSuccess;
int nHD = GetHitDice ( oPlayer );
int nMinXP = ((( nHD * ( nHD - 1) ) / 2 ) * 1000) + 1; //Minimum amount of XP needed to keep level
object oMod = GetModule();
string sPCName = GetName(oPlayer);
string sCDK = GetPCPublicCDKey(oPlayer);
if (iCastLevel > GetCasterLevel(oPlayer))
{
FloatingTextStringOnCreature("You are not experienced enough to imbue this wand.", oPlayer, FALSE);
return;
}
if (iSpellLevel > 4)
{
FloatingTextStringOnCreature("Your spell is too powerful to imbue into a wand.", oPlayer, FALSE);
return;
}
if (iSpellLevel == 0)
{
iCantrip = 0.5f;
iSpellLevel = 1;
}
iCost = FloatToInt(WANDCOST * iCantrip * IntToFloat(iSpellLevel*iCastLevel) );
nXPCost = iCost/25;
if (CheckWandMaterials(iCost/2))
{
if (((nXP >= nXPCost) && ((nXP-nXPCost) >= nMinXP)) || (!WANDXP))
{
//Take XP
if (WANDXP)
SetXP(oPlayer, nXP-nXPCost);
//Destroy Objects
DestroyInventory();
//Set Name of Wand resref
if (iCastLevel < 10)
sCastLevel = IntToString(iCastLevel);
else
{
switch(iCastLevel)
{
case 10: sCastLevel = "0"; break;
case 11: sCastLevel = "a"; break;
case 12: sCastLevel = "b"; break;
case 13: sCastLevel = "c"; break;
case 14: sCastLevel = "d"; break;
case 15: sCastLevel = "e"; break;
case 16: sCastLevel = "f"; break;
case 17: sCastLevel = "g"; break;
case 18: sCastLevel = "h"; break;
case 19: sCastLevel = "i"; break;
case 20: sCastLevel = "j"; break;
}
}
sWandTag = "wand_" + sSpellID + sCastLevel;
//Check for Conversions
string sFinalTag = ConvertMagicItem(sWandTag);
//Create Magical Item
object oNewWand = CreateItemOnObject(sFinalTag, OBJECT_SELF);
FloatingTextStringOnCreature("You have created a " + GetName(oNewWand) +"! It cost you " + IntToString(nXPCost) + " XP.", oPlayer, FALSE);
if (WANDFATIGUE)
{
if (!bFatigued && !bExhausted)
MakePlayerFatigued(oPlayer,"You are fatigued from creating the wand.");
else {
SetLocalInt(oPlayer, "bFatigued", FALSE);
SetLocalInt(oPlayer, "bExhausted", FALSE);
MakePlayerExhausted(oPlayer,"You are exhausted from your efforts.");
}
}
}
else //Not enough xp
{
FloatingTextStringOnCreature("Not enough XP. It costs " + IntToString(nXPCost) + " XP. You need to have a minimum XP level of " + IntToString(nMinXP + nXPCost) + " to create this wand.", oPlayer, FALSE);
return;
}
}
else
{
FloatingTextStringOnCreature("Not enough raw materials to create the wand.", oPlayer, FALSE);
return;
}
}