This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [QUESTION][C++] Item spawn npc in few areas  (Read 1636 times)

bizzlesnaff

  • Registred Member
  • Wiki Incarnate
  • *****
  • Posts: 124
    • View Profile
[QUESTION][C++] Item spawn npc in few areas
« on: June 10, 2015, 04:07:46 am »
Hey folk :)

i've a little question. I work on something like "gildhousing" and now I try to find a way, how someone (maybe the guildleader) is able to spawn some npcs in his area.
To spawn an npc is not my problem, but i don't like it, if any player can jump around the whole world and spawn in any area some npcs. So i like to find any way to make an "map check", and only in the right map (or better) area, the item works.

Yeah...anyone some ideas :)

I know thats really...imprecise..but maybe someone have a good idea :)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Kaev

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 308
    • View Profile
Re: [QUESTION][C++] Item spawn npc in few areas
« Reply #1 on: June 10, 2015, 07:50:07 am »
Add the coordinates of the 4 corners of the guildhouse, map id and guild id to the database.
Load them at server start (and when you create a new area) into a unordered_map or something else if you prefer it.
Write a function, which will return true, if the player is in the rectangle of the guild house, is on the correct map and is the leader of the guild.
Now write a new command, which will only spawn an npc, if the function will return true. :)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

bizzlesnaff

  • Registred Member
  • Wiki Incarnate
  • *****
  • Posts: 124
    • View Profile
Re: [QUESTION][C++] Item spawn npc in few areas
« Reply #2 on: June 10, 2015, 09:41:58 pm »
Wow..thats sounds pretty easy :) Thats a very nice idea :)
I will try to realize that :) Thank you :)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Kaev

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 308
    • View Profile
Re: [QUESTION][C++] Item spawn npc in few areas
« Reply #3 on: June 10, 2015, 10:02:53 pm »
Quote from: "bizzlesnaff"
Wow..thats sounds pretty easy :) Thats a very nice idea :)
I will try to realize that :) Thank you :)
No problem.
First step when you have a programming problem: Cut it in several small problems. Everything will be much easier then. ;)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

bizzlesnaff

  • Registred Member
  • Wiki Incarnate
  • *****
  • Posts: 124
    • View Profile
Re: [QUESTION][C++] Item spawn npc in few areas
« Reply #4 on: June 12, 2015, 09:01:34 pm »
Hey :)
I don't like to create a new topic, so I'll ask here :)
If you don't know the right "script-command" to create anything like you want. Where do you look for an answer?
I try to find a wiki or something, but I even don't know how to look... with "trinitycore c++ script wiki" or "trinitycore c++ commands" I didn't find anything usefull.

Is there a list something like...well i don't know..
ADD_GOSSIP_ITEM : "with this command you add a row in the gossip menu. the syntax is:
player->ADD_GOSSIP_ITEM(    !!ICON!! , "!!!YOUR TEXT!!!" , GOSSIP_SENDER_MAIN, !!!Number!!!);

Well...I hope someone know what I mean :)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Kaev

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 308
    • View Profile
Re: [QUESTION][C++] Item spawn npc in few areas
« Reply #5 on: June 15, 2015, 05:57:42 pm »
Quote from: "bizzlesnaff"
Hey :)
I don't like to create a new topic, so I'll ask here :)
If you don't know the right "script-command" to create anything like you want. Where do you look for an answer?
I try to find a wiki or something, but I even don't know how to look... with "trinitycore c++ script wiki" or "trinitycore c++ commands" I didn't find anything usefull.

Is there a list something like...well i don't know..
ADD_GOSSIP_ITEM : "with this command you add a row in the gossip menu. the syntax is:
player->ADD_GOSSIP_ITEM(    !!ICON!! , "!!!YOUR TEXT!!!" , GOSSIP_SENDER_MAIN, !!!Number!!!);

Well...I hope someone know what I mean :)
If i search a hook, i always search them in this file: https://github.com/TrinityCore/TrinityC ... criptMgr.h
For the other stuff, i test around, use google for script examples, write and read on emudevs (a board related to wow emulator development only, best one imo!) or search a function in the solution in visual studio.
But if i know the command, e.g. add_gossip_item, i type in player->Add_gossip_item and read the parameter names, which will usually tell me everything.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

bizzlesnaff

  • Registred Member
  • Wiki Incarnate
  • *****
  • Posts: 124
    • View Profile
Re: [QUESTION][C++] Item spawn npc in few areas
« Reply #6 on: June 15, 2015, 06:40:21 pm »
Thank you again :)
Thats very usefull :)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »