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)

Reply
 
Thread Tools Display Modes
  #1  
Old 12-18-2007, 10:38 AM
Angelox
AX Classic Developer
 
Join Date: May 2006
Location: filler
Posts: 2,049
Default

Cavedude had mentioned one temporary solution was to give the swimmers the levitation spell - This keeps them steady at what ever grid they are on. Problem is these mobs in Cauldron go in and out of water, so they float on land, and it doesn't look right.
What I'm thinking is. what code is related to levitate? maybe make an "in water" exception and apply what ever it is that removes the "gravity" in Levitate, while swimming. There must be some code that tells the NPC he is in water and this puts him in "swim-mode" (they start swimming while in water). Maybe you can exploit this and use it to eliminate the hopping too (while in swim mode, don't use Z coord).
Reply With Quote
  #2  
Old 12-18-2007, 10:56 AM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

Quote:
Originally Posted by Angelox View Post
There must be some code that tells the NPC he is in water and this puts him in "swim-mode" (they start swimming while in water).
I am fairly sure that there is code in the client that 'knows' that an NPC is in water and turns on the swimming animation, rather than the server telling it. If this is the case, I don't know whether there is some information in the zone S3D/EQG file that the client uses, or whether the client has some hard-coded information.

Maybe I'll try making a zone with Windcatcher's OpenZone with some areas of water and see if the client detects when a player is underwater. If it does, then there must be some information in the S3D that I can extract and use.
Reply With Quote
  #3  
Old 12-19-2007, 04:05 AM
Cripp's Avatar
Cripp
Discordant
 
Join Date: Oct 2003
Location: The Shire
Posts: 474
Default

ive also noticed that mobs that stand on docks or in little huts are pulled through and stuck to the actual ground so they either under water or there head is sticking through the floor...

im possibly gona try and add a way to disable fixZ for selected NPCs

as for water hopping... could check if NPC is in water or not(if possible).. and if its in water walk in a straight line..
(maybe, just an idea)
__________________
Nug Blazers - ServerOP / founder
^^comming... later!

www.nugblazers.com
Reply With Quote
  #4  
Old 12-19-2007, 04:19 AM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

I think an ignorefixz column or something such would be a good addition to npc_types. I too, have found that mobs get glued to the ground when they should be on rocks, huts, chairs, etc. This column would allow us to place exceptions on a per mob basis. The initial setup would be nuts of course, but once most of those mobs are corrected everything will look a lot better. Better yet, the column could be put in spawn2, so any mob that has those spawn points will be effected.

As for mobs in the water... there currently is no way for us to tell where water exists in the map. That's why you can fish anywhere in a zone, and why we can't keep fish from leaving ponds and such. However, if a way of determining where water is can be found, that would enable us to correct fishing, prevent fish and the like from leaving water, and help prevent the hopping under water and/or sticking to the bottom if fixedz is enabled.
Reply With Quote
  #5  
Old 12-19-2007, 06:16 AM
Cripp's Avatar
Cripp
Discordant
 
Join Date: Oct 2003
Location: The Shire
Posts: 474
Default

heres what i came up with today...

Code:
--- mob.h	2007/12/17 02:26:10	1.25
+++ mob.h	2007/12/19 18:08:39	1.26
@@ -902,8 +902,11 @@
 //	uint32	guildeqid; // guild's EQ ID, 0-511, 0xFFFFFFFF = none
 	
 	int8    light;
-	
+#ifdef CRIPP_Z
+	sint16	fixedZ;
+#else
 	float	fixedZ;
+#endif
 	EmuAppearance    _appearance;
 	int8	pRunAnimSpeed;
Code:
--- npc.cpp	2007/12/17 02:26:10	1.20
+++ npc.cpp	2007/12/19 18:08:39	1.21
@@ -152,6 +152,9 @@
 	guard_z = 0;
 	guard_heading = 0;
 	swarmInfoPtr = NULL;
+#ifdef CRIPP_Z
+	fixz = 1;
+#endif
 	
 //	SaveSpawnSpot();
Code:
--- npc.h	2007/12/17 02:26:10	1.15
+++ npc.h	2007/12/19 18:08:39	1.16
@@ -225,6 +225,9 @@
 	//aza77 GWFear
 	void SpawnFearGridNPC(const char* feargrids, float in_x, float in_y, float in_z);
 #endif
+#ifdef CRIPP_Z
+	sint16 fixz;
+#endif
 
 protected:
Code:
--- spawn2.cpp	2006/11/01 20:36:21	1.3
+++ spawn2.cpp	2007/12/19 18:08:39	1.4
@@ -67,7 +67,11 @@
 Spawn2::Spawn2(int32 in_spawn2_id, int32 spawngroup_id, 
 	float in_x, float in_y, float in_z, float in_heading, 
 	int32 respawn, int32 variance, int32 timeleft, int32 grid,
+#ifdef CRIPP_Z
+	uint16 in_cond_id, sint16 in_min_value, sint16 fixZhop)
+#else
 	uint16 in_cond_id, sint16 in_min_value)
+#endif
 : timer(100000)
 {
 	spawn2_id = in_spawn2_id;
@@ -82,6 +86,9 @@
 	condition_id = in_cond_id;
 	condition_min_value = in_min_value;
 	npcthis = NULL;
+#ifdef CRIPP_Z
+	FixedZ = fixZhop;
+#endif
 	
 	if(timeleft == 0xFFFFFFFF) {
 		//special disable timeleft
@@ -169,6 +176,9 @@
 		npcthis = npc;
 		npc->AddLootTable();
 		npc->SetSp2(spawngroup_id_);
+#ifdef CRIPP_Z
+		npc->fixz = FixedZ;
+#endif
 		entity_list.AddNPC(npc);
 		//this limit add must be done after the AddNPC since we need the entity ID.
 		entity_list.LimitAddNPC(npc);
@@ -229,7 +239,11 @@
 	MYSQL_RES *result;
 	MYSQL_ROW row;
 	
+#ifdef CRIPP_Z
+	MakeAnyLenString(&query, "SELECT id, spawngroupID, x, y, z, heading, respawntime, variance, pathgrid, timeleft, _condition, cond_value, fixZ FROM spawn2 WHERE zone='%s'", zone_name);
+#else
 	MakeAnyLenString(&query, "SELECT id, spawngroupID, x, y, z, heading, respawntime, variance, pathgrid, timeleft, _condition, cond_value FROM spawn2 WHERE zone='%s'", zone_name);
+#endif
 	
 	if (RunQuery(query, strlen(query), errbuf, &result))
 	{
@@ -237,7 +251,11 @@
 		while((row = mysql_fetch_row(result)))
 		{
 			Spawn2* newSpawn = 0;
+#ifdef CRIPP_Z
+			newSpawn = new Spawn2(atoi(row[0]), atoi(row[1]), atof(row[2]), atof(row[3]), atof(row[4]), atof(row[5]), atoi(row[6]), atoi(row[7]), atoi(row[9]), atoi(row[8]), atoi(row[10]), atoi(row[11]), atoi(row[12]));
+#else
 			newSpawn = new Spawn2(atoi(row[0]), atoi(row[1]), atof(row[2]), atof(row[3]), atof(row[4]), atof(row[5]), atoi(row[6]), atoi(row[7]), atoi(row[9]), atoi(row[8]), atoi(row[10]), atoi(row[11]));
+#endif
 			//newSpawn->Repop(repopdelay);
 			spawn2_list.Insert( newSpawn );
 		}
@@ -260,12 +278,20 @@
 	MYSQL_RES *result;
 	MYSQL_ROW row;
 
+#ifdef CRIPP_Z
+	if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, spawngroupID, x, y, z, heading, respawntime, variance, pathgrid, _condition, cond_value, fixZ FROM spawn2 WHERE id=%i", spawn2id), errbuf, &result))
+#else
 	if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, spawngroupID, x, y, z, heading, respawntime, variance, pathgrid, _condition, cond_value FROM spawn2 WHERE id=%i", spawn2id), errbuf, &result))
+#endif
 	{
 		if (mysql_num_rows(result) == 1)
 		{
 			row = mysql_fetch_row(result);
+#ifdef CRIPP_Z
+			Spawn2* newSpawn = new Spawn2(atoi(row[0]), atoi(row[1]), atof(row[2]), atof(row[3]), atof(row[4]), atof(row[5]), atoi(row[6]), atoi(row[7]), timeleft, atoi(row[8]), atoi(row[9]), atoi(row[10]), atoi(row[11]));
+#else
 			Spawn2* newSpawn = new Spawn2(atoi(row[0]), atoi(row[1]), atof(row[2]), atof(row[3]), atof(row[4]), atof(row[5]), atoi(row[6]), atoi(row[7]), timeleft, atoi(row[8]), atoi(row[9]), atoi(row[10]));
+#endif
 			spawn2_list.Insert( newSpawn );
 			mysql_free_result(result);
 			safe_delete_array(query);
Code:
--- spawn2.h	2006/06/20 02:36:21	1.2
+++ spawn2.h	2007/12/19 18:08:40	1.3
@@ -35,7 +35,11 @@
 		float x, float y, float z, float heading, 
 		int32 respawn, int32 variance, 
 		int32 timeleft = 0, int32 grid = 0,
+#ifdef CRIPP_Z
+		uint16 cond_id = SC_AlwaysEnabled, sint16 min_value = 0, sint16 fixZhop = 1);
+#else
 		uint16 cond_id = SC_AlwaysEnabled, sint16 min_value = 0);
+#endif
 	~Spawn2();
 
 	void	LoadGrid();
@@ -74,6 +78,9 @@
 	int32	grid_;
 	uint16	condition_id;
 	sint16	condition_min_value;
+#ifdef CRIPP
+	sint16	FixedZ;
+#endif
 };
 
 class SpawnCondition {
Code:
--- waypoints.cpp	2007/12/01 18:11:14	1.7
+++ waypoints.cpp	2007/12/19 18:08:40	1.8
@@ -670,7 +670,9 @@
 					newwp.x = atof(row[0]);
 					newwp.y = atof(row[1]);
 					newwp.z = atof(row[2]);

 					if(zone->map != NULL && RuleB(Map, FixPathingZWhenLoading) ) {
 						// Experimental. This code will send any waypoint that is 'in the air' down to ground level.
 	
@@ -685,14 +687,17 @@
 							float newz = zone->map->FindBestZ(n, dest, NULL, NULL);
 							// The following test is a sanity check. 45 is an arbitrary value, chosen during testing
 							// because all the Z co-ordinates of the waypoints in The Grey where <45 units above the ground.
 							if( (newz > -2000) && ABS(newz-dest.z) < RuleR(Map, FixPathingZMaxDeltaLoading)) {
#ifdef CRIPP_Z
 								if (fixz != 0) {
#endif
 								newwp.z = newz+1;
 								// printf("Updated Z for Grid %d, Waypoint %d from %.3f to %.3f\n",  grid, newwp.index,dest.z,newwp.z);
#ifdef CRIPP_Z
 								}
#endif
 							}
 							//else if(newz > -2000) 
 							//	printf("Delta Z %.3f too big for Grid %d, Waypoint %d from %.3f to %.3f\n", ABS(newz-dest.z), grid, newwp.index,dest.z,newz);
 						}
 					}
 
 					newwp.pause = atoi(row[3]);
 					Waypoints.push_back(newwp);
added definition CRIPP_Z to toggle to default or not... just incase it didnt work.. but i tested once and it seemed to work..

let me know

EDIT:: forgot.. you have to add column in spawn2 table... fixZ tinyint[4] 0 no null default 1
__________________
Nug Blazers - ServerOP / founder
^^comming... later!

www.nugblazers.com

Last edited by Cripp; 12-19-2007 at 11:13 PM..
Reply With Quote
  #6  
Old 12-19-2007, 08:19 AM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

Sweet! I'll try this out on my test box when I get home.
Reply With Quote
  #7  
Old 12-19-2007, 08:20 AM
Bishop4351
Sarnak
 
Join Date: Sep 2006
Location: Texas
Posts: 49
Default

Mental note to install EQ at work for "testing".
Reply With Quote
  #8  
Old 12-19-2007, 08:52 AM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

Quote:
Originally Posted by cavedude View Post
As for mobs in the water... there currently is no way for us to tell where water exists in the map.
I found this old post by Windcatcher:

http://www.eqemulator.net/forums/sho...highlight=.wld

Which talks about how water/lava region information is stored in the zone S3D file. Maybe with this, along with the OpenZone source code, and the .WLD reference linked here:

http://www.eqemulator.net/forums/sho...highlight=.wld

I might be able to figure out how to extract this information from the S3D into a format that can be loaded and used in the emulator. I'll give it a shot.
Reply With Quote
  #9  
Old 12-19-2007, 09:25 AM
narcberry
Sarnak
 
Join Date: Mar 2005
Location: Idaho, USA
Posts: 94
Default

Or instead of doing it right you could hack the solution. "Fix it quick now so we can fix it again later", that's always been my motto:

Apply fixz code only to mobs whose previous position conformed to the fixz code. IE, mobs that start on the ground stay on the ground. Mobs that start out on rocks or swimming are left alone.


Okay, I'll shut up now. Oh, and awesome work.
Reply With Quote
  #10  
Old 12-19-2007, 12:50 PM
Cripp's Avatar
Cripp
Discordant
 
Join Date: Oct 2003
Location: The Shire
Posts: 474
Default

did a little more testing.. and i guess my little fix can only disable fixZ for the whole zone because...

float newz = zone->map->FindBestZ(n, dest, NULL, NULL);

...it loads the bestZ for the whole zone not just the mob i guess..


gonna try it with FixZWhenLoading disables and on SendTo/onWayPoints enabled..

might have to add a few more checks in waypoints.cpp too.. ill keep posted.
__________________
Nug Blazers - ServerOP / founder
^^comming... later!

www.nugblazers.com

Last edited by Cripp; 12-19-2007 at 08:57 PM..
Reply With Quote
  #11  
Old 12-21-2007, 07:43 AM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

Quote:
Originally Posted by cavedude View Post
As for mobs in the water... there currently is no way for us to tell where water exists in the map.

I spent a couple of days working on the water detection and it's looking good (albeit frustrating
at times working with the WLD data!).

I modified Azone to build the BSP tree from the 0x21 fragment as well as process the 0x22 and 0x29 region
fragments. I then wrote a function which given hard-coded X,Y,Z co-ordinates would walk the BSP tree to
the leaf node those co-ordinates are in and return whether or not the co-ordinates are in a special region (water, lava).

I then transplanted the code into Daeken's Openeq (aka freaku) source so I could fly around
zones and test it better with a visual on-screen indication of whether the code thought I was under water.
It seems to work well (I would say flawlessly, but it needs more testing).

Next step is to optimise it/tidy up the code , mod azone to write out a 'water map' file and then put some code
into EQEmu to make use of it. This could be used for fishing quite easily by projecting forward and down from
the player and testing whether the hypothetical end of the fishing line is under water.

One thing I noticed is that although some zone files have the 'special regions' flagged as either water
or lava, some don't, so I will probably have to make azone accept another parameter telling it whether
to mark the regions as water or lava by default if there is no indication in the WLD file of what the region
is.

I have only tested zones in S3d format so far, so I don't know whether this can be adapted to work with newer zones in EQG format.
Reply With Quote
  #12  
Old 12-22-2007, 08:13 AM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default Water / Lava Detection

Well, the creation of the 'water maps' by azone and the processing of them in the emulator is done. I modified the existing #bestz command to tell you whether the code thinks you are in water/lava or nowhere special (on the ground) for debugging purposes:

Ground


Water



Lava



I modified waypoints.cpp to not use BestZ when the mobs where in water or headed to a point in water, but they are still hopping in the Cauldron. Not sure why that is, but I will look into further to see whether it is fixable in code.

If it isn't, I'll post what I've done anyway, as I'm sure it will come in handy for fishing at least!
Reply With Quote
  #13  
Old 12-22-2007, 09:25 AM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

I've been waiting for this for ages, top notch work!
Reply With Quote
  #14  
Old 12-23-2007, 08:50 AM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

Quote:
Originally Posted by Angelox View Post
Cavedude had mentioned one temporary solution was to give the swimmers the levitation spell - This keeps them steady at what ever grid they are on.
I only just realised what a problem pathing in water was, even without the BestZ code. I.e. the client appears to make all the mobs sink to the bottom of the water. You can see this in powater at -232.25,-699.5,-98.125 ... mobs being put in a particular spot by the server, then sinking, and then popping up again when the server sends the next movement update.

I added an extra field to the Mob class, inWater, initialised to false. In the waypoint movement routine, I put a check to see if the mob is underwater and it wasn't previosly (Mob->inWater==false). If this is the case, it puts flymode 1 on the mob and sets Mob->inWater=true.

Likewise if the mob is not in water when it was on the last check, it turns the flymode off.

This seems to help in Powater and Kedge. The mobs hop once after the zone is loaded until they pass through the waypoint routine the first time, and then they swim as they should without the client making them sink. It won't help with static mobs which aren't on grids. They will just spawn and fall to the bottom and stay there. I guess I could put some code in the NPC spawn routine to check if they are in water and turn the flymode 1 on at that point. This would work for the static spawns and stop the initial hop for the wanderers.

I don't know whether there is any downside to doing this. Needs more testing. I wonder how the live servers handle it?
Reply With Quote
  #15  
Old 12-23-2007, 10:17 AM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

I had a PM about when I am going to release these changes I have been working on. I will put something out this week. It may not be in a form that is ready for merging into CVS, but at least it will give people who are interested a chance to test the changes and report on any issues etc.
Reply With Quote
Reply


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 04:31 PM.


 

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