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

Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days.

Reply
 
Thread Tools Display Modes
  #1  
Old 07-17-2004, 12:00 PM
sandy
Hill Giant
 
Join Date: Oct 2002
Posts: 212
Default 2 grids system

Here is the 2 grids table system I have done
not sure if lines correspond exactly =(

in database.h :

line 117 :

add this :

Code:
struct wplist {
	int   index;
	float x;
	float y;
	float z;
	int	  pause;
};
line 404 :

replace by this :

Code:
	void	ModifyGrid(bool remove, int16 id, int8 type = 0, int8 type2 = 0,int16 zoneid = 0);
	void	ModifyWP(int16 grid_id, int16 wp_num, float xpos, float ypos, float zpos, int32 script=0,int16 zoneid =0);
	int8	GetGridType(int16 grid,int16 zoneid);
	int8	GetGridType2(int16 grid,int16 zoneid);
	bool	GetWaypoints(int16 grid, int16 zoneid, int16 num, wplist* wp);
	void	AssignGrid(Client *client, float x, float y, int32 id);
in database.cpp :

add the functions :

Code:
int8 Database::GetGridType(int16 grid,int16 zoneid ) {
    char *query = 0;
	char errbuf[MYSQL_ERRMSG_SIZE];
    MYSQL_RES *result;
    MYSQL_ROW row;
	int type = 0;
	if (RunQuery(query, MakeAnyLenString(&query,"SELECT type from grid where id = %i and zoneid = %i",grid,zoneid),errbuf,&result)) {
		safe_delete_array(query);
		if (mysql_num_rows(result) == 1) {
			row = mysql_fetch_row(result);
			type = atoi( row[0] );
		}
		mysql_free_result(result);
	} else {
		cerr << "Error in GetGridType query '" << query << "' " << errbuf << endl;
		safe_delete_array(query);
	}
	return type;
}

int8 Database::GetGridType2(int16 grid,int16 zoneid ) {
    char *query = 0;
	char errbuf[MYSQL_ERRMSG_SIZE];
    MYSQL_RES *result;
    MYSQL_ROW row;
	int type2 = 0;
	if (RunQuery(query, MakeAnyLenString(&query,"SELECT type2 from grid where id = %i and zoneid = %i",grid,zoneid),errbuf,&result)) {
		safe_delete_array(query);
		if (mysql_num_rows(result) == 1) {
			row = mysql_fetch_row(result);
			type2 = atoi( row[0] );
		}
		mysql_free_result(result);
	} else {
		cerr << "Error in GetGridType2 query '" << query << "' " << errbuf << endl;
		safe_delete_array(query);
	}
	return type2;
}
replace all these functions by :

Code:
bool Database::GetWaypoints(int16 grid,int16 zoneid, int16 num, wplist* wp) {
    char *query = 0;
	char errbuf[MYSQL_ERRMSG_SIZE];
    MYSQL_RES *result;
    MYSQL_ROW row;
	if (RunQuery(query, MakeAnyLenString(&query,"SELECT x, y, z, pause from grid_entries where gridid = %i and number = %i and zoneid = %i",grid,num,zoneid),errbuf,&result)) {
		safe_delete_array(query);
		if (mysql_num_rows(result) == 1) {
			row = mysql_fetch_row(result);
			if ( wp ) {
				wp->index = num;
				wp->x = atof( row[0] );
				wp->y = atof( row[1] );
				wp->z = atof( row[2] );
				wp->pause = atoi( row[3] );
			}
			mysql_free_result(result);
			return true;
		}
		mysql_free_result(result);
	}
	else {
		cerr << "Error in GetWaypoints query '" << query << "' " << errbuf << endl;
		safe_delete_array(query);
	}
	return false;
}

void Database::ModifyGrid(bool remove, int16 id, int8 type, int8 type2, int16 zoneid)
{
    char *query = 0;
	if (!remove)
	{
		RunQuery(query, MakeAnyLenString(&query,"UPDATE grid SET type=%i, type2=%i WHERE id=%i and zoneid=%i)",type,type2,id,zoneid));
		safe_delete_array(query);
	}
	else
	{
		RunQuery(query, MakeAnyLenString(&query,"DELETE FROM grid where id=%i",id));
		safe_delete_array(query);
	}
}

void Database::ModifyWP(int16 grid_id, int16 wp_num, float xpos, float ypos, float zpos, int32 script, int16 zoneid)

{
    char *query = 0;
	RunQuery(query, MakeAnyLenString(&query,"UPDATE grid_entries set x=%f, y=%f, z=%f, pause=%i where id = %i and zoneid = %i and number = %i",xpos,ypos,zpos,script,grid_id,zoneid,wp_num));
	safe_delete_array(query);
}

void Database::DeleteGrid(int32 sg2, int16 grid_num, bool grid_too, int16 zoneid)
{
	char *query=0;
	RunQuery(query, MakeAnyLenString(&query,"insert into spawn2 set pathgrid='0' where spawngroupID='%i'", sg2));
	query = 0;
	if (grid_too) {
	RunQuery(query, MakeAnyLenString(&query,"delete from grid where id='%i' and zoneid = %i", grid_num,zoneid));
		query = 0;
		RunQuery(query, MakeAnyLenString(&query,"delete from grid_entries where gridid='%i' and zoneid = %i", grid_num,zoneid));
		query = 0;
	}
}

void Database::DeleteWaypoint(int16 grid_num, int32 wp_num, int16 zoneid)
{
	char *query=0;
	RunQuery(query, MakeAnyLenString(&query,"delete from grid_entries where gridid='%i' and zoneid = %i and number = %i", grid_num,zoneid, wp_num));
	query = 0;
}
in mobai.cpp :

line 1320 :

replace by :

Code:
 	int16 ranmax = cur_wp;
	int16 ranmax2 = max_wp - cur_wp;
replace the function Mob::AssignWaypoints by :

Code:
void Mob::AssignWaypoints(int16 grid)
{
	Waypoints.ClearListAndData();
#ifdef _EQDEBUG
	cout<<"Assigning waypoints for grid "<<grid<<" to "<<name<<"...\n";
#endif
	if (!database.GetWaypoints(grid,zone->GetZoneID(), 1, NULL))
		return;
	wandertype = database.GetGridType( grid,zone->GetZoneID() );
	pausetype = database.GetGridType2( grid,zone->GetZoneID() );

	adverrorinfo = 7561;
	this->CastToNPC()->SetGrid(grid); //Assign grid number
	roamer = true; //This is a roamer
	wplist* wpstruct = new wplist;

	int i = 1;
	while ( database.GetWaypoints(grid,zone->GetZoneID(), i, wpstruct)) {
				wplist * newwp = new wplist;
				adverrorinfo = 7564;
		newwp->x	 = wpstruct->x;
		newwp->y	 = wpstruct->y;
		newwp->z	 = wpstruct->z;
		newwp->pause = wpstruct->pause;
		newwp->index = i-1;
		i++;

				if (newwp->x && newwp->y && newwp->z) {
					max_wp		 = newwp->index;
					Waypoints.AddItem(newwp);
				}
			}

		 UpdateWaypoint(0); 
         SetWaypointPause(); 

	safe_delete( wpstruct );

#ifdef _EQDEBUG
	cout<<" done."<<endl;
#endif
			adverrorinfo = 7565;
//			UpdateWaypoint(0);
			this->SendTo(cur_wp_x, cur_wp_y, cur_wp_z);
	if (wandertype == 1 || wandertype == 2)
		CalculateNewWaypoint();
}
here's the sql tables :

Code:
#
# Structure de la table `grid`
#

CREATE TABLE `grid` (
  `id` int(10) NOT NULL default '0',
  `zoneid` int(10) NOT NULL default '0',
  `type` int(10) NOT NULL default '0',
  `type2` int(10) NOT NULL default '0',
  KEY `zoneid` (`zoneid`),
  KEY `id` (`id`)
) TYPE=MyISAM;

# --------------------------------------------------------

#
# Structure de la table `grid_entries`
#

CREATE TABLE `grid_entries` (
  `gridid` int(10) NOT NULL default '0',
  `zoneid` int(10) NOT NULL default '0',
  `number` int(10) NOT NULL default '0',
  `x` float NOT NULL default '0',
  `y` float NOT NULL default '0',
  `z` float NOT NULL default '0',
  `heading` float NOT NULL default '0',
  `pause` int(10) NOT NULL default '0',
  KEY `number` (`number`),
  KEY `gridid` (`gridid`),
  KEY `zoneid` (`zoneid`)
) TYPE=MyISAM;
__________________
Sandy
Reply With Quote
  #2  
Old 07-17-2004, 12:58 PM
govtcheeze
Hill Giant
 
Join Date: Mar 2004
Location: South Florida
Posts: 247
Default

The grid converter is at:

http://govtcheeze.eqemulator.net/download/

and download the file called updateGrids.rar
__________________
GovtCheeze, Welfare Warrior
"Listen, here's the thing. If you can't spot the sucker in the first half hour at the table, then you ARE the sucker." -- Mike McDermott, Rounders

Developer of the original (circa 2004):
Loots v2.0, bitch!
Faction v1.0, bitch!
Magelo-like clone v0.3, bitch!
Zone geometry and spawn/path viewer, bitch!
Reply With Quote
  #3  
Old 07-17-2004, 01:33 PM
sotonin
Demi-God
 
Join Date: May 2004
Posts: 1,177
Default

I hope we can finally get this into the Official CVS. it's frustrating having to redo this every release. =(
Reply With Quote
  #4  
Old 07-17-2004, 03:15 PM
Zkhava
Hill Giant
 
Join Date: Jul 2004
Posts: 206
Default

Good Work


Sandy,
__________________
Dont change my profile faget.....
Reply With Quote
  #5  
Old 07-17-2004, 04:19 PM
Scorpious2k's Avatar
Scorpious2k
Demi-God
 
Join Date: Mar 2003
Location: USA
Posts: 1,067
Default

I haven't merged this in yet, because I believe, looking at the code, the #wp command will quit working. I need to change and test before it goes into cvs.
__________________
Maybe I should try making one of these servers...
Reply With Quote
  #6  
Old 07-17-2004, 06:54 PM
sotonin
Demi-God
 
Join Date: May 2004
Posts: 1,177
Default

awesome. ) it's good to see it's finally being dealt with though.

The pathing just has way more potential for detail with the 2 grid system
Reply With Quote
  #7  
Old 07-17-2004, 08:44 PM
Minuss
Sarnak
 
Join Date: Jan 2002
Location: France
Posts: 58
Default

Great, I cant wait to test it
Now that we are talking about waypoints, could you please, if it don't take too much time, add a command that allow to check the waypoint number the npc is currently walking on or heading on, so we can trigger events when he reaches this waypoint.
This'd help me for a lot of my quests...
Thanks
Reply With Quote
  #8  
Old 07-17-2004, 10:00 PM
Scorpious2k's Avatar
Scorpious2k
Demi-God
 
Join Date: Mar 2003
Location: USA
Posts: 1,067
Default

Is event waypoint broken? The $wp variable should contain the current waypoint number during an event waypoint.
__________________
Maybe I should try making one of these servers...
Reply With Quote
  #9  
Old 07-17-2004, 11:19 PM
Minuss
Sarnak
 
Join Date: Jan 2002
Location: France
Posts: 58
Default

Last time I tried something like this :
Code:
sub EVENT_WAYPOINT
{
 if($wp == 10)
 {
  quest::say("Hey I'm at wp 10");
 }

 elsif($wp == 15)
 {
  quest::say("Hey I'm at wp 15);
 }
}
it was not working... Any idea ?
Reply With Quote
  #10  
Old 07-20-2004, 09:05 AM
sandy
Hill Giant
 
Join Date: Oct 2002
Posts: 212
Default

yes scorpious i think it have to be completed with the last commands you created to edit grids ingame and for quests =)
__________________
Sandy
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 10:54 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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3