Custom drops code (prequel to custom events)

If you want to help us or give some corrections / codes, put it here ;)

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Re: Custom drops code (prequel to custom events)

Postby PurpleYouko on Thu Oct 16, 2008 2:07 pm

Did you also edit the structure definitions in CNPCdata ?

if you didn't then those members will not exist.
That will most definitely cause a crash at that point.

As it happens, in later versions i have dropped newnpc->side and newnpc->sidechance altogether since the side drops are controlled from the AIP code.
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: Custom drops code (prequel to custom events)

Postby Drakia on Thu Oct 16, 2008 3:08 pm

Make sure you do a rebuild all, and not just a standard build once you add the code.
My favorite skill is scaring new users away.
If you haven't SEARCHED expect me to yell at you.
Image
Drakia
ospRose dev team
ospRose dev team
 
Posts: 1614
Joined: Tue Sep 18, 2007 6:53 am
Location: Nanaimo, BC, Canada

Re: Custom drops code (prequel to custom events)

Postby Zell Dinch on Thu Oct 16, 2008 3:14 pm

I rebuilt all!
@PY: Well.. I added structure definitions in CNPCdata. Anyways, could you post your new codes?
Zell Dinch
Smoulie
Smoulie
 
Posts: 44
Joined: Wed Sep 26, 2007 5:45 pm

Re: Custom drops code (prequel to custom events)

Postby PurpleYouko on Thu Oct 16, 2008 4:48 pm

Zell Dinch wrote:I rebuilt all!
@PY: Well.. I added structure definitions in CNPCdata. Anyways, could you post your new codes?


Its all in the osprose svn source.
I used the same drops system in there. Slightly updated and modified. ;)

most of it is in the osirose svn too. i don't think Arnold has been following teh minor revisions that i keep making though so it is probably an earlier version.
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: Custom drops code (prequel to custom events)

Postby Zell Dinch on Thu Oct 16, 2008 6:04 pm

Hey, i found that you use mobgroups table in nowhere, so why did it exist in the db files?
Zell Dinch
Smoulie
Smoulie
 
Posts: 44
Joined: Wed Sep 26, 2007 5:45 pm

Re: Custom drops code (prequel to custom events)

Postby PurpleYouko on Thu Oct 16, 2008 6:39 pm

Zell Dinch wrote:Hey, i found that you use mobgroups table in nowhere, so why did it exist in the db files?


Don't know where you got that idea from.
We load the data into a vector in startup.cpp
  1.  
  2. bool CWorldServer::LoadMobGroups() {
  3.   if(GServer->Config.SpawnType == 0)
  4.   {
  5.       Log(MSG_LOAD, "MobGroups data    " );
  6.       vector<CMobGroup*> mobGroups;
  7.       MYSQL_ROW row;
  8.       bool flag = true;
  9.       char* tmp = NULL;
  10.       MYSQL_RES *result = DB->QStore("SELECT id, map, x, y, range, respawntime, `limit`, tacticalpoints, moblist FROM list_mobgroups");
  11.       if (result == NULL) return false;
  12.       while (row = mysql_fetch_row(result))
  13.       {
  14.         CMobGroup* thisgroup = new (nothrow) CMobGroup;
  15.         if (thisgroup == NULL) {
  16.           Log(MSG_ERROR, "Error allocating memory");
  17.           DB->QFree();
  18.           return false;
  19.         }
  20.         thisgroup->id = atoi(row[0]);
  21.         thisgroup->map = atoi(row[1]);
  22.         thisgroup->point.x = atof(row[2]);
  23.         thisgroup->point.y = atof(row[3]);
  24.         thisgroup->range = atoi(row[4]);
  25.         thisgroup->respawntime = atoi(row[5]);
  26.         thisgroup->limit = atoi(row[6]);
  27.         thisgroup->tacticalpoints = atoi(row[7]);
  28.         char* mobList = row[8];
  29.    
  30.         thisgroup->lastRespawnTime = clock();
  31.         thisgroup->active = 0;
  32.         thisgroup->basicKills = 0;
  33.         thisgroup->curTac = 0;
  34.         thisgroup->curBasic = 0;
  35.    
  36.         thisgroup->basicMobs.clear();
  37.         thisgroup->tacMobs.clear();
  38.    
  39.         // Fill in basic/tac mobs
  40.         tmp = strtok(mobList, ",|");
  41.         while (tmp != NULL) {
  42.           int mobId = atoi(tmp);
  43.           tmp = strtok(NULL, ",|");
  44.           if (tmp == NULL) {
  45.             Log(MSG_ERROR, "MobGroup %i is invalid", thisgroup->id);
  46.             flag = false;
  47.             break;
  48.           }
  49.           int amount = atoi(tmp);
  50.           tmp = strtok(NULL, ",|");
  51.           if (tmp == NULL) {
  52.             Log(MSG_ERROR, "MobGroup %i is invalid", thisgroup->id);
  53.             flag = false;
  54.             break;
  55.           }
  56.           int tactical = atoi(tmp);
  57.           CMob *thismob = new (nothrow) CMob;
  58.           if (thismob == NULL) {
  59.             Log(MSG_ERROR, "Error allocating memory");
  60.             DB->QFree();
  61.             return false;
  62.           }
  63.           thismob->amount = amount;
  64.           thismob->tactical = (unsigned int)tactical/2;
  65.           thismob->mobId = mobId;
  66.           thismob->thisnpc = GetNPCDataByID( thismob->mobId );
  67.           thismob->mapdrop = GetDropData( thisgroup->map ); //hmm. We don't even use these drops anymore
  68.           thismob->mobdrop = GetDropData( thismob->thisnpc->dropid );
  69.           if (thismob->thisnpc == NULL) {
  70.             Log(MSG_WARNING, "Invalid mobId - Mob %i will not be added", atoi(row[0]));
  71.             delete thismob;
  72.             continue;
  73.           }
  74.           if (thismob->tactical)
  75.             thisgroup->tacMobs.push_back(thismob);
  76.           else
  77.             thisgroup->basicMobs.push_back(thismob);
  78.           tmp = strtok(NULL, ",|");
  79.         }
  80.         if (!flag) {
  81.           delete thisgroup;
  82.           continue;
  83.         }
  84.         MapList.Index[thisgroup->map]->MobGroupList.push_back(thisgroup);
  85.         mobGroups.push_back(thisgroup);
  86.         }
  87.         DB->QFree( );
  88.     }
  89.     return true;
  90. }

Then we use the vector to do every single spawn in the game.
I dunno about you but i would definitely call that using it. :lol:
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: Custom drops code (prequel to custom events)

Postby Drakia on Thu Oct 16, 2008 10:31 pm

I wrote it, I designed it, it's definitely in use ;)
My favorite skill is scaring new users away.
If you haven't SEARCHED expect me to yell at you.
Image
Drakia
ospRose dev team
ospRose dev team
 
Posts: 1614
Joined: Tue Sep 18, 2007 6:53 am
Location: Nanaimo, BC, Canada

Re: Custom drops code (prequel to custom events)

Postby Zell Dinch on Fri Oct 17, 2008 5:38 am

There is nowhere i can found the LoadMobGroups in OsRose rev80, as well as the codes that you posted in this topic. So that why I asked you.
Zell Dinch
Smoulie
Smoulie
 
Posts: 44
Joined: Wed Sep 26, 2007 5:45 pm

Re: Custom drops code (prequel to custom events)

Postby rl2171 on Fri Oct 17, 2008 5:41 am

Zell Dinch wrote:There is nowhere i can found the LoadMobGroups in OsRose rev80, as well as the codes that you posted in this topic. So that why I asked you.


The MObGroups dont exist in osRose rev80, but will in the upcoming osRose rev81.
Image
rl2171
Admin
Admin
 
Posts: 1706
Joined: Mon Aug 06, 2007 5:17 pm
Location: Sacramento, CA USA - GMT-8

Re: Custom drops code (prequel to custom events)

Postby Zell Dinch on Fri Oct 17, 2008 5:51 am

That's why i asked you 'bout mobgroups. You included the mobgroups table in db files , however there's nowhere loads those records. I wondered if mobgroups code is a requirement for PYDrops?
Zell Dinch
Smoulie
Smoulie
 
Posts: 44
Joined: Wed Sep 26, 2007 5:45 pm

PreviousNext

Return to Submit Code

Who is online

Users browsing this forum: No registered users and 4 guests