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

3011 lines
146 KiB
Plaintext

////////////////////////////////////////////////////////////////////////////////
// champ_2_h - Version 2.0 of the Champion AI
// By Deva B. Winblood. November 22nd, 2008
////////////////////////////////////////////////////////////////////////////////
#include "prc_inc_util"
#include "lib_hos2_shpath"
#include "rts_pathing"
#include "nw_i0_generic"
///////////////////////////////////
// CONSTANTS
///////////////////////////////////
const int CHAMPION_PATH_SPAWN = 0;
const int CHAMPION_PATH_EXPLORE = 1;
const int CHAMPION_PATH_ASSAULT = 2;
const int CHAMPION_PATH_CONTROL = 3;
const int CHAMPION_PATH_ESCAPE = 4;
const int CHAMPION_PATH_RETURN = 5;
const int CHAMPION_ACTION_NONE = 0;
const int CHAMPION_ACTION_SEARCH = 1;
const int CHAMPION_ACTION_REST = 2;
const int CHAMPION_ACTION_BUFF = 3;
const int CHAMPION_ACTION_HEAL = 4;
const int CHAMPION_ACTION_CONDITIONAL_REST = 5;
const int CHAMPION_ACTION_STEAL = 6;
const int CHAMPION_ACTION_DEPOSIT = 7;
const int CHAMPION_ACTION_USE = 8;
const int CHAMPION_ACTION_RETURN = 9;
const int CHAMPION_ACTION_RUN = 10;
const int CHAMPION_ACTION_GATHER = 11;
const int CHAMPION_ACTION_CONTROL = 12;
const int CHAMPION_ACTION_ESCAPE1 = 13;
const int CHAMPION_ACTION_ESCAPE2 = 14;
const int CHAMPION_ACTION_EQUIP = 15;
const int CHAMPION_DEBUG = TRUE;
const string CHAMPION_DEBUG_SPECIFIC = "SPID";
///////////////////////////////////
// PROTOTYPES
///////////////////////////////////
// FILE: champ_2_h FUNCTION: Champion_SetMode()
// This is the keep alive function for making sure the AI for the champion
// did not stop.
void Champion_SetMode(object oChampion);
// FILE: champ_2_h FUNCTION: Champion_AICore()
// This is the core pseudo-heartbeat for the champion. It will fire every
// 3 seconds.
void Champion_AICore(object oChampion);
// FLIE: champ_2_h FUNCTION: Champion_ChooseAction()
// This will setup what action the champion should take.
void Champion_ChooseAction(object oChampion);
// FILE: champ_2_h FUNCTION: Champion_GetNextPath()
// This function will return the next node of the path for oChampion of the
// specified path type CHAMPION_PATH_
object Champion_GetNextPath(object oChampion,int nType);
// FILE: champ_2_h FUNCTION: Champion_GetActionType()
// Return type of action that sName corresponds to
int Champion_GetActionType(string sName);
// FILE: champ_2_h FUNCTION: Champion_Steal()
// This will cause the champion to steal mana if near mana vault or, gold and
// artifact items if near tax chest.
void Champion_Steal(object oChampion);
// FILE: champ_2_h FUNCTION: Champion_Control()
// This will cause the champion to release any units following them and set
// them to guard where they stand, walk.
void Champion_Control(object oChampion);
// FILE: champ_2_h FUNCTION: Champion_GetFollower()
// This will return the nNth follower for oChampion.
object Champion_GetFollower(object oChampion,int nN=1);
// FILE: champ_2_h FUNCTION: Champion_Gather()
// This function will gather troops and set them to follow the champion.
void Champion_Gather(object oChampion);
// FILE: champ_2_h FUNCTION: Champion_Rest()
// This function will cause the champion to rest.
void Champion_Rest(object oChampion);
// FILE: champ_2_h FUNCTION: Champion_CondRest()
// This function will cause the champion to rest if the control point
// near them is under their team control.
void Champion_CondRest(object oChampion);
// FILE: champ_2_h FUNCTION: Champion_Buff()
// This will cause the champion to buff up themselves and if capable they will
// also buff up any units following them.
object Champion_Buff(object oChampion);
// FILE: champ_2_h FUNCTION: Champion_Heal()
// This function will cause the champion to do what they can to heal themselves
// and if capable they will also heal nearby allies.
object Champion_Heal(object oChampion);
// FILE: champ_2_h FUNCTION: Champion_Equip()
// This will cause the champion to update their equipment if possible.
void Champion_Equip(object oChampion);
// FILE: champ_2_h FUNCTION: Champion_Deposit()
// This will cause the champion to deposit gold in the tax chest if near it.
void Champion_Deposit(object oChampion);
// FILE: champ_2_h FUNCTION: Champion_Use()
// This will cause the champion to attempt to use an artifact item in their
// possession if it is appropriate to do so.
void Champion_Use(object oChampion);
// FILE: champ_2_h FUNCTION: Champion_Search()
// This will make the champion return the nearest object of interest to them.
void Champion_Search(object oChampion);
// FILE: champ_2_h FUNCTION: Champion_LevelUp()
// If the champion is capable of leveling up then do so.
void Champion_LevelUp(object oChampion);
// FILE: champ_2_h FUNCTION: Champion_Escape1()
// Part of the shadow plane escape process.
void Champion_Escape1(object oChampion);
//////////////////////////////////////
// FUNCTIONS TO MIMIC ITEM ACTIVATION
//////////////////////////////////////
void fnDMSpeak(object oChampion,string sSay,int bAlways=FALSE)
{ // PURPOSE: If the DM is near speak sSay
object oMod=GetModule();
object oDM=GetLocalObject(oMod,"oDM");
if (!GetIsObjectValid(oDM))
{ // find DM
oDM=GetFirstPC();
while(GetIsObjectValid(oDM)&&!GetIsObjectValid(GetLocalObject(oMod,"oDM")))
{ // find DM
if (GetIsDM(oDM)) SetLocalObject(oMod,"oDM",oDM);
oDM=GetNextPC();
} // find DM
oDM=GetLocalObject(oMod,"oDM");
} // find DM
if (GetIsObjectValid(oDM))
{ // DM exists
if (GetArea(oDM)==GetArea(oChampion)&&(d4()==1||bAlways)) AssignCommand(oChampion,SpeakString(sSay));
} // DM exists
} // fnDMSpeak();
void fnHatch(object oSeed)
{ // create bugs
int nL=0;
int nB=d4();
int nT;
location lLoc=GetLocation(oSeed);
object oBug;
while(nL<nB)
{ // create bugs
nL++;
nT=d6();
switch(nT)
{ // bug type
case 1:
case 2: { // fire beetles
oBug=CreateObject(OBJECT_TYPE_CREATURE,"btlfire001",lLoc,TRUE);
break;
} // fire beetles
case 3:
case 4:
case 5:
{ // stink beetles
oBug=CreateObject(OBJECT_TYPE_CREATURE,"btlstink001",lLoc,TRUE);
break;
} // stink beetles
case 6: { // stag beetle
oBug=CreateObject(OBJECT_TYPE_CREATURE,"btlstag001",lLoc,TRUE);
break;
} // stag beetle
} // bug type
} // create bugs
DestroyObject(oSeed);
} // fnHatch()
object fnGetBugTarget()
{ // find nearest insect or arachnid target
object oRet=OBJECT_INVALID;
int nC=1;
object oMe=OBJECT_SELF;
object oTest=GetNearestObject(OBJECT_TYPE_CREATURE,oMe,nC);
float fDist=GetDistanceBetween(oTest,oMe);
int nType;
string sTag;
while (oTest!=OBJECT_INVALID&&fDist<10.1&&oRet==OBJECT_INVALID)
{ // check creatures within 10 meters
nType=MyPRCGetRacialType(oTest);
sTag=GetTag(oTest);
if (nType==RACIAL_TYPE_VERMIN) oRet=oTest;
else if (sTag=="GiantAntQueen"||sTag=="GiantAntGuard"||sTag=="GiantAntHiveQueen"||sTag=="GiantAntLarva"||sTag=="GiantAntSoldier"||sTag=="GiantAntWorker"||sTag=="PurpleWorm"||sTag=="SPID28"||sTag=="SPID27") oRet=oTest;
nC++;
oTest=GetNearestObject(OBJECT_TYPE_CREATURE,oMe,nC);
fDist=GetDistanceBetween(oTest,oMe);
}// check creatures within 10 meters
return oRet;
} // fnGetBugTarget()
void fnBugZapper()
{ // bug zapper routine
object oMe=OBJECT_SELF;
int nCh=GetLocalInt(oMe,"nCharges");
effect eAttack=EffectBeam(VFX_BEAM_LIGHTNING,oMe,BODY_NODE_CHEST,FALSE);
effect eDmg=EffectDamage(d6(),DAMAGE_TYPE_ELECTRICAL);
object oTarget=fnGetBugTarget();
if (oTarget!=OBJECT_INVALID&&!GetIsDead(oTarget))
{ // we have a target
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eAttack,oTarget,2.0);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eDmg,oTarget,1.0);
nCh=nCh-1;
SetLocalInt(oMe,"nCharges",nCh);
} // we have a target
if (nCh>0) DelayCommand(2.0,fnBugZapper());
else
DestroyObject(oMe);
} // fnBugZapper()
////////////////////////////////////
// private Functions
////////////////////////////////////
int privateHas_ManaCrystal(object oChampion)
{ // PURPOSE: To return TRUE if the champion has a mana crystal
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/21/2006 | Deva B. Winblood | Initial version of this function
object oItem;
oItem=GetItemPossessedBy(oChampion,"MANA_CRYSTAL_5");
if (GetIsObjectValid(oItem)) return TRUE;
oItem=GetItemPossessedBy(oChampion,"MANA_CRYSTAL_2");
if (GetIsObjectValid(oItem)) return TRUE;
oItem=GetItemPossessedBy(oChampion,"MANA_CRYSTAL_1");
if (GetIsObjectValid(oItem)) return TRUE;
return FALSE;
} // privateHas_ManaCrystal()
string privateGetActionName(int nAction)
{ // PURPOSE: Return The Action name for the action for debugging
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
if (nAction==CHAMPION_ACTION_BUFF) return "BUFF";
else if (nAction==CHAMPION_ACTION_CONDITIONAL_REST) return "CONDITIONAL REST";
else if (nAction==CHAMPION_ACTION_CONTROL) return "CONTROL";
else if (nAction==CHAMPION_ACTION_DEPOSIT) return "DEPOSIT";
else if (nAction==CHAMPION_ACTION_EQUIP) return "EQUIP";
else if (nAction==CHAMPION_ACTION_ESCAPE1) return "ESCAPE1";
else if (nAction==CHAMPION_ACTION_ESCAPE2) return "ESCAPE2";
else if (nAction==CHAMPION_ACTION_GATHER) return "GATHER";
else if (nAction==CHAMPION_ACTION_HEAL) return "HEAL";
else if (nAction==CHAMPION_ACTION_NONE) return "--0--";
else if (nAction==CHAMPION_ACTION_REST) return "REST";
else if (nAction==CHAMPION_ACTION_RETURN) return "RETURN";
else if (nAction==CHAMPION_ACTION_RUN) return "RUN";
else if (nAction==CHAMPION_ACTION_SEARCH) return "SEARCH";
else if (nAction==CHAMPION_ACTION_STEAL) return "STEAL";
else if (nAction==CHAMPION_ACTION_USE) return "USE";
return "--0--";
} // privateGetActionName()
int privateHas_PowerReservoir(object oChampion)
{ // PURPOSE: return TRUE if has power reservoir - set flag also
object oItem=GetItemPossessedBy(oChampion,"rts_powerres");
if (GetIsObjectValid(oItem))
{ // has reservoir
effect eVFX;
string sTeamID=GetLocalString(oChampion,"sTeamID");
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oChampion,4.0);
return TRUE;
} // has reservoir
return FALSE;
} // privateHas_PowerReservoir()
void Champion_Debug(object oChampion,string sMsg)
{ // PURPOSE: To print a debug message to the log
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
int nLevel;
if (CHAMPION_DEBUG)
{ // champion debug is on
if (GetStringLength(CHAMPION_DEBUG_SPECIFIC)>0&&GetLocalString(oChampion,"sTeamID")!=CHAMPION_DEBUG_SPECIFIC) return;
nLevel=GetLevelByPosition(1,oChampion)+GetLevelByPosition(2,oChampion)+GetLevelByPosition(3,oChampion);
PrintString("Champion("+GetLocalString(oChampion,"sTeamID")+":"+GetTag(GetArea(oChampion))+":"+IntToString(nLevel)+" XP="+IntToString(GetLocalInt(oChampion,"nXP"))+"/"+IntToString(nLevel*500)+"): "+sMsg);
} // champion debug is on
} // Champion_Debug()
void privateCreate_Follower(object oChampion,string sRes)
{ // PURPOSE: To create a follower that follows oChampion
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
string sTeamID=GetLocalString(oChampion,"sTeamID");
object oCreature=CreateObject(OBJECT_TYPE_CREATURE,sRes,GetLocation(oChampion));
Champion_Debug(oChampion," privateCreate_Follower("+GetName(oCreature)+")");
SetMaxHenchmen(10);
AddHenchman(oChampion,oCreature);
SetLocalString(oCreature,"sTeamID",sTeamID);
SetAILevel(oCreature,AI_LEVEL_NORMAL);
SetLocalInt(oCreature,"nMState",4);
SetLocalInt(oCreature,"nSState",0);
SetLocalObject(oCreature,"oDestWP",oChampion);
SetLocalInt(oCreature,"nFollowDist",0);
} // privateCreate_Follower()
void privateHandle_Buffing(object oChampion,object oTarget)
{ // PURPOSE: This handles the actual buffing of oTarget by oChampion
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
int nRT=MyPRCGetRacialType(oTarget);
int nN;
object oItem;
Champion_Debug(oChampion," privateHandle_Buffing("+GetName(oTarget)+")");
//AssignCommand(oChampion,ClearAllActions());
if (oChampion==oTarget)
{ // self
if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MPOTION005"))&&!GetHasSpellEffect(SPELL_BARKSKIN,oChampion))
{ // okay to use barkskin potion
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION005");
nN=GetItemStackSize(oItem);
if (nN==1) DestroyObject(oItem);
else { SetItemStackSize(oItem,nN-1); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_BARKSKIN,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // okay to use barkskin potion
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MPOTION009"))&&!GetHasSpellEffect(SPELL_BLESS,oChampion))
{ // okay to use bless potion
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION009");
nN=GetItemStackSize(oItem);
if (nN==1) DestroyObject(oItem);
else { SetItemStackSize(oItem,nN-1); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_BLESS,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // okay to use bless potion
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MPOTION015"))&&!GetHasSpellEffect(SPELL_BULLS_STRENGTH,oChampion))
{ // okay to use bulls strength potion
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION015");
nN=GetItemStackSize(oItem);
if (nN==1) DestroyObject(oItem);
else { SetItemStackSize(oItem,nN-1); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_BULLS_STRENGTH,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // okay to use bulls strength potion
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MPOTION007"))&&!GetHasSpellEffect(SPELL_CLARITY,oChampion))
{ // okay to use clarity potion
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION007");
nN=GetItemStackSize(oItem);
if (nN==1) DestroyObject(oItem);
else { SetItemStackSize(oItem,nN-1); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CLARITY,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // okay to use clarity potion
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MPOTION002"))&&!GetHasSpellEffect(SPELL_DEATH_ARMOR,oChampion))
{ // okay to use death armor potion
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION002");
nN=GetItemStackSize(oItem);
if (nN==1) DestroyObject(oItem);
else { SetItemStackSize(oItem,nN-1); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_DEATH_ARMOR,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // okay to use death armor potion
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MPOTION013"))&&!GetHasSpellEffect(SPELL_ENDURANCE,oChampion))
{ // okay to use endurance potion
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION013");
nN=GetItemStackSize(oItem);
if (nN==1) DestroyObject(oItem);
else { SetItemStackSize(oItem,nN-1); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_ENDURANCE,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // okay to use endurance potion
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MPOTION008"))&&!GetHasSpellEffect(SPELL_INVISIBILITY,oChampion))
{ // okay to use invisibility potion
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION008");
nN=GetItemStackSize(oItem);
if (nN==1) DestroyObject(oItem);
else { SetItemStackSize(oItem,nN-1); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_INVISIBILITY,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // okay to use invisibility potion
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MPOTION001"))&&!GetHasSpellEffect(SPELL_IRONGUTS,oChampion))
{ // okay to use ironguts potion
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION001");
nN=GetItemStackSize(oItem);
if (nN==1) DestroyObject(oItem);
else { SetItemStackSize(oItem,nN-1); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_IRONGUTS,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // okay to use ironguts potion
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MPOTION004"))&&!GetHasSpellEffect(SPELL_HASTE,oChampion))
{ // okay to use speed potion
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION004");
nN=GetItemStackSize(oItem);
if (nN==1) DestroyObject(oItem);
else { SetItemStackSize(oItem,nN-1); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_HASTE,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // okay to use speed potion
else
{ // spells
if (GetHasSpell(SPELL_BLESS,oChampion)&&!GetHasSpellEffect(SPELL_BLESS,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_BLESS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_BLESS_WEAPON,oChampion)&&!GetHasSpellEffect(SPELL_BLESS_WEAPON,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_BLESS_WEAPON,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_CLARITY,oChampion)&&!GetHasSpellEffect(SPELL_CLARITY,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CLARITY,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_DARKFIRE,oChampion)&&!GetHasSpellEffect(SPELL_DARKFIRE,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_DARKFIRE,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_DEATH_ARMOR,oChampion)&&!GetHasSpellEffect(SPELL_DEATH_ARMOR,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_DEATH_ARMOR,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_DISPLACEMENT,oChampion)&&!GetHasSpellEffect(SPELL_DISPLACEMENT,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_DISPLACEMENT,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_DIVINE_FAVOR,oChampion)&&!GetHasSpellEffect(SPELL_DIVINE_FAVOR,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_DIVINE_FAVOR,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_DIVINE_MIGHT,oChampion)&&!GetHasSpellEffect(SPELL_DIVINE_MIGHT,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_DIVINE_MIGHT,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_DIVINE_POWER,oChampion)&&!GetHasSpellEffect(SPELL_DIVINE_POWER,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_DIVINE_POWER,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_DIVINE_SHIELD,oChampion)&&!GetHasSpellEffect(SPELL_DIVINE_SHIELD,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_DIVINE_SHIELD,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_ENDURANCE,oChampion)&&!GetHasSpellEffect(SPELL_ENDURANCE,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_ENDURANCE,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_ENDURE_ELEMENTS,oChampion)&&!GetHasSpellEffect(SPELL_ENDURE_ELEMENTS,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_ENDURE_ELEMENTS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_ENTROPIC_SHIELD,oChampion)&&!GetHasSpellEffect(SPELL_ENTROPIC_SHIELD,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_ENTROPIC_SHIELD,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_EPIC_MAGE_ARMOR,oChampion)&&!GetHasSpellEffect(SPELL_EPIC_MAGE_ARMOR,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_EPIC_MAGE_ARMOR,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_FREEDOM_OF_MOVEMENT,oChampion)&&!GetHasSpellEffect(SPELL_FREEDOM_OF_MOVEMENT,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_FREEDOM_OF_MOVEMENT,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_GHOSTLY_VISAGE,oChampion)&&!GetHasSpellEffect(SPELL_GHOSTLY_VISAGE,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_GHOSTLY_VISAGE,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_GREATER_BULLS_STRENGTH,oChampion)&&!GetHasSpellEffect(SPELL_GREATER_BULLS_STRENGTH,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_GREATER_BULLS_STRENGTH,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_GREATER_ENDURANCE,oChampion)&&!GetHasSpellEffect(SPELL_GREATER_ENDURANCE,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_GREATER_ENDURANCE,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_GREATER_MAGIC_WEAPON,oChampion)&&!GetHasSpellEffect(SPELL_GREATER_MAGIC_WEAPON,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_GREATER_MAGIC_WEAPON,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_GREATER_STONESKIN,oChampion)&&!GetHasSpellEffect(SPELL_GREATER_STONESKIN,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_GREATER_STONESKIN,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_GREATER_SPELL_MANTLE,oChampion)&&!GetHasSpellEffect(SPELL_GREATER_SPELL_MANTLE,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_GREATER_SPELL_MANTLE,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_HASTE,oChampion)&&!GetHasSpellEffect(SPELL_HASTE,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_HASTE,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_HOLY_AURA,oChampion)&&!GetHasSpellEffect(SPELL_HOLY_AURA,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_HOLY_AURA,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_HOLY_SWORD,oChampion)&&!GetHasSpellEffect(SPELL_HOLY_SWORD,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_HOLY_SWORD,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_IMPROVED_INVISIBILITY,oChampion)&&!GetHasSpellEffect(SPELL_IMPROVED_INVISIBILITY,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_IMPROVED_INVISIBILITY,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_INVISIBILITY_SPHERE,oChampion)&&!GetHasSpellEffect(SPELL_INVISIBILITY_SPHERE,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_INVISIBILITY_SPHERE,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_IRONGUTS,oChampion)&&!GetHasSpellEffect(SPELL_IRONGUTS,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_IRONGUTS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_KEEN_EDGE,oChampion)&&!GetHasSpellEffect(SPELL_KEEN_EDGE,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_KEEN_EDGE,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_LESSER_MIND_BLANK,oChampion)&&!GetHasSpellEffect(SPELL_LESSER_MIND_BLANK,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_LESSER_MIND_BLANK,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_LESSER_SPELL_MANTLE,oChampion)&&!GetHasSpellEffect(SPELL_LESSER_SPELL_MANTLE,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_LESSER_SPELL_MANTLE,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_MAGE_ARMOR,oChampion)&&!GetHasSpellEffect(SPELL_MAGE_ARMOR,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_MAGE_ARMOR,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_MAGIC_VESTMENT,oChampion)&&!GetHasSpellEffect(SPELL_MAGIC_VESTMENT,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_MAGIC_VESTMENT,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_MAGIC_WEAPON,oChampion)&&!GetHasSpellEffect(SPELL_MAGIC_WEAPON,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_MAGIC_WEAPON,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_MIND_BLANK,oChampion)&&!GetHasSpellEffect(SPELL_MIND_BLANK,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_MIND_BLANK,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_PREMONITION,oChampion)&&!GetHasSpellEffect(SPELL_PREMONITION,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_PREMONITION,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_PRAYER,oChampion)&&!GetHasSpellEffect(SPELL_PRAYER,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_PRAYER,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_SHIELD,oChampion)&&!GetHasSpellEffect(SPELL_SHIELD,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_SHIELD,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_SPELL_MANTLE,oChampion)&&!GetHasSpellEffect(SPELL_SPELL_MANTLE,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_SPELL_MANTLE,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_MINOR_GLOBE_OF_INVULNERABILITY,oChampion)&&!GetHasSpellEffect(SPELL_MINOR_GLOBE_OF_INVULNERABILITY,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_MINOR_GLOBE_OF_INVULNERABILITY,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_GLOBE_OF_INVULNERABILITY,oChampion)&&!GetHasSpellEffect(SPELL_GLOBE_OF_INVULNERABILITY,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_GLOBE_OF_INVULNERABILITY,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_SPELL_RESISTANCE,oChampion)&&!GetHasSpellEffect(SPELL_SPELL_RESISTANCE,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_SPELL_RESISTANCE,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else
{ // done buffing
SetLocalInt(oTarget,"bDoneBuffing",TRUE);
DelayCommand(180.3,DeleteLocalInt(oTarget,"bDoneBuffing"));
} // done buffing
} // spells
} // self
else if (nRT==RACIAL_TYPE_UNDEAD)
{ // undead
if (GetHasSpell(SPELL_STONE_BONES,oChampion)&&!GetHasSpellEffect(SPELL_STONE_BONES,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_STONE_BONES,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_BARKSKIN,oChampion)&&!GetHasSpellEffect(SPELL_BARKSKIN,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_BARKSKIN,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_STONESKIN,oChampion)&&!GetHasSpellEffect(SPELL_STONESKIN,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_STONESKIN,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_BULLS_STRENGTH,oChampion)&&!GetHasSpellEffect(SPELL_BULLS_STRENGTH,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_BULLS_STRENGTH,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_DEATH_ARMOR,oChampion)&&!GetHasSpellEffect(SPELL_DEATH_ARMOR,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_DEATH_ARMOR,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_HASTE,oChampion)&&!GetHasSpellEffect(SPELL_HASTE,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_HASTE,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_INVISIBILITY,oChampion)&&!GetHasSpellEffect(SPELL_INVISIBILITY,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_INVISIBILITY,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_MAGIC_VESTMENT,oChampion)&&!GetHasSpellEffect(SPELL_MAGIC_VESTMENT,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_MAGIC_VESTMENT,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_SEE_INVISIBILITY,oChampion)&&!GetHasSpellEffect(SPELL_SEE_INVISIBILITY,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_SEE_INVISIBILITY,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else
{ // done buffing
SetLocalInt(oTarget,"bDoneBuffing",TRUE);
DelayCommand(180.6,DeleteLocalInt(oTarget,"bDoneBuffing"));
} // done buffing
} // undead
else
{ // other
if (GetHasSpell(SPELL_BARKSKIN,oChampion)&&!GetHasSpellEffect(SPELL_BARKSKIN,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_BARKSKIN,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_STONESKIN,oChampion)&&!GetHasSpellEffect(SPELL_STONESKIN,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_STONESKIN,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_BULLS_STRENGTH,oChampion)&&!GetHasSpellEffect(SPELL_BULLS_STRENGTH,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_BULLS_STRENGTH,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_DEATH_ARMOR,oChampion)&&!GetHasSpellEffect(SPELL_DEATH_ARMOR,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_DEATH_ARMOR,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_HASTE,oChampion)&&!GetHasSpellEffect(SPELL_HASTE,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_HASTE,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_INVISIBILITY,oChampion)&&!GetHasSpellEffect(SPELL_INVISIBILITY,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_INVISIBILITY,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_MAGIC_VESTMENT,oChampion)&&!GetHasSpellEffect(SPELL_MAGIC_VESTMENT,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_MAGIC_VESTMENT,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_SEE_INVISIBILITY,oChampion)&&!GetHasSpellEffect(SPELL_SEE_INVISIBILITY,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_SEE_INVISIBILITY,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_IRONGUTS,oChampion)&&!GetHasSpellEffect(SPELL_IRONGUTS,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_IRONGUTS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else if (GetHasSpell(SPELL_MAGIC_WEAPON,oChampion)&&!GetHasSpellEffect(SPELL_MAGIC_WEAPON,oTarget))
{ // cast spell
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_MAGIC_WEAPON,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast spell
else
{ // done buffing
SetLocalInt(oTarget,"bDoneBuffing",TRUE);
DelayCommand(180.9,DeleteLocalInt(oTarget,"bDoneBuffing"));
} // done buffing
} // other
} // privateHandle_Buffing()
void privateHandle_Healing(object oChampion,object oTarget)
{ // PURPOSE: Heal oTarget
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
int nMax=GetMaxHitPoints(oTarget);
int nCur=GetCurrentHitPoints(oTarget);
object oItem;
int nN;
if (oChampion==oTarget)
{ // self
if (nCur<nMax)
{ // wounded
if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MPOTION001")))
{ // use
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION001");
nN=GetItemStackSize(oItem);
if (nN>1) SetItemStackSize(oItem,nN-1);
else { DestroyObject(oItem); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_LIGHT_WOUNDS,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // use
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MPOTION020")))
{ // use
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION020");
nN=GetItemStackSize(oItem);
if (nN>1) SetItemStackSize(oItem,nN-1);
else { DestroyObject(oItem); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_MODERATE_WOUNDS,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // use
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MPOTION002")))
{ // use
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION002");
nN=GetItemStackSize(oItem);
if (nN>1) SetItemStackSize(oItem,nN-1);
else { DestroyObject(oItem); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_SERIOUS_WOUNDS,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // use
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MPOTION003")))
{ // use
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION003");
nN=GetItemStackSize(oItem);
if (nN>1) SetItemStackSize(oItem,nN-1);
else { DestroyObject(oItem); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_CRITICAL_WOUNDS,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // use
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MPOTION012")))
{ // use
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION012");
nN=GetItemStackSize(oItem);
if (nN>1) SetItemStackSize(oItem,nN-1);
else { DestroyObject(oItem); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_HEAL,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // use
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MEDKIT001")))
{ // use
oItem=GetItemPossessedBy(oChampion,"NW_IT_MEDKIT001");
nN=GetItemStackSize(oItem);
if (nN>1) SetItemStackSize(oItem,nN-1);
else { DestroyObject(oItem); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_LIGHT_WOUNDS,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // use
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MEDKIT002")))
{ // use
oItem=GetItemPossessedBy(oChampion,"NW_IT_MEDKIT002");
nN=GetItemStackSize(oItem);
if (nN>1) SetItemStackSize(oItem,nN-1);
else { DestroyObject(oItem); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_MODERATE_WOUNDS,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // use
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MEDKIT003")))
{ // use
oItem=GetItemPossessedBy(oChampion,"NW_IT_MEDKIT003");
nN=GetItemStackSize(oItem);
if (nN>1) SetItemStackSize(oItem,nN-1);
else { DestroyObject(oItem); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_SERIOUS_WOUNDS,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // use
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MEDKIT004")))
{ // use
oItem=GetItemPossessedBy(oChampion,"NW_IT_MEDKIT004");
nN=GetItemStackSize(oItem);
if (nN>1) SetItemStackSize(oItem,nN-1);
else { DestroyObject(oItem); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_CRITICAL_WOUNDS,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // use
else if (GetHasSpell(SPELL_CURE_MINOR_WOUNDS,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_MINOR_WOUNDS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else if (GetHasSpell(SPELL_CURE_LIGHT_WOUNDS,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_LIGHT_WOUNDS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else if (GetHasSpell(SPELL_CURE_MODERATE_WOUNDS,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_MODERATE_WOUNDS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else if (GetHasSpell(SPELL_CURE_SERIOUS_WOUNDS,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_SERIOUS_WOUNDS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else if (GetHasSpell(SPELL_CURE_CRITICAL_WOUNDS,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_CRITICAL_WOUNDS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else if (GetHasSpell(SPELL_HEALING_STING,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_HEALING_STING,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else if (GetHasSpell(SPELL_HEALING_CIRCLE,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_HEALING_CIRCLE,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else if (GetHasSpell(SPELL_HEAL,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_HEAL,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else if (GetHasSpell(SPELL_MONSTROUS_REGENERATION,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_MONSTROUS_REGENERATION,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else if (GetHasSpell(SPELL_REGENERATE,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_REGENERATE,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else
{ // no spells left
SetLocalInt(oTarget,"bDoneHealing",TRUE);
DelayCommand(180.9,DeleteLocalInt(oTarget,"bDoneHealing"));
} // no spells left
} // wounded
else
{ // not wounded
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION011");
if (GetIsObjectValid(oItem))
{ // have potion of lesser restoration
nN=GetItemStackSize(oItem);
if (nN>1) SetItemStackSize(oItem,nN-1);
else { DestroyObject(oItem); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_LESSER_RESTORATION,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // have potion of lesser restoration
else
{ // check for spell
if (GetHasSpell(SPELL_GREATER_RESTORATION,oChampion))
{ // greater restoration
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_GREATER_RESTORATION,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // greater restoration
else if (GetHasSpell(SPELL_RESTORATION,oChampion))
{ // restoration
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_RESTORATION,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // restoration
else if (GetHasSpell(SPELL_LESSER_RESTORATION,oChampion))
{ // lesser restoration
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_LESSER_RESTORATION,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // lesser restoration
} // check for spell
SetLocalInt(oTarget,"bDoneHealing",TRUE);
DelayCommand(180.9,DeleteLocalInt(oTarget,"bDoneHealing"));
} // not wounded
} // self
else
{ // other
if (nCur<nMax)
{ // wounded
if (MyPRCGetRacialType(oTarget)==RACIAL_TYPE_UNDEAD)
{ // undead
if (GetHasSpell(SPELL_INFLICT_MINOR_WOUNDS,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_INFLICT_MINOR_WOUNDS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else if (GetHasSpell(SPELL_INFLICT_LIGHT_WOUNDS,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_INFLICT_LIGHT_WOUNDS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else if (GetHasSpell(SPELL_INFLICT_MODERATE_WOUNDS,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_INFLICT_MODERATE_WOUNDS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else if (GetHasSpell(SPELL_INFLICT_SERIOUS_WOUNDS,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_INFLICT_SERIOUS_WOUNDS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else
{ // spend no more power
SetLocalInt(oTarget,"bDoneHealing",TRUE);
DelayCommand(180.9,DeleteLocalInt(oTarget,"bDoneHealing"));
} // spend no more power
} // undead
else
{ // not undead
if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MEDKIT001")))
{ // use
oItem=GetItemPossessedBy(oChampion,"NW_IT_MEDKIT001");
nN=GetItemStackSize(oItem);
if (nN>1) SetItemStackSize(oItem,nN-1);
else { DestroyObject(oItem); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_LIGHT_WOUNDS,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // use
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MEDKIT002")))
{ // use
oItem=GetItemPossessedBy(oChampion,"NW_IT_MEDKIT002");
nN=GetItemStackSize(oItem);
if (nN>1) SetItemStackSize(oItem,nN-1);
else { DestroyObject(oItem); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_MODERATE_WOUNDS,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // use
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MEDKIT003")))
{ // use
oItem=GetItemPossessedBy(oChampion,"NW_IT_MEDKIT003");
nN=GetItemStackSize(oItem);
if (nN>1) SetItemStackSize(oItem,nN-1);
else { DestroyObject(oItem); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_SERIOUS_WOUNDS,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // use
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"NW_IT_MEDKIT004")))
{ // use
oItem=GetItemPossessedBy(oChampion,"NW_IT_MEDKIT004");
nN=GetItemStackSize(oItem);
if (nN>1) SetItemStackSize(oItem,nN-1);
else { DestroyObject(oItem); }
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK,1.0,2.0));
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_CRITICAL_WOUNDS,oTarget,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // use
else if (GetHasSpell(SPELL_CURE_MINOR_WOUNDS,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_MINOR_WOUNDS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else if (GetHasSpell(SPELL_CURE_LIGHT_WOUNDS,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_LIGHT_WOUNDS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else if (GetHasSpell(SPELL_CURE_MODERATE_WOUNDS,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_MODERATE_WOUNDS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else if (GetHasSpell(SPELL_CURE_SERIOUS_WOUNDS,oChampion))
{ // cast
AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_CURE_SERIOUS_WOUNDS,oTarget,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // cast
else
{ // expend no power
SetLocalInt(oTarget,"bDoneHealing",TRUE);
DelayCommand(180.9,DeleteLocalInt(oTarget,"bDoneHealing"));
} // expend no power
} // not undead
} // wounded
else
{ // not wounded
SetLocalInt(oTarget,"bDoneHealing",TRUE);
DelayCommand(180.9,DeleteLocalInt(oTarget,"bDoneHealing"));
} // not wounded
} // other
} // privateHandle_Healing()
void privateApothecary(object oChampion, object oApothecary)
{ // PURPOSE: Buy potions from the apothecary
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
object oItem;
int nN;
string sS;
int nBT;
object oCopy;
Champion_Debug(oChampion," privateApothecary()");
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION001");
if (!GetIsObjectValid(oItem)&&GetGold(oItem)>=20)
{ // buy cure light potion
nN=GetGold(oItem);
nN=nN/20;
if (nN>6) nN=6;
oItem=CreateItemOnObject("nw_it_mpotion001",oChampion,nN);
TakeGoldFromCreature(nN*20,oChampion,TRUE);
} // buy cure light potion
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION005");
if (!GetIsObjectValid(oItem)&&GetGold(oItem)>=80)
{ // buy barkskin
nN=GetGold(oItem);
nN=nN/80;
if (nN>2) nN=2;
oItem=CreateItemOnObject("nw_it_mpotion005",oChampion,nN);
TakeGoldFromCreature(nN*80,oChampion,TRUE);
} // buy barkskin
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION011");
if (!GetIsObjectValid(oItem)&&GetGold(oItem)>=120)
{ // buy lesser restoration
nN=GetGold(oItem);
nN=nN/120;
if (nN>2) nN=2;
oItem=CreateItemOnObject("nw_it_mpotion011",oChampion,nN);
TakeGoldFromCreature(nN*120,oChampion,TRUE);
} // buy lesser restoration
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION009");
if (!GetIsObjectValid(oItem)&&GetGold(oItem)>=40)
{ // buy bless
nN=GetGold(oItem);
nN=nN/40;
if (nN>2) nN=2;
oItem=CreateItemOnObject("nw_it_mpotion009",oChampion,nN);
TakeGoldFromCreature(nN*40,oChampion,TRUE);
} // buy bless
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION015");
if (!GetIsObjectValid(oItem)&&GetGold(oItem)>=120)
{ // buy bulls strength
nN=GetGold(oItem);
nN=nN/120;
if (nN>2) nN=2;
oItem=CreateItemOnObject("nw_it_mpotion015",oChampion,nN);
TakeGoldFromCreature(nN*120,oChampion,TRUE);
} // buy bulls strength
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION007");
if (!GetIsObjectValid(oItem)&&GetGold(oItem)>=120)
{ // buy clarity
nN=GetGold(oItem);
nN=nN/120;
if (nN>1) nN=1;
oItem=CreateItemOnObject("nw_it_mpotion007",oChampion,nN);
TakeGoldFromCreature(nN*120,oChampion,TRUE);
} // buy clarity
oItem=GetItemPossessedBy(oChampion,"X2_IT_MPOTION002");
if (!GetIsObjectValid(oItem)&&GetGold(oItem)>=120)
{ // buy death armor
nN=GetGold(oItem);
nN=nN/120;
if (nN>2) nN=2;
oItem=CreateItemOnObject("x2_it_mpotion002",oChampion,nN);
TakeGoldFromCreature(nN*120,oChampion,TRUE);
} // buy death armor
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION004");
if (!GetIsObjectValid(oItem)&&GetGold(oItem)>=300)
{ // buy speed
nN=GetGold(oItem);
nN=nN/300;
if (nN>3) nN=3;
oItem=CreateItemOnObject("nw_it_mpotion004",oChampion,nN);
TakeGoldFromCreature(nN*300,oChampion,TRUE);
} // buy speed
} // privateApothecary()
void privateSmith(object oChampion,object oSmith)
{ // PURPOSE: Trade with the smith
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
object oItem;
int nN;
string sS;
int nBT;
object oCopy;
Champion_Debug(oChampion," privateSmith()");
sS=GetLocalString(oChampion,"sTeamID");
sS=GetStringUpperCase(sS);
if (sS=="UND")
{ // undead - cleric
oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oChampion);
if (GetGoldPieceValue(oItem)<13&&GetGold(oChampion)>=10)
{ // buy a mace
GiveGoldToCreature(oChampion,GetGoldPieceValue(oItem)/4);
oCopy=CreateItemOnObject("nw_wblml001",oChampion);
DestroyObject(oItem);
TakeGoldFromCreature(10,oChampion,TRUE);
} // buy a mace
} // undead - cleric
else if (sS=="UNC")
{ // unclean - barbarian
oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oChampion);
if (GetGoldPieceValue(oItem)<25&&GetGold(oChampion)>=20)
{ // buy a battle axe
GiveGoldToCreature(oChampion,GetGoldPieceValue(oItem)/4);
oCopy=CreateItemOnObject("nw_waxbt001",oChampion);
DestroyObject(oItem);
TakeGoldFromCreature(20,oChampion,TRUE);
} // buy a battle axe
} // unclean - barbarian
else if (sS=="DWF")
{ // dwarves - paladin
oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oChampion);
if (GetGoldPieceValue(oItem)<28&&GetGold(oChampion)>=24)
{ // buy a warhammer
GiveGoldToCreature(oChampion,GetGoldPieceValue(oItem)/4);
oCopy=CreateItemOnObject("nw_wblhw001",oChampion);
DestroyObject(oItem);
TakeGoldFromCreature(24,oChampion,TRUE);
} // buy a warhammer
} // dwarves - paladin
else if (sS=="SPID")
{ // spiders - fighter
oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oChampion);
if (GetGoldPieceValue(oItem)<32&&GetGold(oChampion)>=30)
{ // buy a longsword
GiveGoldToCreature(oChampion,GetGoldPieceValue(oItem)/4);
oCopy=CreateItemOnObject("nw_wswls001",oChampion);
DestroyObject(oItem);
TakeGoldFromCreature(30,oChampion,TRUE);
} // buy a longsword
} // spiders - fighter
oItem=GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oChampion);
if (GetGoldPieceValue(oItem)<706&&GetGold(oChampion)>=706)
{ // buy a large shield
GiveGoldToCreature(oChampion,GetGoldPieceValue(oItem)/4);
oCopy=CreateItemOnObject("nw_ashmlw002",oChampion);
DestroyObject(oItem);
TakeGoldFromCreature(706,oChampion,TRUE);
} // buy a large shield
} // privateSmith()
void privateRotund(object oChampion,object oRotund)
{ // PURPOSE: Trade with rotund
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
object oItem;
int nN;
string sS;
int nBT;
object oCopy;
object oJackedStore=GetObjectByTag("JackedStore");
Champion_Debug(oChampion," privateRotund()");
oItem=GetFirstItemInInventory(oChampion);
while(GetIsObjectValid(oItem))
{ // sell items
if (!GetPlotFlag(oItem))
{ // worth considering
sS=GetTag(oItem);
nBT=GetBaseItemType(oItem);
nN=GetGoldPieceValue(oItem);
if (nBT==BASE_ITEM_GEM||nBT==BASE_ITEM_AMULET||nBT==BASE_ITEM_SCROLL||nBT==BASE_ITEM_SPELLSCROLL)
{ // sell
nN=nN/4;
if (nN<1) nN=1;
oCopy=CreateItemOnObject(GetResRef(oItem),oJackedStore,GetItemStackSize(oItem));
DelayCommand(1.0,DestroyObject(oItem));
GiveGoldToCreature(oChampion,nN);
} // sell
} // worth considering
nN++;
oItem=GetNextItemInInventory(oChampion);
} // sell items
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION001");
if (!GetIsObjectValid(oItem)&&GetGold(oItem)>=50)
{ // buy cure light potion
nN=GetGold(oItem);
nN=nN/50;
if (nN>3) nN=3;
oItem=CreateItemOnObject("nw_it_mpotion001",oChampion,nN);
TakeGoldFromCreature(nN*50,oChampion,TRUE);
} // buy cure light potion
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION005");
if (!GetIsObjectValid(oItem)&&GetGold(oItem)>=200)
{ // buy cure light potion
nN=1;
oItem=CreateItemOnObject("nw_it_mpotion005",oChampion,nN);
TakeGoldFromCreature(nN*200,oChampion,TRUE);
} // buy cure light potion
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION011");
if (!GetIsObjectValid(oItem)&&GetGold(oItem)>=300)
{ // buy cure light potion
nN=1;
oItem=CreateItemOnObject("nw_it_mpotion011",oChampion,nN);
TakeGoldFromCreature(nN*300,oChampion,TRUE);
} // buy cure light potion
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION009");
if (!GetIsObjectValid(oItem)&&GetGold(oItem)>=100)
{ // buy cure light potion
nN=1;
oItem=CreateItemOnObject("nw_it_mpotion009",oChampion,nN);
TakeGoldFromCreature(nN*300,oChampion,TRUE);
} // buy cure light potion
oItem=GetItemPossessedBy(oChampion,"NW_IT_MPOTION015");
if (!GetIsObjectValid(oItem)&&GetGold(oItem)>=300)
{ // buy cure light potion
nN=1;
oItem=CreateItemOnObject("nw_it_mpotion015",oChampion,nN);
TakeGoldFromCreature(nN*300,oChampion,TRUE);
} // buy cure light potion
sS=GetLocalString(oChampion,"sTeamID");
sS=GetStringUpperCase(sS);
if (sS=="UND")
{ // undead - cleric
oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oChampion);
if (GetGoldPieceValue(oItem)<13&&GetGold(oChampion)>=25)
{ // buy a mace
GiveGoldToCreature(oChampion,GetGoldPieceValue(oItem)/4);
oCopy=CreateItemOnObject("nw_wblml001",oChampion);
DestroyObject(oItem);
TakeGoldFromCreature(25,oChampion,TRUE);
} // buy a mace
} // undead - cleric
else if (sS=="UNC")
{ // unclean - barbarian
oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oChampion);
if (GetGoldPieceValue(oItem)<25&&GetGold(oChampion)>=50)
{ // buy a battle axe
GiveGoldToCreature(oChampion,GetGoldPieceValue(oItem)/4);
oCopy=CreateItemOnObject("nw_waxbt001",oChampion);
DestroyObject(oItem);
TakeGoldFromCreature(50,oChampion,TRUE);
} // buy a battle axe
} // unclean - barbarian
else if (sS=="DWF")
{ // dwarves - paladin
oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oChampion);
if (GetGoldPieceValue(oItem)<28&&GetGold(oChampion)>=60)
{ // buy a warhammer
GiveGoldToCreature(oChampion,GetGoldPieceValue(oItem)/4);
oCopy=CreateItemOnObject("nw_wblhw001",oChampion);
DestroyObject(oItem);
TakeGoldFromCreature(60,oChampion,TRUE);
} // buy a warhammer
} // dwarves - paladin
else if (sS=="SPID")
{ // spiders - fighter
oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oChampion);
if (GetGoldPieceValue(oItem)<32&&GetGold(oChampion)>=75)
{ // buy a longsword
GiveGoldToCreature(oChampion,GetGoldPieceValue(oItem)/4);
oCopy=CreateItemOnObject("nw_wswls001",oChampion);
DestroyObject(oItem);
TakeGoldFromCreature(75,oChampion,TRUE);
} // buy a longsword
} // spiders - fighter
oItem=GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oChampion);
if (GetGoldPieceValue(oItem)<40&&GetGold(oChampion)>=125)
{ // buy a large shield
GiveGoldToCreature(oChampion,GetGoldPieceValue(oItem)/4);
oCopy=CreateItemOnObject("nw_ashlw001",oChampion);
DestroyObject(oItem);
TakeGoldFromCreature(125,oChampion,TRUE);
} // buy a large shield
} // privateRotund()
void privateHealer(object oChampion,object oHealer)
{ // PURPOSE: Be healed by the healer
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
Champion_Debug(oChampion," privateHealer()");
AssignCommand(oHealer,ClearAllActions());
AssignCommand(oHealer,ActionCastSpellAtObject(SPELL_RESTORATION,oChampion,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
AssignCommand(oHealer,ActionCastSpellAtObject(SPELL_HEAL,oChampion,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
} // privateHealer()
///////////////////////////////////
// FUNCTIONS
///////////////////////////////////
void Champion_SetMode(object oChampion)
{ // PURPOSE: Keep Alive
if (!GetLocalInt(oChampion,"bSentinel"))
{ // sentinel
Champion_AICore(oChampion);
} // sentinel
else
{ // delete
DeleteLocalInt(oChampion,"bSentinel");
} // delete
} // Champion_SetMode()
void Champion_AICore(object oChampion)
{ // PURPOSE: Core AI Routine for champion
int bPassive=GetLocalInt(oChampion,"bPassive");
int nState=GetLocalInt(oChampion,"nState");
int nAction=GetLocalInt(oChampion,"nAction");
object oDest=GetLocalObject(oChampion,"oPathDest");
object oEnemy=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oChampion,1,CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY);
object oOb;
object oItem;
string sTeamID=GetLocalString(oChampion,"sTeamID");
int nN;
string sS;
if (!GetIsInCombat(oChampion)&&!GetIsDMPossessed(oChampion)&&!IsInConversation(oChampion)&&(!GetIsObjectValid(oEnemy)||bPassive))
{ // process AI
if (privateHas_ManaCrystal(oChampion)||privateHas_PowerReservoir(oChampion))
{ // run back to base
oOb=GetWaypointByTag(sTeamID+"_VAULT");
if (GetArea(oOb)!=GetArea(oChampion))
{ // state 5
nState=5;
} // state 5
else if (privateHas_PowerReservoir(oChampion))
{ // state 6
nState=6;
} // state 6
else
{ // state 7
nState=7;
} // state 7
SetLocalInt(oChampion,"bPassive",TRUE);
SetLocalInt(oChampion,"nState",nState);
SetLocalInt(oChampion,"bRun",TRUE);
} // run back to base
if (!GetIsObjectValid(oDest)) { nState=0; }
if (nState==0)
{ // Choose action
fnDMSpeak(oChampion,"Deciding next action.",TRUE);
if (GetLocalInt(GetArea(oChampion),"bOP"))
{ // is in outer planes - escape
fnDMSpeak(oChampion,"I must escape the outer planes.",TRUE);
SetLocalInt(oChampion,"nMode",CHAMPION_PATH_ESCAPE);
DeleteLocalInt(oChampion,"nPathPosition_EXP");
DeleteLocalInt(oChampion,"nPathPosition_CON");
DeleteLocalInt(oChampion,"nPathPosition_ASS");
DeleteLocalInt(oChampion,"nPathPosition_ESC");
oDest=Champion_GetNextPath(oChampion,CHAMPION_PATH_ESCAPE);
if (GetIsObjectValid(oDest))
{ // path found
SetLocalObject(oChampion,"oPathDest",oDest);
SetLocalInt(oChampion,"nState",1);
} // path found
} // is in outer planes - escape
else
{ // use action chooser
Champion_ChooseAction(oChampion);
} // use action chooser
} // choose action
else if (nState==1)
{ // move to destination
fnDMSpeak(oChampion,"Heading to destination. ["+GetTag(oDest)+"]");
if (GetIsObjectValid(oDest))
{ // destination is valid
nN=MoveToObject(oChampion,oDest,GetLocalInt(oChampion,"bRun"),3.0);
if (nN==1)
{ // process action
SetLocalInt(oChampion,"nState",2);
DeleteLocalInt(oChampion,"nActionInProgress");
} // process action
else if (nN==-1)
{ // cannot reach
DeleteLocalInt(oChampion,"nState");
DeleteLocalInt(oChampion,"nPathPosition_EXP");
DeleteLocalInt(oChampion,"nPathPosition_CON");
DeleteLocalInt(oChampion,"nPathPosition_ASS");
DeleteLocalInt(oChampion,"nPathPosition_ESC");
DeleteLocalInt(oChampion,"nMode");
} // cannot reach
} // destination is valid
else
{ // reset state
DeleteLocalInt(oChampion,"nState");
DeleteLocalInt(oChampion,"nPathPosition_EXP");
DeleteLocalInt(oChampion,"nPathPosition_CON");
DeleteLocalInt(oChampion,"nPathPosition_ASS");
DeleteLocalInt(oChampion,"nPathPosition_ESC");
DeleteLocalInt(oChampion,"nMode");
} // reset state
} // move to destination
else if (nState==2)
{ // process destination action
nN=GetLocalInt(oChampion,"nActionInProgress");
if (nN<1)
{ // no delay to this action
oDest=GetLocalObject(oChampion,"oPathDest");
sS=GetName(oDest);
fnDMSpeak(oChampion,"I am considering an action. ["+sS+"]",TRUE);
nN=Champion_GetActionType(sS);
SetLocalInt(oChampion,"nAction",nN);
if (nN!=CHAMPION_ACTION_NONE)
{ // process action
if (nN==CHAMPION_ACTION_STEAL) Champion_Steal(oChampion);
else if (nN==CHAMPION_ACTION_CONTROL) Champion_Control(oChampion);
else if (nN==CHAMPION_ACTION_GATHER) Champion_Gather(oChampion);
else if (nN==CHAMPION_ACTION_REST) Champion_Rest(oChampion);
else if (nN==CHAMPION_ACTION_CONDITIONAL_REST) Champion_CondRest(oChampion);
else if (nN==CHAMPION_ACTION_BUFF) Champion_Buff(oChampion);
else if (nN==CHAMPION_ACTION_HEAL) Champion_Heal(oChampion);
else if (nN==CHAMPION_ACTION_EQUIP) Champion_Equip(oChampion);
else if (nN==CHAMPION_ACTION_DEPOSIT) Champion_Deposit(oChampion);
else if (nN==CHAMPION_ACTION_USE) Champion_Use(oChampion);
else if (nN==CHAMPION_ACTION_SEARCH) Champion_Search(oChampion);
else if (nN==CHAMPION_ACTION_RETURN)
{ // return
Champion_LevelUp(oChampion);
DeleteLocalInt(oChampion,"nState");
DeleteLocalInt(oChampion,"nPathPosition_EXP");
DeleteLocalInt(oChampion,"nPathPosition_CON");
DeleteLocalInt(oChampion,"nPathPosition_ASS");
DeleteLocalInt(oChampion,"nPathPosition_ESC");
} // return
else if (nN==CHAMPION_ACTION_RUN)
{ // set to run
SetLocalInt(oChampion,"nActionInProgress",1);
SetLocalInt(oChampion,"bRun",TRUE);
} // set to run
else if (nN==CHAMPION_ACTION_ESCAPE1) Champion_Escape1(oChampion);
else if (nN==CHAMPION_ACTION_ESCAPE2)
{ // jump home
sS=GetLocalString(oChampion,"sTeamID");
sS=GetStringUpperCase(sS);
AssignCommand(oChampion,ClearAllActions(TRUE));
AssignCommand(oChampion,JumpToObject(GetWaypointByTag(sS+"_START")));
Champion_LevelUp(oChampion);
DeleteLocalInt(oChampion,"nState");
DeleteLocalInt(oChampion,"nPathPosition_EXP");
DeleteLocalInt(oChampion,"nPathPosition_CON");
DeleteLocalInt(oChampion,"nPathPosition_ASS");
DeleteLocalInt(oChampion,"nPathPosition_ESC");
} // jump home
} // process action
else
{ // none
nN=GetLocalInt(oChampion,"nMode");
oOb=Champion_GetNextPath(oChampion,nN);
if (GetIsObjectValid(oOb))
{ // path to next
SetLocalObject(oChampion,"oPathDest",oOb);
SetLocalInt(oChampion,"nState",1);
} // path to next
else
{ // reset
DeleteLocalInt(oChampion,"nState");
DeleteLocalInt(oChampion,"nPathPosition_EXP");
DeleteLocalInt(oChampion,"nPathPosition_CON");
DeleteLocalInt(oChampion,"nPathPosition_ASS");
DeleteLocalInt(oChampion,"nPathPosition_ESC");
DeleteLocalInt(oChampion,"nMode");
DeleteLocalInt(oChampion,"nActionInProgress");
} // reset
} // none
} // no delay to this action
else
{ // decrement
fnDMSpeak(oChampion,"Still doing an action.");
nN=GetLocalInt(oChampion,"nActionInProgress");
nN=nN-1;
SetLocalInt(oChampion,"nActionInProgress",nN);
if (nN==0)
{ // complete
nN=GetLocalInt(oChampion,"nMode");
if (nN>0)
{ // look for next destination
oOb=Champion_GetNextPath(oChampion,nN);
if (GetIsObjectValid(oOb))
{ // found
SetLocalObject(oChampion,"oPathDest",oOb);
SetLocalInt(oChampion,"nState",1);
} // found
else
{ // choose action
DeleteLocalInt(oChampion,"nState");
DeleteLocalInt(oChampion,"nPathPosition_EXP");
DeleteLocalInt(oChampion,"nPathPosition_CON");
DeleteLocalInt(oChampion,"nPathPosition_ASS");
DeleteLocalInt(oChampion,"nPathPosition_ESC");
DeleteLocalInt(oChampion,"nMode");
DeleteLocalInt(oChampion,"nActionInProgress");
} // choose action
} // look for next destination
else
{ // choose action
DeleteLocalInt(oChampion,"nState");
DeleteLocalInt(oChampion,"nPathPosition_EXP");
DeleteLocalInt(oChampion,"nPathPosition_CON");
DeleteLocalInt(oChampion,"nPathPosition_ASS");
DeleteLocalInt(oChampion,"nPathPosition_ESC");
DeleteLocalInt(oChampion,"nMode");
DeleteLocalInt(oChampion,"nActionInProgress");
} // choose action
} // complete
else { SetLocalInt(oChampion,"nActionInProgress",nN); }
} // decrement
} // process destination action
else if (nState==3)
{ // approach object
} // approach object
else if (nState==4)
{ // interact with object
} // interact with object
else if (nState==5)
{ // return to lair
fnDMSpeak(oChampion,"Returning to lair.",TRUE);
oDest=GetWaypointByTag(sTeamID+"_CHAMP_SPAWN");
oDest=fnReversePath(GetArea(oChampion),oDest,sTeamID);
if (GetIsObjectValid(oDest)&&GetTag(oDest)!=GetTag(GetWaypointByTag(sTeamID+"_CHAMP_SPAWN")))
{ // path
nN=MoveToObject(oChampion,oDest,TRUE);
if (nN==1||nN==-1)
{ // arrived
SetLocalObject(oChampion,"oPathDest",oDest);
SetLocalInt(oChampion,"nState",2);
DeleteLocalInt(oChampion,"nPathPosition_EXP");
DeleteLocalInt(oChampion,"nPathPosition_CON");
DeleteLocalInt(oChampion,"nPathPosition_ASS");
DeleteLocalInt(oChampion,"nPathPosition_ESC");
} // arrived
} // path
else
{ // set to nState
DeleteLocalInt(oChampion,"nState");
DeleteLocalInt(oChampion,"nPathPosition_EXP");
DeleteLocalInt(oChampion,"nPathPosition_CON");
DeleteLocalInt(oChampion,"nPathPosition_ASS");
DeleteLocalInt(oChampion,"nPathPosition_ESC");
} // set to nState
} // return to lair
else if (nState==6)
{ // return to throne
oDest=GetWaypointByTag(sTeamID+"_START");
fnDMSpeak(oChampion,"Going near throne.",TRUE);
if (GetIsObjectValid(oDest)&&GetDistanceBetween(oDest,oChampion)>4.0)
{ // move
nN=MoveToObject(oChampion,oDest,FALSE,4.0);
if (nN==-1)
{ // rethink
DeleteLocalInt(oChampion,"nState");
DeleteLocalInt(oChampion,"nPathPosition_EXP");
DeleteLocalInt(oChampion,"nPathPosition_CON");
DeleteLocalInt(oChampion,"nPathPosition_ASS");
DeleteLocalInt(oChampion,"nPathPosition_ESC");
} // rethink
} // move
else if (GetIsObjectValid(oDest)&&GetDistanceBetween(oDest,oChampion)<4.1)
{ // arrived
oItem=GetItemPossessedBy(oChampion,"rts_powerres");
if (GetIsObjectValid(oItem))
{ // place power reservoir
object oCopy=CreateObject(OBJECT_TYPE_PLACEABLE,"RTS_POWER_RES",GetLocation(oChampion));
DelayCommand(1.0,DestroyObject(oItem));
} // place power reservoir
if (privateHas_ManaCrystal(oChampion)) SetLocalInt(oChampion,"nState",7);
else
{ // home
DeleteLocalInt(oChampion,"nState");
DeleteLocalInt(oChampion,"nPathPosition_EXP");
DeleteLocalInt(oChampion,"nPathPosition_CON");
DeleteLocalInt(oChampion,"nPathPosition_ASS");
DeleteLocalInt(oChampion,"nPathPosition_ESC");
} // home
} // arrived
} // return to throne
else if (nState==7)
{ // return to mana vault
oDest=GetWaypointByTag(sTeamID+"_VAULT");
fnDMSpeak(oChampion,"Going near mana vault.",TRUE);
nN=MoveToObject(oChampion,oDest,TRUE,2.0);
if (nN==-1||nN==1)
{ // home
DeleteLocalInt(oChampion,"nState");
DeleteLocalInt(oChampion,"nPathPosition_EXP");
DeleteLocalInt(oChampion,"nPathPosition_CON");
DeleteLocalInt(oChampion,"nPathPosition_ASS");
DeleteLocalInt(oChampion,"nPathPosition_ESC");
} // home
} // return to mana vault
} // process AI
else if (GetIsInCombat(oChampion)&&bPassive)
{ // run away
AssignCommand(oChampion,ClearAllActions(TRUE));
AssignCommand(oChampion,ActionMoveAwayFromObject(oEnemy,TRUE));
} // run away
else if (!GetIsInCombat(oChampion)&&!GetIsDMPossessed(oChampion)&&GetIsObjectValid(oEnemy))
{ // engage in combat
AssignCommand(oChampion,ClearAllActions());
AssignCommand(oChampion,DetermineCombatRound(oEnemy));
} // engage in combat
SetLocalInt(oChampion,"bSentinel",TRUE);
DelayCommand(3.0,Champion_AICore(oChampion));
} // Champion_AICore()
void Champion_ChooseAction(object oChampion)
{ // PURPOSE: Choose Action to take
string sTeamID=GetLocalString(oChampion,"sTeamID");
object oOb=GetWaypointByTag(sTeamID+"_VAULT");
if (GetArea(oOb)==GetArea(oChampion))
{ // in lair
if (GetCurrentHitPoints(oChampion)<GetMaxHitPoints(oChampion))
{ // return to throne for rest
SetLocalInt(oChampion,"nState",6);
DeleteLocalObject(oChampion,"oPathDest");
DeleteLocalInt(oChampion,"bRun");
DeleteLocalInt(oChampion,"bPassive");
} // return to throne for rest
else
{ // pick a random plan
int nR=d100();
int nMode;
if (nR<51) nMode=CHAMPION_PATH_EXPLORE;
else if (nR<76) nMode=CHAMPION_PATH_ASSAULT;
else { nR=CHAMPION_PATH_CONTROL; }
SetLocalInt(oChampion,"nMode",nMode);
oOb=Champion_GetNextPath(oChampion,nMode);
if (GetIsObjectValid(oOb))
{ // path
if(d4()<3) SetLocalInt(oChampion,"bRun",TRUE);
else { DeleteLocalInt(oChampion,"bRun"); }
SetLocalObject(oChampion,"oPathDest",oOb);
SetLocalInt(oChampion,"nState",1);
} // path
else
{ // cannot find
DeleteLocalInt(oChampion,"nPathPosition_EXP");
DeleteLocalInt(oChampion,"nPathPosition_CON");
DeleteLocalInt(oChampion,"nPathPosition_ASS");
DeleteLocalInt(oChampion,"nPathPosition_ESC");
} // cannot find
} // pick a random plan
} // in lair
else
{ // outside
SetLocalInt(oChampion,"nState",5);
DeleteLocalObject(oChampion,"oPathDest");
DeleteLocalInt(oChampion,"bPassive");
SetLocalInt(oChampion,"bRun",TRUE);
} // outside
} // Champion_ChooseAction()
object Champion_GetNextPath(object oChampion,int nType)
{ // PURPOSE: To return the next waypoint for oChampion of the specified type
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/16/2006 | Deva B. Winblood | Initial version of this function
string sPathType="SPAWN";
string sTeamID=GetLocalString(oChampion,"sTeamID");
string sPath;
object oWP;
int nInc;
int nCount;
Champion_Debug(oChampion,"Champion_GetNextPath("+IntToString(nType)+")");
sTeamID=GetStringUpperCase(sTeamID);
if (nType==CHAMPION_PATH_EXPLORE) sPathType="EXP";
else if (nType==CHAMPION_PATH_ASSAULT) sPathType="ASS";
else if (nType==CHAMPION_PATH_CONTROL) sPathType="CON";
else if (nType==CHAMPION_PATH_ESCAPE) sPathType="ESC";
else
{ // spawn point
sPath=sTeamID+"_CHAMP_SPAWN";
oWP=GetWaypointByTag(sPath);
Champion_Debug(oChampion," ["+GetTag(oWP)+"]");
return oWP;
} // spawn point
nInc=GetLocalInt(oChampion,"nPathPosition_"+sPathType);
nInc++;
SetLocalInt(oChampion,"nPathPosition_"+sPathType,nInc);
nCount=0;
sPath=sTeamID+"_CHAMP_"+sPathType+"_"+IntToString(nInc);
Champion_Debug(oChampion," "+IntToString(nCount)+": "+sPath);
if (sPathType=="ESC") sPath="CHAMPION_ESCAPE_"+IntToString(nInc);
oWP=GetWaypointByTag(sPath);
while(!GetIsObjectValid(oWP)&&nCount<6)
{ // find a waypoint
nInc++;
nCount++;
SetLocalInt(oChampion,"nPathPosition_"+sPathType,nInc);
sPath=sTeamID+"_CHAMP_"+sPathType+"_"+IntToString(nInc);
Champion_Debug(oChampion," "+IntToString(nCount)+": "+sPath);
if (sPathType=="ESC") sPath="CHAMPION_ESCAPE_"+IntToString(nInc);
oWP=GetWaypointByTag(sPath);
} // find a waypoint
if (!GetIsObjectValid(oWP))
{ // path fail
fnDMSpeak(oChampion,"Failed to find path "+sPathType+".",TRUE);
sPath=sTeamID+"_CHAMP_SPAWN";
oWP=GetWaypointByTag(sPath);
Champion_Debug(oChampion," ["+GetTag(oWP)+"]");
} // path fail
Champion_Debug(oChampion," ["+GetTag(oWP)+"] Area:["+GetName(GetArea(oWP))+"]");
fnDMSpeak(oChampion,"My next path is "+GetTag(oWP)+".",TRUE);
return oWP;
} // Champion_GetNextPath()
int Champion_GetActionType(string sName)
{ // PURPOSE: Return the action type
string sS=GetStringUpperCase(sName);
if (sS=="REST") return CHAMPION_ACTION_REST;
else if (sS=="BUFF") return CHAMPION_ACTION_BUFF;
else if (sS=="CONTROL") return CHAMPION_ACTION_CONTROL;
else if (sS=="DEPOSIT") return CHAMPION_ACTION_DEPOSIT;
else if (sS=="EQUIP") return CHAMPION_ACTION_EQUIP;
else if (sS=="ESCAPE1") return CHAMPION_ACTION_ESCAPE1;
else if (sS=="ESCAPE2") return CHAMPION_ACTION_ESCAPE2;
else if (sS=="GATHER") return CHAMPION_ACTION_GATHER;
else if (sS=="HEAL") return CHAMPION_ACTION_HEAL;
else if (sS=="CONDREST") return CHAMPION_ACTION_CONDITIONAL_REST;
else if (sS=="RETURN") return CHAMPION_ACTION_RETURN;
else if (sS=="RUN") return CHAMPION_ACTION_RUN;
else if (sS=="SEARCH") return CHAMPION_ACTION_SEARCH;
else if (sS=="STEAL") return CHAMPION_ACTION_STEAL;
else if (sS=="USE") return CHAMPION_ACTION_USE;
return CHAMPION_ACTION_NONE;
} // Champion_GetActionType()
void Champion_Steal(object oChampion)
{ // PURPOSE: To steal mana, and items from an opponents chest
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
int bHasMana=FALSE;
object oContainer;
object oItem;
object oCopy;
int nN;
string sS;
effect eVFX=EffectBeam(VFX_BEAM_SILENT_ODD,oChampion,BODY_NODE_HAND);
if (GetIsObjectValid(GetItemPossessedBy(oChampion,"MANA_CRYSTAL_5"))) bHasMana=TRUE;
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"MANA_CRYSTAL_2"))) bHasMana=TRUE;
else if (GetIsObjectValid(GetItemPossessedBy(oChampion,"MANA_CRYSTAL_1"))) bHasMana=TRUE;
SetLocalInt(oChampion,"nActionInProgress",2);
fnDMSpeak(oChampion,"I am going to steal something.",TRUE);
if (!bHasMana)
{ // see if mana is near to steal
oItem=GetNearestObjectByTag("MANA_CRYSTAL_5",oChampion);
if (GetIsObjectValid(oItem)&&GetDistanceBetween(oChampion,oItem)<8.0)
{ // large mana crystal
oCopy=CopyObject(oItem,GetLocation(oChampion),oChampion);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oItem,1.8);
DelayCommand(2.0,DestroyObject(oItem));
} // large mana crystal
else
{ // keep looking
oItem=GetNearestObjectByTag("MANA_CRYSTAL_2",oChampion);
if (GetIsObjectValid(oItem)&&GetDistanceBetween(oChampion,oItem)<8.0)
{ // mana crystal
oCopy=CopyObject(oItem,GetLocation(oChampion),oChampion);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oItem,1.8);
DelayCommand(2.0,DestroyObject(oItem));
} // mana crystal
else
{ // keep looking
oItem=GetNearestObjectByTag("MANA_CRYSTAL_1",oChampion);
if (GetIsObjectValid(oItem)&&GetDistanceBetween(oChampion,oItem)<8.0)
{ // mana crystal
oCopy=CopyObject(oItem,GetLocation(oChampion),oChampion);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oItem,1.8);
DelayCommand(2.0,DestroyObject(oItem));
} // mana crystal
} // keep looking
} // keep looking
} // see if mana is near to steal
sS=GetLocalString(GetArea(oChampion),"sTeamID");
sS=GetStringUpperCase(sS);
oContainer=GetNearestObjectByTag(sS+"_CHEST",oChampion);
if (GetIsObjectValid(oContainer)&&GetDistanceBetween(oChampion,oContainer)<8.0)
{ // steal from container
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oContainer,2.0);
oItem=GetFirstItemInInventory(oContainer);
while(GetIsObjectValid(oItem))
{ // check inventory
if (GetPlotFlag(oItem))
{ // plot item
oCopy=CopyObject(oItem,GetLocation(oChampion),oChampion);
DelayCommand(1.0,DestroyObject(oItem));
} // plot item
else if (GetBaseItemType(oItem)==BASE_ITEM_POTIONS)
{ // potions
nN=GetItemStackSize(oItem);
oCopy=CopyObject(oItem,GetLocation(oChampion),oChampion);
DelayCommand(1.0,DestroyObject(oItem));
SetItemStackSize(oCopy,nN);
} // potions
else if (GetBaseItemType(oItem)==BASE_ITEM_RING)
{ // ring
oCopy=CopyObject(oItem,GetLocation(oChampion),oChampion);
DelayCommand(1.0,DestroyObject(oItem));
} // ring
else if (GetBaseItemType(oItem)==BASE_ITEM_GEM)
{ // gem
nN=GetItemStackSize(oItem);
oCopy=CopyObject(oItem,GetLocation(oChampion),oChampion);
DelayCommand(1.0,DestroyObject(oItem));
SetItemStackSize(oCopy,nN);
} // gem
else if (GetBaseItemType(oItem)==BASE_ITEM_GOLD)
{ // gold
nN=GetItemStackSize(oItem);
DelayCommand(1.0,DestroyObject(oItem));
GiveGoldToCreature(oChampion,nN);
} // gold
oItem=GetNextItemInInventory(oContainer);
} // check inventory
} // steal from container
} // Champion_Steal()
void Champion_Control(object oChampion)
{ // PURPOSE: To release any followers and set them to guard where they stand
// and walk
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
int nN;
object oFollower;
object oGArea=GetArea(oChampion);
vector vV=GetPosition(oChampion);
Champion_Debug(oChampion,"Champion_Control()");
fnDMSpeak(oChampion,"I release my followers to control this area.",TRUE);
nN=1;
oFollower=Champion_GetFollower(oChampion,nN);
while(GetIsObjectValid(oFollower))
{ // set followers to guard where they stand and walk
DelayCommand(0.4,AssignCommand(oFollower,ClearAllActions(TRUE)));
DelayCommand(0.5,SetLocalFloat(oFollower,"fGX",vV.x));
DelayCommand(0.5,SetLocalFloat(oFollower,"fGY",vV.y));
DelayCommand(0.5,SetLocalFloat(oFollower,"fGZ",vV.z));
DelayCommand(0.5,SetLocalObject(oFollower,"oGArea",oGArea));
DelayCommand(0.5,SetLocalInt(oFollower,"nMState",2));
DelayCommand(0.5,SetLocalInt(oFollower,"nSState",0));
DelayCommand(0.5,SetLocalInt(oFollower,"nParm",0));
DelayCommand(0.5,SetLocalObject(oFollower,"oDestWP",OBJECT_INVALID));
DelayCommand(0.5,DeleteLocalInt(oFollower,"nRun"));
DelayCommand(0.5,DeleteLocalInt(oFollower,"nGNBRun"));
SetAILevel(oFollower,AI_LEVEL_DEFAULT);
if(GetMaster(oFollower)==oChampion) RemoveHenchman(oChampion,oFollower);
nN++;
oFollower=Champion_GetFollower(oChampion,nN);
} // set followers to guard where they stand and walk
} // Champion_Control()
object Champion_GetFollower(object oChampion,int nN=1)
{ // PURPOSE: To return friendly units set to follow mode for this champion
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
object oRet=OBJECT_INVALID;
object oCur;
int nN=1;
int nCount=0;
Champion_Debug(oChampion," Champion_GetFollower()");
oCur=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oChampion,nN,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_FRIEND);
while(GetIsObjectValid(oCur)&&!GetIsObjectValid(oRet)&&GetDistanceBetween(oCur,oChampion)<20.0)
{ // check nearby allies
if (GetLocalString(oCur,"sTeamID")==GetLocalString(oChampion,"sTeamID"))
{ // same team
if (GetLocalInt(oCur,"nMState")==2&&GetLocalObject(oCur,"oDest")==oChampion)
{ // this is a follower
nCount++;
if (nCount==nN) oRet=oCur;
nN++;
oCur=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oChampion,nN,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_FRIEND);
} // this is a follower
else
{ // not a follower
nN++;
oCur=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oChampion,nN,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_FRIEND);
} // not a follower
} // same team
else
{ // not same
nN++;
oCur=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oChampion,nN,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_FRIEND);
} // not same
} // check nearby allies
return oRet;
} // Champion_GetFollower()
void Champion_Gather(object oChampion)
{ // PURPOSE: To Gather up units to follow the champion
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
object oLeader;
string sID=GetStringUpperCase(GetLocalString(oChampion,"sTeamID"));
int nN;
int nR;
string sRes;
object oFollower;
object oItem;
int nLevel=0;
int nCount=0;
Champion_Debug(oChampion,"Champion_Gather()");
fnDMSpeak(oChampion,"Come with me!",TRUE);
oLeader=GetLocalObject(GetModule(),"oTeamLead"+sID);
SetLocalInt(oChampion,"nActionInProgress",2);
if (GetIsObjectValid(oLeader)) nLevel=GetLevelByPosition(1,oLeader)+GetLevelByPosition(2,oLeader)+GetLevelByPosition(3,oLeader);
nN=1;
oFollower=GetAssociate(ASSOCIATE_TYPE_HENCHMAN,oChampion,nN);
while(GetIsObjectValid(oFollower)||nCount>4)
{ // count
nCount++;
oFollower=GetAssociate(ASSOCIATE_TYPE_HENCHMAN,oChampion,nN);
} // count
if (nCount>4) return; // no need to gather
if (sID=="UND")
{ // undead
oItem=GetItemPossessedBy(oChampion,"rts_it_mag33");
if (GetIsObjectValid(oItem))
{ // has grave digger
if (nLevel<6)
{ // level 0-5
privateCreate_Follower(oChampion,"und24"); // skeleton archer
//Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"und24"); // skeleton archer
privateCreate_Follower(oChampion,"und24"); // skeleton archer
//Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"und24"); // skeleton archer
privateCreate_Follower(oChampion,"und30"); // flaming skeleton
} // level 0-5
else if (nLevel<9)
{ // level 6-8
privateCreate_Follower(oChampion,"und24"); // skeleton archer
//Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"und24"); // skeleton archer
privateCreate_Follower(oChampion,"und30"); // flaming skeleton
//Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"und31"); // frost skeleton
privateCreate_Follower(oChampion,"und29"); // acidic skeleton
} // level 6-8
else if (nLevel<11)
{ // level 9-10
privateCreate_Follower(oChampion,"und30"); // flaming skeleton
//Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"und31"); // frost skeleton
privateCreate_Follower(oChampion,"und29"); // acidic skeleton
//Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"und11"); // wights
privateCreate_Follower(oChampion,"und11"); // wights
} // level 9-10
else if (nLevel<14)
{ // level 11-13
privateCreate_Follower(oChampion,"und7"); // wraiths
//Champion_SetSentinel(oChampion);
} // level 11-13
else if (nLevel<17)
{ // level 14-16
privateCreate_Follower(oChampion,"und8"); // spectres
//Champion_SetSentinel(oChampion);
} // level 14-16
else if (nLevel<19)
{ // level 17-18
privateCreate_Follower(oChampion,"und17"); // skeleton warrior
privateCreate_Follower(oChampion,"und17"); // skeleton warrior
//Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"und19"); // skeletal devourer
privateCreate_Follower(oChampion,"und34"); // skeleton mage
// Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"und34"); // skeleton mage
} // level 17-18
else
{ // level 19+
privateCreate_Follower(oChampion,"und25"); // Necromancer
privateCreate_Follower(oChampion,"und22"); // Mohrg
// Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"und22"); // Mohrg
privateCreate_Follower(oChampion,"und22"); // Mohrg
// Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"und19"); // skeletal devourer
} // level 19+
} // has grave digger
else
{ // no grave digger
if (nLevel<6)
{ // level 0-5
privateCreate_Follower(oChampion,"und24"); // skeleton archer
privateCreate_Follower(oChampion,"und1"); // skeleton
// Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"und1"); // skeleton
privateCreate_Follower(oChampion,"und1"); // skeleton
// Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"und1"); // skeleton
} // level 0-5
else if (nLevel<9)
{ // level 6-8
privateCreate_Follower(oChampion,"und24"); // skeleton archer
privateCreate_Follower(oChampion,"und24"); // skeleton archer
//Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"und3"); // ghoul
// Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"und3"); // ghoul
privateCreate_Follower(oChampion,"und3"); // ghoul
} // level 6-8
else if (nLevel<11)
{ // level 9-10
privateCreate_Follower(oChampion,"und24"); // skeleton archer
privateCreate_Follower(oChampion,"und24"); // skeleton archer
privateCreate_Follower(oChampion,"und11"); // wights
privateCreate_Follower(oChampion,"und11"); // wights
privateCreate_Follower(oChampion,"und11"); // wights
} // level 9-10
else if (nLevel<14)
{ // level 11-13
privateCreate_Follower(oChampion,"und7"); // wraiths
} // level 11-13
else if (nLevel<17)
{ // level 14-16
privateCreate_Follower(oChampion,"und8"); // spectres
} // level 14-16
else if (nLevel<19)
{ // level 17-18
privateCreate_Follower(oChampion,"und17"); // skeleton warrior
privateCreate_Follower(oChampion,"und17"); // skeleton warrior
privateCreate_Follower(oChampion,"und19"); // skeletal devourer
privateCreate_Follower(oChampion,"und34"); // skeleton mage
privateCreate_Follower(oChampion,"und34"); // skeleton mage
} // level 17-18
else
{ // level 19+
privateCreate_Follower(oChampion,"und25"); // Necromancer
privateCreate_Follower(oChampion,"und22"); // Mohrg
privateCreate_Follower(oChampion,"und22"); // Mohrg
privateCreate_Follower(oChampion,"und22"); // Mohrg
privateCreate_Follower(oChampion,"und19"); // skeletal devourer
} // level 19+
} // no grave digger
} // undead
else if (sID=="SPID")
{ // spiders
oItem=GetItemPossessedBy(oChampion,"rts_it_mag34");
if (GetIsObjectValid(oItem))
{ // has plague of spiders
if (nLevel<7)
{ // level 0-6
privateCreate_Follower(oChampion,"spid3ai"); // Small Spider
privateCreate_Follower(oChampion,"spid3ai"); // Small Spider
//Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"spid3ai"); // Small Spider
privateCreate_Follower(oChampion,"spid3ai"); // Small Spider
// Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"spid3ai"); // Small Spider
} // level 0-6
else if (nLevel<10)
{ // level 7-9
privateCreate_Follower(oChampion,"spid19"); // Huge Sword Spider
privateCreate_Follower(oChampion,"spid19"); // Huge Sword Spider
// Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"spid19"); // Huge Sword Spider
privateCreate_Follower(oChampion,"spid19"); // Huge Sword Spider
privateCreate_Follower(oChampion,"spid31"); // Huge Blackwidow Spider
} // level 7-9
else if (nLevel<16)
{ // level 10-15
privateCreate_Follower(oChampion,"spid19"); // Huge Sword Spider
privateCreate_Follower(oChampion,"spid15"); // Huge Phase Spider
privateCreate_Follower(oChampion,"spid23"); // Huge Wraith Spider
privateCreate_Follower(oChampion,"spid31"); // Huge Blackwidow Spider
privateCreate_Follower(oChampion,"spid30"); // Huge Bloodback Spider
} // level 10-15
else if (nLevel<19)
{ // level 16-18
privateCreate_Follower(oChampion,"spid27"); // Drider Warrior
privateCreate_Follower(oChampion,"spid27"); // Drider Warrior
privateCreate_Follower(oChampion,"spid27"); // Drider Warrior
} // level 16-18
else
{ // level 19+
privateCreate_Follower(oChampion,"spid27"); // Drider Warrior
privateCreate_Follower(oChampion,"spidai12");// Gargantuan Dire Spider
} // level 19+
} // has plague of spiders
else
{ // does not have plague of spiders
if (nLevel<7)
{ // level 0-6
privateCreate_Follower(oChampion,"spid3ai"); // Small Spider
// Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"spid3ai"); // Small Spider
privateCreate_Follower(oChampion,"spid3ai"); // Small Spider
} // level 0-6
else if (nLevel<10)
{ // level 7-9
privateCreate_Follower(oChampion,"spid6"); // Huge Spider
// Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"spid6"); // Huge Spider
privateCreate_Follower(oChampion,"spid6"); // Huge Spider
privateCreate_Follower(oChampion,"spid6"); // Huge Spider
} // level 7-9
else if (nLevel<16)
{ // level 10-15
privateCreate_Follower(oChampion,"spid19"); // Huge Sword Spider
// Champion_SetSentinel(oChampion);
privateCreate_Follower(oChampion,"spid19"); // Huge Sword Spider
privateCreate_Follower(oChampion,"spid15"); // Huge Phase Spider
privateCreate_Follower(oChampion,"spid23"); // Huge Wraith Spider
} // level 10-15
else if (nLevel<19)
{ // level 16-18
privateCreate_Follower(oChampion,"spid27"); // Drider Warrior
privateCreate_Follower(oChampion,"spid27"); // Drider Warrior
} // level 16-18
else
{ // level 19+
privateCreate_Follower(oChampion,"spidai12");// Gargantuan Dire Spider
} // level 19+
} // does not have plague of spiders
} // spiders
else if (sID=="UNC")
{ // unclean
if (nLevel<6)
{ // level 0-5
privateCreate_Follower(oChampion,"unc1"); // goblin
privateCreate_Follower(oChampion,"unc1"); // goblin
privateCreate_Follower(oChampion,"unc1"); // goblin
privateCreate_Follower(oChampion,"unc1"); // goblin
privateCreate_Follower(oChampion,"unc1"); // goblin
privateCreate_Follower(oChampion,"unc1"); // goblin
} // level 0-5
else if (nLevel<9)
{ // level 6-8
privateCreate_Follower(oChampion,"unc1"); // goblin
privateCreate_Follower(oChampion,"unc1"); // goblin
privateCreate_Follower(oChampion,"unc1"); // goblin
privateCreate_Follower(oChampion,"unc4"); // goblin elite
privateCreate_Follower(oChampion,"unc2"); // bugbear
privateCreate_Follower(oChampion,"unc2"); // bugbear
} // level 6-8
else if (nLevel<13)
{ // level 9-12
privateCreate_Follower(oChampion,"unc4"); // goblin elite
privateCreate_Follower(oChampion,"unc4"); // goblin elite
privateCreate_Follower(oChampion,"unc4"); // goblin elite
privateCreate_Follower(oChampion,"unc5"); // ogre
privateCreate_Follower(oChampion,"unc5"); // ogre
privateCreate_Follower(oChampion,"unc5"); // ogre
} // level 9-12
else if (nLevel<16)
{ // level 13-15
privateCreate_Follower(oChampion,"unc5"); // ogre
privateCreate_Follower(oChampion,"unc5"); // ogre
privateCreate_Follower(oChampion,"unc5"); // ogre
privateCreate_Follower(oChampion,"unc5"); // ogre
privateCreate_Follower(oChampion,"unc5"); // ogre
privateCreate_Follower(oChampion,"unc11"); // hill giant
} // level 13-15
else if (nLevel<19)
{ // level 16-18
privateCreate_Follower(oChampion,"unc11"); // hill giant
privateCreate_Follower(oChampion,"unc11"); // hill giant
privateCreate_Follower(oChampion,"unc10"); // ettin
privateCreate_Follower(oChampion,"unc7"); // Ogre Berserkers
privateCreate_Follower(oChampion,"unc7"); // Ogre Berserkers
privateCreate_Follower(oChampion,"unc7"); // Ogre Berserkers
} // level 16-18
else
{ // level 19+
privateCreate_Follower(oChampion,"unc9"); // Ogre High Mage
privateCreate_Follower(oChampion,"unc14"); // Troll Berserkers
privateCreate_Follower(oChampion,"unc14"); // Troll Berserkers
privateCreate_Follower(oChampion,"unc14"); // Troll Berserkers
privateCreate_Follower(oChampion,"unc14"); // Troll Berserkers
privateCreate_Follower(oChampion,"unc14"); // Troll Berserkers
} // level 19+
} // unclean
else if (sID=="DWF")
{ // dwarves
oItem=GetObjectByTag("rts_pl_mag35",0);
if (GetIsObjectValid(oItem)&&GetObjectType(oItem)!=OBJECT_TYPE_PLACEABLE) oItem=GetObjectByTag("rts_pl_mag35",1);
if (GetIsObjectValid(oItem)&&GetLocalString(GetArea(oItem),"sTeamID")=="DWF")
{ // Mithril forge is in play
if (nLevel<7)
{ // level 0-6
privateCreate_Follower(oChampion,"dwf1"); // Fighter 1st
privateCreate_Follower(oChampion,"dwf1"); // Fighter 1st
privateCreate_Follower(oChampion,"dwf12"); // Skirmisher 1st
privateCreate_Follower(oChampion,"dwf12"); // Skirmisher 1st
privateCreate_Follower(oChampion,"dwf17"); // Cleric 1st
} // level 0-6
else if (nLevel<11)
{ // level 7-10
privateCreate_Follower(oChampion,"dwf4"); // Fighter 4th
privateCreate_Follower(oChampion,"dwf4"); // Fighter 4th
privateCreate_Follower(oChampion,"dwf13"); // Skirmisher 3rd
privateCreate_Follower(oChampion,"dwf13"); // Skirmisher 3rd
privateCreate_Follower(oChampion,"dwf18"); // Cleric 5th
} // level 7-10
else if (nLevel<16)
{ // level 11-15
privateCreate_Follower(oChampion,"dwf7"); // Fighter 7th
privateCreate_Follower(oChampion,"dwf7"); // Fighter 7th
privateCreate_Follower(oChampion,"dwf14"); // Skirmisher 6th
privateCreate_Follower(oChampion,"dwf14"); // Skirmisher 6th
privateCreate_Follower(oChampion,"dwf19"); // Cleric 10th
} // level 11-15
else if (nLevel<19)
{ // level 16-18
privateCreate_Follower(oChampion,"dwf9"); // Fighter 9th
privateCreate_Follower(oChampion,"dwf20"); // Cleric hero
privateCreate_Follower(oChampion,"dwf23"); // night scout
privateCreate_Follower(oChampion,"dwf24"); // stone golem
} // level 16-18
else
{ // level 19+
privateCreate_Follower(oChampion,"dwf20"); // Cleric hero
privateCreate_Follower(oChampion,"dwf11"); // fighter hero
privateCreate_Follower(oChampion,"dwf16"); // skirmisher hero
privateCreate_Follower(oChampion,"dwf25"); // Iron Golem
} // level 19+
} // Mithril forge is in play
else
{ // no mithril forge
if (nLevel<7)
{ // level 0-6
privateCreate_Follower(oChampion,"dwf22"); // militia
privateCreate_Follower(oChampion,"dwf22"); // militia
privateCreate_Follower(oChampion,"dwf27"); // dog
privateCreate_Follower(oChampion,"dwf12"); // skirmisher 1st
} // level 0-6
else if (nLevel<11)
{ // level 7-10
privateCreate_Follower(oChampion,"dwf28"); // war dog
privateCreate_Follower(oChampion,"dwf4"); // fighter 4th
privateCreate_Follower(oChampion,"dwf13"); // skirmisher 3rd
privateCreate_Follower(oChampion,"dwf13"); // skirmisher 3rd
} // level 7-10
else if (nLevel<16)
{ // level 11-15
privateCreate_Follower(oChampion,"dwf18"); // cleric 5th
privateCreate_Follower(oChampion,"dwf7"); // fighter 7th
privateCreate_Follower(oChampion,"dwf7"); // fighter 7th
privateCreate_Follower(oChampion,"dwf14"); // skirmisher 6th
} // level 11-15
else if (nLevel<19)
{ // level 16-18
privateCreate_Follower(oChampion,"dwf19"); // cleric 10th
privateCreate_Follower(oChampion,"dwf23"); // night scout
privateCreate_Follower(oChampion,"dwf9"); // fighter 9th
} // level 16-18
else
{ // level 19+
privateCreate_Follower(oChampion,"dwf20"); // cleric hero
privateCreate_Follower(oChampion,"dwf11"); // fighter hero
privateCreate_Follower(oChampion,"dwf16"); // skirmisher hero
} // level 19+
} // no mithril forge
} // dwarves
} // Champion_Gather()
void Champion_CondRest(object oChampion)
{ // PURPOSE: Check nearby control point. If it is controlled by this team then
// Rest.
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
object oControl=OBJECT_INVALID;
string sID=GetStringUpperCase(GetLocalString(oChampion,"sTeamID"));
string sTag="CONTROL"+sID;
Champion_Debug(oChampion,"Champion_CondRest()");
fnDMSpeak(oChampion,"I must rest.",TRUE);
oControl=GetNearestObjectByTag(sTag,oChampion,1);
if (GetIsObjectValid(oControl))
{ // control point is near
SetLocalInt(oChampion,"bRestAction",TRUE);
DelayCommand(40.0,DeleteLocalInt(oChampion,"bRestAction"));
SetLocalInt(oChampion,"bRested",TRUE);
DelayCommand(60.0,DeleteLocalInt(oChampion,"bRested"));
AssignCommand(oChampion,ClearAllActions());
AssignCommand(oChampion,PRCForceRest(oChampion));
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS,1.0,25.0));
SetLocalInt(oChampion,"nActionInProgress",21);
} // control point is near
} // Champion_CondRest()
void Champion_Rest(object oChampion)
{ // PURPOSE: To make the champion rest
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
Champion_Debug(oChampion,"Champion_Rest()");
fnDMSpeak(oChampion,"I am resting.");
SetLocalInt(oChampion,"bRestAction",TRUE);
DelayCommand(24.0,DeleteLocalInt(oChampion,"bRestAction"));
SetLocalInt(oChampion,"bRested",TRUE);
DelayCommand(30.0,DeleteLocalInt(oChampion,"bRested"));
AssignCommand(oChampion,ClearAllActions());
AssignCommand(oChampion,PRCForceRest(oChampion));
AssignCommand(oChampion,ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS,1.0,24.0));
SetLocalInt(oChampion,"nActionInProgress",11);
} // Champion_Rest()
object Champion_Buff(object oChampion)
{ // PURPOSE: To buff up yourself and then to buff up nearby friends if possible
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
int nBuffCount=GetLocalInt(oChampion,"nProcessBuffCount");
object oOb=OBJECT_INVALID;
Champion_Debug(oChampion,"Champion_Buff()");
fnDMSpeak(oChampion,"I may want to buff something.",TRUE);
SetLocalInt(oChampion,"nActionInProgress",2);
if (nBuffCount==0) oOb=oChampion;
else
{ // not champion
oOb=Champion_GetFollower(oChampion,nBuffCount);
} // not champion
if (GetIsObjectValid(oOb))
{ // champion
privateHandle_Buffing(oChampion,oOb);
if (GetLocalInt(oOb,"bDoneBuffing"))
{ // done buffing
nBuffCount++;
SetLocalInt(oChampion,"nProcessBuffCount",nBuffCount);
} // done buffing
} // champion
else { DeleteLocalInt(oChampion,"nProcessBuffCount"); }
return oOb;
} // Champion_Buff()
object Champion_Heal(object oChampion)
{ // PURPOSE: To heal the champion and if possible heal companions as well
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
int nHealCount=GetLocalInt(oChampion,"nHealCount");
object oOb=OBJECT_INVALID;
Champion_Debug(oChampion,"Champion_Heal()");
SetLocalInt(oChampion,"nActionInProgress",2);
fnDMSpeak(oChampion,"I may want to heal something.",TRUE);
if (nHealCount==0) oOb=oChampion;
else
{ // not champion
oOb=Champion_GetFollower(oChampion,nHealCount);
} // not champion
if (GetIsObjectValid(oOb))
{ // handle healing
privateHandle_Healing(oChampion,oOb);
if (GetLocalInt(oOb,"bDoneHealing"))
{ // done healing
nHealCount++;
SetLocalInt(oChampion,"nHealCount",nHealCount);
} // done healing
} // handle healing
else { DeleteLocalInt(oChampion,"nHealCount"); }
return oOb;
} // Champion_Heal()
void Champion_Equip(object oChampion)
{ // PURPOSE: To equip better armor, weapons, and artifacts
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
object oItem;
Champion_Debug(oChampion,"Champion_Equip()");
AssignCommand(oChampion,ActionEquipMostDamagingMelee());
AssignCommand(oChampion,ActionEquipMostEffectiveArmor());
oItem=GetItemPossessedBy(oChampion,"rts_it_mag1");
SetLocalInt(oChampion,"nActionInProgress",2);
fnDMSpeak(oChampion,"I must equip myself.",TRUE);
if (GetIsObjectValid(oItem))
{ // equip
AssignCommand(oChampion,ActionEquipItem(oItem,INVENTORY_SLOT_NECK));
} // equip
oItem=GetItemPossessedBy(oChampion,"rts_it_mag8");
if (GetIsObjectValid(oItem))
{ // equip
AssignCommand(oChampion,ActionEquipItem(oItem,INVENTORY_SLOT_BOOTS));
} // equip
oItem=GetItemPossessedBy(oChampion,"fb1_wintercloak");
if (GetIsObjectValid(oItem))
{ // equip
AssignCommand(oChampion,ActionEquipItem(oItem,INVENTORY_SLOT_CLOAK));
} // equip
} // Champion_Equip()
void Champion_Deposit(object oChampion)
{ // PURPOSE: To deposit items in your team chest
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
string sID=GetLocalString(oChampion,"sTeamID");
int nN;
object oItem;
object oCopy;
object oChest;
string sS;
Champion_Debug(oChampion,"Champion_Deposit()");
SetLocalInt(oChampion,"nActionInProgress",3);
fnDMSpeak(oChampion,"I need to deposit some things.",TRUE);
sID=GetStringUpperCase(sID);
oChest=GetNearestObjectByTag(sID+"_CHEST");
if (GetIsObjectValid(oChest))
{ // chest exists
oItem=GetFirstItemInInventory(oChampion);
while(GetIsObjectValid(oItem))
{ // look through inventory
sS=GetTag(oItem);
if (sS=="rts_it_mag24"&&GetLevelByClass(CLASS_TYPE_SORCERER,oChampion)<1)
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (sS=="rts_it_mag17"&&GetLevelByClass(CLASS_TYPE_FIGHTER,oChampion)<1)
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (sS=="rts_it_mag11"&&GetLevelByClass(CLASS_TYPE_BARBARIAN,oChampion)<1)
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (sS=="rts_it_mag23"&&GetLevelByClass(CLASS_TYPE_WIZARD,oChampion)<1)
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (sS=="rts_it_mag14"&&GetLevelByClass(CLASS_TYPE_CLERIC,oChampion)<1)
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (sS=="SoulToken")
{ // soul token
DelayCommand(1.0,DestroyObject(oItem));
} // soul token
else if (sS=="rts_it_mag13"&&MyPRCGetRacialType(oChampion)!=RACIAL_TYPE_HALFORC)
{ // bracers of the unclean
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // bracers of the unclean
else if (sS=="rts_it_mag3"&&!GetHasFeat(FEAT_WEAPON_PROFICIENCY_MARTIAL,oChampion))
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (sS=="rts_it_mag4"&&!GetHasFeat(FEAT_WEAPON_PROFICIENCY_MARTIAL,oChampion))
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (sS=="fb1_heavywinter"&&!GetHasFeat(FEAT_ARMOR_PROFICIENCY_HEAVY,oChampion))
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (sS=="rts_it_mag36"&&sID!="UNC")
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (sS=="rts_it_mag33"&&sID!="UND")
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (sS=="rts_it_mag34"&&sID!="SPID")
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (sS=="rts_it_mag35"&&sID!="DWF")
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (sS=="rts_it_mag25"&&(sID!="SPID"||sID=="UND"))
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (GetBaseItemType(oItem)==BASE_ITEM_ARMOR&&GetGoldPieceValue(oItem)<GetGoldPieceValue(GetItemInSlot(INVENTORY_SLOT_CHEST,oChampion)))
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (GetBaseItemType(oItem)==BASE_ITEM_CLOAK&&GetGoldPieceValue(oItem)<GetGoldPieceValue(GetItemInSlot(INVENTORY_SLOT_CLOAK,oChampion)))
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (GetBaseItemType(oItem)==BASE_ITEM_BOOTS&&GetGoldPieceValue(oItem)<GetGoldPieceValue(GetItemInSlot(INVENTORY_SLOT_BOOTS,oChampion)))
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
else if (GetBaseItemType(oItem)==BASE_ITEM_HELMET&&GetGoldPieceValue(oItem)<GetGoldPieceValue(GetItemInSlot(BASE_ITEM_HELMET,oChampion)))
{ // store
oCopy=CreateItemOnObject(GetResRef(oItem),oChest);
DelayCommand(1.0,DestroyObject(oItem));
} // store
oItem=GetNextItemInInventory(oChampion);
} // look through inventory
} // chest exists
} // Champion_Deposit()
void Champion_Use(object oChampion)
{ // PURPOSE: To get the champion to use some artifacts they may be carrying
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
object oOb;
string sID=GetLocalString(oChampion,"sTeamID");
object oItem;
string sS;
int nN;
object oArea=GetArea(oChampion);
string sTag=GetTag(oArea);
Champion_Debug(oChampion,"Champion_Use()");
sS=GetLocalString(oArea,"sTeamID");
sS=GetStringUpperCase(sS);
sID=GetStringUpperCase(sID);
SetLocalInt(oChampion,"nActionInProgress",2);
fnDMSpeak(oChampion,"I wonder if I have anything useful.",TRUE);
if (sS==sID)
{ // in your own lair
if (sID=="UNC"&&GetIsObjectValid(GetItemPossessedBy(oChampion,"rts_it_mag36")))
{ // sludge factory creator
oItem=GetItemPossessedBy(oChampion,"rts_it_mag36");
DestroyObject(oItem);
oOb=CreateObject(OBJECT_TYPE_PLACEABLE,"rts_pl_mag26",GetLocation(oChampion));
} // sludge factory creator
else if (sID=="DWF"&&GetIsObjectValid(GetItemPossessedBy(oChampion,"rts_it_mag35")))
{ // mithril forge creator
oItem=GetItemPossessedBy(oChampion,"rts_it_mag35");
DestroyObject(oItem);
oOb=CreateObject(OBJECT_TYPE_PLACEABLE,"rts_pl_mag35",GetLocation(oChampion));
} // mithril forge creator
oItem=GetItemPossessedBy(oChampion,"rts_it_mag28");
if (GetIsObjectValid(oItem))
{ // teleportation interdictor
oOb=GetNearestObjectByTag("rts_pl_mag28",oChampion);
if (!GetIsObjectValid(oOb))
{ // create teleportation interdictor
oOb=CreateObject(OBJECT_TYPE_PLACEABLE,"rts_pl_mag28",GetLocation(oChampion));
} // create teleportation interdictor
} // teleportation interdictor
oItem=GetItemPossessedBy(oChampion,"rts_it_mag42");
if (GetIsObjectValid(oItem))
{ // has the tome of ancient evil
if (sID=="DWF")
{ // destroy it
DestroyObject(oItem);
nN=GetLocalInt(oChampion,"nXP");
nN=nN+1000; // 1000 experience
SetLocalInt(oChampion,"nXP",nN);
} // destroy it
else
{ // create big unit
sS="und19";
if (sID=="SPID") sS="spid27";
else if (sID=="UNC") sS="unc14";
privateCreate_Follower(oChampion,sS);
ExecuteScript("rts_it_mag42r",oChampion); // replace book
} // create big unit
} // has the tome of ancient evil
} // in your own lair
else if (GetStringLength(sS)>0)
{ // in someone elses lair
oItem=GetItemPossessedBy(oChampion,"rts_it_mag28");
if (GetIsObjectValid(oItem))
{ // teleportation interdictor
oOb=GetNearestObjectByTag("rts_pl_mag28",oChampion);
if (!GetIsObjectValid(oOb))
{ // create teleportation interdictor
oOb=CreateObject(OBJECT_TYPE_PLACEABLE,"rts_pl_mag28",GetLocation(oChampion));
} // create teleportation interdictor
} // teleportation interdictor
oItem=GetItemPossessedBy(oChampion,"rts_it_mag27");
if (GetIsObjectValid(oItem))
{ // magic bug eggs
oOb=GetNearestObjectByTag("rts_pl_mag27",oChampion);
if (!GetIsObjectValid(oOb))
{ // create magic bug eggs
oOb=CreateObject(OBJECT_TYPE_PLACEABLE,"rts_pl_mag27",GetLocation(oChampion));
DelayCommand(HoursToSeconds(8),fnHatch(oOb));
} // create magic bug eggs
} // magic bug eggs
oItem=GetItemPossessedBy(oChampion,"rts_it_op1");
if (GetIsObjectValid(oItem))
{ // mana mine
DestroyObject(oItem);
oOb=CreateObject(OBJECT_TYPE_PLACEABLE,"rts_it_op1_pl",GetLocation(oChampion));
} // mana mine
} // in someone elses lair
else
{ // outside
oItem=GetItemPossessedBy(oChampion,"rts_it_mag28");
if (GetIsObjectValid(oItem))
{ // teleportation interdictor
oOb=GetNearestObjectByTag("rts_pl_mag28",oChampion);
if (!GetIsObjectValid(oOb))
{ // create teleportation interdictor
oOb=CreateObject(OBJECT_TYPE_PLACEABLE,"rts_pl_mag28",GetLocation(oChampion));
} // create teleportation interdictor
} // teleportation interdictor
if (sID!="SPID")
{ // not spiders
oItem=GetItemPossessedBy(oChampion,"rts_it_mag29");
if (GetIsObjectValid(oItem))
{ // bug zapper
oOb=GetNearestObjectByTag("rts_pl_mag29",oChampion);
if (!GetIsObjectValid(oOb))
{ // place bug zapper
oOb=CreateObject(OBJECT_TYPE_PLACEABLE,"rts_pl_mag29",GetLocation(oChampion));
SetLocalInt(oOb,"nCharges",5);
DelayCommand(5.0,AssignCommand(oOb,fnBugZapper()));
} // place bug zapper
} // bug zapper
} // not spiders
} // outside
} // Champion_Use()
void Champion_Search(object oChampion)
{ // PURPOSE: To search for items, placeables, and creatures of interest and interact
// with them
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
effect eVFX=EffectBeam(VFX_BEAM_SILENT_ODD,oChampion,BODY_NODE_HAND);
object oOb;
object oItem;
object oCopy;
int nN;
string sS;
int bB;
int nBT;
string sID=GetLocalString(oChampion,"sTeamID");
int nSearchMode=GetLocalInt(oChampion,"nSearchMode");
int nSearchParm=GetLocalInt(oChampion,"nSearchParm");
SetLocalInt(oChampion,"nActionInProgress",4);
fnDMSpeak(oChampion,"I need to look around.",TRUE);
Champion_Debug(oChampion,"Champion_Search()");
if (nSearchMode==0)
{ // search for placeables
Champion_Debug(oChampion," Placeables");
nN=nSearchParm;
bB=FALSE;
if(GetIsObjectValid(GetItemPossessedBy(oChampion,"MANA_CRYSTAL_1"))) bB=TRUE;
else if(GetIsObjectValid(GetItemPossessedBy(oChampion,"MANA_CRYSTAL_2"))) bB=TRUE;
else if(GetIsObjectValid(GetItemPossessedBy(oChampion,"MANA_CRYSTAL_5"))) bB=TRUE;
if (nN<1) nN=1;
oOb=GetNearestObject(OBJECT_TYPE_PLACEABLE,oChampion,nN);
while(GetIsObjectValid(oOb)&&GetDistanceBetween(oOb,oChampion)<20.0)
{ // search placeables
sS=GetTag(oOb);
SetIdentified(oItem,TRUE);
if (sS=="RTS_POWER_RES")
{ // power reservoir ---------------------------------------
} // power reservoir ---------------------------------------
else if (sS=="pileogold")
{ // pile of gold
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oOb,1.9);
oItem=GetFirstItemInInventory(oOb);
nSearchParm=GetItemStackSize(oItem);
if (GetIsObjectValid(oItem)) oCopy=CopyItem(oItem,oChampion,TRUE);
DestroyObject(oItem);
DelayCommand(2.0,DestroyObject(oOb));
GiveGoldToCreature(oChampion,nSearchParm);
} // pile of gold
else if (GetHasInventory(oOb))
{ // container
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oOb,1.9);
oItem=GetFirstItemInInventory(oOb);
while(GetIsObjectValid(oItem))
{ // items
oCopy=CopyObject(oItem,GetLocation(oOb));
DelayCommand(0.2,DestroyObject(oItem));
oItem=GetNextItemInInventory(oOb);
} // items
if(!GetPlotFlag(oOb)) DelayCommand(3.0,DestroyObject(oOb));
} // container
else if (!bB&&(sS=="ManaPool"||sS=="MinorManaPool"||sS=="StrongManaPool"))
{ // mana pools
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oOb,1.9);
DelayCommand(2.0,DestroyObject(oOb));
bB=TRUE;
if (sS=="ManaPool") oItem=CreateItemOnObject("mana_crystal_2",oChampion);
else if (sS=="MinorManaPool") oItem=CreateItemOnObject("mana_crystal_1",oChampion);
else if (sS=="StrongManaPool") oItem=CreateItemOnObject("mana_crystal_5",oChampion);
} // mana pools
nN++;
oOb=GetNearestObject(OBJECT_TYPE_PLACEABLE,oChampion,nN);
} // search placeables
SetLocalInt(oChampion,"nSearchMode",1);
} // search for placeables
else if (nSearchMode==1)
{ // search for items
Champion_Debug(oChampion," Items");
bB=FALSE;
if(GetIsObjectValid(GetItemPossessedBy(oChampion,"MANA_CRYSTAL_1"))) bB=TRUE;
else if(GetIsObjectValid(GetItemPossessedBy(oChampion,"MANA_CRYSTAL_2"))) bB=TRUE;
else if(GetIsObjectValid(GetItemPossessedBy(oChampion,"MANA_CRYSTAL_5"))) bB=TRUE;
nN=1;
oItem=GetNearestObject(OBJECT_TYPE_ITEM,oChampion,nN);
object oGuardian=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oItem);
while(GetIsObjectValid(oItem)&&GetDistanceBetween(oItem,oChampion)<20.0)
{ // search items
if (GetIsObjectValid(oGuardian)&&GetDistanceBetween(oGuardian,oItem)<3.0&&GetIsEnemy(oGuardian,oChampion))
{ // do not pickup - guardian present
} // do not pickup - guardian present
else if (GetPlotFlag(oItem))
{ // artifact pick up
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oItem,1.9);
oCopy=CopyItem(oItem,oChampion,TRUE);
DelayCommand(2.0,DestroyObject(oItem));
} // artifact pick up
else
{ // other stuff
sS=GetTag(oItem);
nBT=GetBaseItemType(oItem);
if (nBT==BASE_ITEM_AMULET||nBT==BASE_ITEM_GEM||nBT==BASE_ITEM_POTIONS||nBT==BASE_ITEM_RING)
{ // pick up items
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oItem,1.9);
oCopy=CopyItem(oItem,oChampion,TRUE);
SetIdentified(oCopy,TRUE);
DelayCommand(2.0,DestroyObject(oItem));
} // pick up items
else if (nBT==BASE_ITEM_GOLD)
{ // gold
nBT=GetItemStackSize(oItem);
GiveGoldToCreature(oChampion,nBT);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oItem,1.9);
DelayCommand(2.0,DestroyObject(oItem));
} // gold
else if (nBT==BASE_ITEM_ARMOR)
{ // armor
SetIdentified(oItem,TRUE);
if(GetGoldPieceValue(oItem)>GetGoldPieceValue(GetItemInSlot(INVENTORY_SLOT_CHEST,oChampion)))
{ // armor is worth more than what I am wearing
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oItem,1.9);
oCopy=CopyItem(oItem,oChampion,TRUE);
DelayCommand(2.0,DestroyObject(oItem));
} // armor is worth more than what I am wearing
SetIdentified(oItem,FALSE);
} // armor
else if (nBT==BASE_ITEM_SPELLSCROLL||nBT==BASE_ITEM_SCROLL)
{ // scroll
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oItem,1.9);
oCopy=CopyItem(oItem,oChampion,TRUE);
SetIdentified(oCopy,TRUE);
DelayCommand(2.0,DestroyObject(oItem));
} // scroll
else if (sS=="SoulToken")
{ // pick up
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oItem,1.9);
oCopy=CopyItem(oItem,oChampion);
DelayCommand(2.0,DestroyObject(oItem));
} // pick up
else if (sS=="MANA_CRYSTAL_1"||sS=="MANA_CRYSTAL_2"||sS=="MANA_CRYSTAL_5")
{ // pick up or convert back to a mana pool
if (bB)
{ // already carrying crystal
if (sS=="MANA_CRYSTAL_2") oCopy=CreateObject(OBJECT_TYPE_PLACEABLE,"ManaPool",GetLocation(oItem));
else if (sS=="MANA_CRYSTAL_1") oCopy=CreateObject(OBJECT_TYPE_PLACEABLE,"MinorManaPool",GetLocation(oItem));
else if (sS=="MANA_CRYSTAL_5") oCopy=CreateObject(OBJECT_TYPE_PLACEABLE,"StrongManaPool",GetLocation(oItem));
DelayCommand(1.0,DestroyObject(oItem));
} // already carrying crystal
else
{ // pick up
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oItem,1.9);
oCopy=CopyItem(oItem,oChampion);
DelayCommand(2.0,DestroyObject(oItem));
bB=TRUE;
} // pick up
} // pick up or convert back to a mana pool
else if (GetGoldPieceValue(oItem)<10)
{ // destroy
GiveGoldToCreature(oChampion,GetGoldPieceValue(oItem)/4);
DelayCommand(1.0,DestroyObject(oItem));
} // destroy
} // other stuff
SetIdentified(oItem,FALSE);
nN++;
oItem=GetNearestObject(OBJECT_TYPE_ITEM,oChampion,nN);
oGuardian=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oItem);
} // search items
SetLocalInt(oChampion,"nSearchMode",2);
} // search for items
else if (nSearchMode==2)
{ // search for npcs
Champion_Debug(oChampion," NPCs");
nN=1;
oOb=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oChampion,nN,CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN);
while(GetIsObjectValid(oOb))
{ // go through creatures that can be seen
sS=GetTag(oOb);
if (sS=="Rotund")
{ // trade with rotund
privateRotund(oChampion,oOb);
} // trade with rotund
else if (sS=="Smith")
{ // trade with smith
privateSmith(oChampion,oOb);
} // trade with smith
else if (sS=="Fence")
{ // trade with fence
} // trade with fence
else if (sS=="Apothecary")
{ // trade with apothecary
privateApothecary(oChampion,oOb);
} // trade with apothecary
else if (sS=="Healer")
{ // get healed
privateHealer(oChampion,oOb);
} // get healed
nN++;
oOb=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oChampion,nN,CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN);
} // go through creatures that can be seen
SetLocalInt(oChampion,"nSearchMode",3);
} // search for npcs
} // Champion_Search()
void Champion_LevelUp(object oChampion)
{ // PURPOSE: To levelup the champion if appropriate
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/20/2006 | Deva B. Winblood | Initial version of this function
object oNext;
object oItem;
string sRes;
string sID=GetLocalString(oChampion,"sTeamID");
int nLevel=GetLevelByPosition(1,oChampion)+GetLevelByPosition(2,oChampion)+GetLevelByPosition(3,oChampion);
int nXP=GetLocalInt(oChampion,"nXP");
effect eGhost=EffectCutsceneGhost();
object oCopy;
Champion_Debug(oChampion,"Champion_LevelUp(XP:"+IntToString(nXP)+" CURRENT LEVEL:"+IntToString(nLevel)+")");
if (nXP>nLevel*500)
{ // level
SetLocalInt(oChampion,"nActionInProgress",2);
fnDMSpeak(oChampion,"I have increased in power.",TRUE);
nXP=nXP-(nLevel*500);
SetLocalInt(oChampion,"nXP",nXP);
nLevel++;
sRes=sID+"_champ"+IntToString(nLevel-3);
sRes=GetStringLowerCase(sRes);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eGhost,oChampion,10.0);
oNext=CreateObject(OBJECT_TYPE_CREATURE,sRes,GetLocation(oChampion));
if (GetIsObjectValid(oNext))
{ // creature created
Champion_Debug(oNext," Leveled to Level:"+IntToString(nLevel));
SetLocalInt(oNext,"nXP",nXP);
oItem=GetLocalObject(oChampion,"oPathDest");
SetLocalObject(oNext,"oPathDest",oItem);
nXP=GetLocalInt(oChampion,"nPathPosition_EXP");
SetLocalInt(oNext,"nPathPosition_EXP",nXP);
nXP=GetLocalInt(oChampion,"nPathPosition_CON");
SetLocalInt(oNext,"nPathPosition_CON",nXP);
nXP=GetLocalInt(oChampion,"nPathPosition_ASS");
SetLocalInt(oNext,"nPathPosition_ASS",nXP);
nXP=GetLocalInt(oChampion,"nPathPosition_ESC");
SetLocalInt(oNext,"nPathPosition_ESC",nXP);
nXP=GetLocalInt(oChampion,"nPathMode");
SetLocalInt(oNext,"nPathMode",nXP);
oItem=GetFirstItemInInventory(oChampion);
while(GetIsObjectValid(oItem))
{ // copy inventory
oCopy=CopyItem(oItem,oNext,TRUE);
DelayCommand(0.6,DestroyObject(oItem));
oItem=GetNextItemInInventory(oChampion);
} // copy inventory
SetAILevel(oNext,AI_LEVEL_HIGH);
AssignCommand(oNext,ClearAllActions());
AssignCommand(oNext,SetIsDestroyable(FALSE,TRUE,TRUE));
oItem=GetItemInSlot(INVENTORY_SLOT_ARMS,oChampion);
if (GetIsObjectValid(oItem))
{ // copy and equip
oCopy=CopyItem(oItem,oNext,TRUE);
DelayCommand(0.7,DestroyObject(oItem));
AssignCommand(oNext,ActionEquipItem(oItem,INVENTORY_SLOT_ARMS));
} // copy and equip
oItem=GetItemInSlot(INVENTORY_SLOT_ARROWS,oChampion);
if (GetIsObjectValid(oItem))
{ // copy and equip
oCopy=CopyItem(oItem,oNext,TRUE);
DelayCommand(0.7,DestroyObject(oItem));
AssignCommand(oNext,ActionEquipItem(oItem,INVENTORY_SLOT_ARROWS));
} // copy and equip
oItem=GetItemInSlot(INVENTORY_SLOT_BELT,oChampion);
if (GetIsObjectValid(oItem))
{ // copy and equip
oCopy=CopyItem(oItem,oNext,TRUE);
DelayCommand(0.7,DestroyObject(oItem));
AssignCommand(oNext,ActionEquipItem(oItem,INVENTORY_SLOT_BELT));
} // copy and equip
oItem=GetItemInSlot(INVENTORY_SLOT_BOLTS,oChampion);
if (GetIsObjectValid(oItem))
{ // copy and equip
oCopy=CopyItem(oItem,oNext,TRUE);
DelayCommand(0.7,DestroyObject(oItem));
AssignCommand(oNext,ActionEquipItem(oItem,INVENTORY_SLOT_BOLTS));
} // copy and equip
oItem=GetItemInSlot(INVENTORY_SLOT_BOOTS,oChampion);
if (GetIsObjectValid(oItem))
{ // copy and equip
oCopy=CopyItem(oItem,oNext,TRUE);
DelayCommand(0.7,DestroyObject(oItem));
AssignCommand(oNext,ActionEquipItem(oItem,INVENTORY_SLOT_BOOTS));
} // copy and equip
oItem=GetItemInSlot(INVENTORY_SLOT_BULLETS,oChampion);
if (GetIsObjectValid(oItem))
{ // copy and equip
oCopy=CopyItem(oItem,oNext,TRUE);
DelayCommand(0.7,DestroyObject(oItem));
AssignCommand(oNext,ActionEquipItem(oItem,INVENTORY_SLOT_BULLETS));
} // copy and equip
oItem=GetItemInSlot(INVENTORY_SLOT_CHEST,oChampion);
if (GetIsObjectValid(oItem))
{ // copy and equip
oCopy=CopyItem(oItem,oNext,TRUE);
DelayCommand(0.7,DestroyObject(oItem));
AssignCommand(oNext,ActionEquipItem(oItem,INVENTORY_SLOT_CHEST));
} // copy and equip
oItem=GetItemInSlot(INVENTORY_SLOT_CLOAK,oChampion);
if (GetIsObjectValid(oItem))
{ // copy and equip
oCopy=CopyItem(oItem,oNext,TRUE);
DelayCommand(0.7,DestroyObject(oItem));
AssignCommand(oNext,ActionEquipItem(oItem,INVENTORY_SLOT_CLOAK));
} // copy and equip
oItem=GetItemInSlot(INVENTORY_SLOT_HEAD,oChampion);
if (GetIsObjectValid(oItem))
{ // copy and equip
oCopy=CopyItem(oItem,oNext,TRUE);
DelayCommand(0.7,DestroyObject(oItem));
AssignCommand(oNext,ActionEquipItem(oItem,INVENTORY_SLOT_HEAD));
} // copy and equip
oItem=GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oChampion);
if (GetIsObjectValid(oItem))
{ // copy and equip
oCopy=CopyItem(oItem,oNext,TRUE);
DelayCommand(0.7,DestroyObject(oItem));
AssignCommand(oNext,ActionEquipItem(oItem,INVENTORY_SLOT_LEFTHAND));
} // copy and equip
oItem=GetItemInSlot(INVENTORY_SLOT_LEFTRING,oChampion);
if (GetIsObjectValid(oItem))
{ // copy and equip
oCopy=CopyItem(oItem,oNext,TRUE);
DelayCommand(0.7,DestroyObject(oItem));
AssignCommand(oNext,ActionEquipItem(oItem,INVENTORY_SLOT_LEFTRING));
} // copy and equip
oItem=GetItemInSlot(INVENTORY_SLOT_NECK,oChampion);
if (GetIsObjectValid(oItem))
{ // copy and equip
oCopy=CopyItem(oItem,oNext,TRUE);
DelayCommand(0.7,DestroyObject(oItem));
AssignCommand(oNext,ActionEquipItem(oItem,INVENTORY_SLOT_NECK));
} // copy and equip
oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oChampion);
if (GetIsObjectValid(oItem))
{ // copy and equip
oCopy=CopyItem(oItem,oNext,TRUE);
DelayCommand(0.7,DestroyObject(oItem));
AssignCommand(oNext,ActionEquipItem(oItem,INVENTORY_SLOT_RIGHTHAND));
} // copy and equip
oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTRING,oChampion);
if (GetIsObjectValid(oItem))
{ // copy and equip
oCopy=CopyItem(oItem,oNext,TRUE);
DelayCommand(0.7,DestroyObject(oItem));
AssignCommand(oNext,ActionEquipItem(oItem,INVENTORY_SLOT_RIGHTRING));
} // copy and equip
AssignCommand(oChampion,SetIsDestroyable(TRUE,FALSE,FALSE));
DelayCommand(0.9,DestroyObject(oChampion));
nXP=GetGold(oChampion);
if (GetGold(oNext)<nXP)
{ // give gold
nXP=nXP-GetGold(oNext);
GiveGoldToCreature(oNext,nXP);
} // give gold
} // creature created
} // level
} // Champion_LevelUp()
void Champion_Escape1(object oChampion)
{ // PURPOSE: Escape action 1
int nN;
if (GetArea(oChampion)!=GetArea(GetWaypointByTag("SHADOW_DOWN_THE_WELL")))
{ // jump
AssignCommand(oChampion,ClearAllActions(TRUE));
AssignCommand(oChampion,JumpToObject(GetWaypointByTag("SHADOW_DOWN_THE_WELL")));
SetLocalInt(oChampion,"nActionInProgress",2);
DelayCommand(2.0,Champion_Escape1(oChampion));
} // jump
else if (GetDistanceBetween(oChampion,GetObjectByTag("SHADOW_PORTAL"))>3.0)
{ // keep moving
nN=MoveToObject(oChampion,GetObjectByTag("SHADOW_PORTAL"),TRUE,3.0);
SetLocalInt(oChampion,"nActionInProgress",2);
DelayCommand(2.0,Champion_Escape1(oChampion));
} // keep moving
else
{ // arrived
AssignCommand(oChampion,ClearAllActions(TRUE));
AssignCommand(oChampion,JumpToObject(GetWaypointByTag("SHADOW_ROUTE_2")));
SetLocalInt(oChampion,"nActionInProgress",1);
} // arrived
} // Champion_Escape1()
//void main(){}