From 79d63d98564f36c9372bdd76009d1e133db7233f Mon Sep 17 00:00:00 2001 From: HoraK-FDF Date: Sat, 12 Nov 2022 03:51:50 +0100 Subject: mobinfo add3 --- src/map/globals.cpp | 2 +- src/map/globals.hpp | 2 +- src/map/mob.cpp | 2 +- src/map/mob.hpp | 3 ++- src/map/pc.cpp | 30 +++++------------------ src/map/script-fun.cpp | 62 +++++++++++++++++++++++++++++++++++------------- src/map/script-fun.t.hpp | 2 +- 7 files changed, 58 insertions(+), 45 deletions(-) diff --git a/src/map/globals.cpp b/src/map/globals.cpp index 8a4d22b..d2c1993 100644 --- a/src/map/globals.cpp +++ b/src/map/globals.cpp @@ -70,7 +70,7 @@ namespace tmwa block_list bl_head; std::unique_ptr map_logfile; long map_logfile_index; - mob_db_ mob_db[MaxMobs]; + mob_db_ mob_db[MaxMobID+1]; std::list npc_srcs; int npc_warp, npc_shop, npc_script, npc_mob; BlockId npc_id = START_NPC_NUM; diff --git a/src/map/globals.hpp b/src/map/globals.hpp index f33f316..2fcdd95 100644 --- a/src/map/globals.hpp +++ b/src/map/globals.hpp @@ -64,7 +64,7 @@ namespace tmwa extern block_list bl_head; extern std::unique_ptr map_logfile; extern long map_logfile_index; - extern mob_db_ mob_db[MaxMobs]; + extern mob_db_ mob_db[MaxMobID+1]; extern std::list npc_srcs; extern int npc_warp, npc_shop, npc_script, npc_mob; extern BlockId npc_id; diff --git a/src/map/mob.cpp b/src/map/mob.cpp index f4c7216..0f273a8 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -115,7 +115,7 @@ Species mobdb_searchname(MobName str) Species mobdb_checkid(Species id) { // value range is [1001, 2000] - if (wrap(1000) < id && id < wrap(2001)) + if (wrap(MinMobID-1) < id && id < wrap(MaxMobID+1)) return id; return Species(); } diff --git a/src/map/mob.hpp b/src/map/mob.hpp index a1f9226..47da095 100644 --- a/src/map/mob.hpp +++ b/src/map/mob.hpp @@ -44,7 +44,8 @@ namespace map #define MOB_THIS_MAP stringish("this"_s) #define MaxDrops 8 -#define MaxMobs 2001 +#define MinMobID 1001 +#define MaxMobID 2000 struct mob_skill { diff --git a/src/map/pc.cpp b/src/map/pc.cpp index d427ab9..6c2f673 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -130,7 +130,7 @@ earray aspd_base_0 //= 650_ms, // 0 NONE 700_ms, // 1 BLADE or some other common weapons 750_ms, // 2 -610_ms, // 3 SETZER_AND_SCYTHE +600_ms, // 3 SETZER_AND_SCYTHE 2000_ms, // 4 2000_ms, // 5 800_ms, // 6 Falchion @@ -792,7 +792,7 @@ void pc_set_attack_info(dumb_ptr sd, interval_t speed, int ran } else { - pc_calcstatus(sd, 9); + sd->aspd = speed; clif_updatestatus(sd, SP::ASPD); clif_updatestatus(sd, SP::ATTACKRANGE); } @@ -1085,12 +1085,6 @@ void pc_set_weapon_look(dumb_ptr sd) * When first==0, the parameter to be calculated is from before the call * If it changes, it will automatically send it, * Actively changed parameters should be send on their own - * - * First is a bitmask - * &1 = ? - * &2 = ? - * &4 = ? - * &8 = magic override *------------------------------------------ */ int pc_calcstatus(dumb_ptr sd, int first) @@ -1523,18 +1517,11 @@ int pc_calcstatus(dumb_ptr sd, int first) if (sd->speed_rate != 100) sd->speed = sd->speed * sd->speed_rate / 100; sd->speed = std::max(sd->speed, 1_ms); - - /* Magic speed */ - if (sd->attack_spell_override || first & 8) - sd->aspd = sd->attack_spell_delay; - if (aspd_rate != 100) sd->aspd = sd->aspd * aspd_rate / 100; - /* Red Threshold Calculation */ - if (sd->aspd < 300_ms) { - sd->aspd = 300_ms + ((sd->aspd - 300_ms) * 15 / 20); - } + if (sd->attack_spell_override) + sd->aspd = sd->attack_spell_delay; sd->aspd = std::max(sd->aspd, battle_config.max_aspd); sd->amotion = sd->aspd; @@ -2877,7 +2864,7 @@ void pc_attack_timer(TimerData *, tick_t tick, BlockId id) {"@target_id"_s, static_cast(unwrap(bl->bl_id))}, }; npc_event_do_l(sd->magic_attack, sd->bl_id, arg); - sd->attackabletime = tick + sd->aspd; // sd->attack_spell_delay + sd->attackabletime = tick + sd->attack_spell_delay; sd->attack_spell_charges--; if (!sd->attack_spell_charges) { @@ -3137,10 +3124,7 @@ int pc_gainexp_reason(dumb_ptr sd, int base_exp, int job_exp, } // Double Xp Weekends - if (reason != PC_GAINEXP_REASON::SCRIPT) - base_exp = (base_exp * static_cast(battle_config.base_exp_rate) / 100.); - - // Sanitization + base_exp = (base_exp * static_cast(battle_config.base_exp_rate) / 100.); if (base_exp <= 0) base_exp = 0; else if (base_exp > 1000000000) @@ -5631,8 +5615,6 @@ int pc_logout(dumb_ptr sd) // [fate] Player logs out #endif pc_setglobalreg(sd, stringish("MAGIC_CAST_TICK"_s), 0); - npc_event_doall_l(stringish("OnPCLogoutEvent"_s), sd->bl_id, nullptr); - MAP_LOG_STATS(sd, "LOGOUT"_fmt); return 0; } diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 2c79b68..fd3eec0 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -2624,7 +2624,8 @@ void builtin_getexp(ScriptState *st) } /*========================================== - * + * Returns attributes of a monster + * return value -1 = mob not found *------------------------------------------ */ static @@ -2636,6 +2637,12 @@ void builtin_mobinfo(ScriptState *st) AString info_str; char mode = 0; // 0 = int, 1 = str + if (mobdb_checkid(mob_id) == Species()) + { + push_int(st->stack, -1); + return; + } + switch (request) { case MobInfo::ID: @@ -2842,8 +2849,8 @@ void builtin_mobinfo(ScriptState *st) break; default: PRINTF("builtin_mobinfo: unknown request\n"_fmt); - info_str = "mobinfo: unknown request"_s; - mode = 1; + push_int(st->stack, -1); + return; break; } if (!mode) @@ -2853,12 +2860,15 @@ void builtin_mobinfo(ScriptState *st) } /*========================================== - * - * + * Returns drops of a monster to an array + * return values: + * 0 = mob not found or error + * 1 = mob found and has drops + * 2 = mob found and has no drops *------------------------------------------ */ static -void builtin_mobinfo_droparrays(ScriptState *st) +void builtin_getmobdrops(ScriptState *st) { dumb_ptr bl = nullptr; @@ -2871,10 +2881,13 @@ void builtin_mobinfo_droparrays(ScriptState *st) char prefix = name.front(); char postfix = name.back(); + + int status = 0; // 0 = mob not found or error, 1 = mob found and has drops, 2 = mob found and has no drops if (prefix != '$' && prefix != '@' && prefix != '.') { - PRINTF("builtin_mobinfo_droparrays: illegal scope!\n"_fmt); + PRINTF("builtin_getmobdrops: illegal scope!\n"_fmt); + push_int(st->stack, 0); return; } @@ -2891,32 +2904,44 @@ void builtin_mobinfo_droparrays(ScriptState *st) case MobInfo_DropArrays::IDS: if (postfix == '$') { - PRINTF("builtin_mobinfo_droparrays: wrong array type for ID's (Int expected but String found)!\n"_fmt); + PRINTF("builtin_getmobdrops: wrong array type for ID's (Int expected but String found)!\n"_fmt); + push_int(st->stack, 0); return; } break; case MobInfo_DropArrays::NAMES: if (postfix != '$') { - PRINTF("builtin_mobinfo_droparrays: wrong array type for Names (String expected but Int found)!\n"_fmt); + PRINTF("builtin_getmobdrops: wrong array type for Names (String expected but Int found)!\n"_fmt); + push_int(st->stack, 0); return; } break; case MobInfo_DropArrays::PERCENTS: if (postfix == '$') { - PRINTF("builtin_mobinfo_droparrays: wrong array type for Percents (Int expected but String found)!\n"_fmt); + PRINTF("builtin_getmobdrops: wrong array type for Percents (Int expected but String found)!\n"_fmt); + push_int(st->stack, 0); return; } break; default: - PRINTF("builtin_mobinfo_droparrays: unknown request\n"_fmt); + PRINTF("builtin_getmobdrops: unknown request\n"_fmt); + push_int(st->stack, 0); + return; break; } + if (mobdb_checkid(mob_id) == Species()) + { + push_int(st->stack, status); + return; + } + for (int i = 0; i < MaxDrops; ++i) if (get_mob_db(mob_id).dropitem[i].nameid) { + status = 1; switch (request) { case MobInfo_DropArrays::IDS: @@ -2954,8 +2979,13 @@ void builtin_mobinfo_droparrays(ScriptState *st) } } else + { + if (i == 0) + status = 2; break; + } + push_int(st->stack, status); } /*========================================== @@ -3484,7 +3514,7 @@ void builtin_mapannounce(ScriptState *st) /*========================================== * ユーザー数所得 - * User Count + * User Revenue *------------------------------------------ */ static @@ -3495,9 +3525,9 @@ void builtin_getusers(ScriptState *st) int val = 0; switch (flag & 0x07) { - /*case 0: + case 0: val = bl->bl_m->users; - break;*/ + break; case 1: val = map_getusers(); break; @@ -3507,7 +3537,7 @@ void builtin_getusers(ScriptState *st) /*========================================== * マップ指定ユーザー数所得 - * maps Designated User Count + * maps Designated User Income *------------------------------------------ */ static @@ -5470,7 +5500,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(openstorage, ""_s, '\0'), BUILTIN(getexp, "ii"_s, '\0'), BUILTIN(mobinfo, "ii"_s, 'v'), - BUILTIN(mobinfo_droparrays, "iiN"_s, '\0'), + BUILTIN(getmobdrops, "iiN"_s, 'i'), BUILTIN(summon, "Mxyssmii?"_s, '\0'), BUILTIN(monster, "Mxysmi?"_s, '\0'), BUILTIN(areamonster, "Mxyxysmi?"_s, '\0'), diff --git a/src/map/script-fun.t.hpp b/src/map/script-fun.t.hpp index f08925c..d0c753b 100644 --- a/src/map/script-fun.t.hpp +++ b/src/map/script-fun.t.hpp @@ -1,5 +1,5 @@ #pragma once -// script-call.t.hpp - EAthena script frontend, engine, and library. +// script-fun.t.hpp - EAthena script frontend, engine, and library. // // Copyright © ????-2004 Athena Dev Teams // Copyright © 2004-2011 The Mana World Development Team -- cgit v1.2.3-60-g2f50