EOSERV Forum > EOSERV > EO Main Accurate NPC Chat Release
Page: << 1 >>
EO Main Accurate NPC Chat Release
Author Message
Post #202624 EO Main Accurate NPC Chat Release

This is the closest to EO Main NPC Chat. Not enough lines here to be worth pastebin'ing.  The code goes in NPC::Act just before this: if (this->spawn_type == 7)

Make sure to declare double last_chat in npc.hpp, and enter this->last_chat = 0.0; in NPC::NPC and load the npc_chat_config file in world.cpp (hint, same two places as shop and drop config files are loaded). Also, if "now" isn't declared in your build: double now = Timer::GetTime(); before this code:

    if (this->last_chat + 5.0 < now && this->InCharacterRange()) //declare double last_chat in npc.hpp
    {
        int chats = util::to_int(this->map->world->npc_chat_config[util::to_string(this->id) + ".chats"]);//read the npc_chat_config file in world.cpp same as shops, etc
        chats = std::max(1, chats);
        int rand = util::rand(1, chats);
        int chance = util::rand(1,100);
        int rate = util::to_int(this->map->world->npc_chat_config[util::to_string(this->id) + ".rate"]);
        rate = rate * double(this->map->world->config["NPCGlobalChatRate"]); //this isn't necessary, but fun I suppose
        std::string message = static_cast<std::string>(this->map->world->npc_chat_config[util::to_string(this->id) + "." + util::to_string(rand)]);
        if (message.size() != 0 && chance < rate) this->Msg(message);
        this->last_chat = Timer::GetTime();
        UTIL_FOREACH(this->map->npcs, npc)
  {
   if (npc->spawn_x == this->spawn_x && npc->spawn_y == this->spawn_y)
   {
                npc->last_chat = this->last_chat;
   }
  }
    }

1 year, 7 weeks ago
Post #202870 Re: EO Main Accurate NPC Chat Release

Great!

1 year, 5 weeks ago
Post #202946 Re: EO Main Accurate NPC Chat Release

Aye thanks Apollo :)

1 year, 5 weeks ago
Page: << 1 >>

EOSERV Forum > EOSERV > EO Main Accurate NPC Chat Release