Thread: grids
View Single Post
  #8  
Old 02-27-2004, 03:15 PM
smogo
Discordant
 
Join Date: Jan 2004
Location: 47
Posts: 339
Default

That was clear from your post, and i didn't disagree.


What i meant is that pathing is a solution for mob displacement, that we experience the limits of.
Let's change it, fine.
So we must try to think of everything involved.

http://www.eqemulator.net/forums/vie...highlight=path
http://www.eqemulator.net/forums/vie...highlight=path
http://www.eqemulator.net/forums/vie...highlight=path
to mention only a few threads already discussed.

*** added ***
i was curious about tweaking the code. Below are changes according to the discussion. It may work (i need to sleep now, so just made the changes, compiled, but no testing whatsoever, not even running). It may not work.

- did not update the commands, you must edit the DB by hand.
- no starting point stuff. There is still something i can't figure out : how does the mob get from spawn point to the first waypoint ? There more to discuss about this.

below are the diffs as of feb 23 cvs

Code:
--- ./../common/_database.cpp   2004-02-28 04:51:14.000000000 +0000
+++ ../common/database.cpp      2004-02-28 06:08:24.000000000 +0000
@@ -4875,14 +4875,23 @@

 bool Database::GetWaypoints(int16 grid, int8 num, char* data) {
     char *query = 0;
+               char *qstr = 0;
        char errbuf[MYSQL_ERRMSG_SIZE];
     MYSQL_RES *result;
     MYSQL_ROW row;
-       if (RunQuery(query, MakeAnyLenString(&query,"SELECT type,type2,wp1,wp2,w
p3,wp4,wp5,wp6,wp7,wp8,wp9,wp10,wp11,wp12,wp13,wp14,wp15,wp16,wp17,wp18,wp19,wp2
0,wp21,wp22,wp23,wp24,wp25,wp26,wp27,wp28,wp29,wp30,wp31,wp32,wp33,wp34,wp35,wp3
6,wp37,wp38,wp39,wp40,wp41,wp42,wp43,wp44,wp45,wp46,wp47,wp48,wp49,wp50 from gri
d where id = %i",grid),errbuf,&result)) {
+               switch( num ){
+                       case 0:
+                               qstr="select type from grid where id=%i";
+                       case 1:
+                               qstr="select type2 from grid where id=%i";
+                       default:
+                               qstr="select concat(x," ",y," ",z," ",pause) fro
m waypoints where grid_id=%i and num=%i";
+               }
+       if (RunQuery(query, MakeAnyLenString(&query,qstr,grid,num-1),errbuf,&res
ult)) {
                safe_delete_array(query);
                if (mysql_num_rows(result) == 1) {
                        row = mysql_fetch_row(result);
-                       strcpy(data, row[num]);
+                       strcpy(data, row[0]);
                        mysql_free_result(result);
                        return true;
                }
Code:
--- _MobAI.cpp  2004-02-28 04:51:44.000000000 +0000
+++ MobAI.cpp   2004-02-28 06:13:12.000000000 +0000
@@ -1203,6 +1203,16 @@
                        cur_wp = cur_wp + 1;
                break;
 // end Myra
+// KD reverse
+    case 5:
+                 if(reached_beginning){
+                               cur_wp = max_wp;
+                       }else{
+                               cur_wp = cur_wp - 1;
+                       }
+               break;
+// end KD
+
        }
        // Check to see if we need to update the waypoint. - Wes
        if (cur_wp != old_wp)
@@ -1430,18 +1440,20 @@
        adverrorinfo = 7561;
        this->CastToNPC()->SetGrid(grid); //Assign grid number
        roamer = true; //This is a roamer
-       for (int i=0; i < 52; i++) {
+       for (int i=0; i >=0; i++) {
                adverrorinfo = 7562;
                char wpstruct[100];
                if (!database.GetWaypoints(grid, i, wpstruct))
-                       i=53;
+                       i=-1;
                else {
-                       if (i < 2) {
-                               adverrorinfo = 7563;
-                               //wp_a[i+1] = atoi(wpstruct); //Assign wandering
 type and pause type
-                               ((i==0) ? wandertype : pausetype) = atoi(wpstruc
t);
+                       switch (i){
+                               case 0:{
+                                 wandertype = atoi(wpstruct); break;
                        }
-                       else { //Retrieve a waypoint
+                               case 1:{
+                                 pausetype = atoi(wpstruct); break;
+                               }
+                               default:{
                                wplist * newwp = new wplist;
                                adverrorinfo = 7564;
                                Seperator sep(wpstruct, ' ', 4);
@@ -1456,6 +1468,7 @@
                                        Waypoints.AddItem(newwp);
                                }
                        }
+               }

                 UpdateWaypoint(0);
          SetWaypointPause();
plus some stuff to the DB
Code:
-- create waypoints table
-- no index defined (should be on grid_id and num presumbly)
create table waypoints (
  grid_id int(10),
  num int(10),
  x float,
  y float,
  z float,
  pause int(10));
-- extra columns not dropped


insert into waypoints values(1064 , 1 , -324.0 ,-987.0 , -54.0 , 5);
insert into waypoints values(1064 , 1 , -710.0 ,-883.0 , -54.0 , 5);
insert into waypoints values(1064 , 1 , -899.0 ,-1308.0 , -54.0 , 5);
insert into waypoints values(1064 , 1 , -159.0 ,-1658.0 , -54.0 , 5);

-- wandertype
update grid set type=5 where grid_id=1064;
the waypoints are valid for freporte.Wandertype 5 is new reverse mode.

If you want to give it a try...
Reply With Quote