--[[ $Id: chat.lua 86 2004-06-28 14:16:10Z mitsu $ Simple framework for chatting to monsters. Upon chat, this script checks monster name and prints a random line from specified table. If you want a function to trigger upon chat, reference it with "action". The function is called with the argument 'm_idx'. Created for Intets Hevn 0.2.3 by Kjell Heskestad. Updated for Intets Hevn 0.3.0 by Kjell Heskestad. ]] -- See 'chat_responses.lua' for response tables. Add actions to 'chat_actions.lua'. chatlist = { --["foo"] = { chat = bar, action = baz }, ["inane ex-farmer"] = { chat = inane_chat }, ["police officer"] = { chat = police_chat }, ["elderly gentleman"] = { chat = gentle_chat }, ["filthy street urchin"] = { chat = urchin_chat }, ["woodsman"] = { chat = woodsman_chat }, ["boil-covered wretch"] = { chat = wretch_chat }, ["pitiful-looking beggar"] = { chat = beggar_chat }, ["mangy-looking leper"] = { chat = leper_chat }, ["agent of the black market"] = { chat = agent_chat }, ["gin-soaked man"] = { chat = gin_chat }, ["aimless-looking merchant"] = { chat = merchant_chat }, ["mean-looking mercenary"] = { chat = mercenary_chat }, ["battle-scarred veteran"] = { chat = veteran_chat }, ["novice warrior"] = { chat = nov_war_chat }, ["novice rogue"] = { chat = nov_rogue_chat }, ["novice priest"] = { chat = nov_priest_chat}, ["novice mage"] = { chat = nov_mage_chat }, ["scruffy-looking farmer"] = { chat = farmer_chat }, ["novice ranger"] = { chat = nov_ranger_chat}, ["novice paladin"] = { chat = nov_palad_chat }, ["blue yeek"] = { action = yeek_check, chat = yeek_chat }, ["brown yeek"] = { action = yeek_check, chat = yeek_chat }, ["master yeek"] = { action = yeek_check, chat = yeek_chat }, ["small kobold"] = { action = kobold_check, chat = kobold_chat }, ["kobold"] = { action = kobold_check, chat = kobold_chat }, ["large kobold"] = { action = kobold_check, chat = kobold_chat }, ["aquatic kobold"] = { action = kobold_check, chat = kobold_chat }, ["snotling"] = { action = ork_check, chat = ork_chat }, ["orke-trell"] = { action = ork_check, chat = ork_chat }, ["cave ork"] = { action = ork_check, chat = ork_chat }, ["hill ork"] = { action = ork_check, chat = ork_chat }, ["black ork"] = { action = ork_check, chat = ork_chat }, ["soldat-ork"] = { action = ork_check, chat = ork_chat }, ["elite soldat-ork"] = { action = ork_check, chat = ork_chat }, }; -- Checks chatlist for monster entry. function __hook_monster_chat(m_idx) local m_ptr = monster(m_idx); local m_name = cap_first(monster_desc(m_ptr, 0)); -- get nondecorated monster name. there's probably a better way of doing this... local stripped_m_name = gsub(strlower(m_name), "the ", "", 1); if(chatlist[stripped_m_name]) then if(chatlist[stripped_m_name].action) then chatlist[stripped_m_name].action(m_idx) end if(getn(chatlist[stripped_m_name].chat) > 0) then msg_print(format("%s %s", m_name, rand_item(chatlist[stripped_m_name].chat))); end return TRUE end end add_hook_script(HOOK_CHAT, "__hook_monster_chat", "__hook_monster_chat");