diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/battle.cpp | 11 | ||||
-rw-r--r-- | src/map/battle.hpp | 1 | ||||
-rw-r--r-- | src/map/chrif.cpp | 133 | ||||
-rw-r--r-- | src/map/chrif.hpp | 1 | ||||
-rw-r--r-- | src/map/clif.cpp | 108 | ||||
-rw-r--r-- | src/map/clif.hpp | 5 | ||||
-rw-r--r-- | src/map/npc.cpp | 21 | ||||
-rw-r--r-- | src/map/npc.hpp | 1 | ||||
-rw-r--r-- | src/map/pc.cpp | 180 | ||||
-rw-r--r-- | src/map/pc.hpp | 5 | ||||
-rw-r--r-- | src/map/script-fun.cpp | 83 |
11 files changed, 89 insertions, 460 deletions
diff --git a/src/map/battle.cpp b/src/map/battle.cpp index 28c9d5f..0a6ffa7 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -985,17 +985,6 @@ int battle_stopattack(dumb_ptr<block_list> bl) return 0; } -// 移動停止 -int battle_stopwalking(dumb_ptr<block_list> bl, int type) -{ - nullpo_retz(bl); - if (bl->bl_type == BL::MOB) - return mob_stop_walking(bl->is_mob(), type); - else if (bl->bl_type == BL::PC) - return pc_stop_walking(bl->is_player(), type); - return 0; -} - /*========================================== * ダメージ最終計算 *------------------------------------------ diff --git a/src/map/battle.hpp b/src/map/battle.hpp index aa96a72..7733391 100644 --- a/src/map/battle.hpp +++ b/src/map/battle.hpp @@ -58,7 +58,6 @@ int battle_heal(dumb_ptr<block_list> bl, dumb_ptr<block_list> target, int hp, // 攻撃や移動を止める int battle_stopattack(dumb_ptr<block_list> bl); -int battle_stopwalking(dumb_ptr<block_list> bl, int type); // 通常攻撃処理まとめ ATK battle_weapon_attack(dumb_ptr<block_list> bl, dumb_ptr<block_list> target, diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp index 7119ee8..9a36a60 100644 --- a/src/map/chrif.cpp +++ b/src/map/chrif.cpp @@ -912,126 +912,6 @@ int chrif_recvgmaccounts(Session *s, const std::vector<Packet_Repeat<0x2b15>>& r return 0; } -/*========================================== - * Request to reload GM accounts and their levels: send to char-server by [Yor] - *------------------------------------------ - */ -int chrif_reloadGMdb(void) -{ - if (!char_session) - return -1; - - Packet_Fixed<0x2af7> fixed_f7; - send_fpacket<0x2af7, 2>(char_session, fixed_f7); - - return 0; -} - -/*======================================== - * Map item IDs - *---------------------------------------- - */ - -static -void ladmin_itemfrob_fix_item(ItemNameId source, ItemNameId dest, Item *item) -{ - if (item && item->nameid == source) - { - item->nameid = dest; - item->equip = EPOS::ZERO; - } -} - -static -void ladmin_itemfrob_c2(dumb_ptr<block_list> bl, ItemNameId source_id, ItemNameId dest_id) -{ -#define IFIX(v) if (v == source_id) {v = dest_id; } -#define FIX(item) ladmin_itemfrob_fix_item(source_id, dest_id, &item) - - if (!bl) - return; - - switch (bl->bl_type) - { - case BL::PC: - { - dumb_ptr<map_session_data> pc = bl->is_player(); - - for (IOff0 j : IOff0::iter()) - IFIX(pc->status.inventory[j].nameid); - // cart is no longer supported - // IFIX(pc->status.weapon); - IFIX(pc->status.shield); - IFIX(pc->status.head_top); - IFIX(pc->status.head_mid); - IFIX(pc->status.head_bottom); - - Option<P<Storage>> stor_ = account2storage2(pc->status_key.account_id); - if OPTION_IS_SOME_NOLOOP(stor, stor_) - { - for (SOff0 j : SOff0::iter()) - FIX(stor->storage_[j]); - } - - for (IOff0 j : IOff0::iter()) - { - P<struct item_data> item = TRY_UNWRAP(pc->inventory_data[j], continue); - if (item->nameid == source_id) - { - item->nameid = dest_id; - if (bool(item->equip)) - pc_unequipitem(pc, j, CalcStatus::NOW); - item->nameid = dest_id; - } - } - - break; - } - - case BL::MOB: - { - dumb_ptr<mob_data> mob = bl->is_mob(); - for (Item& itm : mob->lootitemv) - FIX(itm); - break; - } - - case BL::ITEM: - { - dumb_ptr<flooritem_data> item = bl->is_item(); - FIX(item->item_data); - break; - } - } -#undef FIX -#undef IFIX -} - -static -void ladmin_itemfrob_c(dumb_ptr<block_list> bl, ItemNameId source_id, ItemNameId dest_id) -{ - ladmin_itemfrob_c2(bl, source_id, dest_id); -} - -static -void ladmin_itemfrob(Session *, const Packet_Fixed<0x2afa>& fixed) -{ - ItemNameId source_id = fixed.source_item_id; - ItemNameId dest_id = fixed.dest_item_id; - dumb_ptr<block_list> bl = map_get_first_session(); - - // flooritems - map_foreachobject(std::bind(ladmin_itemfrob_c, ph::_1, source_id, dest_id), - BL::NUL /* any object */); - - // player characters (and, hopefully, mobs) - while (bl->bl_next) - { - ladmin_itemfrob_c2(bl, source_id, dest_id); - bl = bl->bl_next; - } -} - static void chrif_delete(Session *s) { @@ -1066,16 +946,6 @@ void chrif_parse(Session *s) chrif_connectack(s, fixed); break; } - case 0x2afa: - { - Packet_Fixed<0x2afa> fixed; - rv = recv_fpacket<0x2afa, 10>(s, fixed); - if (rv != RecvResult::Complete) - break; - - ladmin_itemfrob(s, fixed); - break; - } case 0x2afb: { Packet_Fixed<0x2afb> fixed; @@ -1095,12 +965,11 @@ void chrif_parse(Session *s) AccountId id = payload.account_id; int login_id2 = payload.login_id2; - TimeT connect_until_time = payload.connect_until; short tmw_version = payload.packet_tmw_version; CharKey st_key = payload.char_key; CharData st_data = payload.char_data; pc_authok(id, login_id2, - connect_until_time, tmw_version, + tmw_version, &st_key, &st_data); break; } diff --git a/src/map/chrif.hpp b/src/map/chrif.hpp index 4bd00aa..59fb541 100644 --- a/src/map/chrif.hpp +++ b/src/map/chrif.hpp @@ -47,7 +47,6 @@ void chrif_changeemail(AccountId id, AccountEmail actual_email, AccountEmail new void chrif_char_ask_name(AccountId id, CharName character_name, short operation_type, HumanTimeDiff modif); int chrif_saveaccountreg2(dumb_ptr<map_session_data> sd); -int chrif_reloadGMdb(void); int chrif_send_divorce(CharId char_id); void do_init_chrif(void); diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 3a84e03..61fa8c5 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -622,37 +622,6 @@ int clif_clearchar(dumb_ptr<block_list> bl, BeingRemoveWhy type) return 0; } -static -void clif_clearchar_delay_sub(TimerData *, tick_t, - dumb_ptr<block_list> bl, BeingRemoveWhy type) -{ - clif_clearchar(bl, type); - MapBlockLock::freeblock(bl); -} - -int clif_clearchar_delay(tick_t tick, - dumb_ptr<block_list> bl, BeingRemoveWhy type) -{ - dumb_ptr<block_list> tmpbl; - tmpbl.new_(); - - // yikes! - tmpbl->bl_next = bl->bl_next; - tmpbl->bl_prev = bl->bl_prev; - tmpbl->bl_id = bl->bl_id; - tmpbl->bl_m = bl->bl_m; - tmpbl->bl_x = bl->bl_x; - tmpbl->bl_y = bl->bl_y; - tmpbl->bl_type = bl->bl_type; - - Timer(tick, - std::bind(clif_clearchar_delay_sub, ph::_1, ph::_2, - tmpbl, type) - ).detach(); - - return 0; -} - /*========================================== * *------------------------------------------ @@ -2686,43 +2655,6 @@ void clif_mobinsight(dumb_ptr<block_list> bl, dumb_ptr<mob_data> md) } /*========================================== - * - *------------------------------------------ - */ -int clif_skillinfo(dumb_ptr<map_session_data> sd, SkillID skillid, int type, - int range) -{ - nullpo_retz(sd); - - Session *s = sd->sess; - if (!sd->status.skill[skillid].lv) - return 0; - Packet_Fixed<0x0147> fixed_147; - fixed_147.info.skill_id = skillid; - if (type < 0) - fixed_147.info.type_or_inf = skill_get_inf(skillid); - else - fixed_147.info.type_or_inf = type; - fixed_147.info.flags = SkillFlags::ZERO; - fixed_147.info.level = sd->status.skill[skillid].lv; - fixed_147.info.sp = skill_get_sp(skillid, sd->status.skill[skillid].lv); - if (range < 0) - { - range = skill_get_range(skillid, sd->status.skill[skillid].lv); - if (range < 0) - range = battle_get_range(sd) - (range + 1); - fixed_147.info.range = range; - } - else - fixed_147.info.range = range; - fixed_147.info.unused = ""_s; - fixed_147.info.can_raise = sd->status.skill[skillid].lv < skill_get_max_raise(skillid); - send_fpacket<0x0147, 39>(s, fixed_147); - - return 0; -} - -/*========================================== * スキルリストを送信する *------------------------------------------ */ @@ -3203,21 +3135,6 @@ int clif_movetoattack(dumb_ptr<map_session_data> sd, dumb_ptr<block_list> bl) } /*========================================== - * MVPエフェクト - *------------------------------------------ - */ -int clif_mvp_effect(dumb_ptr<map_session_data> sd) -{ - nullpo_retz(sd); - - Packet_Fixed<0x010c> fixed_10c; - fixed_10c.block_id = sd->bl_id; - Buffer buf = create_fpacket<0x010c, 6>(fixed_10c); - clif_send(buf, sd, SendWho::AREA); - return 0; -} - -/*========================================== * エモーション *------------------------------------------ */ @@ -3844,25 +3761,6 @@ RecvResult clif_parse_Emotion(Session *s, dumb_ptr<map_session_data> sd) *------------------------------------------ */ static -RecvResult clif_parse_HowManyConnections(Session *s, dumb_ptr<map_session_data>) -{ - Packet_Fixed<0x00c1> fixed; - RecvResult rv = recv_fpacket<0x00c1, 2>(s, fixed); - if (rv != RecvResult::Complete) - return rv; - - Packet_Fixed<0x00c2> fixed_c2; - fixed_c2.users = map_getusers(); - send_fpacket<0x00c2, 6>(s, fixed_c2); - - return rv; -} - -/*========================================== - * - *------------------------------------------ - */ -static RecvResult clif_parse_ActionRequest(Session *s, dumb_ptr<map_session_data> sd) { Packet_Fixed<0x0089> fixed; @@ -4757,7 +4655,7 @@ RecvResult clif_parse_RemovePartyMember(Session *s, dumb_ptr<map_session_data> s *------------------------------------------ */ static -RecvResult clif_parse_PartyChangeOpt0(Session *s, dumb_ptr<map_session_data> sd) +RecvResult clif_parse_PartyChangeOption(Session *s, dumb_ptr<map_session_data> sd) { Packet_Fixed<0x0102> fixed; RecvResult rv = recv_fpacket<0x0102, 6>(s, fixed); @@ -5002,7 +4900,7 @@ func_table clif_parse_func_table[0x0220] = {0, 5, nullptr, }, // 0x00be {1000, 3, clif_parse_Emotion, }, // 0x00bf {0, 7, nullptr, }, // 0x00c0 - {0, 2, clif_parse_HowManyConnections, }, // 0x00c1 + {0, 2, nullptr, }, // 0x00c1 {0, 6, nullptr, }, // 0x00c2 {0, 8, nullptr, }, // 0x00c3 {0, 6, nullptr, }, // 0x00c4 @@ -5067,7 +4965,7 @@ func_table clif_parse_func_table[0x0220] = {0, 10, clif_parse_ReplyPartyInvite, }, // 0x00ff {0, 2, clif_parse_LeaveParty, }, // 0x0100 {0, 6, nullptr, }, // 0x0101 - {0, 6, clif_parse_PartyChangeOpt0, }, // 0x0102 + {0, 6, clif_parse_PartyChangeOption, }, // 0x0102 {0, 30, clif_parse_RemovePartyMember, }, // 0x0103 {0, 79, nullptr, }, // 0x0104 {0, 31, nullptr, }, // 0x0105 diff --git a/src/map/clif.hpp b/src/map/clif.hpp index 24f4b80..2242949 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -52,7 +52,6 @@ int clif_charselectok(BlockId); int clif_dropflooritem(dumb_ptr<flooritem_data>); int clif_clearflooritem(dumb_ptr<flooritem_data>, Session *); int clif_clearchar(dumb_ptr<block_list>, BeingRemoveWhy); // area or fd -int clif_clearchar_delay(tick_t, dumb_ptr<block_list>, BeingRemoveWhy); void clif_clearchar_id(BlockId, BeingRemoveWhy, Session *); int clif_spawnpc(dumb_ptr<map_session_data>); //area int clif_spawnnpc(dumb_ptr<npc_data>); // area @@ -131,8 +130,6 @@ void clif_pcoutsight(dumb_ptr<block_list>, dumb_ptr<map_session_data>); void clif_mobinsight(dumb_ptr<block_list>, dumb_ptr<mob_data>); void clif_moboutsight(dumb_ptr<block_list>, dumb_ptr<mob_data>); -int clif_skillinfo(dumb_ptr<map_session_data> sd, SkillID skillid, int type, - int range); void clif_skillinfoblock(dumb_ptr<map_session_data> sd); int clif_skillup(dumb_ptr<map_session_data> sd, SkillID skill_num); @@ -152,8 +149,6 @@ void clif_wis_end(Session *s, int flag); void clif_itemlist(dumb_ptr<map_session_data> sd); void clif_equiplist(dumb_ptr<map_session_data> sd); -int clif_mvp_effect(dumb_ptr<map_session_data> sd); - int clif_movetoattack(dumb_ptr<map_session_data> sd, dumb_ptr<block_list> bl); // party diff --git a/src/map/npc.cpp b/src/map/npc.cpp index 90ac917..cd80cdf 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -199,27 +199,6 @@ int npc_delete(dumb_ptr<npc_data> nd) return 0; } -void npc_timer_event(NpcEvent eventname) -{ - P<struct event_data> ev = TRY_UNWRAP(ev_db.search(eventname), - { - PRINTF("npc_event: event not found [%s]\n"_fmt, - eventname); - return; - }); - - dumb_ptr<npc_data_script> nd; - - if ((nd = ev->nd) == nullptr) - { - PRINTF("npc_event: event not found [%s]\n"_fmt, - eventname); - return; - } - - run_script(ScriptPointer(borrow(*nd->scr.script), ev->pos), nd->bl_id, nd->bl_id); -} - /*========================================== * 全てのNPCのOn*イベント実行 *------------------------------------------ diff --git a/src/map/npc.hpp b/src/map/npc.hpp index cb42dbd..e62faf2 100644 --- a/src/map/npc.hpp +++ b/src/map/npc.hpp @@ -44,7 +44,6 @@ constexpr Species INVISIBLE_CLASS = wrap<Species>(32767); int npc_event_dequeue(dumb_ptr<map_session_data> sd); int npc_event(dumb_ptr<map_session_data> sd, NpcEvent npcname, int); -void npc_timer_event(NpcEvent eventname); // Added by RoVeRT int npc_command(dumb_ptr<map_session_data> sd, NpcName npcname, XString command); int npc_touch_areanpc(dumb_ptr<map_session_data>, Borrowed<map_local>, int, int); int npc_click(dumb_ptr<map_session_data>, BlockId); diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 55e430a..a38c05f 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -606,7 +606,7 @@ int pc_isequip(dumb_ptr<map_session_data> sd, IOff0 n) * char鯖から送られてきたステータスを設定 *------------------------------------------ */ -int pc_authok(AccountId id, int login_id2, TimeT connect_until_time, +int pc_authok(AccountId id, int login_id2, short tmw_version, const CharKey *st_key, const CharData *st_data) { dumb_ptr<map_session_data> sd = nullptr; @@ -760,15 +760,6 @@ int pc_authok(AccountId id, int login_id2, TimeT connect_until_time, sd->packet_flood_reset_due = TimeT(); sd->packet_flood_in = 0; - // message of the limited time of the account - if (connect_until_time) - { - timestamp_seconds_buffer buffer; - stamp_time(buffer, &connect_until_time); - AString tmpstr = STRPRINTF("Your account time limit is: %s"_fmt, buffer); - - clif_wis_message(sd->sess, wisp_server_name, tmpstr); - } pc_calcstatus(sd, 1); return 0; @@ -2530,72 +2521,6 @@ void pc_touch_all_relevant_npcs(dumb_ptr<map_session_data> sd) sd->areanpc_id = BlockId(); } -/*========================================== - * - *------------------------------------------ - */ -int pc_movepos(dumb_ptr<map_session_data> sd, int dst_x, int dst_y) -{ - int moveblock; - int dx, dy; - - struct walkpath_data wpd; - - nullpo_retz(sd); - - if (path_search(&wpd, sd->bl_m, sd->bl_x, sd->bl_y, dst_x, dst_y, 0)) - return 1; - - sd->dir = sd->head_dir = map_calc_dir(sd, dst_x, dst_y); - - dx = dst_x - sd->bl_x; - dy = dst_y - sd->bl_y; - - moveblock = (sd->bl_x / BLOCK_SIZE != dst_x / BLOCK_SIZE - || sd->bl_y / BLOCK_SIZE != dst_y / BLOCK_SIZE); - - map_foreachinmovearea(std::bind(clif_pcoutsight, ph::_1, sd), - sd->bl_m, - sd->bl_x - AREA_SIZE, sd->bl_y - AREA_SIZE, - sd->bl_x + AREA_SIZE, sd->bl_y + AREA_SIZE, - dx, dy, - BL::NUL); - - if (moveblock) - map_delblock(sd); - sd->bl_x = dst_x; - sd->bl_y = dst_y; - if (moveblock) - map_addblock(sd); - - map_foreachinmovearea(std::bind(clif_pcinsight, ph::_1, sd), - sd->bl_m, - sd->bl_x - AREA_SIZE, sd->bl_y - AREA_SIZE, - sd->bl_x + AREA_SIZE, sd->bl_y + AREA_SIZE, - -dx, -dy, - BL::NUL); - - if (sd->status.party_id) - { // パーティのHP情報通知検査 - Option<PartyPair> p = party_search(sd->status.party_id); - if (p.is_some()) - { - int flag = 0; - map_foreachinmovearea(std::bind(party_send_hp_check, ph::_1, sd->status.party_id, &flag), - sd->bl_m, - sd->bl_x - AREA_SIZE, sd->bl_y - AREA_SIZE, - sd->bl_x + AREA_SIZE, sd->bl_y + AREA_SIZE, - -dx, -dy, - BL::PC); - if (flag) - sd->party_hp = -1; - } - } - - pc_touch_all_relevant_npcs(sd); - return 0; -} - // // 武器戦闘 // @@ -3146,94 +3071,6 @@ int pc_skillup(dumb_ptr<map_session_data> sd, SkillID skill_num) } /*========================================== - * /resetlvl - *------------------------------------------ - */ -int pc_resetlvl(dumb_ptr<map_session_data> sd, int type) -{ - nullpo_retz(sd); - - for (SkillID i : erange(SkillID(1), MAX_SKILL)) - { - sd->status.skill[i].lv = 0; - } - - if (type == 1) - { - sd->status.skill_point = 0; - sd->status.base_level = 1; - sd->status.job_level = 1; - sd->status.base_exp = 0; - sd->status.job_exp = 0; - sd->status.option = Opt0::ZERO; - - for (ATTR attr : ATTRs) - sd->status.attrs[attr] = 1; - } - - if (type == 2) - { - sd->status.skill_point = 0; - sd->status.base_level = 1; - sd->status.job_level = 1; - sd->status.base_exp = 0; - sd->status.job_exp = 0; - } - if (type == 3) - { - sd->status.base_level = 1; - sd->status.base_exp = 0; - } - if (type == 4) - { - sd->status.job_level = 1; - sd->status.job_exp = 0; - } - - clif_updatestatus(sd, SP::STATUSPOINT); - clif_updatestatus(sd, SP::STR); - clif_updatestatus(sd, SP::AGI); - clif_updatestatus(sd, SP::VIT); - clif_updatestatus(sd, SP::INT); - clif_updatestatus(sd, SP::DEX); - clif_updatestatus(sd, SP::LUK); - clif_updatestatus(sd, SP::BASELEVEL); - clif_updatestatus(sd, SP::JOBLEVEL); - clif_updatestatus(sd, SP::STATUSPOINT); - clif_updatestatus(sd, SP::NEXTBASEEXP); - clif_updatestatus(sd, SP::NEXTJOBEXP); - clif_updatestatus(sd, SP::SKILLPOINT); - - clif_updatestatus(sd, SP::USTR); // Updates needed stat points - Valaris - clif_updatestatus(sd, SP::UAGI); - clif_updatestatus(sd, SP::UVIT); - clif_updatestatus(sd, SP::UINT); - clif_updatestatus(sd, SP::UDEX); - clif_updatestatus(sd, SP::ULUK); // End Addition - - for (EQUIP i : EQUIPs) - { - // unequip items that can't be equipped by base 1 [Valaris] - IOff0 *idx = &sd->equip_index_maybe[i]; - if ((*idx).ok()) - { - if (!pc_isequip(sd, *idx)) - { - pc_unequipitem(sd, *idx, CalcStatus::LATER); - *idx = IOff0::from(-1); - } - } - } - - clif_skillinfoblock(sd); - pc_calcstatus(sd, 0); - - MAP_LOG_STATS(sd, "STATRESET"_fmt); - - return 0; -} - -/*========================================== * /resetstate *------------------------------------------ */ @@ -3943,21 +3780,6 @@ int pc_changelook(dumb_ptr<map_session_data> sd, LOOK type, int val) } /*========================================== - * 付属品(鷹,ペコ,カート)設定 - *------------------------------------------ - */ -int pc_setoption(dumb_ptr<map_session_data> sd, Opt0 type) -{ - nullpo_retz(sd); - - sd->status.option = type; - clif_changeoption(sd); - pc_calcstatus(sd, 0); - - return 0; -} - -/*========================================== * script用変数の値を読む *------------------------------------------ */ diff --git a/src/map/pc.hpp b/src/map/pc.hpp index 9795443..c889e44 100644 --- a/src/map/pc.hpp +++ b/src/map/pc.hpp @@ -77,7 +77,7 @@ int pc_counttargeted(dumb_ptr<map_session_data> sd, dumb_ptr<block_list> src, int pc_setrestartvalue(dumb_ptr<map_session_data> sd, int type); void pc_makesavestatus(dumb_ptr<map_session_data>); int pc_setnewpc(dumb_ptr<map_session_data>, AccountId, CharId, int, uint32_t /*tick_t*/, SEX); -int pc_authok(AccountId, int, TimeT, short tmw_version, const CharKey *, const CharData *); +int pc_authok(AccountId, int, short tmw_version, const CharKey *, const CharData *); int pc_authfail(AccountId accid); EPOS pc_equippoint(dumb_ptr<map_session_data> sd, IOff0 n); @@ -87,7 +87,6 @@ IOff0 pc_checkequip(dumb_ptr<map_session_data> sd, EPOS pos); int pc_walktoxy(dumb_ptr<map_session_data>, int, int); int pc_stop_walking(dumb_ptr<map_session_data>, int); -int pc_movepos(dumb_ptr<map_session_data>, int, int); int pc_setpos(dumb_ptr<map_session_data>, MapName, int, int, BeingRemoveWhy); void pc_setsavepoint(dumb_ptr<map_session_data>, MapName, int, int); int pc_randomwarp(dumb_ptr<map_session_data> sd, BeingRemoveWhy type); @@ -127,7 +126,6 @@ int pc_need_status_point(dumb_ptr<map_session_data>, SP); int pc_statusup(dumb_ptr<map_session_data>, SP); int pc_statusup2(dumb_ptr<map_session_data>, SP, int); int pc_skillup(dumb_ptr<map_session_data>, SkillID); -int pc_resetlvl(dumb_ptr<map_session_data>, int type); int pc_resetstate(dumb_ptr<map_session_data>); int pc_resetskill(dumb_ptr<map_session_data>); int pc_equipitem(dumb_ptr<map_session_data>, IOff0, EPOS); @@ -139,7 +137,6 @@ int pc_damage(dumb_ptr<block_list>, dumb_ptr<map_session_data>, int); int pc_heal(dumb_ptr<map_session_data>, int, int); int pc_itemheal(dumb_ptr<map_session_data> sd, int hp, int sp); int pc_percentheal(dumb_ptr<map_session_data> sd, int, int); -int pc_setoption(dumb_ptr<map_session_data>, Opt0); int pc_changelook(dumb_ptr<map_session_data>, LOOK, int); int pc_readparam(dumb_ptr<map_session_data>, SP); diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index a291a11..f9334bc 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -2574,6 +2574,69 @@ void builtin_npcwarp(ScriptState *st) } /*========================================== + * npcareawarp [remoitnane] [wushin] + * Move NPC to a new area on the same map. + *------------------------------------------ + */ +static +void builtin_npcareawarp(ScriptState *st) +{ + int x0, y0, x1, y1, x, y, max, cb, lx = -1, ly = -1, j = 0; + dumb_ptr<npc_data> nd = nullptr; + + NpcName npc = stringish<NpcName>(ZString(conv_str(st, &AARG(5)))); + nd = npc_name2id(npc); + + x0 = conv_num(st, &AARG(0)); + y0 = conv_num(st, &AARG(1)); + x1 = conv_num(st, &AARG(2)); + y1 = conv_num(st, &AARG(3)); + cb = conv_num(st, &AARG(4)); + + if (!nd) + { + PRINTF("builtin_npcareawarp: no such npc: %s\n"_fmt, npc); + return; + } + + max = (y1 - y0 + 1) * (x1 - x0 + 1) * 3; + if (max > 1000) + max = 1000; + + P<map_local> m = nd->bl_m; + if (cb) { + do + { + x = random_::in(x0, x1); + y = random_::in(y0, y1); + } + while (bool(map_getcell(m, x, y) & MapCell::UNWALKABLE) + && (++j) < max); + if (j >= max) + { + if (lx >= 0) + { // Since reference went wrong, the place which boiled before is used. + x = lx; + y = ly; + } + else + return; // Since reference of the place which boils first went wrong, it stops. + } + } + else + x = random_::in(x0, x1); + y = random_::in(y0, y1); + + npc_enable(npc, 0); + map_delblock(nd); /* [Freeyorp] */ + nd->bl_x = x; + nd->bl_y = y; + map_addblock(nd); + npc_enable(npc, 1); + +} + +/*========================================== * message [MouseJstr] *------------------------------------------ */ @@ -2745,6 +2808,24 @@ void builtin_isin(ScriptState *st) && (str == sd->bl_m->name_)); } +/*========================================== + * Check whether the coords are collision + *------------------------------------------ + */ +static +void builtin_iscollision(ScriptState *st) +{ + int x, y; + MapName mapname = stringish<MapName>(ZString(conv_str(st, &AARG(0)))); + P<map_local> m = TRY_UNWRAP(map_mapname2mapid(mapname), return); + + x = conv_num(st, &AARG(1)); + y = conv_num(st, &AARG(2)); + + push_int<ScriptDataInt>(st->stack, + bool(map_getcell(m, x, y) & MapCell::UNWALKABLE)); +} + // Trigger the shop on a (hopefully) nearby shop NPC static void builtin_shop(ScriptState *st) @@ -2954,12 +3035,14 @@ BuiltinFunction builtin_functions[] = BUILTIN(unequipbyid, "i"_s, '\0'), BUILTIN(gmcommand, "s"_s, '\0'), BUILTIN(npcwarp, "xys"_s, '\0'), + BUILTIN(npcareawarp, "xyxyis"_s, '\0'), BUILTIN(message, "Ps"_s, '\0'), BUILTIN(npctalk, "s"_s, '\0'), BUILTIN(getlook, "i"_s, 'i'), BUILTIN(getsavepoint, "i"_s, '.'), BUILTIN(areatimer, "MxyxytE"_s, '\0'), BUILTIN(isin, "Mxyxy"_s, 'i'), + BUILTIN(iscollision, "Mxy"_s, 'i'), BUILTIN(shop, "s"_s, '\0'), BUILTIN(isdead, ""_s, 'i'), BUILTIN(fakenpcname, "ssi"_s, '\0'), |