summaryrefslogtreecommitdiff
path: root/src/map/battle.h
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-03-01 15:59:09 -0300
committershennetsind <ind@henn.et>2013-03-01 15:59:09 -0300
commit858e0f3d0d3e760b6b3060fe669685202bbd189c (patch)
tree4c9723f3a6e8925723f4b054dc3347aa24eba2e6 /src/map/battle.h
parent0f3e2cb1cc2889d463f6595a9c922f4c037a4709 (diff)
downloadhercules-858e0f3d0d3e760b6b3060fe669685202bbd189c.tar.gz
hercules-858e0f3d0d3e760b6b3060fe669685202bbd189c.tar.bz2
hercules-858e0f3d0d3e760b6b3060fe669685202bbd189c.tar.xz
hercules-858e0f3d0d3e760b6b3060fe669685202bbd189c.zip
Hercules Renewal: battle.c
http://hercules.ws/board/topic/237-hercules-renewal/ Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map/battle.h')
-rw-r--r--src/map/battle.h245
1 files changed, 138 insertions, 107 deletions
diff --git a/src/map/battle.h b/src/map/battle.h
index 0e888fc9e..848c9c3db 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -5,49 +5,28 @@
#ifndef _BATTLE_H_
#define _BATTLE_H_
-// state of a single attack attempt; used in flee/def penalty calculations when mobbed
-typedef enum damage_lv {
- ATK_NONE, // not an attack
- ATK_LUCKY, // attack was lucky-dodged
- ATK_FLEE, // attack was dodged
- ATK_MISS, // attack missed because of element/race modifier.
- ATK_BLOCK, // attack was blocked by some skills.
- ATK_DEF // attack connected
-} damage_lv;
-
-// dammage structure
-struct Damage {
- int damage,damage2; //right, left dmg
- int type,div_; //chk clif_damage for type @TODO add an enum ? ; nb of hit
- int amotion,dmotion;
- int blewcount; //nb of knockback
- int flag; //chk BF_* flag, (enum below)
- enum damage_lv dmg_lv; //ATK_LUCKY,ATK_FLEE,ATK_DEF
-};
-
-//(Used in read pc.c,) attribute table (battle_attr_fix)
-extern int attr_fix_table[4][10][10];
-
+/**
+ * Declarations
+ **/
struct map_session_data;
struct mob_data;
struct block_list;
-// Damage Calculation
-
-struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct block_list *target,uint16 skill_id,uint16 skill_lv,int count);
-
-int battle_calc_return_damage(struct block_list *bl, struct block_list *src, int *, int flag, uint16 skill_id);
-
-void battle_drain(struct map_session_data *sd, struct block_list *tbl, int rdamage, int ldamage, int race, int boss);
+/**
+ * Defines
+ **/
+#define MIN_HAIR_STYLE battle_config.min_hair_style
+#define MAX_HAIR_STYLE battle_config.max_hair_style
+#define MIN_HAIR_COLOR battle_config.min_hair_color
+#define MAX_HAIR_COLOR battle_config.max_hair_color
+#define MIN_CLOTH_COLOR battle_config.min_cloth_color
+#define MAX_CLOTH_COLOR battle_config.max_cloth_color
-int battle_attr_ratio(int atk_elem,int def_type, int def_lv);
-int battle_attr_fix(struct block_list *src, struct block_list *target, int damage,int atk_elem,int def_type, int def_lv);
-int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_list *target, int nk, int s_ele, int s_ele_, int damage, int left, int flag);
+#define is_boss(bl) (status_get_mode(bl)&MD_BOSS) // Can refine later [Aru]
-// Final calculation Damage
-int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damage *d,int damage,uint16 skill_id,uint16 skill_lv);
-int battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int damage,int div_,uint16 skill_id,uint16 skill_lv,int flag);
-int battle_calc_bg_damage(struct block_list *src,struct block_list *bl,int damage,int div_,uint16 skill_id,uint16 skill_lv,int flag);
+/**
+ * Enumerations
+ **/
enum { // Flag of the final calculation
BF_WEAPON = 0x0001,
@@ -62,20 +41,17 @@ enum { // Flag of the final calculation
BF_SKILLMASK= 0x0f00,
};
-int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src, struct block_list *target, int attack_type, uint16 skill_id, uint16 skill_lv, int damage, enum damage_lv dmg_lv, int ddelay, bool additional_effects);
-
-// Summary normal attack treatment (basic attack)
-enum damage_lv battle_weapon_attack( struct block_list *bl,struct block_list *target,unsigned int tick,int flag);
-
-// Accessors
-struct block_list* battle_get_master(struct block_list *src);
-struct block_list* battle_gettargeted(struct block_list *target);
-struct block_list* battle_getenemy(struct block_list *target, int type, int range);
-int battle_gettarget(struct block_list *bl);
-int battle_getcurrentskill(struct block_list *bl);
+// state of a single attack attempt; used in flee/def penalty calculations when mobbed
+typedef enum damage_lv {
+ ATK_NONE, // not an attack
+ ATK_LUCKY, // attack was lucky-dodged
+ ATK_FLEE, // attack was dodged
+ ATK_MISS, // attack missed because of element/race modifier.
+ ATK_BLOCK, // attack was blocked by some skills.
+ ATK_DEF // attack connected
+} damage_lv;
-enum e_battle_check_target
-{//New definitions [Skotlex]
+enum e_battle_check_target { //New definitions [Skotlex]
BCT_ENEMY = 0x020000,
BCT_NOENEMY = 0x1d0000, //This should be (~BCT_ENEMY&BCT_ALL)
BCT_PARTY = 0x040000,
@@ -88,24 +64,22 @@ enum e_battle_check_target
BCT_NEUTRAL = 0x100000,
};
-#define is_boss(bl) (status_get_mode(bl)&MD_BOSS) // Can refine later [Aru]
-
-int battle_check_undead(int race,int element);
-int battle_check_target(struct block_list *src, struct block_list *target,int flag);
-bool battle_check_range(struct block_list *src,struct block_list *bl,int range);
-void battle_consume_ammo(struct map_session_data* sd, int skill, int lv);
-// Settings
+/**
+ * Structures
+ **/
-#define MIN_HAIR_STYLE battle_config.min_hair_style
-#define MAX_HAIR_STYLE battle_config.max_hair_style
-#define MIN_HAIR_COLOR battle_config.min_hair_color
-#define MAX_HAIR_COLOR battle_config.max_hair_color
-#define MIN_CLOTH_COLOR battle_config.min_cloth_color
-#define MAX_CLOTH_COLOR battle_config.max_cloth_color
+// dammage structure
+struct Damage {
+ int damage,damage2; //right, left dmg
+ int type,div_; //chk clif_damage for type @TODO add an enum ? ; nb of hit
+ int amotion,dmotion;
+ int blewcount; //nb of knockback
+ int flag; //chk BF_* flag, (enum below)
+ enum damage_lv dmg_lv; //ATK_LUCKY,ATK_FLEE,ATK_DEF
+};
-extern struct Battle_Config
-{
+struct Battle_Config {
int warp_point_debug;
int enable_critical;
int mob_critical_rate;
@@ -185,7 +159,7 @@ extern struct Battle_Config
int emergency_call;
int guild_aura;
int pc_invincible_time;
-
+
int pet_catch_rate;
int pet_rename;
int pet_friendly_rate;
@@ -205,7 +179,7 @@ extern struct Battle_Config
int pet_max_atk2; //[Skotlex]
int pet_no_gvg; //Disables pets in gvg. [Skotlex]
int pet_equip_required;
-
+
int skill_min_damage;
int finger_offensive_type;
int heal_exp;
@@ -286,9 +260,9 @@ extern struct Battle_Config
int show_picker_item_type;
int attack_attr_none;
int item_rate_mvp, item_rate_common, item_rate_common_boss, item_rate_card, item_rate_card_boss,
- item_rate_equip, item_rate_equip_boss, item_rate_heal, item_rate_heal_boss, item_rate_use,
- item_rate_use_boss, item_rate_treasure, item_rate_adddrop;
-
+ item_rate_equip, item_rate_equip_boss, item_rate_heal, item_rate_heal_boss, item_rate_use,
+ item_rate_use_boss, item_rate_treasure, item_rate_adddrop;
+
int logarithmic_drops;
int item_drop_common_min,item_drop_common_max; // Added by TyrNemesis^
int item_drop_card_min,item_drop_card_max;
@@ -298,9 +272,9 @@ extern struct Battle_Config
int item_drop_use_min,item_drop_use_max; //End
int item_drop_treasure_min,item_drop_treasure_max; //by [Skotlex]
int item_drop_adddrop_min,item_drop_adddrop_max; //[Skotlex]
-
+
int prevent_logout; // Added by RoVeRT
-
+
int alchemist_summon_reward; // [Valaris]
int drops_by_luk;
int drops_by_luk2;
@@ -311,10 +285,10 @@ extern struct Battle_Config
int max_exp_gain_rate; //Max amount of exp bar % you can get in one go.
int pk_mode;
int pk_level_range;
-
+
int manner_system; // end additions [Valaris]
int show_mob_info;
-
+
int gx_allhit;
int gx_disptype;
int devotion_level_difference;
@@ -330,14 +304,14 @@ extern struct Battle_Config
int bone_drop;
int buyer_name;
int dancing_weaponswitch_fix;
-
-// eAthena additions
+
+ // eAthena additions
int night_at_start; // added by [Yor]
int day_duration; // added by [Yor]
int night_duration; // added by [Yor]
int ban_hack_trade; // added by [Yor]
int packet_ver_flag; // added by [Yor]
-
+
int min_hair_style; // added by [MouseJstr]
int max_hair_style; // added by [MouseJstr]
int min_hair_color; // added by [MouseJstr]
@@ -345,12 +319,12 @@ extern struct Battle_Config
int min_cloth_color; // added by [MouseJstr]
int max_cloth_color; // added by [MouseJstr]
int pet_hair_style; // added by [Skotlex]
-
+
int castrate_dex_scale; // added by [MouseJstr]
int area_size; // added by [MouseJstr]
-
+
int max_def, over_def_bonus; //added by [Skotlex]
-
+
int zeny_from_mobs; // [Valaris]
int mobs_level_up; // [Valaris]
int mobs_level_up_exp_rate; // [Valaris]
@@ -372,12 +346,12 @@ extern struct Battle_Config
int delay_battle_damage;
int hide_woe_damage;
int display_version;
-
+
int display_hallucination; // [Skotlex]
int use_statpoint_table; // [Skotlex]
-
+
int ignore_items_gender; //[Lupus]
-
+
int copyskill_restrict; // [Aru]
int berserk_cancels_buffs; // [Aru]
int debuff_on_logout; // Removes a few "official" negative Scs on logout. [Skotlex]
@@ -388,26 +362,26 @@ extern struct Battle_Config
int mob_remove_delay; // Dynamic Mobs - delay before removing mobs from a map [Skotlex]
int mob_active_time; //Duration through which mobs execute their Hard AI after players leave their area of sight.
int boss_active_time;
-
+
int show_hp_sp_drain, show_hp_sp_gain; //[Skotlex]
-
+
int mob_npc_event_type; //Determines on who the npc_event is executed. [Skotlex]
-
+
int character_size; // if riders have size=2, and baby class riders size=1 [Lupus]
int mob_max_skilllvl; // Max possible skill level [Lupus]
int rare_drop_announce; // chance <= to show rare drops global announces
-
+
int retaliate_to_master; //Whether when a mob is attacked by another mob, it will retaliate versus the mob or the mob's master. [Skotlex]
-
+
int duel_allow_pvp; // [LuzZza]
int duel_allow_gvg; // [LuzZza]
int duel_allow_teleport; // [LuzZza]
int duel_autoleave_when_die; // [LuzZza]
int duel_time_interval; // [LuzZza]
int duel_only_on_same_map; // [Toms]
-
+
int skip_teleport_lv1_menu; // possibility to disable (skip) Teleport Lv1 menu, that have only two lines `Random` and `Cancel` [LuzZza]
-
+
int allow_skill_without_day; // [Komurka]
int allow_es_magic_pc; // [Skotlex]
int skill_wall_check; // [Skotlex]
@@ -420,7 +394,7 @@ extern struct Battle_Config
int mob_luk_sc_def;
int pc_max_sc_def;
int mob_max_sc_def;
-
+
int sg_angel_skill_ratio;
int sg_miracle_skill_ratio;
int sg_miracle_skill_duration;
@@ -460,7 +434,7 @@ extern struct Battle_Config
int client_limit_unit_lv;
int hom_max_level;
int hom_S_max_level;
-
+
// [BattleGround Settings]
int bg_update_interval;
int bg_short_damage_rate;
@@ -469,20 +443,20 @@ extern struct Battle_Config
int bg_magic_damage_rate;
int bg_misc_damage_rate;
int bg_flee_penalty;
-
+
// rAthena
int max_third_parameter;
int max_baby_third_parameter;
int atcommand_max_stat_bypass;
int max_third_aspd;
int vcast_stat_scale;
-
+
int mvp_tomb_enabled;
-
+
int atcommand_suggestions_enabled;
int min_npc_vending_distance;
int atcommand_mobinfo_type;
-
+
int mob_size_influence; // Enable modifications on earned experience, drop rates and monster status depending on monster size. [mkbu95]
/** Hercules **/
@@ -493,19 +467,76 @@ extern struct Battle_Config
} battle_config;
-void do_init_battle(void);
-void do_final_battle(void);
-extern int battle_config_read(const char *cfgName);
-extern void battle_validate_conf(void);
-extern void battle_set_defaults(void);
-int battle_set_value(const char* w1, const char* w2);
-int battle_get_value(const char* w1);
-//
-struct block_list* battle_getenemyarea(struct block_list *src, int x, int y, int range, int type, int ignore_id);
/**
- * Royal Guard
+ * Misc Vars
**/
-int battle_damage_area( struct block_list *bl, va_list ap);
+//attribute table
+extern int attr_fix_table[4][10][10];
+/**
+ * Battle.c Interface
+ **/
+struct battle_interface {
+ /* init */
+ void (*init) (void);
+ /* final */
+ void (*final) (void);
+ /* damage calculation */
+ struct Damage (*calc_attack) (int attack_type, struct block_list *bl, struct block_list *target, uint16 skill_id, uint16 skill_lv, int count);
+ /* generic final damage calculation */
+ int (*calc_damage) (struct block_list *src, struct block_list *bl, struct Damage *d, int damage, uint16 skill_id, uint16 skill_lv);
+ /* gvg final damage calculation */
+ int (*calc_gvg_damage) (struct block_list *src, struct block_list *bl, int damage, int div_, uint16 skill_id, uint16 skill_lv, int flag);
+ /* battlegrounds final damage calculation */
+ int (*calc_bg_damage) (struct block_list *src, struct block_list *bl, int damage, int div_, uint16 skill_id, uint16 skill_lv, int flag);
+ /* normal weapon attack */
+ enum damage_lv (*weapon_attack) (struct block_list *bl, struct block_list *target, unsigned int tick, int flag);
+ /* calculate weapon attack */
+ struct Damage (*calc_weapon_attack) (struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int wflag);
+ /* delays damage or skills by a timer */
+ int (*delay_damage) (unsigned int tick, int amotion, struct block_list *src, struct block_list *target, int attack_type, uint16 skill_id, uint16 skill_lv, int damage, enum damage_lv dmg_lv, int ddelay, bool additional_effects);
+ /* drain damage */
+ void (*drain) (struct map_session_data *sd, struct block_list *tbl, int rdamage, int ldamage, int race, int boss);
+ /* damage return/reflect */
+ int (*calc_return_damage) (struct block_list *bl, struct block_list *src, int *, int flag, uint16 skill_id);
+ /* attribute rate */
+ int (*attr_ratio) (int atk_elem, int def_type, int def_lv);
+ /* applies attribute modifiers */
+ int (*attr_fix) (struct block_list *src, struct block_list *target, int damage, int atk_elem, int def_type, int def_lv);
+ /* applies card modifiers */
+ int (*calc_cardfix) (int attack_type, struct block_list *src, struct block_list *target, int nk, int s_ele, int s_ele_, int damage, int left, int flag);
+ /* get master (who does this unit respond to?) */
+ struct block_list *(*get_master) (struct block_list *src);
+ /* returns a random unit who is targeting this unit */
+ struct block_list *(*get_targeted) (struct block_list *target);
+ /* picks a random enemy unit who is in the area of sight */
+ struct block_list *(*get_enemy) (struct block_list *target, int type, int range);
+ /* the target id (if any) of this unit */
+ int (*get_target) (struct block_list *bl);
+ /* the current skill being processed/casted by this unit */
+ int (*get_current_skill) (struct block_list *bl);
+ /* is either this race or element enough to be considered undead? */
+ int (*check_undead) (int race,int element);
+ /* check if src and target are part of flag (e.g. enemies or allies) */
+ int (*check_target) (struct block_list *src, struct block_list *target,int flag);
+ /* is src and bl within range? */
+ bool (*check_range) (struct block_list *src,struct block_list *bl,int range);
+ /* consume amo for this skill and lv */
+ void (*consume_ammo) (struct map_session_data* sd, int skill, int lv);
+ /* - battle_config */
+ int (*config_read) (const char *cfgName);
+ void (*config_set_defaults) (void);
+ int (*config_set_value) (const char* w1, const char* w2);
+ int (*config_get_value) (const char* w1);
+ /* ----------------------------------------- */
+ /* picks a random enemy within the specified range */
+ struct block_list* (*get_enemy_area) (struct block_list *src, int x, int y, int range, int type, int ignore_id);
+ /* damages area, originally for royal guard's reflect damage */
+ int (*damage_area) ( struct block_list *bl, va_list ap);
+} battle_s;
+
+struct battle_interface *battle;
+
+void battle_defaults(void);
#endif /* _BATTLE_H_ */