/////////////////////////////////////////////////// // Beholder Ray: Include file // /////////////////////////////////////////////////// /* These are the functions the beholder uses to act in it's most evil way... hehe */ /////////////////////////////////////////////////// // Created By: Zarathustra217 // // Created On: Jan 28. 2003 // /////////////////////////////////////////////////// #include "prc_inc_spells" #include "prc_inc_sp_tch" // object OBJECT_SELF = OBJECT_SELF; <- Just here for testing float ConvAngle(float fAngle) { while(fAngle<0.0) { fAngle=fAngle+360.0; } while(fAngle>=360.0) { fAngle=fAngle-360.0; } return fAngle; } int GetLevel(object oTarget) { int nTemp=1; int nLevel=0; while(nTemp<9) { int nClass=GetClassByPosition(nTemp,oTarget); nLevel+=GetLevelByPosition(nTemp,oTarget); nTemp++; } return nLevel; } int ClassSpellLvl(object oTarget) { int nTemp=1; int nSpellLvl=0; while(nTemp<9) { int nClass=GetClassByPosition(nTemp,oTarget); if(nClass==CLASS_TYPE_CLERIC||nClass==CLASS_TYPE_DRUID||nClass==CLASS_TYPE_SORCERER||nClass==CLASS_TYPE_WIZARD) { nSpellLvl+=GetLevelByPosition(nTemp,oTarget); nTemp++; } else { nTemp++; } } return nSpellLvl; } int GetSpellCasterLvl(object oTarget) { if(ClassSpellLvl(oTarget)>0) { return ClassSpellLvl(oTarget); } else { return 0; } } //Angle relative to beholder calculater float CalcAngle(object oTarget) { float fBangle=GetFacing(OBJECT_SELF); vector vBpos=GetPosition(OBJECT_SELF); vector vTpos=GetPosition(oTarget); vector vAngelvector=Vector(vTpos.x-vBpos.x,vTpos.y-vBpos.y,0.0); float fAngle=fBangle-VectorToAngle(vAngelvector); return ConvAngle(fAngle); } int CalcArc(object oTarget) { float fTangle=CalcAngle(oTarget); if(fTangle>=225.0&&fTangle<=315.0) { return 4; } else if(fTangle>=135.0&&fTangle<=225.0) { return 3; } else if(fTangle>=45.0&&fTangle<=135.0) { return 2; } else if(315.03.0) { //Debug String //AssignCommand(OBJECT_SELF,SpeakString("This position is good!")); //ID:1 if(GetLocalInt(OBJECT_SELF,"CurrentAction")!=1) { SetLocalInt(OBJECT_SELF,"CurrentAction",1); AssignCommand(OBJECT_SELF,ClearAllActions()); AssignCommand(OBJECT_SELF,SetFacingPoint(GetPosition(oFacing))); AssignCommand(OBJECT_SELF,ActionAttack(oFacing,TRUE)); } else { AssignCommand(OBJECT_SELF,ActionAttack(oFacing,TRUE)); } } else { //Debug String //AssignCommand(OBJECT_SELF,SpeakString("This position is ok!")); //ID:2 if(GetLocalInt(OBJECT_SELF,"CurrentAction")!=2) { SetLocalInt(OBJECT_SELF,"CurrentAction",2); AssignCommand(OBJECT_SELF,ClearAllActions()); AssignCommand(OBJECT_SELF,ActionAttack(oFacing,FALSE)); } else { AssignCommand(OBJECT_SELF,ActionAttack(oFacing,FALSE)); } } //AssignCommand(OBJECT_SELF,ActionAttack(oFacing,TRUE)); } else { //Debug String //AssignCommand(OBJECT_SELF,SpeakString("I'll just eat you!")); //ID:3 if(GetLocalInt(OBJECT_SELF,"CurrentAction")!=3) { SetLocalInt(OBJECT_SELF,"CurrentAction",3); AssignCommand(OBJECT_SELF,ClearAllActions()); AssignCommand(OBJECT_SELF,ActionAttack(oNearestE,FALSE)); } else { AssignCommand(OBJECT_SELF,ActionAttack(oNearestE,FALSE)); } } } else { //Debug String //AssignCommand(OBJECT_SELF,SpeakString("This position is bad!")); //ID:4 if(GetLocalInt(OBJECT_SELF,"CurrentAction")!=4||GetCurrentAction(OBJECT_SELF)!=ACTION_MOVETOPOINT) { SetLocalInt(OBJECT_SELF,"CurrentAction",4); AssignCommand(OBJECT_SELF,ClearAllActions()); if(GetDistanceBetween(OBJECT_SELF,oFacing)>fPrefDist) { AssignCommand(OBJECT_SELF,ActionAttack(oFacing,FALSE)); } else { AssignCommand(OBJECT_SELF,ActionMoveAwayFromObject(oNearestE,TRUE,1.5*fPrefDist)); } } else { if(GetDistanceBetween(OBJECT_SELF,oFacing)>fPrefDist) { AssignCommand(OBJECT_SELF,ActionAttack(oFacing,FALSE)); } else { AssignCommand(OBJECT_SELF,ActionMoveAwayFromObject(oNearestE,TRUE,1.5*fPrefDist)); } } } } //:: void main (){}