HoS_PRC8/_mod/_module/nss/plc_e_sumclose.nss
Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

120 lines
3.8 KiB
Plaintext

////////////////////////////////////////////////////////////////////////////////
// plc_e_sumclose - Summoning Circle Lair Add-On for Spider Cultists
// By Deva B. Winblood. November 20th, 2008.
////////////////////////////////////////////////////////////////////////////////
#include "rtsh_multiplay"
//////////////////////////////
// FUNCTIONS
//////////////////////////////
void fnExpellItems(object oHere)
{ // PURPOSE: Expell contents
object oItem;
object oCopy;
oItem=GetFirstItemInInventory(oHere);
while(GetIsObjectValid(oItem))
{ // expell items
oCopy=CopyObject(oItem,GetLocation(oHere));
DelayCommand(0.3,DestroyObject(oItem));
oItem=GetNextItemInInventory(oHere);
} // expell items
} // fnExpellItems()
void fnSummon(object oHere,int nLevel)
{ // PURPOSE: Summon the creature
effect eVFX=EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1);
object oSummon;
string sRes;
if (nLevel==1) sRes="sumcircspid1";
else if (nLevel==2) sRes="sumcircspid2";
else if (nLevel==3) sRes="sumcircspid3";
if (GetStringLength(sRes)>0)
{ // summon
effect eFlame=EffectVisualEffect(VFX_IMP_FLAME_S);
int nN=1;
object oOb=GetNearestObjectByTag("VFX_SUMMON",oHere,nN);
while(GetIsObjectValid(oOb))
{ // flame summon
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eFlame,GetLocation(oOb));
nN++;
oOb=GetNearestObjectByTag("VFX_SUMMON",oHere,nN);
} // flame summon
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eVFX,GetLocation(oHere));
oSummon=CreateObject(OBJECT_TYPE_CREATURE,sRes,GetLocation(oHere));
string sTID=GetLocalString(oHere,"sTeamID");
SetLocalString(oSummon,"sTeamID",sTID);
object oProxy=GetObjectByTag(sTID+"_PROXY");
ChangeFaction(oSummon,oProxy);
SetLocalObject(oHere,"oSummoned",oSummon);
} // summon
} // fnSummon()
int fnCountSouls(object oHere)
{ // Count Souls
int nRet=0;
object oItem=GetFirstItemInInventory(oHere);
while(GetIsObjectValid(oItem)&&nRet<3)
{ // count
if (GetTag(oItem)=="SoulToken") nRet++;
oItem=GetNextItemInInventory(oHere);
} // count
return nRet;
} // fnCountSouls()
void fnUseSouls(object oHere,int nCount)
{ // PURPOSE: Use nCount soul tokens
if (nCount>0)
{ // destroy
object oItem=GetItemPossessedBy(oHere,"SoulToken");
DestroyObject(oItem);
DelayCommand(0.3,fnUseSouls(oHere,nCount-1));
} // destroy
else
{ // expell
fnExpellItems(oHere);
} // expell
} // fnUseSouls()
/////////////////////////////////////////////////////////////////[ MAIN ]///////
void main()
{
object oMe=OBJECT_SELF;
object oSummoned=GetLocalObject(oMe,"oSummoned");
object oPC=GetLastOpenedBy();
if (!GetIsObjectValid(oSummoned))
{ // okay to summon
int nCount=fnCountSouls(oMe);
if (nCount>0)
{ // possible to summon
int nMana=fnGetTeamMana(oPC);
if (nMana>=(nCount*30))
{ // have enough mana
nMana=nMana-(nCount*30);
fnSetTeamMana(oPC,nMana);
fnSummon(oMe,nCount);
DelayCommand(0.5,fnUseSouls(oMe,nCount));
} // have enough mana
else
{ // not enough mana
FloatingTextStringOnCreature("** Not enough mana **",oPC,FALSE);
} // not enough mana
} // possible to summon
else
{ // expell
fnExpellItems(oMe);
} // expell
} // okay to summon
else
{ // already summoned
FloatingTextStringOnCreature("** Summoned creature already exists **",oPC,FALSE);
fnExpellItems(oMe);
} // already summoned
}
/////////////////////////////////////////////////////////////////[ MAIN ]///////