Jimmyee

Joined: 13th Mar 2009
Posts: 205
[Release] Spawn NPC command
So i wrote command for spawn NPC.
First You need add this code into eoserv/map.cpp in last line:
void Map::CreateNPC(int id, Map* map, int x, int y, int s_type, int s_time, int index)
{
NPC *newnpc = new NPC(map, id, x, y, s_type, s_time, index);
npcs.push_back(newnpc);
}
In handlers/talk.cpp add this:
else if (command.length() >= 2 && command.compare(0,2,"sn") == 0 && arguments.size() >= 1 && this->player->character->admin >= static_cast<int>(admin_config["spawn"]))
{
int id = static_cast<int>(util::variant(arguments[0]));
int x = this->player->character->x;
int y = this->player->character->y;
Map* map = this->player->character->map;
int s_type = (arguments.size() >= 4)?static_cast<int>(util::variant(arguments[1])):1;
int s_time = (arguments.size() >= 5)?static_cast<int>(util::variant(arguments[2])):2;
int index = (arguments.size() >= 6)?static_cast<int>(util::variant(arguments[3])):index + 1;
{
this->player->character->map->CreateNPC(id, map, x, y, s_type, s_time, index);
// the_world->ServerMsg("An npc has been spawned by: " + this->player->character->name +"");
}
}
And this in eoserv.hpp, class map:
void CreateNPC(int id, Map* map, int x, int y, int s_type, int s_time, int index);
Example of usage:
$sn 225 10 2 1
or just
$sn 225
You can spawn just one NPC per map, could anyone help me fix it?
16 years, 8 weeks ago
|
Jimbo
Joined: 17th Mar 2009
Posts: 416
Re: [Release] Spawn NPC command
Oh sweet, thanks!
---
I forgot what I was going to write...
16 years, 8 weeks ago
|
Syran

Joined: 26th Mar 2009
Posts: 1391
Re: [Release] Spawn NPC command
Jimmy, thanks for fixing my code to work with the new npc system lol.
And about the one spawn thing, I noticed that the first time I wrote it, and it does spawn more than one, the first one shows, the others are invisible until the first one dies, then they start appearing. Only one shows at a time, and I could never figure that out either.
---
May he now rest under aegis of mirage -
As the sands slowly turn to Elysian fields
16 years, 8 weeks ago
|
Bryant
Joined: 17th Mar 2009
Posts: 226
Re: [Release] Spawn NPC command
Looks good just from reading the code :P
16 years, 8 weeks ago
|
Stephx
Joined: 21st Feb 2009
Posts: 299
Re: [Release] Spawn NPC command
lol its funny i just finished coding an Npc spawn command today and it looks alot like that one, but mines goes $spawn 1 and it spawns no need for anything else (stating Spawn type and spawn time, X, Y dont make a difference because well SpawnType and Spawn time dont seem to make a difference lol
and the X and Y and randomised in a 2 coordinate radius aroudn you) and index i dotn have to state cause i made it randomised a series of numbers from 1 to 1000
16 years, 8 weeks ago
|
Bryant
Joined: 17th Mar 2009
Posts: 226
Re: [Release] Spawn NPC command
I was about to start making this, but noticed this was posted.
16 years, 8 weeks ago
|
xsepx

Joined: 11th Mar 2009
Posts: 350
Re: [Release] Spawn NPC command
works nice, but sometimes they don't spawn right away, and sometimes it seems they are speeding really fast.
16 years, 8 weeks ago
|
Stephx
Joined: 21st Feb 2009
Posts: 299
Re: [Release] Spawn NPC command
Well i havent tested his command, maybe i will in the future. Heres a picture : 
16 years, 8 weeks ago
|
Re: [Release] Spawn NPC command
thanks for this! quick question do the NPCs respawn after you spawn them =P?
16 years, 8 weeks ago
|
Jimmyee

Joined: 13th Mar 2009
Posts: 205
Re: [Release] Spawn NPC command
Yes of course!
Anyway, Steph, could You tell me how to fix it? I want spawn more NPC than one lol
16 years, 8 weeks ago
|
Re: [Release] Spawn NPC command
i can spawn more than one at a time o.o i didnt even make any changes to your code but is their anyway to define the respawn time or stop it from respawning?
16 years, 8 weeks ago
|
Razor

Joined: 22nd Mar 2009
Posts: 195
Re: Spawn NPC command
Why it doesnt work?
i did what he all said....
16 years, 8 weeks ago
| | | | | | | | | | | | |