- else if (strcmp(command, "spawn")==0)
- {
- if(Config.Command_Spawn > thisclient->Session->accesslevel)
- return true;
- int spawnid;
- int mobid;
- int mobcount;
- int interval;
- int radius;
- if ((tmp = strtok(NULL, " "))==NULL)
- return true;
- else
- spawnid = atoi(tmp);
- if ((tmp = strtok(NULL, " "))==NULL)
- return true;
- else
- mobid = atoi(tmp);
- if ((tmp = strtok(NULL, " "))==NULL)
- return true;
- else
- mobcount = atoi(tmp);
- if ((tmp = strtok(NULL, " "))==NULL)
- return true;
- else
- interval = atoi(tmp);
- if ((tmp = strtok(NULL, " "))==NULL)
- return true;
- else
- radius = atoi(tmp);
- GServer->DB->QExecute("INSERT INTO spawns (spawnid,mapname,mapid,spawn_interval,mob_limit,radius,tactic,pos_x,pos_y,spawn_x,spawn_y,special,bmob1,bcount1,bmob2,bcount2,bmob3,bcount3,bmob4,bcount4,bmob5,bcount5,tmob1,tcount1,tmob2,tcount2,dir)
- VALUES(%i,%i,%i,%i,%i,%i,%i,%i,%i,%f,%f,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,)",
- spawnid,NULL,thisclient->Position->Map, interval, 20, radius, 200,0,0,thisclient->Position->current.x,thisclient->Position->current.y,0,mobid,mobcount,mobid,mobcount,mobid,mobcount,mobid,mobcount,mobid,mobcount,0,0,0,0,0);
I would like to revise the mob groups - I just want to keep track of all the mobs there is - of my server.
And putting them manually is very hard, and it consumes alot of time.
So I thought why not code a spawn command-
I actually tried but failed, FAILED completely.
So, please help me out.
I took the Ktrose code for "spawn" in gmcmds.cpp, and revised it to this:
//Do I have to put <= 100 after accesslevel?
//GM/DEV's would code it :: /spawn (spawnid) (mobid) (howMany) (IntervalOfSpawn) (radius)
//I've been having problems with the %i says NOT DECLARED everytime I compile it, so I'm guessing I've wrong.
//I just copied how its done in ktRose tho - sorry. Just wanna ask also, why x and y coors are %f.
//the NULL there is mapname, which I don't see how it would automatically put map name on it, it's just a description so just set it to NULL.
//all mob limits are default to 20.
//all tactics are default to 200.
//posx and posy are, useless?
//the mob id and count will automatically be entered to all bmobs and bcounts.
//Very important question tho.. is there a way to make the spawnid automatically count ++? dunno if this : GServer->maxSpawnId++;thisspawn->id = GServer->maxSpawnId; has something to do with that.
NOW THE SECOND PART SUDDENLY GOT BLOODY.
I'm guessing this is where the server sends a spawn code to the client.
This is from KTROSE.
- CSpawnArea* thisspawn = new (nothrow) CSpawnArea;
- if(thisspawn == NULL)
- {
- Log(MSG_ERROR, "Error allocing memory" );
- DB->QFree( );
- return false;
- }
- GServer->maxSpawnId++;
- thisspawn->id = GServer->maxSpawnId;
- thisspawn->map = thisclient->Position->Map;
- thisspawn->montype = mobid;
- thisspawn->min = 0;//atoi(row[3]);
- thisspawn->max = max;
- thisspawn->respawntime = stime;
- thisspawn->point.x = thisclient->Position->current.x;
- thisspawn->point.y = thisclient->Position->current.y;
- thisspawn->radius = radius;
- thisspawn->amon = 0;
- thisspawn->lastRespawnTime = 0;
- thisspawn->type = spawntype;
- thisspawn->triggertype = triggermontype;
- thisspawn->triggeramount = triggeramount;
- thisspawn->aggressive = aggro;
- thisspawn->typeoftrigger = 1;
- thisspawn->limit = lim;
- thisspawn->spawnkey = spawnk;
- thisspawn->triggercount = 0;
- thisspawn->thisnpc = GetNPCDataByID( thisspawn->montype );
- thisspawn->RefVar = refvar;
- thisspawn->RefVal = refval;
- if(thisspawn->thisnpc == NULL)
- {
- SendPM(thisclient, "Invalid montype - Spawn %i will not be added", thisspawn->id );
- delete thisspawn;
- return true;
- }
- MapList.Index[thisspawn->map]->MonsterSpawnList.push_back( thisspawn );
- SendPM(thisclient,"Spawn successfully saved with spawn id %i.",thisspawn->id);
- return true;
- }
I got this from Rev4 startup.cpp
- CSpawnArea* thisspawn = new (nothrow) CSpawnArea;
- if(thisspawn == NULL)
- {
- Log(MSG_ERROR, "Error allocing memory" );
- DB->QFree( );
- return false;
- }
- thisspawn->id = atoi(row[0]);
- thisspawn->map = atoi(row[1]);
- thisspawn->radius = atoi(row[2]);
- thisspawn->points.x = atof(row[3]);
- thisspawn->points.y = atof(row[4]);
- thisspawn->tactic = atoi(row[5]);
- thisspawn->bmob[1] = atoi(row[6]);
- thisspawn->bmob[2] = atoi(row[7]);
- thisspawn->bmob[3] = atoi(row[8]);
- thisspawn->bmob[4] = atoi(row[9]);
- thisspawn->bmob[5] = atoi(row[10]);
- thisspawn->bcount[1] = atoi(row[11]);
- thisspawn->bcount[2] = atoi(row[12]);
- thisspawn->bcount[3] = atoi(row[13]);
- thisspawn->bcount[4] = atoi(row[14]);
- thisspawn->bcount[5] = atoi(row[15]);
- thisspawn->tmob[1] = atoi(row[16]);
- thisspawn->tmob[2] = atoi(row[17]);
- thisspawn->tcount[1] = atoi(row[18]);
- thisspawn->tcount[2] = atoi(row[19]);
- thisspawn->respawntime = atoi(row[20]);
I don't know what came to me but I came up with this:
- thisspawn->id = spawnid;
- thisspawn->map = thisclient->Position->Map;
- thisspawn->radius = radius;
- thisspawn->points.x = thisclient->Position->current.x;
- thisspawn->points.y = thisclient->Position->current.y;
- thisspawn->tactic = 200;
- thisspawn->bmob[1] = mobid;
- thisspawn->bmob[2] = mobid;
- thisspawn->bmob[3] = mobid;
- thisspawn->bmob[4] = mobid;;
- thisspawn->bmob[5] = mobid;
- thisspawn->bcount[1] = mobcount;
- thisspawn->bcount[2] = mobcount;
- thisspawn->bcount[3] = mobcount;
- thisspawn->bcount[4] = mobcount;
- thisspawn->bcount[5] = mobcount;
- thisspawn->tmob[1] = 0;
- thisspawn->tmob[2] = 0;
- thisspawn->tcount[1] = 0;
- thisspawn->tcount[2] = 0;
- thisspawn->respawntime = interval;
NOW THIS PART I TOTALLY GAVE UP BECAUSE I DON'T KNOW WHAT TO DO ANYMORE. I TRIED, BUT, I got exhausted.
this is also from KtRose, don't know how to revise it.
- thisspawn->thisnpc = GetNPCDataByID( thisspawn->montype );
- thisspawn->RefVar = refvar;
- thisspawn->RefVal = refval;
- if(thisspawn->thisnpc == NULL)
- {
- SendPM(thisclient, "Invalid montype - Spawn %i will not be added", thisspawn->id );
- delete thisspawn;
- return true;
- }
- MapList.Index[thisspawn->map]->MonsterSpawnList.push_back( thisspawn );
- SendPM(thisclient,"Spawn successfully saved with spawn id %i.",thisspawn->id);
- return true;
- }
I would just like to stress out I'am not a coder, but I'm trying to learn. Please be patient with me.