summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt3
-rw-r--r--src/map/battle.c63
-rw-r--r--src/map/skill.c24
-rw-r--r--src/map/skill.h2
4 files changed, 69 insertions, 23 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 74b7b5479..7ce97d3d6 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/04/05
+ * Modified the ammo checks so that ammo is consumed at the end of
+ battle_calc_weapon_attack (should fix element being lost on final arrow).
+ [Skotlex]
* Added a define list for weapon types in pc.h [Skotlex]
* Cleaned up pc_checkallowskill and moved the Gatling fever check to it.
[Skotlex]
diff --git a/src/map/battle.c b/src/map/battle.c
index bdaf7171a..ff8a55c7f 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -915,6 +915,30 @@ static void battle_calc_base_damage(struct block_list *src, struct block_list *t
return;
}
+/*==========================================
+ * Consumes ammo for the given skill.
+ *------------------------------------------
+ */
+static void battle_consume_ammo(TBL_PC*sd, int skill, int lv)
+{
+ int qty=1;
+ if (!battle_config.arrow_decrement)
+ return;
+
+ if (skill)
+ {
+ qty = skill_get_ammo_qty(skill, lv);
+ if (!qty) { //Generic skill that consumes ammo?
+ qty = skill_get_num(skill, lv);
+ if (qty < 0) qty *= -1;
+ else
+ if (qty == 0) qty = 1;
+ }
+ }
+ if(sd->equip_index[10]>=0) //Qty check should have been done in skill_check_condition
+ pc_delitem(sd,sd->equip_index[10],qty,0);
+}
+
//For quick div adjustment.
#define damage_div_fix(dmg, div) { if (div > 1) (dmg)*=div; else if (div < 0) (div)*=-1; }
/*==========================================
@@ -1021,6 +1045,7 @@ static struct Damage battle_calc_weapon_attack(
}
//Set miscellaneous data that needs be filled regardless of hit/miss
if(sd) {
+ if (!skill_num) //Ammo condition for weapons is lower below.
switch (sd->status.weapon) {
case W_BOW:
case W_REVOLVER:
@@ -1035,7 +1060,10 @@ static struct Damage battle_calc_weapon_attack(
} else if (status_get_range(src) > 3)
wd.flag=(wd.flag&~BF_RANGEMASK)|BF_LONG;
- if(skill_num && skill_get_ammotype(skill_num)) {
+ if(skill_num &&
+ (skill_get_ammotype(skill_num) ||
+ (sd && skill_isammotype(sd, skill_num)))
+ ){
//Skills that require a consumable are also long-ranged arrow-types
wd.flag=(wd.flag&~BF_RANGEMASK)|BF_LONG;
flag.arrow = 1;
@@ -1045,11 +1073,6 @@ static struct Damage battle_calc_weapon_attack(
wd.flag=(wd.flag&~BF_SKILLMASK)|BF_SKILL;
switch(skill_num)
{
- case HT_PHANTASMIC:
- case GS_MAGICALBULLET:
- flag.arrow = 0;
- break;
-
case MO_FINGEROFFENSIVE:
if(sd) {
if (battle_config.finger_offensive_type)
@@ -1140,6 +1163,8 @@ static struct Damage battle_calc_weapon_attack(
wd.type=0x0b;
wd.dmg_lv=ATK_LUCKY;
if (wd.div_ < 0) wd.div_*=-1;
+ if (sd && flag.arrow)
+ battle_consume_ammo(sd, skill_num, skill_lv);
return wd;
}
}
@@ -1331,6 +1356,8 @@ static struct Damage battle_calc_weapon_attack(
if(tsd && tsd->special_state.no_weapon_damage) {
if (wd.div_ < 0) wd.div_*=-1;
+ if (sd && flag.arrow)
+ battle_consume_ammo(sd, skill_num, skill_lv);
return wd;
}
@@ -2093,8 +2120,12 @@ static struct Damage battle_calc_weapon_attack(
wd.damage = 1;
if (flag.lh && (flag.hit || wd.damage2>0))
wd.damage2 = 1;
- if (!(battle_config.skill_min_damage&1)) //Do not return if you are supposed to deal greater damage to plants than 1. [Skotlex]
+ if (!(battle_config.skill_min_damage&1))
+ { //Do not return if you are supposed to deal greater damage to plants than 1. [Skotlex]
+ if (sd && flag.arrow)
+ battle_consume_ammo(sd, skill_num, skill_lv);
return wd;
+ }
}
if(sd && !skill_num && !flag.cri)
@@ -2153,6 +2184,8 @@ static struct Damage battle_calc_weapon_attack(
if(wd.damage > 0 && wd.damage2 < 1) wd.damage2 = 1;
flag.lh = 1;
}
+ if (flag.arrow) //Consume the arrow.
+ battle_consume_ammo(sd, skill_num, skill_lv);
}
if(wd.damage > 0 || wd.damage2 > 0)
@@ -2227,6 +2260,7 @@ static struct Damage battle_calc_weapon_attack(
skill_break_equip(target, EQP_ARMOR, breakrate[1], BCT_ENEMY);
}
}
+
return wd;
}
@@ -2985,16 +3019,11 @@ int battle_weapon_attack( struct block_list *src,struct block_list *target,
race = status_get_race(target);
ele = status_get_elem_type(target);
- if(sd && (sd->status.weapon == W_BOW || (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE))
- ) {
- if(sd->equip_index[10] >= 0) {
- if(battle_config.arrow_decrement)
- pc_delitem(sd,sd->equip_index[10],1,0);
- }
- else {
- clif_arrow_fail(sd,0);
- return 0;
- }
+ if (sd && (sd->status.weapon == W_BOW || (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE))
+ && sd->equip_index[10] < 0)
+ {
+ clif_arrow_fail(sd,0);
+ return 0;
}
//Check for counter attacks that block your attack. [Skotlex]
diff --git a/src/map/skill.c b/src/map/skill.c
index c4d41781f..a4fd1f7bc 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -7524,6 +7524,20 @@ static int skill_check_condition_hermod_sub(struct block_list *bl,va_list ap)
}
/*==========================================
+ * Determines if a given skill should be made to consume ammo
+ * when used by the player. [Skotlex]
+ *------------------------------------------
+ */
+int skill_isammotype(TBL_PC *sd, int skill)
+{
+ return (
+ (sd->status.weapon == W_BOW || (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)) &&
+ skill != HT_PHANTASMIC && skill != GS_MAGICALBULLET &&
+ skill_get_type(skill) == BF_WEAPON && !(skill_get_nk(skill)&NK_NO_DAMAGE)
+ )
+}
+
+/*==========================================
* ƒXƒLƒ‹Žg—p?Œ??i?‚ÅŽg—pŽ¸”s?j
*------------------------------------------
*/
@@ -7635,10 +7649,7 @@ int skill_check_condition(struct map_session_data *sd,int skill, int lv, int typ
else
sp += (sd->status.max_sp * abs(sp_rate))/100;
- if (!ammo && sd->status.weapon == W_BOW && skill &&
- skill != HT_PHANTASMIC && skill != GS_MAGICALBULLET &&
- skill_get_type(skill) == BF_WEAPON && !(skill_get_nk(skill)&NK_NO_DAMAGE)
- )
+ if (!ammo && skill && skill_isammotype(sd, skill))
{ //Assume this skill is using the weapon, therefore it requires arrows.
ammo = 2; //1<<1 <- look 1 (arrows) moved right 1 times.
ammo_qty = skill_get_num(skill, lv);
@@ -8213,8 +8224,9 @@ int skill_check_condition(struct map_session_data *sd,int skill, int lv, int typ
if(index[i] >= 0)
pc_delitem(sd,index[i],amount[i],0); // ƒAƒCƒeƒ€?Á”ï
}
- if (ammo && battle_config.arrow_decrement)
- pc_delitem(sd,sd->equip_index[10],ammo_qty,0);
+// Ammo is now reduced in battle_calc_weapon_attack. [Skotlex]
+// if (ammo && battle_config.arrow_decrement)
+// pc_delitem(sd,sd->equip_index[10],ammo_qty,0);
}
if(type&2)
diff --git a/src/map/skill.h b/src/map/skill.h
index 0d2827149..b34f413b6 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -154,6 +154,7 @@ int skill_get_time2( int id ,int lv );
int skill_get_castdef( int id );
int skill_get_weapontype( int id );
int skill_get_ammotype( int id );
+int skill_get_ammo_qty( int id, int lv );
int skill_get_unit_id(int id,int flag);
int skill_get_inf2( int id );
int skill_get_castcancel( int id );
@@ -164,6 +165,7 @@ int skill_get_unit_target( int id );
int skill_tree_get_max( int id, int b_class ); // Celest
const char* skill_get_name( int id ); // [Skotlex]
+void skill_isammoy_type(TBL_PC *sd, int skill);
int skill_castend_id( int tid, unsigned int tick, int id,int data );
int skill_castend_pos( int tid, unsigned int tick, int id,int data );
int skill_castend_map( struct map_session_data *sd,int skill_num, const char *map);