Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-14-2004, 05:46 AM
mollymillions's Avatar
mollymillions
Hill Giant
 
Join Date: May 2003
Posts: 176
Default Pathing

I have a solution to get MOBs to flee using their grid waypoints only. It seems to work 100% (really!). MOBs that do not have grids assigned will not flee.



Code:
Index: attack.cpp
===================================================================
RCS file: /cvsroot/eqemulator/EQEmuCVS/Source/zone/attack.cpp,v
retrieving revision 1.23
diff -u -w -b -r1.23 attack.cpp
--- attack.cpp	16 Nov 2004 20:06:34 -0000	1.23
+++ attack.cpp	15 Dec 2004 18:27:32 -0000
@@ -1763,6 +1763,19 @@
 		Death(other, damage, spell_id, attack_skill);

 		return;

 	}

+	//Flee if HP low
+	if ( flee_state == fleeStateNotFleeing  && !IsRooted() && GetHPRatio() <= 20){				
+	
+		sint16 gridno = CastToNPC()->GetGrid(); 		
+		if (gridno > 0)  {
+			Mob::CalculateNewWaypoint();	
+			flee_state = fleeStateFleeing;
+		} else {
+			flee_state = fleeStateGridless;
+ 		}
+	}
+
 	APPLAYER* outapp = new APPLAYER(OP_Damage, sizeof(CombatDamage_Struct));

 	//outapp->pBuffer = new uchar[outapp->size];

 	//memset(outapp->pBuffer, 0, sizeof(CombatDamage_Struct)); 					

Index: mob.cpp
===================================================================
RCS file: /cvsroot/eqemulator/EQEmuCVS/Source/zone/mob.cpp,v
retrieving revision 1.17
diff -u -w -b -r1.17 mob.cpp
--- mob.cpp	8 Nov 2004 23:02:06 -0000	1.17
+++ mob.cpp	15 Dec 2004 18:17:58 -0000
@@ -309,6 +309,8 @@
 	cur_wp=0;
 	patrol=0;
 	follow=0;
+	flee_state = fleeStateNotFleeing;
+
 #ifdef ENABLE_FEAR_PATHING
 	fear_state = fearStateNotFeared;
 #endif
@@ -482,6 +484,8 @@
         return 0.0f;
     if (spellbonuses.movementspeed || itembonuses.movementspeed)
         aa_speed += (spellbonuses.movementspeed+itembonuses.movementspeed) / 100.0f;
+	if (GetHPRatio() < 20)
+		return (runspeed * aa_speed * (GetHPRatio()/20));
 
         return (runspeed * aa_speed);
 }
Index: MobAI.cpp
===================================================================
RCS file: /cvsroot/eqemulator/EQEmuCVS/Source/zone/MobAI.cpp,v
retrieving revision 1.7
diff -u -w -b -r1.7 MobAI.cpp
--- MobAI.cpp	8 Nov 2004 23:01:45 -0000	1.7
+++ MobAI.cpp	15 Dec 2004 18:17:58 -0000
@@ -506,6 +506,37 @@
 	}
 #endif
 	
+	if(flee_state == fleeStateFleeing) {
+		
+		//stop fleeing if HP recovered
+		if (GetHPRatio() > 20) {
+			flee_state = fleeStateNotFleeing;
+		}
+		
+		if(IsRooted()) {
+			if(IsMoving()) {
+				SetHeading(CalculateHeadingToTarget(target->GetX(), target->GetY()));				
+				SetRunAnimSpeed(0);
+				SendPosition();
+				SetMoving(false);
+				moved=false;
+			}
+			return;
+		}
+		
+		if(AImovement_timer->Check()) {
+			if (cur_wp_x == GetX() && cur_wp_y == GetY()) {
+				entity_list.OpenDoorsNear(CastToNPC());
+				CalculateNewWaypoint();
+			}	
+
+			CalculateNewPosition2(cur_wp_x, cur_wp_y, cur_wp_z, GetRunspeed(), true);		    
+		}
+
+		return;
+	}
+
 	if (IsEngaged()) 
 	{
 		_ZP(Mob_AI_Process_engaged);
Index: mob.h
===================================================================
RCS file: /cvsroot/eqemulator/EQEmuCVS/Source/zone/mob.h,v
retrieving revision 1.9
diff -u -w -b -r1.9 mob.h
--- mob.h	16 Nov 2004 20:06:37 -0000	1.9
+++ mob.h	15 Dec 2004 18:17:58 -0000
@@ -102,6 +102,15 @@
 				//X,Y,Z are old interactive NPC codes

 };

 

+enum {	//flee states
+
+	fleeStateNotFleeing = 0,	
+	
+	fleeStateFleeing,
+
+	fleeStateGridless
+
+};


 enum {	//fear states

 	fearStateNotFeared = 0,

 	fearStateRunning,

@@ -928,7 +937,7 @@
 	int32	npc_spells_id;

 	AISpells_Struct	AIspells[MAX_AISPELLS]; // expected to be pre-sorted, best at low index

 	HateList hate_list;

-	

+	uint8 flee_state;

 	

 #ifdef ENABLE_FEAR_PATHING

 	void SetFeared(Mob *caster, int32 duration);
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 11:23 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3