2025-04-30 12:23:15 -04:00

197 lines
6.7 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Malor (Apport)
//:: malor.nss
//:: Copyright (c) 2025 WizardryEE Project
//:://////////////////////////////////////////////
/*
Teleports the party to a random location in combat,
or to a selected dungeon level and location when
used in camp. If a party teleports into stone it
is lost forever, so the spell is best used in
conjunction with DUMAPIC.
Level 7 Mage spell.
In Wizardry: Proving Grounds of the Mad Overlord,
this is a Level 7 Mage field/support spell that
affects the entire party.
*/
//:://////////////////////////////////////////////
//:: Created By: WizardryEE Project
//:: Created On: April 26, 2025
//:://////////////////////////////////////////////
#include "prc_inc_spells"
#include "prc_add_spell_dc"
void main()
{
// Spell implementation for WizardryEE
// Core functionality: Teleport party
// Spellcast Hook Code
if (!X2PreSpellCastCode()) return;
// Set spell school for proper record keeping
PRCSetSchool(SPELL_SCHOOL_CONJURATION);
// Declare major variables
object oCaster = OBJECT_SELF;
int nCasterLevel = PRCGetCasterLevel(oCaster);
int nMetaMagic = PRCGetMetaMagicFeat();
// Check if in combat
int bInCombat = GetLocalInt(oCaster, "IN_COMBAT");
// Create teleport visual effects
effect eVis = EffectVisualEffect(VFX_FNF_TELEPORT_OUT);
effect eVis2 = EffectVisualEffect(VFX_FNF_TELEPORT_IN);
if (bInCombat)
{
// Random teleport during combat
// Get current area
object oArea = GetArea(oCaster);
// Generate random coordinates within the area
float fAreaWidth = 100.0; // Example area size
float fAreaHeight = 100.0;
vector vNewPos;
vNewPos.x = IntToFloat(Random(FloatToInt(fAreaWidth)));
vNewPos.y = IntToFloat(Random(FloatToInt(fAreaHeight)));
vNewPos.z = 0.0;
location lNewLoc = Location(oArea, vNewPos, 0.0);
// Roll for teleport mishap (5% chance)
int nMishapRoll = d100();
if (nMishapRoll <= 5)
{
// Teleport mishap - party is lost
// Apply teleport out effect at caster location
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(oCaster));
// Get all party members
object oMember = GetFirstFactionMember(oCaster, TRUE);
while (GetIsObjectValid(oMember))
{
// Mark as permanently lost
SetLocalInt(oMember, "PERMANENTLY_LOST", 1);
// Get next party member
oMember = GetNextFactionMember(oCaster, TRUE);
}
// Notify mishap
FloatingTextStringOnCreature("MALOR: Party teleported into solid matter and was lost forever!", oCaster, TRUE);
}
else
{
// Successful teleport
// Apply teleport out effect at caster location
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(oCaster));
// Apply teleport in effect at destination
DelayCommand(1.0f, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis2, lNewLoc));
// Get all party members
object oMember = GetFirstFactionMember(oCaster, TRUE);
while (GetIsObjectValid(oMember))
{
// Teleport to new location
DelayCommand(1.0f, AssignCommand(oMember, JumpToLocation(lNewLoc)));
// Get next party member
oMember = GetNextFactionMember(oCaster, TRUE);
}
// Notify success
FloatingTextStringOnCreature("MALOR: Party teleported to random location!", oCaster, TRUE);
}
}
else
{
// Targeted teleport during camp
// Get target level and coordinates from user input
int nTargetLevel = GetLocalInt(oCaster, "TELEPORT_TARGET_LEVEL");
float fTargetX = GetLocalFloat(oCaster, "TELEPORT_TARGET_X");
float fTargetY = GetLocalFloat(oCaster, "TELEPORT_TARGET_Y");
// If no target level is set, use the current level
if (nTargetLevel == 0)
{
nTargetLevel = GetLocalInt(GetArea(oCaster), "DUNGEON_LEVEL");
// If still no level, default to level 1
if (nTargetLevel == 0)
nTargetLevel = 1;
}
// Create target location
object oTargetArea = GetObjectByTag("DUNGEON_LEVEL_" + IntToString(nTargetLevel));
// If target area doesn't exist, use current area
if (!GetIsObjectValid(oTargetArea))
oTargetArea = GetArea(oCaster);
vector vTargetPos;
vTargetPos.x = fTargetX;
vTargetPos.y = fTargetY;
vTargetPos.z = 0.0;
location lTargetLoc = Location(oTargetArea, vTargetPos, 0.0);
// Roll for teleport mishap (5% chance)
int nMishapRoll = d100();
if (nMishapRoll <= 5)
{
// Teleport mishap - party is lost
// Apply teleport out effect at caster location
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(oCaster));
// Get all party members
object oMember = GetFirstFactionMember(oCaster, TRUE);
while (GetIsObjectValid(oMember))
{
// Mark as permanently lost
SetLocalInt(oMember, "PERMANENTLY_LOST", 1);
// Get next party member
oMember = GetNextFactionMember(oCaster, TRUE);
}
// Notify mishap
FloatingTextStringOnCreature("MALOR: Party teleported into solid matter and was lost forever!", oCaster, TRUE);
}
else
{
// Successful teleport
// Apply teleport out effect at caster location
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(oCaster));
// Apply teleport in effect at destination
DelayCommand(1.0f, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis2, lTargetLoc));
// Get all party members
object oMember = GetFirstFactionMember(oCaster, TRUE);
while (GetIsObjectValid(oMember))
{
// Teleport to target location
DelayCommand(1.0f, AssignCommand(oMember, JumpToLocation(lTargetLoc)));
// Get next party member
oMember = GetNextFactionMember(oCaster, TRUE);
}
// Notify success
FloatingTextStringOnCreature("MALOR: Party teleported to level " +
IntToString(nTargetLevel) + " at (" +
FloatToString(fTargetX, 0, 0) + "," +
FloatToString(fTargetY, 0, 0) + ")!", oCaster, TRUE);
}
}
// Clean up spell school variable
PRCSetSchool();
}