diff options
Diffstat (limited to 'src/map/npc.cpp')
-rw-r--r-- | src/map/npc.cpp | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/src/map/npc.cpp b/src/map/npc.cpp index 0175916..eaf54ec 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -146,15 +146,24 @@ dumb_ptr<npc_data> npc_name2id(NpcName name) } /*========================================== - * NPCを名前で探す + * NPC Spells *------------------------------------------ */ -NpcEvent spell_name2id(RString name) +NpcName spell_name2id(RString name) { return spells_by_name.get(name); } /*========================================== + * NPC Spells Events + *------------------------------------------ + */ +NpcEvent spell_event2id(RString name) +{ + return spells_by_events.get(name); +} + +/*========================================== * Spell Toknise * Return a pair of strings, {spellname, parameter} * Parameter may be empty. @@ -189,26 +198,45 @@ std::pair<XString, XString> magic_tokenise(XString src) */ int magic_message(dumb_ptr<map_session_data> caster, XString source_invocation) { - if (pc_isdead(caster)) - return 0; - if (bool(caster->status.option & Opt0::HIDE)) - return 0; - if (caster->cast_tick > gettick()) - return 0; - auto pair = magic_tokenise(source_invocation); // Spell Cast - NpcName spell_name = stringish<NpcName>(pair.first); + NpcName spell_name = spell_name2id(pair.first); + NpcEvent spell_event = spell_event2id(pair.first); + PRINTF("Cast: %s\n"_fmt, RString(pair.first)); + RString spell_params = pair.second; - NpcEvent event = spell_name2id(spell_name); + dumb_ptr<npc_data> nd = npc_name2id(spell_name); - if (event) + if (nd) { - PRINTF("Cast: %s\n"_fmt, spell_name); - PRINTF("event: %s\n"_fmt, event); + PRINTF("NPC: %s %d\n"_fmt, nd->name, nd->bl_id); PRINTF("Params: %s\n"_fmt, spell_params); - npc_event(caster, event, 0); + caster->npc_id = nd->bl_id; + dumb_ptr<block_list> map_bl = map_id2bl(nd->bl_id); + if (!map_bl) + map_addnpc(caster->bl_m, nd); + argrec_t arg[1] = + { + {"@args$"_s, spell_params}, + }; + caster->npc_pos = run_script_l(ScriptPointer(borrow(*nd->is_script()->scr.script), 0), caster->bl_id, nd->bl_id, arg); + return 1; + } + if (spell_event.label) + { + dumb_ptr<npc_data> nd = npc_name2id(spell_event.npc); + PRINTF("NPC: %s %d\n"_fmt, nd->name, nd->bl_id); + PRINTF("Params: %s\n"_fmt, spell_params); + caster->npc_id = nd->bl_id; + dumb_ptr<block_list> map_bl = map_id2bl(nd->bl_id); + if (!map_bl) + map_addnpc(caster->bl_m, nd); + argrec_t arg[1] = + { + {"@args$"_s, spell_params}, + }; + caster->npc_pos = npc_event_do_l(spell_event, caster->bl_id, arg); return 1; } return 0; |