|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days. |
|
|
|
07-17-2004, 12:00 PM
|
Hill Giant
|
|
Join Date: Oct 2002
Posts: 212
|
|
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
|
|
|
|
07-17-2004, 01:33 PM
|
Demi-God
|
|
Join Date: May 2004
Posts: 1,177
|
|
I hope we can finally get this into the Official CVS. it's frustrating having to redo this every release. =(
|
07-17-2004, 03:15 PM
|
Hill Giant
|
|
Join Date: Jul 2004
Posts: 206
|
|
Good Work
Sandy,
__________________
Dont change my profile faget.....
|
07-17-2004, 04:19 PM
|
|
Demi-God
|
|
Join Date: Mar 2003
Location: USA
Posts: 1,067
|
|
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...
|
07-17-2004, 06:54 PM
|
Demi-God
|
|
Join Date: May 2004
Posts: 1,177
|
|
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
|
07-17-2004, 08:44 PM
|
Sarnak
|
|
Join Date: Jan 2002
Location: France
Posts: 58
|
|
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
|
07-17-2004, 10:00 PM
|
|
Demi-God
|
|
Join Date: Mar 2003
Location: USA
Posts: 1,067
|
|
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...
|
07-17-2004, 11:19 PM
|
Sarnak
|
|
Join Date: Jan 2002
Location: France
Posts: 58
|
|
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 ?
|
07-20-2004, 09:05 AM
|
Hill Giant
|
|
Join Date: Oct 2002
Posts: 212
|
|
yes scorpious i think it have to be completed with the last commands you created to edit grids ingame and for quests =)
__________________
Sandy
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 01:08 AM.
|
|
|
|
|
|
|
|
|
|
|
|
|