summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-04-20 23:24:20 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-04-20 23:24:20 +0000
commit8cd804f247a2d36ff8dc69d09a1004f5ec84197a (patch)
tree88c4f726d6a9fea3d3a13032db4bb1b850a2ddee /src/map/pc.c
parenta09e5436e06f844688f708c23975d3ce7e4b3965 (diff)
downloadhercules-8cd804f247a2d36ff8dc69d09a1004f5ec84197a.tar.gz
hercules-8cd804f247a2d36ff8dc69d09a1004f5ec84197a.tar.bz2
hercules-8cd804f247a2d36ff8dc69d09a1004f5ec84197a.tar.xz
hercules-8cd804f247a2d36ff8dc69d09a1004f5ec84197a.zip
- Added two columns to item_db: equip_script and unequip_script are scripts that are executed once when the corresponding item is equipped or unequipped respectively.
- Removed bonuses bDamageWhenUnequip, bLoseSPWhenUnequip - Updated sql-files/item_db.sql with latest. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6204 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c129
1 files changed, 43 insertions, 86 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index b9b532ea1..c7cf8b24f 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -1184,7 +1184,6 @@ static int pc_bonus_item_drop(struct s_add_drop *drop, short *count, short id, s
*/
int pc_bonus(struct map_session_data *sd,int type,int val)
{
- int i;
nullpo_retr(0, sd);
switch(type){
@@ -1642,30 +1641,6 @@ int pc_bonus(struct map_session_data *sd,int type,int val)
if(!sd->state.lr_flag)
sd->hp_gain_value += val;
break;
- case SP_DAMAGE_WHEN_UNEQUIP:
- if(!sd->state.lr_flag) {
- for (i=0; i<11; i++) {
- //I think this one is bugged, notice how it uses the item_db info rather
- // than inventory equipped position index [Skotlex]
-// if (sd->inventory_data[current_equip_item_index]->equip & equip_pos[i]) {
- if(sd->status.inventory[current_equip_item_index].equip & equip_pos[i]) {
- sd->unequip_losehp[i] += val;
- break;
- }
- }
- }
- break;
- case SP_LOSESP_WHEN_UNEQUIP:
- if(!sd->state.lr_flag) {
- for (i=0; i<11; i++) {
-// if (sd->inventory_data[current_equip_item_index]->equip & equip_pos[i]) {
- if(sd->status.inventory[current_equip_item_index].equip & equip_pos[i]) {
- sd->unequip_losesp[i] += val;
- break;
- }
- }
- }
- break;
default:
if(battle_config.error_log)
ShowWarning("pc_bonus: unknown type %d %d !\n",type,val);
@@ -6231,7 +6206,10 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos)
sd->status.inventory[arrow].equip=32768;
}
status_calc_pc(sd,0);
-
+ //OnEquip script [Skotlex]
+ if (sd->inventory_data[n] && sd->inventory_data[n]->equip_script)
+ run_script(sd->inventory_data[n]->equip_script,0,sd->bl.id,0);
+
if(sd->sc.count) {
if (sd->sc.data[SC_SIGNUMCRUCIS].timer != -1 && !battle_check_undead(7,sd->def_ele))
status_change_end(&sd->bl,SC_SIGNUMCRUCIS,-1);
@@ -6250,7 +6228,6 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos)
*/
int pc_unequipitem(struct map_session_data *sd,int n,int flag)
{
- short hp = 0, sp = 0;
nullpo_retr(0, sd);
// -- moonsoul (if player is berserk then cannot unequip)
@@ -6262,73 +6239,53 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag)
if(battle_config.battle_log)
ShowInfo("unequip %d %x:%x\n",n,pc_equippoint(sd,n),sd->status.inventory[n].equip);
- if(sd->status.inventory[n].equip){
- int i;
- for(i=0;i<11;i++) {
- if(sd->status.inventory[n].equip & equip_pos[i]) {
- sd->equip_index[i] = -1;
- if(sd->unequip_losehp[i] > 0) {
- hp += sd->unequip_losehp[i];
- sd->unequip_losehp[i] = 0;
- }
- if(sd->unequip_losesp[i] > 0) {
- sp += sd->unequip_losesp[i];
- sd->unequip_losesp[i] = 0;
- }
- }
- }
- if(sd->status.inventory[n].equip & 0x0002) {
- sd->weapontype1 = 0;
- sd->status.weapon = sd->weapontype2;
- pc_calcweapontype(sd);
- clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
- if(sd->sc.data[SC_DANCING].timer!=-1) //When unequipping, stop dancing. [Skotlex]
- skill_stop_dancing(&sd->bl);
- }
- if(sd->status.inventory[n].equip & 0x0020) {
- sd->status.shield = sd->weapontype2 = 0;
- pc_calcweapontype(sd);
- clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
- }
- if(sd->status.inventory[n].equip & 0x0001) {
- sd->status.head_bottom = 0;
- clif_changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
- }
- if(sd->status.inventory[n].equip & 0x0100) {
- sd->status.head_top = 0;
- clif_changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
- }
- if(sd->status.inventory[n].equip & 0x0200) {
- sd->status.head_mid = 0;
- clif_changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
- }
- if(sd->status.inventory[n].equip & 0x0040)
- clif_changelook(&sd->bl,LOOK_SHOES,0);
-
- clif_unequipitemack(sd,n,sd->status.inventory[n].equip,1);
- sd->status.inventory[n].equip=0;
- if(flag&1)
- pc_checkallowskill(sd);
- if(sd->weapontype1 == 0 && sd->weapontype2 == 0)
- skill_enchant_elemental_end(&sd->bl,-1); //���펝�������͖�?����?���t?����
- } else {
+ if(!sd->status.inventory[n].equip){ //Nothing to unequip
clif_unequipitemack(sd,n,0,0);
+ return 0;
+ }
+
+ if(sd->status.inventory[n].equip & 0x0002) {
+ sd->weapontype1 = 0;
+ sd->status.weapon = sd->weapontype2;
+ pc_calcweapontype(sd);
+ clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
+ if(sd->sc.data[SC_DANCING].timer!=-1) //When unequipping, stop dancing. [Skotlex]
+ skill_stop_dancing(&sd->bl);
+ }
+ if(sd->status.inventory[n].equip & 0x0020) {
+ sd->status.shield = sd->weapontype2 = 0;
+ pc_calcweapontype(sd);
+ clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
}
+ if(sd->status.inventory[n].equip & 0x0001) {
+ sd->status.head_bottom = 0;
+ clif_changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
+ }
+ if(sd->status.inventory[n].equip & 0x0100) {
+ sd->status.head_top = 0;
+ clif_changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
+ }
+ if(sd->status.inventory[n].equip & 0x0200) {
+ sd->status.head_mid = 0;
+ clif_changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
+ }
+ if(sd->status.inventory[n].equip & 0x0040)
+ clif_changelook(&sd->bl,LOOK_SHOES,0);
+ clif_unequipitemack(sd,n,sd->status.inventory[n].equip,1);
+ sd->status.inventory[n].equip=0;
+ if(flag&1)
+ pc_checkallowskill(sd);
+ if(sd->weapontype1 == 0 && sd->weapontype2 == 0)
+ skill_enchant_elemental_end(&sd->bl,-1); //���펝�������͖�?����?���t?����
if(flag&1) {
status_calc_pc(sd,0);
if(sd->sc.count && sd->sc.data[SC_SIGNUMCRUCIS].timer != -1 && !battle_check_undead(7,sd->def_ele))
status_change_end(&sd->bl,SC_SIGNUMCRUCIS,-1);
}
-
- if (hp > 0 || sp > 0) {
- if (hp > sd->status.hp)
- hp = sd->status.hp;
- if (sp > sd->status.sp)
- sp = sd->status.sp;
- pc_heal(sd, -hp, -sp);
- }
-
+ //OnUnEquip script [Skotlex]
+ if (sd->inventory_data[n] && sd->inventory_data[n]->unequip_script)
+ run_script(sd->inventory_data[n]->unequip_script,0,sd->bl.id,0);
return 0;
}