diff options
author | mekolat <mekolat@users.noreply.github.com> | 2015-06-25 20:45:03 -0400 |
---|---|---|
committer | mekolat <mekolat@users.noreply.github.com> | 2016-04-15 11:45:24 -0400 |
commit | c7592866c56e4c5bc2f603c462148ac5cf4fd374 (patch) | |
tree | 89d8e87a6ed65a41f61cacc393d380721f39f9c6 | |
parent | e0ab38974d08268fd0bbbae16293afb31686c9f8 (diff) | |
download | tmwa-c7592866c56e4c5bc2f603c462148ac5cf4fd374.tar.gz tmwa-c7592866c56e4c5bc2f603c462148ac5cf4fd374.tar.bz2 tmwa-c7592866c56e4c5bc2f603c462148ac5cf4fd374.tar.xz tmwa-c7592866c56e4c5bc2f603c462148ac5cf4fd374.zip |
allow to get mob/npc params and add more params to readparam
-rw-r--r-- | src/map/battle.cpp | 9 | ||||
-rw-r--r-- | src/map/battle.hpp | 9 | ||||
-rw-r--r-- | src/map/pc.cpp | 102 | ||||
-rw-r--r-- | src/map/pc.hpp | 2 | ||||
-rw-r--r-- | src/map/script-call.cpp | 2 | ||||
-rw-r--r-- | src/map/script-fun.cpp | 14 |
6 files changed, 104 insertions, 34 deletions
diff --git a/src/map/battle.cpp b/src/map/battle.cpp index 991a489..ef1567e 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -341,7 +341,6 @@ int battle_get_luk(dumb_ptr<block_list> bl) * 戻りは整数で1以上 *------------------------------------------ */ -static int battle_get_flee(dumb_ptr<block_list> bl) { int flee = 1; @@ -370,7 +369,6 @@ int battle_get_flee(dumb_ptr<block_list> bl) * 戻りは整数で1以上 *------------------------------------------ */ -static int battle_get_hit(dumb_ptr<block_list> bl) { int hit = 1; @@ -398,7 +396,6 @@ int battle_get_hit(dumb_ptr<block_list> bl) * 戻りは整数で1以上 *------------------------------------------ */ -static int battle_get_flee2(dumb_ptr<block_list> bl) { int flee2 = 1; @@ -430,7 +427,6 @@ int battle_get_flee2(dumb_ptr<block_list> bl) * 戻りは整数で1以上 *------------------------------------------ */ -static int battle_get_critical(dumb_ptr<block_list> bl) { int critical = 1; @@ -457,7 +453,6 @@ int battle_get_critical(dumb_ptr<block_list> bl) * 戻りは整数で1以上 *------------------------------------------ */ -static int battle_get_baseatk(dumb_ptr<block_list> bl) { eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data; @@ -484,7 +479,6 @@ int battle_get_baseatk(dumb_ptr<block_list> bl) * 戻りは整数で0以上 *------------------------------------------ */ -static int battle_get_atk(dumb_ptr<block_list> bl) { eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data; @@ -507,7 +501,6 @@ int battle_get_atk(dumb_ptr<block_list> bl) * 戻りは整数で0以上 *------------------------------------------ */ -static int battle_get_atk2(dumb_ptr<block_list> bl) { nullpo_retz(bl); @@ -530,7 +523,6 @@ int battle_get_atk2(dumb_ptr<block_list> bl) * 戻りは整数で0以上 *------------------------------------------ */ -static int battle_get_matk1(dumb_ptr<block_list> bl) { eptr<struct status_change, StatusChange, StatusChange::MAX_STATUSCHANGE> sc_data; @@ -554,7 +546,6 @@ int battle_get_matk1(dumb_ptr<block_list> bl) * 戻りは整数で0以上 *------------------------------------------ */ -static int battle_get_matk2(dumb_ptr<block_list> bl) { nullpo_retz(bl); diff --git a/src/map/battle.hpp b/src/map/battle.hpp index 8f31fe0..2925b58 100644 --- a/src/map/battle.hpp +++ b/src/map/battle.hpp @@ -83,6 +83,15 @@ int battle_get_def(dumb_ptr<block_list> bl); int battle_get_mdef(dumb_ptr<block_list> bl); int battle_get_def2(dumb_ptr<block_list> bl); int battle_get_mdef2(dumb_ptr<block_list> bl); +int battle_get_atk(dumb_ptr<block_list> bl); +int battle_get_atk2(dumb_ptr<block_list> bl); +int battle_get_matk1(dumb_ptr<block_list> bl); +int battle_get_matk2(dumb_ptr<block_list> bl); +int battle_get_hit(dumb_ptr<block_list> bl); +int battle_get_flee(dumb_ptr<block_list> bl); +int battle_get_flee2(dumb_ptr<block_list> bl); +int battle_get_critical(dumb_ptr<block_list> bl); +int battle_get_baseatk(dumb_ptr<block_list> bl); interval_t battle_get_speed(dumb_ptr<block_list> bl); interval_t battle_get_adelay(dumb_ptr<block_list> bl); interval_t battle_get_amotion(dumb_ptr<block_list> bl); diff --git a/src/map/pc.cpp b/src/map/pc.cpp index f65e2b4..84d02a4 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -3382,64 +3382,105 @@ int pc_damage(dumb_ptr<block_list> src, dumb_ptr<map_session_data> sd, * script用PCステータス読み出し *------------------------------------------ */ -int pc_readparam(dumb_ptr<map_session_data> sd, SP type) +int pc_readparam(dumb_ptr<block_list> bl, SP type) { + nullpo_retz(bl); + dumb_ptr<map_session_data> sd; + dumb_ptr<npc_data> nd; + dumb_ptr<mob_data> md; int val = 0; - nullpo_retz(sd); + if (bl->bl_type == BL::PC) + sd = bl->is_player(); + else if (bl->bl_type == BL::MOB) + md = bl->is_mob(); + else if (bl->bl_type == BL::NPC) + nd = bl->is_npc(); + else + return val; switch (type) { case SP::SKILLPOINT: - val = sd->status.skill_point; + val = sd ? sd->status.skill_point : 0; break; case SP::STATUSPOINT: - val = sd->status.status_point; + val = sd ? sd->status.status_point : 0; break; case SP::ZENY: - val = sd->status.zeny; + val = sd ? sd->status.zeny : 0; break; case SP::BASELEVEL: - val = sd->status.base_level; + val = battle_get_lv(bl); break; case SP::JOBLEVEL: - val = sd->status.job_level; + val = sd ? sd->status.job_level : 0; break; case SP::CLASS: - val = unwrap<Species>(sd->status.species); + val = unwrap<Species>(battle_get_class(bl)); break; case SP::SEX: - val = static_cast<uint8_t>(sd->status.sex); + if (sd) + val = static_cast<uint8_t>(sd->status.sex); + else if (nd) + val = static_cast<uint8_t>(nd->sex); break; case SP::WEIGHT: - val = sd->weight; + val = sd ? sd->weight : 0; break; case SP::MAXWEIGHT: - val = sd->max_weight; + val = sd ? sd->max_weight : 0; break; case SP::BASEEXP: - val = sd->status.base_exp; + val = sd ? sd->status.base_exp : 0; break; case SP::JOBEXP: - val = sd->status.job_exp; + val = sd ? sd->status.job_exp : 0; break; case SP::NEXTBASEEXP: - val = pc_nextbaseexp(sd); + val = sd ? pc_nextbaseexp(sd) : 0; break; case SP::NEXTJOBEXP: - val = pc_nextjobexp(sd); + val = sd ? pc_nextjobexp(sd) : 0; break; case SP::HP: - val = sd->status.hp; + val = battle_get_hp(bl); break; case SP::MAXHP: - val = sd->status.max_hp; + val = battle_get_max_hp(bl); break; case SP::SP: - val = sd->status.sp; + val = sd ? sd->status.sp : 0; break; case SP::MAXSP: - val = sd->status.max_sp; + val = sd ? sd->status.max_sp : 0; + break; + case SP::BASE_ATK: + val = battle_get_baseatk(bl); + break; + case SP::ATK1: + val = battle_get_atk(bl); + break; + case SP::ATK2: + val = battle_get_atk2(bl); + break; + case SP::DEF1: + val = battle_get_def(bl); + break; + case SP::DEF2: + val = battle_get_def2(bl); + break; + case SP::MATK1: + val = battle_get_matk1(bl); + break; + case SP::MATK2: + val = battle_get_matk2(bl); + break; + case SP::MDEF1: + val = battle_get_mdef(bl); + break; + case SP::MDEF2: + val = battle_get_mdef2(bl); break; case SP::STR: case SP::AGI: @@ -3447,7 +3488,28 @@ int pc_readparam(dumb_ptr<map_session_data> sd, SP type) case SP::INT: case SP::DEX: case SP::LUK: - val = sd->status.attrs[sp_to_attr(type)]; + val = battle_get_stat(type, bl); + break; + case SP::SPEED: + val = battle_get_speed(bl).count(); + break; + case SP::HIT: + val = battle_get_hit(bl); + break; + case SP::FLEE1: + val = battle_get_flee(bl); + break; + case SP::FLEE2: + val = battle_get_flee2(bl); + break; + case SP::CRITICAL: + val = battle_get_critical(bl); + break; + case SP::GM: + val = sd ? pc_isGM(sd).get_all_bits() : 0; + break; + case SP::ATTACKRANGE: + val = battle_get_range(bl); break; } diff --git a/src/map/pc.hpp b/src/map/pc.hpp index 6bcfadb..35ca975 100644 --- a/src/map/pc.hpp +++ b/src/map/pc.hpp @@ -142,7 +142,7 @@ 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_changelook(dumb_ptr<map_session_data>, LOOK, int); -int pc_readparam(dumb_ptr<map_session_data>, SP); +int pc_readparam(dumb_ptr<block_list>, SP); int pc_setparam(dumb_ptr<map_session_data>, SP, int); int pc_readreg(dumb_ptr<block_list>, SIR); void pc_setreg(dumb_ptr<block_list>, SIR, int); diff --git a/src/map/script-call.cpp b/src/map/script-call.cpp index 2ebfca3..8d2f58f 100644 --- a/src/map/script-call.cpp +++ b/src/map/script-call.cpp @@ -88,7 +88,7 @@ void get_val(dumb_ptr<block_list> sd, struct script_data *data) PRINTF("get_val error param SP::%d\n"_fmt, u.reg.sp()); int numi = 0; if (sd) - numi = pc_readparam(sd->is_player(), u.reg.sp()); + numi = pc_readparam(sd, u.reg.sp()); *data = ScriptDataInt{numi}; } MATCH_CASE (const ScriptDataVariable&, u) diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 8afe4ef..5990e47 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -1676,7 +1676,11 @@ void builtin_freeloop(ScriptState *st) static void builtin_bonus(ScriptState *st) { - SP type = SP(conv_num(st, &AARG(0))); + SP type; + if (auto *u = AARG(0).get_if<ScriptDataParam>()) + type = u->reg.sp(); + else + type = SP(conv_num(st, &AARG(0))); int val = conv_num(st, &AARG(1)); dumb_ptr<map_session_data> sd = script_rid2sd(st); pc_bonus(sd, type, val); @@ -1690,7 +1694,11 @@ void builtin_bonus(ScriptState *st) static void builtin_bonus2(ScriptState *st) { - SP type = SP(conv_num(st, &AARG(0))); + SP type; + if (auto *u = AARG(0).get_if<ScriptDataParam>()) + type = u->reg.sp(); + else + type = SP(conv_num(st, &AARG(0))); int type2 = conv_num(st, &AARG(1)); int val = conv_num(st, &AARG(2)); dumb_ptr<map_session_data> sd = script_rid2sd(st); @@ -3291,7 +3299,7 @@ void builtin_get(ScriptState *st) if (bl == nullptr) return; - int var = pc_readparam(bl->is_player(), reg.sp()); + int var = pc_readparam(bl, reg.sp()); push_int<ScriptDataInt>(st->stack, var); return; } |