EOSERV Forum > EOSERV > Spawn NPC command
Topic is locked.
Page: << 1 >>
Spawn NPC command
Author Message
Post #6352 [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
Post #6353 Re: [Release] Spawn NPC command

Oh sweet, thanks!

---
I forgot what I was going to write...
16 years, 8 weeks ago
Post #6355 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
Post #6360 Re: [Release] Spawn NPC command

Looks good just from reading the code :P

16 years, 8 weeks ago
Post #6374 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
Post #6376 Re: [Release] Spawn NPC command

I was about to start making this, but noticed this was posted.

16 years, 8 weeks ago
Post #6378 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
Post #6381 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
Post #6405 Re: [Release] Spawn NPC command

thanks for this! quick question do the NPCs respawn after you spawn them =P?

16 years, 8 weeks ago
Post #6409 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
Post #6417 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
Post #6673 Re: Spawn NPC command

Why it doesnt work?

i did what he all said....

16 years, 8 weeks ago
Page: << 1 >>
Topic is locked.
EOSERV Forum > EOSERV > Spawn NPC command