///////////////////////////////////////////// // Enter second shadow plane ///////////////////////////////////////////// #include "antistuck_h" #include "prc_inc_skin" string fnSpawnType(object oPC) { // return resref of creature to spawn string sRet="nw_shadow1"; int nLevel=GetLevelByPosition(1,oPC); int nR=d100(); nLevel=nLevel+GetLevelByPosition(2,oPC); nLevel=nLevel+GetLevelByPosition(3,oPC); if (nLevel<3) { // lowest level if (nR<75) sRet="nw_shadow1"; else if (nR<95) sRet="nw_shmastif1"; else if (nR<100) sRet="nw_shfiend1"; else { sRet="nw_bodak1"; } } // lowest level else if (nLevel<6) { // second stage if (nR<50) sRet="nw_shadow1"; else if (nR<80) sRet="nw_shmastif1"; else if (nR<98) sRet="nw_shfiend1"; else { sRet="nw_bodak1"; } } // second stage else if (nLevel<10) { // third stage if (nR<33) sRet="nw_shadow1"; else if (nR<50) sRet="nw_shmastif1"; else if (nR<80) sRet="nw_shfiend1"; else if (nR<95) sRet="nw_bodak1"; else { sRet="nighthag"; } } // third stage else if (nLevel<15) { // fourth stage if (nR<20) sRet="nw_shadow1"; else if (nR<33) sRet="nw_shmastif1"; else if (nR<50) sRet="nw_shfiend1"; else if (nR<80) sRet="nw_bodak1"; else { sRet="nighthag"; } } // fourth stage else if (nLevel<19) { // fifth stage if (nR<10) sRet="nw_shadow1"; else if (nR<20) sRet="nw_shmastif1"; else if (nR<33) sRet="nw_shfiend1"; else if (nR<50) sRet="nw_bodak1"; else if (nR<90) sRet="nighthag"; else { sRet="nightwalker"; } } // fifth stage else { // final stage if (nR<10) sRet="nw_shfiend1"; else if (nR<33) sRet="nw_bodak1"; else if (nR<75) sRet="nighthag"; else if (nR<95) sRet="nightwalker"; else { sRet="dragonshad002"; } } // final stage return sRet; } // fnSpawnType() int HasLightSource(object oT) { // check to see if the object has a light source ready int nRet=FALSE; effect eTest; object oItem; effect eCompare1=EffectVisualEffect(VFX_DUR_LIGHT); effect eCompare2=EffectVisualEffect(VFX_DUR_LIGHT_WHITE_20); effect eCompare3=EffectVisualEffect(VFX_DUR_LIGHT_WHITE_15); effect eCompare4=EffectVisualEffect(VFX_DUR_LIGHT_WHITE_10); effect eCompare5=EffectVisualEffect(VFX_DUR_LIGHT_WHITE_5); effect eCompare6=EffectVisualEffect(VFX_DUR_LIGHT_YELLOW_20); effect eCompare7=EffectVisualEffect(VFX_DUR_LIGHT_YELLOW_15); effect eCompare8=EffectVisualEffect(VFX_DUR_LIGHT_YELLOW_10); effect eCompare9=EffectVisualEffect(VFX_DUR_LIGHT_YELLOW_5); effect eCompare10=EffectVisualEffect(VFX_DUR_LIGHT_BLUE_20); effect eCompare11=EffectVisualEffect(VFX_DUR_LIGHT_BLUE_15); effect eCompare12=EffectVisualEffect(VFX_DUR_LIGHT_GREY_20); effect eCompare13=EffectVisualEffect(VFX_DUR_LIGHT_ORANGE_20); effect eCompare14=EffectVisualEffect(VFX_DUR_LIGHT_PURPLE_20); effect eCompare15=EffectVisualEffect(VFX_DUR_LIGHT_RED_20); oItem=GetItemInSlot(INVENTORY_SLOT_ARMS,oT); if (GetItemHasItemProperty(oItem,ITEM_PROPERTY_LIGHT)==TRUE) nRet=TRUE; oItem=GetItemInSlot(INVENTORY_SLOT_BELT,oT); if (GetItemHasItemProperty(oItem,ITEM_PROPERTY_LIGHT)==TRUE) nRet=TRUE; oItem=GetItemInSlot(INVENTORY_SLOT_BOOTS,oT); if (GetItemHasItemProperty(oItem,ITEM_PROPERTY_LIGHT)==TRUE) nRet=TRUE; //oItem=GetItemInSlot(INVENTORY_SLOT_CARMOUR,oT); oItem = GetPCSkin(oT); if (GetItemHasItemProperty(oItem,ITEM_PROPERTY_LIGHT)==TRUE) nRet=TRUE; oItem=GetItemInSlot(INVENTORY_SLOT_CHEST,oT); if (GetItemHasItemProperty(oItem,ITEM_PROPERTY_LIGHT)==TRUE) nRet=TRUE; oItem=GetItemInSlot(INVENTORY_SLOT_CLOAK,oT); if (GetItemHasItemProperty(oItem,ITEM_PROPERTY_LIGHT)==TRUE) nRet=TRUE; oItem=GetItemInSlot(INVENTORY_SLOT_CWEAPON_B,oT); if (GetItemHasItemProperty(oItem,ITEM_PROPERTY_LIGHT)==TRUE) nRet=TRUE; oItem=GetItemInSlot(INVENTORY_SLOT_CWEAPON_L,oT); if (GetItemHasItemProperty(oItem,ITEM_PROPERTY_LIGHT)==TRUE) nRet=TRUE; oItem=GetItemInSlot(INVENTORY_SLOT_CWEAPON_R,oT); if (GetItemHasItemProperty(oItem,ITEM_PROPERTY_LIGHT)==TRUE) nRet=TRUE; oItem=GetItemInSlot(INVENTORY_SLOT_HEAD,oT); if (GetItemHasItemProperty(oItem,ITEM_PROPERTY_LIGHT)==TRUE) nRet=TRUE; oItem=GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oT); if (GetItemHasItemProperty(oItem,ITEM_PROPERTY_LIGHT)==TRUE) nRet=TRUE; oItem=GetItemInSlot(INVENTORY_SLOT_LEFTRING,oT); if (GetItemHasItemProperty(oItem,ITEM_PROPERTY_LIGHT)==TRUE) nRet=TRUE; oItem=GetItemInSlot(INVENTORY_SLOT_NECK,oT); if (GetItemHasItemProperty(oItem,ITEM_PROPERTY_LIGHT)==TRUE) nRet=TRUE; oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oT); if (GetItemHasItemProperty(oItem,ITEM_PROPERTY_LIGHT)==TRUE) nRet=TRUE; oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTRING,oT); if (GetItemHasItemProperty(oItem,ITEM_PROPERTY_LIGHT)==TRUE) nRet=TRUE; if (nRet!=TRUE) { // test for light spell effect eTest=GetFirstEffect(oT); while(GetEffectType(eTest)!=EFFECT_TYPE_INVALIDEFFECT&&nRet==FALSE) { // check for light if(eTest==eCompare1) nRet=TRUE; else if (eTest==eCompare2) nRet=TRUE; else if (eTest==eCompare3) nRet=TRUE; else if (eTest==eCompare4) nRet=TRUE; else if (eTest==eCompare5) nRet=TRUE; else if (eTest==eCompare6) nRet=TRUE; else if (eTest==eCompare7) nRet=TRUE; else if (eTest==eCompare8) nRet=TRUE; else if (eTest==eCompare9) nRet=TRUE; else if (eTest==eCompare10) nRet=TRUE; else if (eTest==eCompare11) nRet=TRUE; else if (eTest==eCompare12) nRet=TRUE; else if (eTest==eCompare13) nRet=TRUE; else if (eTest==eCompare14) nRet=TRUE; else if (eTest==eCompare15) nRet=TRUE; eTest=GetNextEffect(oT); } // check for light } // test for light spell effect return nRet; } // HasLightSource() void fnShadowAI() { // make the shadows on this level react object oPortal=GetNearestObjectByTag("SHADOW_PORTAL",OBJECT_SELF,1); object oEnemy=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,OBJECT_SELF,1,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY); object oPerc=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,OBJECT_SELF,1,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY,CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN); float fDist=GetDistanceBetween(OBJECT_SELF,oEnemy); if (GetIsInCombat(OBJECT_SELF)!=TRUE) { // not fighting if (fDist<20.0&&oEnemy!=OBJECT_INVALID&&oEnemy==oPerc) { // engage enemy ActionAttack(oEnemy); } // engage enemy else if (HasLightSource(oEnemy)==TRUE) { // run to enemy AssignCommand(OBJECT_SELF,ASActionMoveToObject(oEnemy,TRUE,1.0)); } // run to enemy else { // walk to portal AssignCommand(OBJECT_SELF,ASActionMoveToObject(oPortal,FALSE,2.0)); } // walk to portal } // not fighting DelayCommand(8.0,fnShadowAI()); } // fnShadowAI() void fnMovePortal(object oPortal,object oArea) { // object oP; object oDest; if (oPortal!=OBJECT_INVALID) DestroyObject(oPortal); SetLocalInt(oArea,"nPortalStarted",TRUE); oDest=GetWaypointByTag("SHAD_PORTAL_"+IntToString(d12())); oP=CreateObject(OBJECT_TYPE_PLACEABLE,"shadow_portal",GetLocation(oDest)); DelayCommand(5.0,AssignCommand(oP,PlaySound("al_mg_crystalev1"))); DelayCommand(HoursToSeconds(2),fnMovePortal(oP,oArea)); } // fnMovePortal() void fnDarknessStorm(object oMe) { // storm of darkness int nX=Random(16)*10; int nY=Random(16)*10; int nZ=Random(4)*10; effect eDarkness=EffectVisualEffect(VFX_DUR_DARKNESS); vector vVec=Vector(IntToFloat(nX),IntToFloat(nY),IntToFloat(nZ)); location lLoc=Location(oMe,vVec,0.0); int nN=1; ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY,eDarkness,lLoc,4.0); while(nN<6) { // darkness nX=Random(16)*10; nY=Random(16)*10; nZ=Random(4)*10; vVec=Vector(IntToFloat(nX),IntToFloat(nY),IntToFloat(nZ)); lLoc=Location(oMe,vVec,0.0); nN++; ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY,eDarkness,lLoc,4.0); } // darkness DelayCommand(10.0,fnDarknessStorm(oMe)); } // fnDarknessStorm() void main() { object oPC=GetEnteringObject(); object oMe=OBJECT_SELF; object oDest; int nR=d6(); int nC=0; int nL; object oCR; string sTag; if (GetIsPC(oPC)==TRUE) { // is PC nL=1; oCR=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oPC,nL,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY); while(oCR!=OBJECT_INVALID) { // !OI sTag=GetResRef(oCR); if (sTag=="nw_shadow"||sTag=="nw_shmastif"||sTag=="nw_shfiend") nC++; else if (sTag=="nw_bodak"||sTag=="nighthag"||sTag=="nightwalker"||sTag=="dragonshad002") nC++; nL++; oCR=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oPC,nL,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY); } // !Oi if (nC<8) { // spawn sTag=fnSpawnType(oPC); oDest=GetWaypointByTag("SHAD2_SPAWN_"+IntToString(nR)); if (oDest!=OBJECT_INVALID&&GetObjectType(oDest)==OBJECT_TYPE_WAYPOINT) { // spawn okay oCR=CreateObject(OBJECT_TYPE_CREATURE,sTag,GetLocation(oDest)); AssignCommand(oCR,fnShadowAI()); } // spawn okay } // spawn oCR=GetNearestObjectByTag("SHADOW_PORTAL",oPC,1); if (GetLocalInt(GetArea(oPC),"nPortalStarted")!=TRUE) { fnMovePortal(oCR,GetArea(oPC)); } if (GetLocalInt(oMe,"nDarknessStorm")!=TRUE) { // activate darkness storm SetLocalInt(oMe,"nDarknessStorm",TRUE); fnDarknessStorm(oMe); } // activate darkness storm ExecuteScript("area_visit",OBJECT_SELF); } // is PC }