Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void world_speak_npcs(void *world_void)
- {
- World *world = static_cast<World *>(world_void);
- UTIL_FOREACH(world->maps, map)
- {
- UTIL_FOREACH(map->npcs, npc)
- {
- double timeinterval = util::to_float(world->npcs_config[util::to_string(npc->id) + ".interval"]);
- double current_time = Timer::GetTime();
- if (timeinterval > 0 && (current_time - npc->last_chat) >= timeinterval)
- {
- std::vector<std::string> chats;
- for (int i = 1; std::string(world->npcs_config[util::to_string(npc->id) + ".chat" + util::to_string(i)]) != "0"; i++)
- chats.push_back(world->npcs_config[util::to_string(npc->id) + ".chat" + util::to_string(i)]);
- if (util::rand(0, 100) <= (util::to_int(world->npcs_config[util::to_string(npc->id) + ".frequency"])) && chats.size() > 0)
- {
- npc->ShowDialog(chats.at(util::rand(0, chats.size() - 1)));
- npc->last_chat = current_time;
- }
- else
- {
- npc->last_chat = current_time;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement