summaryrefslogtreecommitdiff
path: root/src/map/pc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/pc.h')
-rw-r--r--src/map/pc.h566
1 files changed, 319 insertions, 247 deletions
diff --git a/src/map/pc.h b/src/map/pc.h
index 43d5d40c7..bec4522df 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -1,28 +1,36 @@
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#ifndef _PC_H_
-#define _PC_H_
-#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus
-#include "../common/ers.h"
-#include "../common/timer.h" // INVALID_TIMER
-#include "atcommand.h" // AtCommandType
-#include "battle.h" // battle_config
-#include "battleground.h"
+
+#ifndef MAP_PC_H
+#define MAP_PC_H
+
+#include "../config/core.h" // AUTOLOOTITEM_SIZE, RENEWAL, SECURE_NPCTIMEOUT
+
+#include "battle.h" // battle
+#include "battleground.h" // enum bg_queue_types
#include "buyingstore.h" // struct s_buyingstore
-#include "itemdb.h" // MAX_ITEMGROUP
-#include "map.h" // RC_MAX
-#include "script.h" // struct script_reg, struct script_regstr
+#include "itemdb.h" // MAX_ITEMDELAYS
+#include "log.h" // struct e_log_pick_type
+#include "map.h" // RC_MAX, ELE_MAX
+#include "pc_groups.h" // GroupSettings
+#include "script.h" // struct reg_db
#include "searchstore.h" // struct s_search_store_info
-#include "status.h" // OPTION_*, struct weapon_atk
-#include "unit.h" // unit_stop_attack(), unit_stop_walking()
+#include "status.h" // enum sc_type, OPTION_*
+#include "unit.h" // struct unit_data, struct view_data
#include "vending.h" // struct s_vending
-#include "mob.h"
-#include "log.h"
-#include "pc_groups.h"
+#include "../common/cbasetypes.h"
+#include "../common/ers.h" // struct eri
+#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus, NEW_CARTS
+
+/**
+ * Defines
+ **/
#define MAX_PC_BONUS 10
#define MAX_PC_SKILL_REQUIRE 5
#define MAX_PC_FEELHATE 3
+#define PVP_CALCRANK_INTERVAL 1000 // PVP calculation interval
+
//Equip indexes constants. (eg: sd->equip_index[EQI_AMMO] returns the index
//where the arrows are equipped)
enum equip_index {
@@ -41,6 +49,12 @@ enum equip_index {
EQI_COSTUME_LOW,
EQI_COSTUME_GARMENT,
EQI_AMMO,
+ EQI_SHADOW_ARMOR,
+ EQI_SHADOW_WEAPON,
+ EQI_SHADOW_SHIELD,
+ EQI_SHADOW_SHOES,
+ EQI_SHADOW_ACC_R,
+ EQI_SHADOW_ACC_L,
EQI_MAX
};
struct weapon_data {
@@ -102,6 +116,12 @@ enum npc_timeout_type {
NPCT_MENU = 1,
NPCT_WAIT = 2,
};
+
+struct pc_combos {
+ struct script_code *bonus;/* the script of the combo */
+ unsigned short id;/* this combo id */
+};
+
struct map_session_data {
struct block_list bl;
struct unit_data ud;
@@ -126,7 +146,6 @@ struct map_session_data {
unsigned int abra_flag : 2; // Abracadabra bugfix by Aru
unsigned int autocast : 1; // Autospell flag [Inkfish]
unsigned int autotrade : 1; //By Fantik
- unsigned int reg_dirty : 4; //By Skotlex (marks whether registry variables have been saved or not yet)
unsigned int showdelay :1;
unsigned int showexp :1;
unsigned int showzeny :1;
@@ -153,15 +172,22 @@ struct map_session_data {
short pmap; // Previous map on Map Change
unsigned short autoloot;
unsigned short autolootid[AUTOLOOTITEM_SIZE]; // [Zephyrus]
+ unsigned short autoloottype;
unsigned int autolooting : 1; //performance-saver, autolooting state for @alootid
unsigned short autobonus; //flag to indicate if an autobonus is activated. [Inkfish]
- struct guild *gmaster_flag;
+ unsigned int gmaster_flag : 1;
unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.
unsigned int warping : 1;//states whether you're in the middle of a warp processing
unsigned int permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc().
unsigned int dialog : 1;
unsigned int prerefining : 1;
unsigned int workinprogress : 3; // 1 = disable skill/item, 2 = disable npc interaction, 3 = disable both
+ unsigned int hold_recalc : 1;
+ unsigned int snovice_call_flag : 3; //Summon Angel (stage 1~3)
+ unsigned int hpmeter_visible : 1;
+ unsigned int itemcheck : 1;
+ unsigned int standalone : 1;/* [Ind/Hercules <3] */
+ unsigned int loggingout : 1;
} state;
struct {
unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
@@ -177,12 +203,13 @@ struct map_session_data {
} special_state;
int login_id1, login_id2;
unsigned short class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex]
- int group_id, group_pos, group_level;
- unsigned int permissions;/* group permissions */
- bool group_log_command;
+
+ /// Groups & permissions
+ int group_id;
+ GroupSettings *group;
+ unsigned int extra_temp_permissions; /* permissions from @addperm */
struct mmo_charstatus status;
- struct registry save_reg;
struct item_data* inventory_data[MAX_INVENTORY]; // direct pointers to itemdb entries (faster than doing item_id lookups)
short equip_index[EQI_MAX];
unsigned int weight,max_weight;
@@ -199,10 +226,10 @@ struct map_session_data {
char npc_str[CHATBOX_SIZE]; // for passing npc input box text to script engine
int npc_timer_id; //For player attached npc timers. [Skotlex]
unsigned int chatID;
- time_t idletime;
- struct{
+ int64 idletime;
+ struct {
int npc_id;
- unsigned int timeout;
+ int64 timeout;
} progressbar; //Progress Bar [Inkfish]
struct{
char name[NAME_LENGTH];
@@ -214,22 +241,21 @@ struct map_session_data {
uint16 skill_id_old,skill_lv_old;
uint16 skill_id_dance,skill_lv_dance;
short cook_mastery; // range: [0,1999] [Inkfish]
- unsigned char blockskill[MAX_SKILL];
+ bool blockskill[MAX_SKILL];
int cloneskill_id, reproduceskill_id;
int menuskill_id, menuskill_val, menuskill_val2;
int invincible_timer;
- unsigned int canlog_tick;
- unsigned int canuseitem_tick; // [Skotlex]
- unsigned int canusecashfood_tick;
- unsigned int canequip_tick; // [Inkfish]
- unsigned int cantalk_tick;
- unsigned int canskill_tick; // used to prevent abuse from no-delay ACT files
- unsigned int cansendmail_tick; // [Mail System Flood Protection]
- unsigned int ks_floodprotect_tick; // [Kill Steal Protection]
- unsigned int bloodylust_tick; // bloodylust player timer [out/in re full-heal protection]
+ int64 canlog_tick;
+ int64 canuseitem_tick; // [Skotlex]
+ int64 canusecashfood_tick;
+ int64 canequip_tick; // [Inkfish]
+ int64 cantalk_tick;
+ int64 canskill_tick; /// used to prevent abuse from no-delay ACT files
+ int64 cansendmail_tick; /// Mail System Flood Protection
+ int64 ks_floodprotect_tick; /// [Kill Steal Protection]
struct {
short nameid;
- unsigned int tick;
+ int64 tick;
} item_delay[MAX_ITEMDELAYS]; // [Paradox924X]
short weapontype1,weapontype2;
short disguise; // [Valaris]
@@ -256,7 +282,6 @@ struct map_session_data {
int expaddrace[RC_MAX];
int ignore_mdef[RC_MAX];
int ignore_def[RC_MAX];
- int itemgrouphealrate[MAX_ITEMGROUP];
short sp_gain_race[RC_MAX];
short sp_gain_race_attack[RC_MAX];
short hp_gain_race_attack[RC_MAX];
@@ -286,6 +311,10 @@ struct map_session_data {
short flag, rate;
unsigned char ele;
} subele2[MAX_PC_BONUS];
+ struct {
+ short value;
+ int rate, tick;
+ } def_set_race[RC_MAX], mdef_set_race[RC_MAX];
// zeroed structures end here
// manually zeroed structures start here.
struct s_autobonus autobonus[MAX_PC_BONUS], autobonus2[MAX_PC_BONUS], autobonus3[MAX_PC_BONUS]; //Auto script on attack, when attacked, on skill usage
@@ -319,14 +348,13 @@ struct map_session_data {
short add_heal_rate, add_heal2_rate;
short sp_gain_value, hp_gain_value, magic_sp_gain_value, magic_hp_gain_value;
short sp_vanish_rate;
- short sp_vanish_per;
+ short sp_vanish_per, sp_vanish_trigger;
unsigned short unbreakable; // chance to prevent ANY equipment breaking [celest]
unsigned short unbreakable_equip; //100% break resistance on certain equipment
unsigned short unstripable_equip;
int fixcastrate,varcastrate;
int add_fixcast,add_varcast;
int ematk; // matk bonus from equipment
- int eatk; // atk bonus from equipment
} bonus;
// zeroed vars end here.
int castrate,delayrate,hprate,sprate,dsprate;
@@ -345,10 +373,6 @@ struct map_session_data {
short mission_mobid; //Stores the target mob_id for TK_MISSION
int die_counter; //Total number of times you've died
int devotion[5]; //Stores the account IDs of chars devoted to.
- int reg_num; //Number of registries (type numeric)
- int regstr_num; //Number of registries (type string)
- struct script_reg *reg;
- struct script_regstr *regstr;
int trade_partner;
struct {
struct {
@@ -421,12 +445,11 @@ struct map_session_data {
bool changed; // if true, should sync with charserver on next mailbox request
} mail;
- //Quest log system [Kevin] [Inkfish]
- int num_quests;
- int avail_quests;
- int quest_index[MAX_QUEST_DB];
- struct quest quest_log[MAX_QUEST_DB];
- bool save_quest;
+ // Quest log system
+ int num_quests; ///< Number of entries in quest_log
+ int avail_quests; ///< Number of Q_ACTIVE and Q_INACTIVE entries in quest log (index of the first Q_COMPLETE entry)
+ struct quest *quest_log; ///< Quest log entries (note: Q_COMPLETE quests follow the first <avail_quests>th enties
+ bool save_quest; ///< Whether the quest_log entries were modified and are waitin to be saved
// temporary debug [flaviojs]
const char* debug_file;
@@ -434,7 +457,6 @@ struct map_session_data {
const char* debug_func;
unsigned int bg_id;
- unsigned short user_font;
/**
* For the Secure NPC Timeout option (check config/Secure.h) [RR]
@@ -452,17 +474,14 @@ struct map_session_data {
* @info
* - It is updated on every NPC iteration as mentioned above
**/
- unsigned int npc_idle_tick;
+ int64 npc_idle_tick;
/* */
enum npc_timeout_type npc_idle_type;
#endif
- struct {
- struct script_code **bonus;/* the script */
- unsigned short *id;/* array of combo ids */
- unsigned char count;
- } combos;
-
+ struct pc_combos *combos;
+ unsigned char combo_count;
+
/**
* Guarantees your friend request is legit (for bugreport:4629)
**/
@@ -477,13 +496,13 @@ struct map_session_data {
bool stealth;
unsigned char fontcolor;
unsigned int fontcolor_tid;
- unsigned int hchsysch_tick;
+ int64 hchsysch_tick;
/* [Ind/Hercules] */
struct sc_display_entry **sc_display;
unsigned char sc_display_count;
- unsigned short *instance;
+ short *instance;
unsigned short instances;
/* Possible Thanks to Yommy~! */
@@ -498,7 +517,31 @@ struct map_session_data {
unsigned int queues_count;
/* Made Possible Thanks to Yommy~! */
- unsigned int cryptKey;
+ unsigned int cryptKey; ///< Packet obfuscation key to be used for the next received packet
+ unsigned short (*parse_cmd_func)(int fd, struct map_session_data *sd); ///< parse_cmd_func used by this player
+
+ unsigned char delayed_damage;//ref. counter bugreport:7307 [Ind/Hercules]
+
+ /* HPM Custom Struct */
+ struct HPluginData **hdata;
+ unsigned int hdatac;
+
+ /* expiration_time timer id */
+ int expiration_tid;
+ time_t expiration_time;
+
+ /* */
+ struct {
+ unsigned int second,third;
+ } sktree;
+
+ /**
+ * Account/Char variables & array control of those variables
+ **/
+ struct reg_db regs;
+ unsigned char vars_received;/* char loading is only complete when you get it all. */
+ bool vars_ok;
+ bool vars_dirty;
// temporary debugging of bug #3504
const char* delunit_prevfile;
@@ -506,86 +549,14 @@ struct map_session_data {
};
-struct eri *pc_sc_display_ers;
-
-//Update this max as necessary. 55 is the value needed for Super Baby currently
-//Raised to 84 since Expanded Super Novice needs it.
-#define MAX_SKILL_TREE 84
-//Total number of classes (for data storage)
-#define CLASS_COUNT (JOB_MAX - JOB_NOVICE_HIGH + JOB_MAX_BASIC)
-
-enum weapon_type {
- W_FIST, //Bare hands
- W_DAGGER, //1
- W_1HSWORD, //2
- W_2HSWORD, //3
- W_1HSPEAR, //4
- W_2HSPEAR, //5
- W_1HAXE, //6
- W_2HAXE, //7
- W_MACE, //8
- W_2HMACE, //9 (unused)
- W_STAFF, //10
- W_BOW, //11
- W_KNUCKLE, //12
- W_MUSICAL, //13
- W_WHIP, //14
- W_BOOK, //15
- W_KATAR, //16
- W_REVOLVER, //17
- W_RIFLE, //18
- W_GATLING, //19
- W_SHOTGUN, //20
- W_GRENADE, //21
- W_HUUMA, //22
- W_2HSTAFF, //23
- MAX_WEAPON_TYPE,
- // dual-wield constants
- W_DOUBLE_DD, // 2 daggers
- W_DOUBLE_SS, // 2 swords
- W_DOUBLE_AA, // 2 axes
- W_DOUBLE_DS, // dagger + sword
- W_DOUBLE_DA, // dagger + axe
- W_DOUBLE_SA, // sword + axe
-};
-
-enum ammo_type {
- A_ARROW = 1,
- A_DAGGER, //2
- A_BULLET, //3
- A_SHELL, //4
- A_GRENADE, //5
- A_SHURIKEN, //6
- A_KUNAI, //7
- A_CANNONBALL, //8
- A_THROWWEAPON //9
-};
-
-//Equip position constants
-enum equip_pos {
- EQP_HEAD_LOW = 0x0001,
- EQP_HEAD_MID = 0x0200, //512
- EQP_HEAD_TOP = 0x0100, //256
- EQP_HAND_R = 0x0002, //2
- EQP_HAND_L = 0x0020, //32
- EQP_ARMOR = 0x0010, //16
- EQP_SHOES = 0x0040, //64
- EQP_GARMENT = 0x0004, //4
- EQP_ACC_L = 0x0008, //8
- EQP_ACC_R = 0x0080, //128
- EQP_COSTUME_HEAD_TOP = 0x0400, //1024
- EQP_COSTUME_HEAD_MID = 0x0800, //2048
- EQP_COSTUME_HEAD_LOW = 0x1000, //4096
- EQP_COSTUME_GARMENT = 0x2000, //8192
- EQP_AMMO = 0x8000, //32768
-};
-
#define EQP_WEAPON EQP_HAND_R
#define EQP_SHIELD EQP_HAND_L
#define EQP_ARMS (EQP_HAND_R|EQP_HAND_L)
#define EQP_HELM (EQP_HEAD_LOW|EQP_HEAD_MID|EQP_HEAD_TOP)
#define EQP_ACC (EQP_ACC_L|EQP_ACC_R)
#define EQP_COSTUME (EQP_COSTUME_HEAD_TOP|EQP_COSTUME_HEAD_MID|EQP_COSTUME_HEAD_LOW|EQP_COSTUME_GARMENT)
+#define EQP_SHADOW_ACC (EQP_SHADOW_ACC_R|EQP_SHADOW_ACC_L)
+#define EQP_SHADOW_ARMS (EQP_SHADOW_WEAPON|EQP_SHADOW_SHIELD)
/// Equip positions that use a visible sprite
#if PACKETVER < 20110111
@@ -598,7 +569,7 @@ enum equip_pos {
#define pc_setsit(sd) ( (sd)->state.dead_sit = (sd)->vd.dead_sit = 2 )
#define pc_isdead(sd) ( (sd)->state.dead_sit == 1 )
#define pc_issit(sd) ( (sd)->vd.dead_sit == 2 )
-#define pc_isidle(sd) ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(last_tick, (sd)->idletime) >= battle_config.idle_no_share )
+#define pc_isidle(sd) ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(sockt->last_tick, (sd)->idletime) >= battle->bc->idle_no_share )
#define pc_istrading(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->state.trading )
#define pc_cant_act(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->chatID || ((sd)->sc.opt1 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading || (sd)->state.storage_flag || (sd)->state.prevend )
@@ -620,9 +591,9 @@ enum equip_pos {
#define pc_isfalcon(sd) ( (sd)->sc.option&OPTION_FALCON )
#define pc_isriding(sd) ( (sd)->sc.option&OPTION_RIDING )
#define pc_isinvisible(sd) ( (sd)->sc.option&OPTION_INVISIBLE )
-#define pc_is50overweight(sd) ( (sd)->weight*100 >= (sd)->max_weight*battle_config.natural_heal_weight_rate )
+#define pc_is50overweight(sd) ( (sd)->weight*100 >= (sd)->max_weight*battle->bc->natural_heal_weight_rate )
#define pc_is90overweight(sd) ( (sd)->weight*10 >= (sd)->max_weight*9 )
-#define pc_maxparameter(sd) ( ((((sd)->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO) || (sd)->class_&JOBL_THIRD ? ((sd)->class_&JOBL_BABY ? battle_config.max_baby_third_parameter : battle_config.max_third_parameter) : ((sd)->class_&JOBL_BABY ? battle_config.max_baby_parameter : battle_config.max_parameter)) )
+#define pc_maxparameter(sd) ( (((sd)->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO || ((sd)->class_&MAPID_UPPERMASK) == MAPID_REBELLION || ((sd)->class_&MAPID_THIRDMASK) == MAPID_SUPER_NOVICE_E) ? battle->bc->max_extended_parameter : (sd)->class_&JOBL_THIRD ? ((sd)->class_&JOBL_BABY ? battle->bc->max_baby_third_parameter : battle->bc->max_third_parameter) : ((sd)->class_&JOBL_BABY ? battle->bc->max_baby_parameter : battle->bc->max_parameter) )
/**
* Ranger
**/
@@ -633,8 +604,8 @@ enum equip_pos {
// Rune Knight Dragon
#define pc_isridingdragon(sd) ( (sd)->sc.option&OPTION_DRAGON )
-#define pc_stop_walking(sd, type) unit_stop_walking(&(sd)->bl, type)
-#define pc_stop_attack(sd) unit_stop_attack(&(sd)->bl)
+#define pc_stop_walking(sd, type) (unit->stop_walking(&(sd)->bl, (type)))
+#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_WEAPON_TYPE? \
@@ -648,19 +619,20 @@ enum equip_pos {
|| ( (class_) >= JOB_RUNE_KNIGHT && (class_) <= JOB_MECHANIC_T2 ) \
|| ( (class_) >= JOB_BABY_RUNE && (class_) <= JOB_BABY_MECHANIC2 ) \
|| ( (class_) >= JOB_SUPER_NOVICE_E && (class_) <= JOB_SUPER_BABY_E ) \
-|| ( (class_) >= JOB_KAGEROU && (class_) < JOB_MAX ) \
+|| ( (class_) >= JOB_KAGEROU && (class_) <= JOB_OBORO ) \
+|| ( (class_) >= JOB_REBELLION && (class_) < JOB_MAX ) \
)
-#define pcdb_checkid(class_) pcdb_checkid_sub((unsigned int)class_)
+#define pcdb_checkid(class_) pcdb_checkid_sub((unsigned int)(class_))
// clientside display macros (values to the left/right of the "+")
#ifdef RENEWAL
#define pc_leftside_atk(sd) ((sd)->battle_status.batk)
- #define pc_rightside_atk(sd) ((sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk + (sd)->battle_status.rhw.atk2 + (sd)->battle_status.lhw.atk2 + (sd)->bonus.eatk )
+ #define pc_rightside_atk(sd) ((sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk + (sd)->battle_status.rhw.atk2 + (sd)->battle_status.lhw.atk2 + (sd)->battle_status.equip_atk )
#define pc_leftside_def(sd) ((sd)->battle_status.def2)
#define pc_rightside_def(sd) ((sd)->battle_status.def)
#define pc_leftside_mdef(sd) ((sd)->battle_status.mdef2)
#define pc_rightside_mdef(sd) ((sd)->battle_status.mdef)
-#define pc_leftside_matk(sd) (status_base_matk(status_get_status_data(&(sd)->bl), (sd)->status.base_level))
+#define pc_leftside_matk(sd) (status->base_matk(status->get_status_data(&(sd)->bl), (sd)->status.base_level))
#define pc_rightside_matk(sd) ((sd)->battle_status.rhw.matk+(sd)->battle_status.lhw.matk+(sd)->bonus.ematk)
#else
#define pc_leftside_atk(sd) ((sd)->battle_status.batk + (sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk)
@@ -685,24 +657,27 @@ enum equip_pos {
#define pc_get_group_id(sd) ( (sd)->group_id )
-#define pc_has_permission(sd, permission) ( ((sd)->permissions&permission) != 0 )
-#define pc_should_log_commands(sd) ( (sd)->group_log_command != false )
-
#define pc_checkoverhp(sd) ((sd)->battle_status.hp == (sd)->battle_status.max_hp)
#define pc_checkoversp(sd) ((sd)->battle_status.sp == (sd)->battle_status.max_sp)
-#define pc_readglobalreg(sd,reg) pc->readregistry(sd,reg,3)
-#define pc_setglobalreg(sd,reg,val) pc->setregistry(sd,reg,val,3)
-#define pc_readglobalreg_str(sd,reg) pc->readregistry_str(sd,reg,3)
-#define pc_setglobalreg_str(sd,reg,val) pc->setregistry_str(sd,reg,val,3)
-#define pc_readaccountreg(sd,reg) pc->readregistry(sd,reg,2)
-#define pc_setaccountreg(sd,reg,val) pc->setregistry(sd,reg,val,2)
-#define pc_readaccountregstr(sd,reg) pc->readregistry_str(sd,reg,2)
-#define pc_setaccountregstr(sd,reg,val) pc->setregistry_str(sd,reg,val,2)
-#define pc_readaccountreg2(sd,reg) pc->readregistry(sd,reg,1)
-#define pc_setaccountreg2(sd,reg,val) pc->setregistry(sd,reg,val,1)
-#define pc_readaccountreg2str(sd,reg) pc->readregistry_str(sd,reg,1)
-#define pc_setaccountreg2str(sd,reg,val) pc->setregistry_str(sd,reg,val,1)
+#define pc_readglobalreg(sd,reg) (pc->readregistry((sd),(reg)))
+#define pc_setglobalreg(sd,reg,val) (pc->setregistry((sd),(reg),(val)))
+#define pc_readglobalreg_str(sd,reg) (pc->readregistry_str((sd),(reg)))
+#define pc_setglobalreg_str(sd,reg,val) (pc->setregistry_str((sd),(reg),(val)))
+#define pc_readaccountreg(sd,reg) (pc->readregistry((sd),(reg)))
+#define pc_setaccountreg(sd,reg,val) (pc->setregistry((sd),(reg),(val)))
+#define pc_readaccountregstr(sd,reg) (pc->readregistry_str((sd),(reg)))
+#define pc_setaccountregstr(sd,reg,val) (pc->setregistry_str((sd),(reg),(val)))
+#define pc_readaccountreg2(sd,reg) (pc->readregistry((sd),(reg)))
+#define pc_setaccountreg2(sd,reg,val) (pc->setregistry((sd),(reg),(val)))
+#define pc_readaccountreg2str(sd,reg) (pc->readregistry_str((sd),(reg)))
+#define pc_setaccountreg2str(sd,reg,val) (pc->setregistry_str((sd),(reg),(val)))
+
+/* pc_groups easy access */
+#define pc_get_group_level(sd) ( (sd)->group->level )
+#define pc_has_permission(sd,permission) ( ((sd)->extra_temp_permissions&(permission)) != 0 || ((sd)->group->e_permissions&(permission)) != 0 )
+#define pc_can_give_items(sd) ( pc_has_permission((sd),PC_PERM_TRADE) )
+#define pc_can_give_bound_items(sd) ( pc_has_permission((sd),PC_PERM_TRADE_BOUND) )
struct skill_tree_entry {
short id;
@@ -716,54 +691,103 @@ struct skill_tree_entry {
} need[MAX_PC_SKILL_REQUIRE];
}; // Celest
-extern struct skill_tree_entry skill_tree[CLASS_COUNT][MAX_SKILL_TREE];
-
struct sg_data {
short anger_id;
short bless_id;
short comfort_id;
char feel_var[NAME_LENGTH];
char hate_var[NAME_LENGTH];
- int (*day_func)(void);
+ bool (*day_func)(void);
};
-extern const struct sg_data sg_info[MAX_PC_FEELHATE];
+enum { ADDITEM_EXIST , ADDITEM_NEW , ADDITEM_OVERAMOUNT };
-extern struct fame_list smith_fame_list[MAX_FAME_LIST];
-extern struct fame_list chemist_fame_list[MAX_FAME_LIST];
-extern struct fame_list taekwon_fame_list[MAX_FAME_LIST];
+/**
+ * Item Cool Down Delay Saving
+ * Struct item_cd is not a member of struct map_session_data
+ * to keep cooldowns in memory between player log-ins.
+ * All cooldowns are reset when server is restarted.
+ **/
+struct item_cd {
+ int64 tick[MAX_ITEMDELAYS];//tick
+ short nameid[MAX_ITEMDELAYS];//skill id
+};
-enum {ADDITEM_EXIST,ADDITEM_NEW,ADDITEM_OVERAMOUNT};
+enum e_pc_autotrade_update_action {
+ PAUC_START,
+ PAUC_REFRESH,
+ PAUC_REMOVE,
+};
+
+/**
+ * Used to temporarily remember vending data
+ **/
+struct autotrade_vending {
+ struct item list[MAX_VENDING];
+ struct s_vending vending[MAX_VENDING];
+ unsigned char vend_num;
+};
-#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
-#endif
/*=====================================
-* Interface : pc.h
+* Interface : pc.h
* Generated by HerculesInterfaceMaker
* created by Susu
*-------------------------------------*/
struct pc_interface {
- /* vars */
- // timer for night.day
+ /* */
+ DBMap *at_db;/* char id -> struct autotrade_vending */
+ /* */
+ DBMap* itemcd_db;
+ /* */
int day_timer_tid;
int night_timer_tid;
+ /* */
+ unsigned int exp_table[CLASS_COUNT][2][MAX_LEVEL];
+ unsigned int max_level[CLASS_COUNT][2];
+ unsigned int statp[MAX_LEVEL+1];
+ unsigned int level_penalty[3][RC_MAX][MAX_LEVEL*2+1];
+ unsigned int equip_pos[EQI_MAX];
+ /* */
+ struct skill_tree_entry skill_tree[CLASS_COUNT][MAX_SKILL_TREE];
+ struct fame_list smith_fame_list[MAX_FAME_LIST];
+ struct fame_list chemist_fame_list[MAX_FAME_LIST];
+ struct fame_list taekwon_fame_list[MAX_FAME_LIST];
+ struct sg_data sg_info[MAX_PC_FEELHATE];
+ /* */
+ struct eri *sc_display_ers;
+ /* global expiration timer id */
+ int expiration_tid;
+ /**
+ * ERS for the bulk of pc vars
+ **/
+ struct eri *num_reg_ers;
+ struct eri *str_reg_ers;
+ /* */
+ bool reg_load;
/* funcs */
+ void (*init) (bool minimal);
+ void (*final) (void);
+ struct map_session_data* (*get_dummy_sd) (void);
int (*class2idx) (int class_);
- int (*get_group_level) (struct map_session_data *sd);
- int (*getrefinebonus) (int lv,int type);
+ //int (*getrefinebonus) (int lv,int type); FIXME: This function does not exist, nor it is ever called
bool (*can_give_items) (struct map_session_data *sd);
-
+ bool (*can_give_bound_items) (struct map_session_data *sd);
+ bool (*can_talk) (struct map_session_data *sd);
+ bool (*can_attack) ( struct map_session_data *sd, int target_id );
+
bool (*can_use_command) (struct map_session_data *sd, const char *command);
-
+ int (*set_group) (struct map_session_data *sd, int group_id);
+ bool (*should_log_commands) (struct map_session_data *sd);
+
int (*setrestartvalue) (struct map_session_data *sd,int type);
- int (*makesavestatus) (struct map_session_data *);
+ int (*makesavestatus) (struct map_session_data *sd);
void (*respawn) (struct map_session_data* sd, clr_type clrtype);
- int (*setnewpc) (struct map_session_data*,int,int,int,unsigned int,int,int);
+ int (*setnewpc) (struct map_session_data *sd, int account_id, int char_id, int login_id1, unsigned int client_tick, int sex, int fd);
bool (*authok) (struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers);
- void (*authfail) (struct map_session_data *);
+ void (*authfail) (struct map_session_data *sd);
int (*reg_received) (struct map_session_data *sd);
int (*isequip) (struct map_session_data *sd,int n);
@@ -779,18 +803,19 @@ struct pc_interface {
int (*calc_skilltree_normalize_job) (struct map_session_data *sd);
int (*clean_skilltree) (struct map_session_data *sd);
- int (*setpos) (struct map_session_data* sd, unsigned short mapindex, int x, int y, clr_type clrtype);
- int (*setsavepoint) (struct map_session_data*,short,int,int);
+ int (*setpos) (struct map_session_data* sd, unsigned short map_index, int x, int y, clr_type clrtype);
+ int (*setsavepoint) (struct map_session_data *sd, short map_index, int x, int y);
int (*randomwarp) (struct map_session_data *sd,clr_type type);
int (*memo) (struct map_session_data* sd, int pos);
- int (*checkadditem) (struct map_session_data*,int,int);
- int (*inventoryblank) (struct map_session_data*);
+ int (*checkadditem) (struct map_session_data *sd,int nameid,int amount);
+ int (*inventoryblank) (struct map_session_data *sd);
int (*search_inventory) (struct map_session_data *sd,int item_id);
- int (*payzeny) (struct map_session_data*,int, enum e_log_pick_type type, struct map_session_data*);
- int (*additem) (struct map_session_data*,struct item*,int,e_log_pick_type);
- int (*getzeny) (struct map_session_data*,int, enum e_log_pick_type, struct map_session_data*);
- int (*delitem) (struct map_session_data*,int,int,int,short,e_log_pick_type);
+ int (*payzeny) (struct map_session_data *sd,int zeny, enum e_log_pick_type type, struct map_session_data *tsd);
+ int (*additem) (struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type);
+ int (*getzeny) (struct map_session_data *sd,int zeny, enum e_log_pick_type type, struct map_session_data *tsd);
+ int (*delitem) (struct map_session_data *sd,int n,int amount,int type, short reason, e_log_pick_type log_type);
+
// Special Shop System
int (*paycash) (struct map_session_data *sd, int price, int points);
int (*getcash) (struct map_session_data *sd, int cash, int points);
@@ -801,8 +826,8 @@ struct pc_interface {
int (*getitemfromcart) (struct map_session_data *sd,int idx,int amount);
int (*cartitem_amount) (struct map_session_data *sd,int idx,int amount);
- int (*takeitem) (struct map_session_data*,struct flooritem_data*);
- int (*dropitem) (struct map_session_data*,int,int);
+ int (*takeitem) (struct map_session_data *sd,struct flooritem_data *fitem);
+ int (*dropitem) (struct map_session_data *sd,int n,int amount);
bool (*isequipped) (struct map_session_data *sd, int nameid);
bool (*can_Adopt) (struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd);
@@ -810,53 +835,54 @@ struct pc_interface {
int (*updateweightstatus) (struct map_session_data *sd);
- int (*addautobonus) (struct s_autobonus *bonus,char max,const char *script,short rate,unsigned int dur,short atk_type,const char *o_script,unsigned short pos,bool onskill);
+ int (*addautobonus) (struct s_autobonus *bonus,char max,const char *bonus_script,short rate,unsigned int dur,short atk_type,const char *o_script,unsigned short pos,bool onskill);
int (*exeautobonus) (struct map_session_data* sd,struct s_autobonus *bonus);
- int (*endautobonus) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*endautobonus) (int tid, int64 tick, int id, intptr_t data);
int (*delautobonus) (struct map_session_data* sd,struct s_autobonus *bonus,char max,bool restore);
- int (*bonus) (struct map_session_data*,int,int);
- int (*bonus2) (struct map_session_data *sd,int,int,int);
- int (*bonus3) (struct map_session_data *sd,int,int,int,int);
- int (*bonus4) (struct map_session_data *sd,int,int,int,int,int);
- int (*bonus5) (struct map_session_data *sd,int,int,int,int,int,int);
- int (*skill) (struct map_session_data* sd, int id, int level, int flag);
+ int (*bonus) (struct map_session_data *sd,int type,int val);
+ int (*bonus2) (struct map_session_data *sd,int type,int type2,int val);
+ int (*bonus3) (struct map_session_data *sd,int type,int type2,int type3,int val);
+ int (*bonus4) (struct map_session_data *sd,int type,int type2,int type3,int type4,int val);
+ int (*bonus5) (struct map_session_data *sd,int type,int type2,int type3,int type4,int type5,int val);
+ int (*skill) (struct map_session_data *sd, int id, int level, int flag);
int (*insert_card) (struct map_session_data *sd,int idx_card,int idx_equip);
int (*steal_item) (struct map_session_data *sd,struct block_list *bl, uint16 skill_lv);
int (*steal_coin) (struct map_session_data *sd,struct block_list *bl);
- int (*modifybuyvalue) (struct map_session_data*,int);
- int (*modifysellvalue) (struct map_session_data*,int);
+ int (*modifybuyvalue) (struct map_session_data *sd,int orig_value);
+ int (*modifysellvalue) (struct map_session_data *sd,int orig_value);
- int (*follow) (struct map_session_data*, int); // [MouseJstr]
- int (*stop_following) (struct map_session_data*);
+ int (*follow) (struct map_session_data *sd, int target_id); // [MouseJstr]
+ int (*stop_following) (struct map_session_data *sd);
unsigned int (*maxbaselv) (struct map_session_data *sd);
unsigned int (*maxjoblv) (struct map_session_data *sd);
int (*checkbaselevelup) (struct map_session_data *sd);
int (*checkjoblevelup) (struct map_session_data *sd);
- int (*gainexp) (struct map_session_data*,struct block_list*,unsigned int,unsigned int, bool);
- unsigned int (*nextbaseexp) (struct map_session_data *);
- unsigned int (*thisbaseexp) (struct map_session_data *);
- unsigned int (*nextjobexp) (struct map_session_data *);
- unsigned int (*thisjobexp) (struct map_session_data *);
- int (*gets_status_point) (int);
- int (*need_status_point) (struct map_session_data *,int,int);
- int (*statusup) (struct map_session_data*,int);
- int (*statusup2) (struct map_session_data*,int,int);
- int (*skillup) (struct map_session_data*,uint16 skill_id);
- int (*allskillup) (struct map_session_data*);
- int (*resetlvl) (struct map_session_data*,int type);
- int (*resetstate) (struct map_session_data*);
- int (*resetskill) (struct map_session_data*, int);
- int (*resetfeel) (struct map_session_data*);
- int (*resethate) (struct map_session_data*);
- int (*equipitem) (struct map_session_data*,int,int);
- int (*unequipitem) (struct map_session_data*,int,int);
- int (*checkitem) (struct map_session_data*);
- int (*useitem) (struct map_session_data*,int);
+ bool (*gainexp) (struct map_session_data *sd, struct block_list *src, unsigned int base_exp, unsigned int job_exp, bool is_quest);
+ unsigned int (*nextbaseexp) (struct map_session_data *sd);
+ unsigned int (*thisbaseexp) (struct map_session_data *sd);
+ unsigned int (*nextjobexp) (struct map_session_data *sd);
+ unsigned int (*thisjobexp) (struct map_session_data *sd);
+ int (*gets_status_point) (int level);
+ int (*need_status_point) (struct map_session_data *sd,int type,int val);
+ int (*maxparameterincrease) (struct map_session_data* sd, int type);
+ bool (*statusup) (struct map_session_data *sd, int type, int increase);
+ int (*statusup2) (struct map_session_data *sd,int type,int val);
+ int (*skillup) (struct map_session_data *sd,uint16 skill_id);
+ int (*allskillup) (struct map_session_data *sd);
+ int (*resetlvl) (struct map_session_data *sd,int type);
+ int (*resetstate) (struct map_session_data *sd);
+ int (*resetskill) (struct map_session_data *sd, int flag);
+ int (*resetfeel) (struct map_session_data *sd);
+ int (*resethate) (struct map_session_data *sd);
+ int (*equipitem) (struct map_session_data *sd,int n,int req_pos);
+ int (*unequipitem) (struct map_session_data *sd,int n,int flag);
+ int (*checkitem) (struct map_session_data *sd);
+ int (*useitem) (struct map_session_data *sd,int n);
int (*skillatk_bonus) (struct map_session_data *sd, uint16 skill_id);
int (*skillheal_bonus) (struct map_session_data *sd, uint16 skill_id);
@@ -867,26 +893,26 @@ struct pc_interface {
void (*revive) (struct map_session_data *sd,unsigned int hp, unsigned int sp);
void (*heal) (struct map_session_data *sd,unsigned int hp,unsigned int sp, int type);
int (*itemheal) (struct map_session_data *sd,int itemid, int hp,int sp);
- int (*percentheal) (struct map_session_data *sd,int,int);
- int (*jobchange) (struct map_session_data *,int, int);
- int (*setoption) (struct map_session_data *,int);
+ int (*percentheal) (struct map_session_data *sd,int hp,int sp);
+ int (*jobchange) (struct map_session_data *sd,int job, int upper);
+ int (*setoption) (struct map_session_data *sd,int type);
int (*setcart) (struct map_session_data* sd, int type);
int (*setfalcon) (struct map_session_data* sd, int flag);
int (*setriding) (struct map_session_data* sd, int flag);
- int (*setmadogear) (struct map_session_data* sd, int flag);
- int (*changelook) (struct map_session_data *,int,int);
+ void (*setmadogear) (struct map_session_data* sd, int flag);
+ int (*changelook) (struct map_session_data *sd,int type,int val);
int (*equiplookall) (struct map_session_data *sd);
- int (*readparam) (struct map_session_data*,int);
- int (*setparam) (struct map_session_data*,int,int);
- int (*readreg) (struct map_session_data*,int);
- int (*setreg) (struct map_session_data*,int,int);
- char * (*readregstr) (struct map_session_data *sd,int reg);
- int (*setregstr) (struct map_session_data *sd,int reg,const char *str);
- int (*readregistry) (struct map_session_data*,const char*,int);
- int (*setregistry) (struct map_session_data*,const char*,int,int);
- char * (*readregistry_str) (struct map_session_data*,const char*,int);
- int (*setregistry_str) (struct map_session_data*,const char*,const char*,int);
+ int (*readparam) (struct map_session_data *sd,int type);
+ int (*setparam) (struct map_session_data *sd,int type,int val);
+ int (*readreg) (struct map_session_data *sd, int64 reg);
+ void (*setreg) (struct map_session_data *sd, int64 reg,int val);
+ char * (*readregstr) (struct map_session_data *sd, int64 reg);
+ void (*setregstr) (struct map_session_data *sd, int64 reg, const char *str);
+ int (*readregistry) (struct map_session_data *sd, int64 reg);
+ int (*setregistry) (struct map_session_data *sd, int64 reg, int val);
+ char * (*readregistry_str) (struct map_session_data *sd, int64 reg);
+ int (*setregistry_str) (struct map_session_data *sd, int64 reg, const char *val);
int (*addeventtimer) (struct map_session_data *sd,int tick,const char *name);
int (*deleventtimer) (struct map_session_data *sd,const char *name);
@@ -894,7 +920,7 @@ struct pc_interface {
int (*addeventtimercount) (struct map_session_data *sd,const char *name,int tick);
int (*calc_pvprank) (struct map_session_data *sd);
- int (*calc_pvprank_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*calc_pvprank_timer) (int tid, int64 tick, int id, intptr_t data);
int (*ismarried) (struct map_session_data *sd);
int (*marriage) (struct map_session_data *sd,struct map_session_data *dstsd);
@@ -918,17 +944,15 @@ struct pc_interface {
void (*setinvincibletimer) (struct map_session_data* sd, int val);
void (*delinvincibletimer) (struct map_session_data* sd);
- int (*addspiritball) (struct map_session_data *sd,int,int);
- int (*delspiritball) (struct map_session_data *sd,int,int);
+ int (*addspiritball) (struct map_session_data *sd,int interval,int max);
+ int (*delspiritball) (struct map_session_data *sd,int count,int type);
void (*addfame) (struct map_session_data *sd,int count);
unsigned char (*famerank) (int char_id, int job);
int (*set_hate_mob) (struct map_session_data *sd, int pos, struct block_list *bl);
int (*readdb) (void);
- int (*do_init_pc) (void);
- void (*do_final_pc) (void);
- int (*map_day_timer) (int tid, unsigned int tick, int id, intptr_t data); // by [yor]
- int (*map_night_timer) (int tid, unsigned int tick, int id, intptr_t data); // by [yor]
+ int (*map_day_timer) (int tid, int64 tick, int id, intptr_t data); // by [yor]
+ int (*map_night_timer) (int tid, int64 tick, int id, intptr_t data); // by [yor]
// Rental System
void (*inventory_rentals) (struct map_session_data *sd);
int (*inventory_rental_clear) (struct map_session_data *sd);
@@ -949,13 +973,61 @@ struct pc_interface {
int (*del_charm) (struct map_session_data *sd,int count,int type);
void (*baselevelchanged) (struct map_session_data *sd);
-#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
- int (*level_penalty_mod) (struct map_session_data *sd, struct mob_data * md, int type);
-#endif
-} pc_s;
+ int (*level_penalty_mod) (int diff, unsigned char race, unsigned short mode, int type);
+ int (*calc_skillpoint) (struct map_session_data* sd);
+
+ int (*invincible_timer) (int tid, int64 tick, int id, intptr_t data);
+ int (*spiritball_timer) (int tid, int64 tick, int id, intptr_t data);
+ int (*check_banding) ( struct block_list *bl, va_list ap );
+ int (*inventory_rental_end) (int tid, int64 tick, int id, intptr_t data);
+ void (*check_skilltree) (struct map_session_data *sd, int skill_id);
+ int (*bonus_autospell) (struct s_autospell *spell, int max, short id, short lv, short rate, short flag, short card_id);
+ int (*bonus_autospell_onskill) (struct s_autospell *spell, int max, short src_skill, short id, short lv, short rate, short card_id);
+ int (*bonus_addeff) (struct s_addeffect* effect, int max, enum sc_type id, short rate, short arrow_rate, unsigned char flag);
+ int (*bonus_addeff_onskill) (struct s_addeffectonskill* effect, int max, enum sc_type id, short rate, short skill_id, unsigned char target);
+ int (*bonus_item_drop) (struct s_add_drop *drop, const short max, short id, short group, int race, int rate);
+ void (*calcexp) (struct map_session_data *sd, unsigned int *base_exp, unsigned int *job_exp, struct block_list *src);
+ int (*respawn_timer) (int tid, int64 tick, int id, intptr_t data);
+ int (*jobchange_killclone) (struct block_list *bl, va_list ap);
+ int (*getstat) (struct map_session_data* sd, int type);
+ int (*setstat) (struct map_session_data* sd, int type, int val);
+ int (*eventtimer) (int tid, int64 tick, int id, intptr_t data);
+ int (*daynight_timer_sub) (struct map_session_data *sd,va_list ap);
+ int (*charm_timer) (int tid, int64 tick, int id, intptr_t data);
+ bool (*readdb_levelpenalty) (char* fields[], int columns, int current);
+ int (*autosave) (int tid, int64 tick, int id, intptr_t data);
+ int (*follow_timer) (int tid, int64 tick, int id, intptr_t data);
+ void (*read_skill_tree) (void);
+ int (*isUseitem) (struct map_session_data *sd,int n);
+ int (*show_steal) (struct block_list *bl,va_list ap);
+ int (*checkcombo) (struct map_session_data *sd, struct item_data *data );
+ int (*calcweapontype) (struct map_session_data *sd);
+ int (*removecombo) (struct map_session_data *sd, struct item_data *data );
+
+ void (*bank_deposit) (struct map_session_data *sd, int money);
+ void (*bank_withdraw) (struct map_session_data *sd, int money);
+
+ void (*rental_expire) (struct map_session_data *sd, int i);
+ void (*scdata_received) (struct map_session_data *sd);
+
+ void (*bound_clear) (struct map_session_data *sd, enum e_item_bound_type type);
+
+ int (*expiration_timer) (int tid, int64 tick, int id, intptr_t data);
+ int (*global_expiration_timer) (int tid, int64 tick, int id, intptr_t data);
+ void (*expire_check) (struct map_session_data *sd);
+
+ /**
+ * Autotrade persistency [Ind/Hercules <3]
+ **/
+ void (*autotrade_load) (void);
+ void (*autotrade_update) (struct map_session_data *sd, enum e_pc_autotrade_update_action action);
+ void (*autotrade_start) (struct map_session_data *sd);
+ void (*autotrade_prepare) (struct map_session_data *sd);
+ void (*autotrade_populate) (struct map_session_data *sd);
+};
struct pc_interface *pc;
void pc_defaults(void);
-#endif /* _PC_H_ */
+#endif /* MAP_PC_H */