summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-12-03 03:41:08 +0100
committerHaru <haru@dotalux.com>2017-09-17 17:48:15 +0200
commita681d759cc887e8adccbd30d3b7a7ca355bbda96 (patch)
treecdea2ed4340cd81f31d05e34772ad0d2cf7ffd57 /src
parent9a7536d2e092d9a7737e795094e68e6d1f94f6e9 (diff)
downloadhercules-a681d759cc887e8adccbd30d3b7a7ca355bbda96.tar.gz
hercules-a681d759cc887e8adccbd30d3b7a7ca355bbda96.tar.bz2
hercules-a681d759cc887e8adccbd30d3b7a7ca355bbda96.tar.xz
hercules-a681d759cc887e8adccbd30d3b7a7ca355bbda96.zip
Differentiate variables that hold a ViewSprite and a weapon Subtype
`sd->status.weapon` is renamed to `sd->status.look.weapon` and only holds ViewSprite IDs. Its previous other meaning is now transferred to `sd->weapontype` (holding the currently equipped weapon type, considering both hands at once) Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c10
-rw-r--r--src/common/mmo.h4
-rw-r--r--src/map/battle.c36
-rw-r--r--src/map/clif.c4
-rw-r--r--src/map/pc.c58
-rw-r--r--src/map/pc.h13
-rw-r--r--src/map/script.c2
-rw-r--r--src/map/skill.c10
-rw-r--r--src/map/status.c39
9 files changed, 94 insertions, 82 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 4687d4d6b..09aa8684b 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -460,7 +460,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
(p->int_ != cp->int_) || (p->dex != cp->dex) || (p->luk != cp->luk) ||
(p->option != cp->option) ||
(p->party_id != cp->party_id) || (p->guild_id != cp->guild_id) ||
- (p->pet_id != cp->pet_id) || (p->weapon != cp->weapon) || (p->hom_id != cp->hom_id) ||
+ (p->pet_id != cp->pet_id) || (p->look.weapon != cp->look.weapon) || (p->hom_id != cp->hom_id) ||
(p->ele_id != cp->ele_id) || (p->shield != cp->shield) || (p->head_top != cp->head_top) ||
(p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->delete_date != cp->delete_date) ||
(p->rename != cp->rename) || (p->slotchange != cp->slotchange) || (p->robe != cp->robe) ||
@@ -490,7 +490,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point,
p->str, p->agi, p->vit, p->int_, p->dex, p->luk,
p->option, p->party_id, p->guild_id, p->pet_id, p->hom_id, p->ele_id,
- p->weapon, p->shield, p->head_top, p->head_mid, p->head_bottom,
+ p->look.weapon, p->shield, p->head_top, p->head_mid, p->head_bottom,
mapindex_id2name(p->last_point.map), p->last_point.x, p->last_point.y,
mapindex_id2name(p->save_point.map), p->save_point.x, p->save_point.y, p->rename,
(unsigned long)p->delete_date, // FIXME: platform-dependent size
@@ -1094,7 +1094,7 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 25, SQLDT_SHORT, &p.hair_color, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_SHORT, &p.clothes_color, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_SHORT, &p.body, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_SHORT, &p.weapon, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_SHORT, &p.look.weapon, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_SHORT, &p.shield, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p.head_top, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL)
@@ -1208,7 +1208,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p->hair_color, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_SHORT, &p->body, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_SHORT, &p->weapon, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_SHORT, &p->look.weapon, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p->shield, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p->head_top, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL)
@@ -1942,7 +1942,7 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) {
//When the weapon is sent and your option is riding, the client crashes on login!?
// FIXME[Haru]: is OPTION_HANBOK intended to be part of this list? And if it is, should the list also include other OPTION_ costumes?
- WBUFW(buf,56) = (p->option&(OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR|OPTION_HANBOK)) ? 0 : p->weapon;
+ WBUFW(buf,56) = (p->option&(OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR|OPTION_HANBOK)) ? 0 : p->look.weapon;
WBUFW(buf,58) = p->base_level;
WBUFW(buf,60) = min(p->skill_point, INT16_MAX);
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 7670a7ac8..1ade0caa9 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -612,7 +612,9 @@ struct mmo_charstatus {
int spear_faith, spear_calls;
int sword_faith, sword_calls;
- short weapon; // enum weapon_type
+ struct {
+ short weapon; ///< Weapon view sprite id.
+ } look;
short shield; // view-id
short head_top,head_mid,head_bottom;
short robe;
diff --git a/src/map/battle.c b/src/map/battle.c
index 9d67242a2..2861599b8 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -875,7 +875,7 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target,
}
#else
if( skill_id != ASC_BREAKER && weapon ) // Adv Katar Mastery is does not applies to ASC_BREAKER, but other masteries DO apply >_>
- if( sd->status.weapon == W_KATAR && (skill2_lv=pc->checkskill(sd,ASC_KATAR)) > 0 )
+ if (sd->weapontype == W_KATAR && (skill2_lv=pc->checkskill(sd,ASC_KATAR)) > 0)
damage += damage * (10 + 2 * skill2_lv) / 100;
#endif
@@ -2032,7 +2032,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
skillratio += 100 + 100 * skill_lv + 100 * (skill_lv / 2);
break;
case RG_BACKSTAP:
- if( sd && sd->status.weapon == W_BOW && battle_config.backstab_bow_penalty )
+ if (sd != NULL && sd->weapontype == W_BOW && battle_config.backstab_bow_penalty)
skillratio += (200 + 40 * skill_lv) / 2;
else
skillratio += 200 + 40 * skill_lv;
@@ -2053,10 +2053,10 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
case CR_HOLYCROSS:
{
int ratio = 35 * skill_lv;
- #ifdef RENEWAL
- if(sd && sd->status.weapon == W_2HSPEAR)
- ratio *= 2;
- #endif
+#ifdef RENEWAL
+ if (sd != NULL && sd->weapontype == W_2HSPEAR)
+ ratio *= 2;
+#endif
skillratio += ratio;
break;
}
@@ -2714,7 +2714,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
skillratio += 2*sc->data[SC_TRUESIGHT]->val1;
if( sc->data[SC_LKCONCENTRATION] )
skillratio += sc->data[SC_LKCONCENTRATION]->val2;
- if( sd && sd->status.weapon == W_KATAR && (i=pc->checkskill(sd,ASC_KATAR)) > 0 )
+ if (sd != NULL && sd->weapontype == W_KATAR && (i=pc->checkskill(sd,ASC_KATAR)) > 0)
skillratio += skillratio * (10 + 2 * i) / 100;
#endif
if( (!skill_id || skill_id == KN_AUTOCOUNTER) && sc->data[SC_CRUSHSTRIKE] ){
@@ -3023,7 +3023,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
status_change_end(bl,SC_DEEP_SLEEP,INVALID_TIMER);
}
if( s_sd && t_sd && sc->data[SC_COLD] && flag&BF_WEAPON ){
- switch(s_sd->status.weapon){
+ switch (s_sd->weapontype) {
case W_MACE:
case W_2HMACE:
case W_1HAXE:
@@ -3165,7 +3165,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
if( (sce = sc->data[SC_STONEHARDSKIN]) && flag&(BF_SHORT|BF_WEAPON) && damage > 0 ) {
sce->val2 -= (int)cap_value(damage,INT_MIN,INT_MAX);
if( src->type == BL_PC ) {
- if (s_sd && s_sd->status.weapon != W_BOW)
+ if (s_sd != NULL && s_sd->weapontype != W_BOW)
skill->break_equip(src, EQP_WEAPON, 3000, BCT_SELF);
} else
skill->break_equip(src, EQP_WEAPON, 3000, BCT_SELF);
@@ -4648,7 +4648,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
short cri = sstatus->cri;
if (sd != NULL) {
// if show_katar_crit_bonus is enabled, it already done the calculation in status.c
- if (!battle_config.show_katar_crit_bonus && sd->status.weapon == W_KATAR) {
+ if (!battle_config.show_katar_crit_bonus && sd->weapontype == W_KATAR) {
cri <<= 1;
}
@@ -4821,8 +4821,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if ((temp = pc->checkskill(sd,BS_WEAPONRESEARCH)) > 0)
hitrate += hitrate * ( 2 * temp ) / 100;
- if( (sd->status.weapon == W_1HSWORD || sd->status.weapon == W_DAGGER) &&
- (temp = pc->checkskill(sd, GN_TRAINING_SWORD))>0 )
+ if ((sd->weapontype == W_1HSWORD || sd->weapontype == W_DAGGER) && (temp = pc->checkskill(sd, GN_TRAINING_SWORD)) > 0)
hitrate += 3 * temp;
}
@@ -4956,7 +4955,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
(!skill_id && sc && sc->data[SC_HLIF_CHANGE]?4:0)|
(sc && sc->data[SC_WEAPONPERFECT]?8:0);
if (flag.arrow && sd)
- switch(sd->status.weapon) {
+ switch (sd->weapontype) {
case W_BOW:
case W_REVOLVER:
case W_GATLING:
@@ -5582,7 +5581,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if(wd.damage < 1) wd.damage = 1;
if(wd.damage2 < 1) wd.damage2 = 1;
#endif
- } else if(sd->status.weapon == W_KATAR && !skill_id) { //Katars (offhand damage only applies to normal attacks, tested on Aegis 10.2)
+ } else if (sd->weapontype == W_KATAR && skill_id == 0) {
+ // Katars (offhand damage only applies to normal attacks, tested on Aegis 10.2)
temp = pc->checkskill(sd,TF_DOUBLE);
wd.damage2 = wd.damage * (1 + (temp * 2))/100;
@@ -5701,7 +5701,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
//Reject Sword bugreport:4493 by Daegaladh
if (wd.damage != 0 && tsc != NULL && tsc->data[SC_SWORDREJECT] != NULL
- && (sd == NULL || sd->weapontype1 == W_DAGGER || sd->weapontype1 == W_1HSWORD || sd->status.weapon == W_2HSWORD)
+ && (sd == NULL || sd->weapontype1 == W_DAGGER || sd->weapontype1 == W_1HSWORD || sd->weapontype == W_2HSWORD)
&& rnd()%100 < tsc->data[SC_SWORDREJECT]->val2
) {
ATK_RATER(50);
@@ -6099,7 +6099,7 @@ bool battle_check_arrows(struct map_session_data *sd)
}
//Ammo check by Ishizu-chan
if (sd->inventory_data[index]) {
- switch (sd->status.weapon) {
+ switch (sd->weapontype) {
case W_BOW:
if (sd->inventory_data[index]->subtype != A_ARROW) {
clif->arrow_fail(sd, 0);
@@ -6160,7 +6160,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
if (sd)
{
- sd->state.arrow_atk = (sd->status.weapon == W_BOW || (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE));
+ sd->state.arrow_atk = (sd->weapontype == W_BOW || (sd->weapontype >= W_REVOLVER && sd->weapontype <= W_GRENADE));
if (sd->state.arrow_atk)
{
if (battle->check_arrows(sd) == false)
@@ -6186,7 +6186,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
return ATK_BLOCK;
}
}
- if( tsc && tsc->data[SC_BLADESTOP_WAIT] && !is_boss(src) && (src->type == BL_PC || tsd == NULL || distance_bl(src, target) <= (tsd->status.weapon == W_FIST ? 1 : 2)) )
+ if( tsc && tsc->data[SC_BLADESTOP_WAIT] && !is_boss(src) && (src->type == BL_PC || tsd == NULL || distance_bl(src, target) <= (tsd->weapontype == W_FIST ? 1 : 2)) )
{
uint16 skill_lv = tsc->data[SC_BLADESTOP_WAIT]->val1;
int duration = skill->get_time2(MO_BLADESTOP,skill_lv);
diff --git a/src/map/clif.c b/src/map/clif.c
index 3599640b9..2962aaa8b 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -888,7 +888,7 @@ void clif_get_weapon_view(struct map_session_data* sd, unsigned short *rhand, un
}
#if PACKETVER < 4
- *rhand = sd->status.weapon;
+ *rhand = sd->status.look.weapon;
*lhand = sd->status.shield;
#else
if (sd->equip_index[EQI_HAND_R] >= 0 &&
@@ -9449,7 +9449,7 @@ void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) {
// Character Looks
#if PACKETVER < 4
- clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
+ clif->changelook(&sd->bl, LOOK_WEAPON, sd->status.look.weapon);
clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
#else
clif->changelook(&sd->bl,LOOK_WEAPON,0);
diff --git a/src/map/pc.c b/src/map/pc.c
index 904867f76..c30161a0c 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -829,40 +829,40 @@ int pc_calcweapontype(struct map_session_data *sd)
// single-hand
if(sd->weapontype2 == W_FIST) {
- sd->status.weapon = sd->weapontype1;
+ sd->weapontype = sd->weapontype1;
return 1;
}
if(sd->weapontype1 == W_FIST) {
- sd->status.weapon = sd->weapontype2;
+ sd->weapontype = sd->weapontype2;
return 1;
}
// dual-wield
- sd->status.weapon = W_FIST;
+ sd->weapontype = W_FIST;
switch (sd->weapontype1){
case W_DAGGER:
switch (sd->weapontype2) {
- case W_DAGGER: sd->status.weapon = W_DOUBLE_DD; break;
- case W_1HSWORD: sd->status.weapon = W_DOUBLE_DS; break;
- case W_1HAXE: sd->status.weapon = W_DOUBLE_DA; break;
+ case W_DAGGER: sd->weapontype = W_DOUBLE_DD; break;
+ case W_1HSWORD: sd->weapontype = W_DOUBLE_DS; break;
+ case W_1HAXE: sd->weapontype = W_DOUBLE_DA; break;
}
break;
case W_1HSWORD:
switch (sd->weapontype2) {
- case W_DAGGER: sd->status.weapon = W_DOUBLE_DS; break;
- case W_1HSWORD: sd->status.weapon = W_DOUBLE_SS; break;
- case W_1HAXE: sd->status.weapon = W_DOUBLE_SA; break;
+ case W_DAGGER: sd->weapontype = W_DOUBLE_DS; break;
+ case W_1HSWORD: sd->weapontype = W_DOUBLE_SS; break;
+ case W_1HAXE: sd->weapontype = W_DOUBLE_SA; break;
}
break;
case W_1HAXE:
switch (sd->weapontype2) {
- case W_DAGGER: sd->status.weapon = W_DOUBLE_DA; break;
- case W_1HSWORD: sd->status.weapon = W_DOUBLE_SA; break;
- case W_1HAXE: sd->status.weapon = W_DOUBLE_AA; break;
+ case W_DAGGER: sd->weapontype = W_DOUBLE_DA; break;
+ case W_1HSWORD: sd->weapontype = W_DOUBLE_SA; break;
+ case W_1HAXE: sd->weapontype = W_DOUBLE_AA; break;
}
}
// unknown, default to right hand type
- if (sd->status.weapon == W_FIST)
- sd->status.weapon = sd->weapontype1;
+ if (sd->weapontype == W_FIST)
+ sd->weapontype = sd->weapontype1;
return 2;
}
@@ -885,10 +885,13 @@ int pc_setequipindex(struct map_session_data *sd)
sd->equip_index[j] = i;
if (sd->status.inventory[i].equip & EQP_HAND_R) {
- if (sd->inventory_data[i])
+ if (sd->inventory_data[i]) {
sd->weapontype1 = sd->inventory_data[i]->subtype;
- else
+ sd->status.look.weapon = sd->inventory_data[i]->view_sprite;
+ } else {
sd->weapontype1 = W_FIST;
+ sd->status.look.weapon = 0;
+ }
}
if (sd->status.inventory[i].equip & EQP_HAND_L) {
@@ -2486,7 +2489,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) {
}
switch (sd->state.lr_flag) {
case 2:
- switch (sd->status.weapon) {
+ switch (sd->weapontype) {
case W_BOW:
case W_REVOLVER:
case W_RIFLE:
@@ -2553,7 +2556,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) {
case SP_ATTACKRANGE:
switch (sd->state.lr_flag) {
case 2:
- switch (sd->status.weapon) {
+ switch (sd->weapontype) {
case W_BOW:
case W_REVOLVER:
case W_RIFLE:
@@ -5940,7 +5943,7 @@ int pc_checkallowskill(struct map_session_data *sd)
status_change_end(&sd->bl, scw_list[i], INVALID_TIMER);
}
- if(sd->sc.data[SC_STRUP] && sd->status.weapon != W_FIST)
+ if(sd->sc.data[SC_STRUP] && sd->weapontype != W_FIST)
// Spurt requires bare hands (feet, in fact xD)
status_change_end(&sd->bl, SC_STRUP, INVALID_TIMER);
@@ -8842,7 +8845,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val)
case LOOK_BASE:
status->set_viewdata(&sd->bl, val);
clif->changelook(&sd->bl, LOOK_BASE, sd->vd.class);
- clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
+ clif->changelook(&sd->bl, LOOK_WEAPON, sd->status.look.weapon);
if (sd->vd.cloth_color)
clif->changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color);
if (sd->vd.body_style)
@@ -8861,7 +8864,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val)
}
break;
case LOOK_WEAPON:
- sd->status.weapon=val;
+ sd->status.look.weapon = val;
break;
case LOOK_HEAD_BOTTOM:
sd->status.head_bottom=val;
@@ -9755,12 +9758,15 @@ void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int n,
nullpo_retv(sd);
if ((!map_no_view(sd->bl.m,EQP_SHADOW_WEAPON) && pos & EQP_SHADOW_WEAPON) ||
(pos & EQP_HAND_R)) {
- if (id != NULL)
+ if (id != NULL) {
sd->weapontype1 = id->subtype;
- else
+ sd->status.look.weapon = id->view_sprite;
+ } else {
sd->weapontype1 = W_FIST;
+ sd->status.look.weapon = 0;
+ }
pc->calcweapontype(sd);
- clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
+ clif->changelook(&sd->bl, LOOK_WEAPON, sd->status.look.weapon);
}
if ((!map_no_view(sd->bl.m,EQP_SHADOW_SHIELD) && pos & EQP_SHADOW_SHIELD) ||
(pos & EQP_HAND_L)) {
@@ -9988,9 +9994,9 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos)
nullpo_retv(sd);
if (pos & EQP_HAND_R) {
sd->weapontype1 = W_FIST;
- sd->status.weapon = sd->weapontype2;
pc->calcweapontype(sd);
- clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
+ sd->status.look.weapon = 0;
+ clif->changelook(&sd->bl, LOOK_WEAPON, sd->status.look.weapon);
if (!battle_config.dancing_weaponswitch_fix)
status_change_end(&sd->bl, SC_DANCING, INVALID_TIMER); // Unequipping => stop dancing.
}
diff --git a/src/map/pc.h b/src/map/pc.h
index c94ec6099..62129b5ae 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -308,7 +308,9 @@ struct map_session_data {
short nameid;
int64 tick;
} item_delay[MAX_ITEMDELAYS]; // [Paradox924X]
- short weapontype1,weapontype2;
+ int16 weapontype; ///< Weapon type considering both hands (@see enum weapon_type).
+ int16 weapontype1; ///< Weapon type in the right/primary hand (@see enum weapon_type).
+ int16 weapontype2; ///< Weapon type in the left/secondary hand (@see enum weapon_type).
short disguise; // [Valaris]
struct weapon_data right_weapon, left_weapon;
@@ -685,8 +687,13 @@ END_ZEROED_BLOCK;
#define pc_stop_attack(sd) (unit->stop_attack(&(sd)->bl))
//Weapon check considering dual wielding.
-#define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_SINGLE_WEAPON_TYPE? \
- 1<<(sd)->status.weapon:(1<<(sd)->weapontype1)|(1<<(sd)->weapontype2)|(1<<(sd)->status.weapon)))
+#define pc_check_weapontype(sd, type) ( \
+ (type) & ( \
+ (sd)->weapontype < MAX_SINGLE_WEAPON_TYPE ? \
+ 1 << (sd)->weapontype : \
+ (1 << (sd)->weapontype1) | (1 << (sd)->weapontype2) \
+ ) \
+ )
// clientside display macros (values to the left/right of the "+")
#ifdef RENEWAL
diff --git a/src/map/script.c b/src/map/script.c
index a919467cf..58dd65173 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -15519,7 +15519,7 @@ BUILDIN(getlook)
type=script_getnum(st,2);
switch(type) {
case LOOK_HAIR: val = sd->status.hair; break; //1
- case LOOK_WEAPON: val = sd->status.weapon; break; //2
+ case LOOK_WEAPON: val = sd->status.look.weapon; break; //2
case LOOK_HEAD_BOTTOM: val = sd->status.head_bottom; break; //3
case LOOK_HEAD_TOP: val = sd->status.head_top; break; //4
case LOOK_HEAD_MID: val = sd->status.head_mid; break; //5
diff --git a/src/map/skill.c b/src/map/skill.c
index 1f510e6fe..4649ace42 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -806,7 +806,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
break; // If a normal attack is a skill, it's splash damage. [Inkfish]
if(sd) {
// Automatic trigger of Blitz Beat
- if (pc_isfalcon(sd) && sd->status.weapon == W_BOW && (temp=pc->checkskill(sd,HT_BLITZBEAT))>0 &&
+ if (pc_isfalcon(sd) && sd->weapontype == W_BOW && (temp=pc->checkskill(sd,HT_BLITZBEAT))>0 &&
rnd()%1000 <= sstatus->luk*3 ) {
rate = sd->status.job_level / 10 + 1;
skill->castend_damage_id(src,bl,HT_BLITZBEAT,(temp<rate)?temp:rate,tick,SD_LEVEL);
@@ -815,7 +815,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
if( pc_iswug(sd) && (temp=pc->checkskill(sd,RA_WUGSTRIKE)) > 0 && rnd()%1000 <= sstatus->luk*3 )
skill->castend_damage_id(src,bl,RA_WUGSTRIKE,temp,tick,0);
// Gank
- if(dstmd && sd->status.weapon != W_BOW &&
+ if(dstmd && sd->weapontype != W_BOW &&
(temp=pc->checkskill(sd,RG_SNATCHER)) > 0 &&
(temp*15 + 55) + pc->checkskill(sd,TF_STEAL)*10 > rnd()%1000) {
if(pc->steal_item(sd,bl,pc->checkskill(sd,TF_STEAL)))
@@ -2012,7 +2012,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in
if (sd->bonus.unbreakable)
rate -= rate*sd->bonus.unbreakable/100;
if (where&EQP_WEAPON) {
- switch (sd->status.weapon) {
+ switch (sd->weapontype) {
case W_FIST: //Bare fists should not break :P
case W_1HAXE:
case W_2HAXE:
@@ -5917,7 +5917,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case SA_LIGHTNINGLOADER:
case SA_SEISMICWEAPON:
if (dstsd) {
- if(dstsd->status.weapon == W_FIST ||
+ if (dstsd->weapontype == W_FIST ||
(dstsd->sc.count && !dstsd->sc.data[type] &&
( //Allow re-enchanting to lengthen time. [Skotlex]
dstsd->sc.data[SC_PROPERTYFIRE] ||
@@ -13391,7 +13391,7 @@ int skill_isammotype (struct map_session_data *sd, int skill_id)
nullpo_ret(sd);
return (
battle_config.arrow_decrement==2 &&
- (sd->status.weapon == W_BOW || (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)) &&
+ (sd->weapontype == W_BOW || (sd->weapontype >= W_REVOLVER && sd->weapontype <= W_GRENADE)) &&
skill_id != HT_PHANTASMIC &&
skill->get_type(skill_id) == BF_WEAPON &&
!(skill->get_nk(skill_id)&NK_NO_DAMAGE) &&
diff --git a/src/map/status.c b/src/map/status.c
index 0d2171eac..ed29e85be 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -2713,9 +2713,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
sd->left_weapon.atkmods[1] = status->dbs->atkmods[1][sd->weapontype2];
sd->left_weapon.atkmods[2] = status->dbs->atkmods[2][sd->weapontype2];
- if ((pc_isridingpeco(sd) || pc_isridingdragon(sd))
- && (sd->status.weapon==W_1HSPEAR || sd->status.weapon==W_2HSPEAR)
- ) {
+ if ((pc_isridingpeco(sd) || pc_isridingdragon(sd)) && (sd->weapontype == W_1HSPEAR || sd->weapontype == W_2HSPEAR)) {
//When Riding with spear, damage modifier to mid-class becomes
//same as versus large size.
sd->right_weapon.atkmods[1] = sd->right_weapon.atkmods[2];
@@ -2779,8 +2777,8 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
// Base batk value is set on status->calc_misc
// weapon-type bonus (FIXME: Why is the weapon_atk bonus applied to base attack?)
- if (sd->status.weapon < MAX_SINGLE_WEAPON_TYPE && sd->weapon_atk[sd->status.weapon])
- bstatus->batk += sd->weapon_atk[sd->status.weapon];
+ if (sd->weapontype < MAX_SINGLE_WEAPON_TYPE && sd->weapon_atk[sd->weapontype])
+ bstatus->batk += sd->weapon_atk[sd->weapontype];
// Absolute modifiers from passive skills
#ifndef RENEWAL
if((skill_lv=pc->checkskill(sd,BS_HILTBINDING))>0) // it doesn't work in RE.
@@ -2928,10 +2926,10 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
#ifndef RENEWAL
bstatus->hit += skill_lv;
#endif
- if(sd->status.weapon == W_BOW)
+ if (sd->weapontype == W_BOW)
bstatus->rhw.range += skill_lv;
}
- if(sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE) {
+ if (sd->weapontype >= W_REVOLVER && sd->weapontype <= W_GRENADE) {
if((skill_lv=pc->checkskill(sd,GS_SINGLEACTION))>0)
bstatus->hit += 2*skill_lv;
if((skill_lv=pc->checkskill(sd,GS_SNAKEEYE))>0) {
@@ -2939,9 +2937,9 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
bstatus->rhw.range += skill_lv;
}
}
- if( (sd->status.weapon == W_1HAXE || sd->status.weapon == W_2HAXE) && (skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0 )
+ if ((sd->weapontype == W_1HAXE || sd->weapontype == W_2HAXE) && (skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0)
bstatus->hit += 3*skill_lv;
- if((sd->status.weapon == W_MACE || sd->status.weapon == W_2HMACE) && (skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0)
+ if ((sd->weapontype == W_MACE || sd->weapontype == W_2HMACE) && (skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0)
bstatus->hit += 2*skill_lv;
if (pc->checkskill(sd, SU_POWEROFLIFE) > 0)
bstatus->hit += 20;
@@ -3001,12 +2999,11 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
// Relative modifiers from passive skills
#ifndef RENEWAL_ASPD
- if((skill_lv=pc->checkskill(sd,SA_ADVANCEDBOOK))>0 && sd->status.weapon == W_BOOK)
+ if (sd->weapontype == W_BOOK && (skill_lv=pc->checkskill(sd,SA_ADVANCEDBOOK)) > 0)
bstatus->aspd_rate -= 5*skill_lv;
if((skill_lv = pc->checkskill(sd,SG_DEVIL)) > 0 && !pc->nextjobexp(sd))
bstatus->aspd_rate -= 30*skill_lv;
- if((skill_lv=pc->checkskill(sd,GS_SINGLEACTION))>0 &&
- (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE))
+ if (sd->weapontype >= W_REVOLVER && sd->weapontype <= W_GRENADE && (skill_lv=pc->checkskill(sd,GS_SINGLEACTION)) > 0)
bstatus->aspd_rate -= ((skill_lv+1)/2) * 10;
if (pc_isridingpeco(sd))
bstatus->aspd_rate += 500-100*pc->checkskill(sd,KN_CAVALIERMASTERY);
@@ -3896,7 +3893,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
} else {
st->cri = status->calc_critical(bl, sc, bst->cri + 3*(st->luk - bst->luk), true);
}
- if (battle_config.show_katar_crit_bonus && bl->type == BL_PC && BL_UCAST(BL_PC, bl)->status.weapon == W_KATAR) {
+ if (battle_config.show_katar_crit_bonus && bl->type == BL_PC && BL_UCAST(BL_PC, bl)->weapontype == W_KATAR) {
st->cri *= 2;
}
}
@@ -4327,11 +4324,11 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st)
nullpo_ret(st);
amotion = status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype1];
- if ( sd->status.weapon > MAX_SINGLE_WEAPON_TYPE)
+ if (sd->weapontype > MAX_SINGLE_WEAPON_TYPE)
amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype2] / 4;
if ( sd->status.shield )
amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class)][MAX_SINGLE_WEAPON_TYPE];
- switch ( sd->status.weapon ) {
+ switch (sd->weapontype) {
case W_BOW:
case W_MUSICAL:
case W_WHIP:
@@ -4346,15 +4343,15 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st)
temp = st->dex * st->dex / 5.0f + st->agi * st->agi * 0.5f;
}
temp = (float)(sqrt(temp) * 0.25f) + 0xc4;
- if ( (skill_lv = pc->checkskill(sd, SA_ADVANCEDBOOK)) > 0 && sd->status.weapon == W_BOOK )
+ if (sd->weapontype == W_BOOK && (skill_lv = pc->checkskill(sd, SA_ADVANCEDBOOK)) > 0)
val += (skill_lv - 1) / 2 + 1;
if ( (skill_lv = pc->checkskill(sd, GS_SINGLEACTION)) > 0 )
val += ((skill_lv + 1) / 2);
amotion = ((int)(temp + ((float)(status->calc_aspd(&sd->bl, &sd->sc, 1) + val) * st->agi / 200)) - min(amotion, 200));
#else
// base weapon delay
- amotion = (sd->status.weapon < MAX_SINGLE_WEAPON_TYPE)
- ? (status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->status.weapon]) // single weapon
+ amotion = (sd->weapontype < MAX_SINGLE_WEAPON_TYPE)
+ ? (status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype]) // single weapon
: (status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype1] + status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype2]) * 7 / 10; // dual-wield
// percentual delay reduction from stats
@@ -4381,7 +4378,7 @@ unsigned short status_base_atk(const struct block_list *bl, const struct status_
return 0;
if (bl->type == BL_PC) {
- switch (BL_UCCAST(BL_PC, bl)->status.weapon) {
+ switch (BL_UCCAST(BL_PC, bl)->weapontype) {
case W_BOW:
case W_MUSICAL:
case W_WHIP:
@@ -5942,7 +5939,7 @@ short status_calc_aspd(struct block_list *bl, struct status_change *sc, short fl
if (bl->type != BL_PC) {
bonus = sc->data[SC_ASSNCROS]->val2;
} else {
- switch (BL_UCCAST(BL_PC, bl)->status.weapon) {
+ switch (BL_UCCAST(BL_PC, bl)->weapontype) {
case W_BOW:
case W_REVOLVER:
case W_RIFLE:
@@ -6103,7 +6100,7 @@ short status_calc_aspd_rate(struct block_list *bl, struct status_change *sc, int
if (bl->type != BL_PC) {
max = sc->data[SC_ASSNCROS]->val2;
} else {
- switch (BL_UCCAST(BL_PC, bl)->status.weapon) {
+ switch (BL_UCCAST(BL_PC, bl)->weapontype) {
case W_BOW:
case W_REVOLVER:
case W_RIFLE: