summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c2
-rw-r--r--src/map/atcommand.h2
-rw-r--r--src/map/battle.c433
-rw-r--r--src/map/battle.h2
-rw-r--r--src/map/battleground.c69
-rw-r--r--src/map/battleground.h4
-rw-r--r--src/map/buyingstore.c2
-rw-r--r--src/map/buyingstore.h2
-rw-r--r--src/map/chrif.c12
-rw-r--r--src/map/chrif.h11
-rw-r--r--src/map/clif.c67
-rw-r--r--src/map/clif.h6
-rw-r--r--src/map/guild.c1
-rw-r--r--src/map/guild.h2
-rw-r--r--src/map/homunculus.c2
-rw-r--r--src/map/homunculus.h2
-rw-r--r--src/map/instance.c2
-rw-r--r--src/map/instance.h2
-rw-r--r--src/map/irc-bot.c2
-rw-r--r--src/map/irc-bot.h2
-rw-r--r--src/map/itemdb.c2
-rw-r--r--src/map/itemdb.h2
-rw-r--r--src/map/log.c1
-rw-r--r--src/map/log.h2
-rw-r--r--src/map/mail.c2
-rw-r--r--src/map/mail.h2
-rw-r--r--src/map/map.c6
-rw-r--r--src/map/map.h2
-rw-r--r--src/map/npc.c120
-rw-r--r--src/map/packets_struct.h6
-rw-r--r--src/map/party.c2
-rw-r--r--src/map/party.h2
-rw-r--r--src/map/pc.c2
-rw-r--r--src/map/pc.h8
-rw-r--r--src/map/script.c191
-rw-r--r--src/map/script.h16
-rw-r--r--src/map/searchstore.c1
-rw-r--r--src/map/searchstore.h2
-rw-r--r--src/map/skill.c117
-rw-r--r--src/map/skill.h21
-rw-r--r--src/map/status.c94
-rw-r--r--src/map/status.h2
-rw-r--r--src/map/storage.c3
-rw-r--r--src/map/storage.h4
-rw-r--r--src/map/trade.c2
-rw-r--r--src/map/trade.h2
-rw-r--r--src/map/unit.c2
-rw-r--r--src/map/vending.c2
-rw-r--r--src/map/vending.h2
49 files changed, 797 insertions, 450 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index b778aab6c..f35bf8a12 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -51,6 +51,8 @@
#include <string.h>
#include <math.h>
+struct atcommand_interface atcommand_s;
+
static char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
static char atcmd_output[CHAT_SIZE_MAX];
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index f09b1f2b8..12439ab32 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -86,7 +86,7 @@ struct atcommand_interface {
void (*final_msg) (void);
/* atcommand binding */
struct atcmd_binding_data* (*get_bind_byname) (const char* name);
-} atcommand_s;
+};
struct atcommand_interface *atcommand;
diff --git a/src/map/battle.c b/src/map/battle.c
index d67684e7b..1d14c1828 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -39,6 +39,7 @@
int attr_fix_table[4][ELE_MAX][ELE_MAX];
struct Battle_Config battle_config;
+struct battle_interface battle_s;
static struct eri *delay_damage_ers; //For battle delay damage structures.
int battle_getcurrentskill(struct block_list *bl) { //Returns the current/last skill in use by this bl.
@@ -367,8 +368,8 @@ int battle_attr_fix(struct block_list *src, struct block_list *target, int damag
status_change_end(target, SC_THORNS_TRAP, INVALID_TIMER);
if( tsc->data[SC_FIRE_CLOAK_OPTION])
damage -= damage * tsc->data[SC_FIRE_CLOAK_OPTION]->val2 / 100;
- if( tsc->data[SC_CRYSTALIZE] && target->type != BL_MOB)
- status_change_end(target, SC_CRYSTALIZE, INVALID_TIMER);
+ if( tsc->data[SC_COLD] && target->type != BL_MOB)
+ status_change_end(target, SC_COLD, INVALID_TIMER);
if( tsc->data[SC_EARTH_INSIGNIA]) damage += damage/2;
if( tsc->data[SC_VOLCANIC_ASH]) damage += damage/2; //150%
break;
@@ -379,7 +380,7 @@ int battle_attr_fix(struct block_list *src, struct block_list *target, int damag
if( tsc->data[SC_VENOMIMPRESS]) ratio += tsc->data[SC_VENOMIMPRESS]->val2;
break;
case ELE_WIND:
- if( tsc->data[SC_CRYSTALIZE] && target->type != BL_MOB) damage += damage/2;
+ if( tsc->data[SC_COLD] && target->type != BL_MOB) damage += damage/2;
if( tsc->data[SC_WATER_INSIGNIA]) damage += damage/2;
break;
case ELE_WATER:
@@ -704,17 +705,21 @@ int battle_addmastery(struct map_session_data *sd,struct block_list *target,int
*------------------------------------------*/
int battle_calc_masteryfix(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int damage, int div, bool left, bool weapon){
int skill, i;
- struct map_session_data *sd;
struct status_change *sc;
+ struct map_session_data *sd;
+ struct status_data *tstatus;
nullpo_ret(src);
nullpo_ret(target);
-
- sd = BL_CAST(BL_PC, src);
+
sc = status_get_sc(src);
+ sd = BL_CAST(BL_PC, src);
+ tstatus = status_get_status_data(target);
if ( !sd )
return damage;
+
+ damage = battle->add_mastery(sd, target, damage, left);
switch( skill_id ){ // specific skill masteries
case MO_INVESTIGATE:
@@ -737,29 +742,48 @@ int battle_calc_masteryfix(struct block_list *src, struct block_list *target, ui
damage += 60;
break;
#endif
- case RA_WUGDASH:
+ case RA_WUGDASH://(Caster Current Weight x 10 / 8)
+ if( sd->weight )
+ damage += sd->weight / 8 ;
case RA_WUGSTRIKE:
case RA_WUGBITE:
damage += 30*pc->checkskill(sd, RA_TOOTHOFWUG);
break;
- }
-
- if ( sc && sc->data[SC_MIRACLE] ) i = 2; //Star anger
- else
- ARR_FIND(0, MAX_PC_FEELHATE, i, status_get_class(target) == sd->hate_mob[i]);
- if ( i < MAX_PC_FEELHATE && (skill=pc->checkskill(sd,sg_info[i].anger_id)) && weapon ){
- int ratio = sd->status.base_level + status_get_dex(src) + status_get_luk(src);
- if ( i == 2 ) ratio += status_get_str(src); //Star Anger
- if (skill < 4 )
- ratio /= (12 - 3 * skill);
- damage += damage * ratio / 100;
+ case HT_FREEZINGTRAP:
+ damage += 40 * pc->checkskill(sd, RA_RESEARCHTRAP);
+ break;
}
- if( sc ){
+ if( sc ){ // sc considered as masteries
if(sc->data[SC_GN_CARTBOOST])
damage += 10 * sc->data[SC_GN_CARTBOOST]->val1;
if(sc->data[SC_CAMOUFLAGE])
damage += 30 * ( 10 - sc->data[SC_CAMOUFLAGE]->val4 );
+#ifdef RENEWAL
+ if(sc->data[SC_NIBELUNGEN] && weapon)
+ damage += sc->data[SC_NIBELUNGEN]->val2;
+ if(sc->data[SC_IMPOSITIO])
+ damage += sc->data[SC_IMPOSITIO]->val2;
+ if(sc->data[SC_DRUMBATTLE]){
+ if(tstatus->size == SZ_SMALL)
+ damage += sc->data[SC_DRUMBATTLE]->val2;
+ else if(tstatus->size == SZ_MEDIUM)
+ damage += 10 * sc->data[SC_DRUMBATTLE]->val1;
+ //else no bonus for large target
+ }
+ if(sc->data[SC_GS_MADNESSCANCEL])
+ damage += 100;
+ if(sc->data[SC_GS_GATLINGFEVER]){
+ if(tstatus->size == SZ_SMALL)
+ damage += 10 * sc->data[SC_GS_GATLINGFEVER]->val1;
+ else if(tstatus->size == SZ_MEDIUM)
+ damage += -5 * sc->data[SC_GS_GATLINGFEVER]->val1;
+ else
+ damage += sc->data[SC_GS_GATLINGFEVER]->val1;
+ }
+ //if(sc->data[SC_SPECIALZONE])
+ // damage += sc->data[SC_SPECIALZONE]->val2 >> 4;
+#endif
}
// general skill masteries
@@ -770,18 +794,35 @@ int battle_calc_masteryfix(struct block_list *src, struct block_list *target, ui
damage += div * sd->spiritball * 3;
if( skill_id != CR_SHIELDBOOMERANG ) // Only Shield boomerang doesn't takes the Star Crumbs bonus.
damage += div * (left ? sd->left_weapon.star : sd->right_weapon.star);
+
+ if(sd->status.party_id && (skill=pc->checkskill(sd,TK_POWER)) > 0){
+ if( (i = party_foreachsamemap(party->sub_count, sd, 0)) > 1 )
+ damage += 2 * skill * i * (damage /*+ unknown value*/) / 100 /*+ unknown value*/;
+ }
#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 && (skill=pc->checkskill(sd,ASC_KATAR)) > 0 )
damage += damage * (10 + 2 * skill) / 100;
#endif
+ // percentage factor masteries
+ if ( sc && sc->data[SC_MIRACLE] )
+ i = 2; //Star anger
+ else
+ ARR_FIND(0, MAX_PC_FEELHATE, i, status_get_class(target) == sd->hate_mob[i]);
+ if ( i < MAX_PC_FEELHATE && (skill=pc->checkskill(sd,sg_info[i].anger_id)) && weapon ){
+ int ratio = sd->status.base_level + status_get_dex(src) + status_get_luk(src);
+ if ( i == 2 ) ratio += status_get_str(src); //Star Anger
+ if (skill < 4 )
+ ratio /= (12 - 3 * skill);
+ damage += damage * ratio / 100;
+ }
- damage = battle->add_mastery(sd, target, damage, left);
-
- if((skill = pc->checkskill(sd,AB_EUCHARISTICA)) > 0 &&
- (status_get_status_data(target)->race == RC_DEMON || status_get_status_data(target)->def_ele == ELE_DARK) )
- damage += damage * skill / 100;
+ if( sd->status.class_ == JOB_ARCH_BISHOP_T || sd->status.class_ == JOB_ARCH_BISHOP ){
+ if((skill = pc->checkskill(sd,AB_EUCHARISTICA)) > 0 &&
+ (tstatus->race == RC_DEMON || tstatus->def_ele == ELE_DARK) )
+ damage += damage * skill / 100;
+ }
return damage;
}
@@ -817,12 +858,12 @@ int battle_calc_elefix(struct block_list *src, struct block_list *target, uint16
#ifndef RENEWAL
if( sc && sc->data[SC_SUB_WEAPONPROPERTY] )
{ // Descriptions indicate this means adding a percent of a normal attack in another element. [Skotlex]
- damage = battle->calc_base_damage(sstatus, &sstatus->rhw, sc, tstatus->size, BL_CAST(BL_PC, src), (flag?2:0)) * sc->data[SC_SUB_WEAPONPROPERTY]->val2 / 100;
- damage += battle->attr_fix(src, target, damage, sc->data[SC_SUB_WEAPONPROPERTY]->val1, tstatus->def_ele, tstatus->ele_lv);
- if( left ){
- damage = battle->calc_base_damage(sstatus, &sstatus->lhw, sc, tstatus->size, BL_CAST(BL_PC, src), (flag?2:0)) * sc->data[SC_SUB_WEAPONPROPERTY]->val2 / 100;
- damage += battle->attr_fix(src, target, damage, sc->data[SC_SUB_WEAPONPROPERTY]->val1, tstatus->def_ele, tstatus->ele_lv);
- }
+ int temp = battle->calc_base_damage(sstatus, &sstatus->rhw, sc, tstatus->size, BL_CAST(BL_PC, src), (flag?2:0)) * sc->data[SC_SUB_WEAPONPROPERTY]->val2 / 100;
+ damage += battle->attr_fix(src, target, temp, sc->data[SC_SUB_WEAPONPROPERTY]->val1, tstatus->def_ele, tstatus->ele_lv);
+ if( left ){
+ temp = battle->calc_base_damage(sstatus, &sstatus->lhw, sc, tstatus->size, BL_CAST(BL_PC, src), (flag?2:0)) * sc->data[SC_SUB_WEAPONPROPERTY]->val2 / 100;
+ damage += battle->attr_fix(src, target, temp, sc->data[SC_SUB_WEAPONPROPERTY]->val1, tstatus->def_ele, tstatus->ele_lv);
+ }
}
#endif
return damage;
@@ -918,39 +959,14 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li
break;
case BF_WEAPON:
t_race2 = status_get_race2(target);
- if( cflag&2 && sd && !(nk&NK_NO_CARDFIX_ATK) )
- {
- short cardfix_ = 1000;
- if(sd->state.arrow_atk)
- {
- cardfix = cardfix * (100 + sd->right_weapon.addrace[tstatus->race] + sd->arrow_addrace[tstatus->race]) / 100;
- if (!(nk&NK_NO_ELEFIX))
- {
- int ele_fix = sd->right_weapon.addele[tstatus->def_ele] + sd->arrow_addele[tstatus->def_ele];
- for (i = 0; ARRAYLENGTH(sd->right_weapon.addele2) > i && sd->right_weapon.addele2[i].rate != 0; i++) {
- if (sd->right_weapon.addele2[i].ele != tstatus->def_ele) continue;
- if(!(sd->right_weapon.addele2[i].flag&wflag&BF_WEAPONMASK &&
- sd->right_weapon.addele2[i].flag&wflag&BF_RANGEMASK &&
- sd->right_weapon.addele2[i].flag&wflag&BF_SKILLMASK))
- continue;
- ele_fix += sd->right_weapon.addele2[i].rate;
- }
- cardfix = cardfix * (100 + ele_fix) / 100;
- }
- cardfix = cardfix * (100 + sd->right_weapon.addsize[tstatus->size]+sd->arrow_addsize[tstatus->size]) / 100;
- cardfix = cardfix * (100 + sd->right_weapon.addrace2[t_race2]) / 100;
- cardfix = cardfix * (100 + sd->right_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS] + sd->arrow_addrace[is_boss(target)?RC_BOSS:RC_NONBOSS]) / 100;
- if( tstatus->race != RC_DEMIHUMAN )
- cardfix = cardfix * (100 + sd->right_weapon.addrace[RC_NONDEMIHUMAN]+sd->arrow_addrace[RC_NONDEMIHUMAN]) / 100;
- }
- else
- { // Melee attack
- if( !battle_config.left_cardfix_to_right )
- {
- cardfix=cardfix*(100+sd->right_weapon.addrace[tstatus->race])/100;
- if (!(nk&NK_NO_ELEFIX)) {
- int ele_fix = sd->right_weapon.addele[tstatus->def_ele];
- for (i = 0; ARRAYLENGTH(sd->right_weapon.addele2) > i && sd->right_weapon.addele2[i].rate != 0; i++) {
+ if( cflag&2 ){
+ if( sd && !(nk&NK_NO_CARDFIX_ATK) ){
+ short cardfix_ = 1000;
+ if( sd->state.arrow_atk ){
+ cardfix = cardfix * (100 + sd->right_weapon.addrace[tstatus->race] + sd->arrow_addrace[tstatus->race]) / 100;
+ if( !(nk&NK_NO_ELEFIX) ){
+ int ele_fix = sd->right_weapon.addele[tstatus->def_ele] + sd->arrow_addele[tstatus->def_ele];
+ for(i = 0; ARRAYLENGTH(sd->right_weapon.addele2) > i && sd->right_weapon.addele2[i].rate != 0; i++){
if (sd->right_weapon.addele2[i].ele != tstatus->def_ele) continue;
if(!(sd->right_weapon.addele2[i].flag&wflag&BF_WEAPONMASK &&
sd->right_weapon.addele2[i].flag&wflag&BF_RANGEMASK &&
@@ -958,154 +974,161 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li
continue;
ele_fix += sd->right_weapon.addele2[i].rate;
}
- cardfix = cardfix * (100+ele_fix) / 100;
+ cardfix = cardfix * (100 + ele_fix) / 100;
}
- cardfix = cardfix * (100+sd->right_weapon.addsize[tstatus->size]) / 100;
- cardfix = cardfix * (100+sd->right_weapon.addrace2[t_race2]) / 100;
- cardfix = cardfix * (100+sd->right_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS]) / 100;
+ cardfix = cardfix * (100 + sd->right_weapon.addsize[tstatus->size]+sd->arrow_addsize[tstatus->size]) / 100;
+ cardfix = cardfix * (100 + sd->right_weapon.addrace2[t_race2]) / 100;
+ cardfix = cardfix * (100 + sd->right_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS] + sd->arrow_addrace[is_boss(target)?RC_BOSS:RC_NONBOSS]) / 100;
if( tstatus->race != RC_DEMIHUMAN )
- cardfix = cardfix * (100 + sd->right_weapon.addrace[RC_NONDEMIHUMAN]) / 100;
-
- if( cflag&1 )
- {
- cardfix_=cardfix_*(100+sd->left_weapon.addrace[tstatus->race])/100;
- if (!(nk&NK_NO_ELEFIX)) {
- int ele_fix_lh = sd->left_weapon.addele[tstatus->def_ele];
- for (i = 0; ARRAYLENGTH(sd->left_weapon.addele2) > i && sd->left_weapon.addele2[i].rate != 0; i++) {
- if (sd->left_weapon.addele2[i].ele != tstatus->def_ele) continue;
- if(!(sd->left_weapon.addele2[i].flag&wflag&BF_WEAPONMASK &&
- sd->left_weapon.addele2[i].flag&wflag&BF_RANGEMASK &&
- sd->left_weapon.addele2[i].flag&wflag&BF_SKILLMASK))
+ cardfix = cardfix * (100 + sd->right_weapon.addrace[RC_NONDEMIHUMAN]+sd->arrow_addrace[RC_NONDEMIHUMAN]) / 100;
+ }else{ // Melee attack
+ if( !battle_config.left_cardfix_to_right ){
+ cardfix=cardfix*(100+sd->right_weapon.addrace[tstatus->race])/100;
+ if( !(nk&NK_NO_ELEFIX) ){
+ int ele_fix = sd->right_weapon.addele[tstatus->def_ele];
+ for (i = 0; ARRAYLENGTH(sd->right_weapon.addele2) > i && sd->right_weapon.addele2[i].rate != 0; i++) {
+ if (sd->right_weapon.addele2[i].ele != tstatus->def_ele) continue;
+ if(!(sd->right_weapon.addele2[i].flag&wflag&BF_WEAPONMASK &&
+ sd->right_weapon.addele2[i].flag&wflag&BF_RANGEMASK &&
+ sd->right_weapon.addele2[i].flag&wflag&BF_SKILLMASK))
continue;
- ele_fix_lh += sd->left_weapon.addele2[i].rate;
+ ele_fix += sd->right_weapon.addele2[i].rate;
}
- cardfix = cardfix * (100+ele_fix_lh) / 100;
+ cardfix = cardfix * (100+ele_fix) / 100;
}
- cardfix_ = cardfix_ * (100+sd->left_weapon.addsize[tstatus->size]) / 100;
- cardfix_ = cardfix_ * (100+sd->left_weapon.addrace2[t_race2]) / 100;
- cardfix_ = cardfix_ * (100+sd->left_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS]) / 100;
+ cardfix = cardfix * (100+sd->right_weapon.addsize[tstatus->size]) / 100;
+ cardfix = cardfix * (100+sd->right_weapon.addrace2[t_race2]) / 100;
+ cardfix = cardfix * (100+sd->right_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS]) / 100;
if( tstatus->race != RC_DEMIHUMAN )
- cardfix_=cardfix_*(100+sd->left_weapon.addrace[RC_NONDEMIHUMAN])/100;
- }
- }
- else
- {
- int ele_fix = sd->right_weapon.addele[tstatus->def_ele] + sd->left_weapon.addele[tstatus->def_ele];
- for (i = 0; ARRAYLENGTH(sd->right_weapon.addele2) > i && sd->right_weapon.addele2[i].rate != 0; i++) {
- if (sd->right_weapon.addele2[i].ele != tstatus->def_ele) continue;
- if(!(sd->right_weapon.addele2[i].flag&wflag&BF_WEAPONMASK &&
- sd->right_weapon.addele2[i].flag&wflag&BF_RANGEMASK &&
- sd->right_weapon.addele2[i].flag&wflag&BF_SKILLMASK))
- continue;
- ele_fix += sd->right_weapon.addele2[i].rate;
- }
- for (i = 0; ARRAYLENGTH(sd->left_weapon.addele2) > i && sd->left_weapon.addele2[i].rate != 0; i++) {
- if (sd->left_weapon.addele2[i].ele != tstatus->def_ele) continue;
- if(!(sd->left_weapon.addele2[i].flag&wflag&BF_WEAPONMASK &&
- sd->left_weapon.addele2[i].flag&wflag&BF_RANGEMASK &&
- sd->left_weapon.addele2[i].flag&wflag&BF_SKILLMASK))
- continue;
- ele_fix += sd->left_weapon.addele2[i].rate;
- }
-
- cardfix = cardfix * (100 + sd->right_weapon.addrace[tstatus->race] + sd->left_weapon.addrace[tstatus->race]) / 100;
- cardfix = cardfix * (100 + ele_fix) / 100;
- cardfix = cardfix * (100 + sd->right_weapon.addsize[tstatus->size] + sd->left_weapon.addsize[tstatus->size])/100;
- cardfix = cardfix * (100 + sd->right_weapon.addrace2[t_race2] + sd->left_weapon.addrace2[t_race2])/100;
- cardfix = cardfix * (100 + sd->right_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS] + sd->left_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS]) / 100;
- if( tstatus->race != RC_DEMIHUMAN )
- cardfix = cardfix * (100+sd->right_weapon.addrace[RC_NONDEMIHUMAN] + sd->left_weapon.addrace[RC_NONDEMIHUMAN]) / 100;
- }
- }
+ cardfix = cardfix * (100 + sd->right_weapon.addrace[RC_NONDEMIHUMAN]) / 100;
+
+ if( cflag&1 ){
+ cardfix_ = cardfix_*(100+sd->left_weapon.addrace[tstatus->race])/100;
+ if (!(nk&NK_NO_ELEFIX)){
+ int ele_fix_lh = sd->left_weapon.addele[tstatus->def_ele];
+ for (i = 0; ARRAYLENGTH(sd->left_weapon.addele2) > i && sd->left_weapon.addele2[i].rate != 0; i++) {
+ if (sd->left_weapon.addele2[i].ele != tstatus->def_ele) continue;
+ if(!(sd->left_weapon.addele2[i].flag&wflag&BF_WEAPONMASK &&
+ sd->left_weapon.addele2[i].flag&wflag&BF_RANGEMASK &&
+ sd->left_weapon.addele2[i].flag&wflag&BF_SKILLMASK))
+ continue;
+ ele_fix_lh += sd->left_weapon.addele2[i].rate;
+ }
+ cardfix = cardfix * (100+ele_fix_lh) / 100;
+ }
+ cardfix_ = cardfix_ * (100+sd->left_weapon.addsize[tstatus->size]) / 100;
+ cardfix_ = cardfix_ * (100+sd->left_weapon.addrace2[t_race2]) / 100;
+ cardfix_ = cardfix_ * (100+sd->left_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS]) / 100;
+ if( tstatus->race != RC_DEMIHUMAN )
+ cardfix_ = cardfix_*(100+sd->left_weapon.addrace[RC_NONDEMIHUMAN])/100;
+ }
+ }else{
+ int ele_fix = sd->right_weapon.addele[tstatus->def_ele] + sd->left_weapon.addele[tstatus->def_ele];
+ for (i = 0; ARRAYLENGTH(sd->right_weapon.addele2) > i && sd->right_weapon.addele2[i].rate != 0; i++){
+ if (sd->right_weapon.addele2[i].ele != tstatus->def_ele) continue;
+ if(!(sd->right_weapon.addele2[i].flag&wflag&BF_WEAPONMASK &&
+ sd->right_weapon.addele2[i].flag&wflag&BF_RANGEMASK &&
+ sd->right_weapon.addele2[i].flag&wflag&BF_SKILLMASK))
+ continue;
+ ele_fix += sd->right_weapon.addele2[i].rate;
+ }
+ for (i = 0; ARRAYLENGTH(sd->left_weapon.addele2) > i && sd->left_weapon.addele2[i].rate != 0; i++){
+ if (sd->left_weapon.addele2[i].ele != tstatus->def_ele) continue;
+ if(!(sd->left_weapon.addele2[i].flag&wflag&BF_WEAPONMASK &&
+ sd->left_weapon.addele2[i].flag&wflag&BF_RANGEMASK &&
+ sd->left_weapon.addele2[i].flag&wflag&BF_SKILLMASK))
+ continue;
+ ele_fix += sd->left_weapon.addele2[i].rate;
+ }
- for( i = 0; i < ARRAYLENGTH(sd->right_weapon.add_dmg) && sd->right_weapon.add_dmg[i].rate; i++ )
- {
- if( sd->right_weapon.add_dmg[i].class_ == t_class )
- {
- cardfix = cardfix * (100 + sd->right_weapon.add_dmg[i].rate) / 100;
- break;
+ cardfix = cardfix * (100 + sd->right_weapon.addrace[tstatus->race] + sd->left_weapon.addrace[tstatus->race]) / 100;
+ cardfix = cardfix * (100 + ele_fix) / 100;
+ cardfix = cardfix * (100 + sd->right_weapon.addsize[tstatus->size] + sd->left_weapon.addsize[tstatus->size])/100;
+ cardfix = cardfix * (100 + sd->right_weapon.addrace2[t_race2] + sd->left_weapon.addrace2[t_race2])/100;
+ cardfix = cardfix * (100 + sd->right_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS] + sd->left_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS]) / 100;
+ if( tstatus->race != RC_DEMIHUMAN )
+ cardfix = cardfix * (100+sd->right_weapon.addrace[RC_NONDEMIHUMAN] + sd->left_weapon.addrace[RC_NONDEMIHUMAN]) / 100;
+ }
}
- }
- if( cflag&1 )
- {
- for( i = 0; i < ARRAYLENGTH(sd->left_weapon.add_dmg) && sd->left_weapon.add_dmg[i].rate; i++ )
- {
- if( sd->left_weapon.add_dmg[i].class_ == t_class )
- {
- cardfix_ = cardfix_ * (100 + sd->left_weapon.add_dmg[i].rate) / 100;
+ for( i = 0; i < ARRAYLENGTH(sd->right_weapon.add_dmg) && sd->right_weapon.add_dmg[i].rate; i++ ){
+ if( sd->right_weapon.add_dmg[i].class_ == t_class ){
+ cardfix = cardfix * (100 + sd->right_weapon.add_dmg[i].rate) / 100;
break;
}
}
- }
- if( wflag&BF_LONG )
- cardfix = cardfix * (100 + sd->bonus.long_attack_atk_rate) / 100;
+ if( cflag&1 ){
+ for( i = 0; i < ARRAYLENGTH(sd->left_weapon.add_dmg) && sd->left_weapon.add_dmg[i].rate; i++ ){
+ if( sd->left_weapon.add_dmg[i].class_ == t_class ){
+ cardfix_ = cardfix_ * (100 + sd->left_weapon.add_dmg[i].rate) / 100;
+ break;
+ }
+ }
+ }
- if( (cflag&1) && cardfix_ != 1000 )
- damage = damage * cardfix_ / 1000;
- else if( cardfix != 1000 )
- damage = damage * cardfix / 1000;
+ if( wflag&BF_LONG )
+ cardfix = cardfix * (100 + sd->bonus.long_attack_atk_rate) / 100;
- break; // end Attacker side
- }
- // Target side
- if( tsd && !(nk&NK_NO_CARDFIX_DEF) )
- {
- if( !(nk&NK_NO_ELEFIX) )
- {
- int ele_fix = tsd->subele[s_ele];
- for (i = 0; ARRAYLENGTH(tsd->subele2) > i && tsd->subele2[i].rate != 0; i++)
- {
- if(tsd->subele2[i].ele != s_ele) continue;
- if(!(tsd->subele2[i].flag&wflag&BF_WEAPONMASK &&
- tsd->subele2[i].flag&wflag&BF_RANGEMASK &&
- tsd->subele2[i].flag&wflag&BF_SKILLMASK))
- continue;
- ele_fix += tsd->subele2[i].rate;
- }
- cardfix=cardfix*(100-ele_fix)/100;
- if( cflag&1 && s_ele_ != s_ele )
- {
- int ele_fix_lh = tsd->subele[s_ele_];
+ if( (cflag&1) && cardfix_ != 1000 )
+ damage = damage * cardfix_ / 1000;
+ else if( cardfix != 1000 )
+ damage = damage * cardfix / 1000;
+ }
+ }else{
+ // Target side
+ if( tsd && !(nk&NK_NO_CARDFIX_DEF) ){
+ if( !(nk&NK_NO_ELEFIX) ){
+ int ele_fix = tsd->subele[s_ele];
for (i = 0; ARRAYLENGTH(tsd->subele2) > i && tsd->subele2[i].rate != 0; i++)
{
- if(tsd->subele2[i].ele != s_ele_) continue;
+ if(tsd->subele2[i].ele != s_ele) continue;
if(!(tsd->subele2[i].flag&wflag&BF_WEAPONMASK &&
tsd->subele2[i].flag&wflag&BF_RANGEMASK &&
tsd->subele2[i].flag&wflag&BF_SKILLMASK))
continue;
- ele_fix_lh += tsd->subele2[i].rate;
+ ele_fix += tsd->subele2[i].rate;
+ }
+ cardfix = cardfix * (100-ele_fix) / 100;
+ if( cflag&1 && s_ele_ != s_ele ){
+ int ele_fix_lh = tsd->subele[s_ele_];
+ for (i = 0; ARRAYLENGTH(tsd->subele2) > i && tsd->subele2[i].rate != 0; i++){
+ if(tsd->subele2[i].ele != s_ele_) continue;
+ if(!(tsd->subele2[i].flag&wflag&BF_WEAPONMASK &&
+ tsd->subele2[i].flag&wflag&BF_RANGEMASK &&
+ tsd->subele2[i].flag&wflag&BF_SKILLMASK))
+ continue;
+ ele_fix_lh += tsd->subele2[i].rate;
+ }
+ cardfix = cardfix * (100 - ele_fix_lh) / 100;
}
- cardfix = cardfix * (100 - ele_fix_lh) / 100;
}
- }
- cardfix = cardfix * (100-tsd->subsize[sstatus->size]) / 100;
- cardfix = cardfix * (100-tsd->subrace2[s_race2]) / 100;
- cardfix = cardfix * (100-tsd->subrace[sstatus->race]) / 100;
- cardfix = cardfix * (100-tsd->subrace[is_boss(src)?RC_BOSS:RC_NONBOSS]) / 100;
- if( sstatus->race != RC_DEMIHUMAN )
- cardfix = cardfix * (100-tsd->subrace[RC_NONDEMIHUMAN]) / 100;
-
- for( i = 0; i < ARRAYLENGTH(tsd->add_def) && tsd->add_def[i].rate;i++ )
- {
- if( tsd->add_def[i].class_ == s_class )
- {
- cardfix = cardfix * (100 - tsd->add_def[i].rate) / 100;
- break;
+ cardfix = cardfix * (100-tsd->subsize[sstatus->size]) / 100;
+ cardfix = cardfix * (100-tsd->subrace2[s_race2]) / 100;
+ cardfix = cardfix * (100-tsd->subrace[sstatus->race]) / 100;
+ cardfix = cardfix * (100-tsd->subrace[is_boss(src)?RC_BOSS:RC_NONBOSS]) / 100;
+ if( sstatus->race != RC_DEMIHUMAN )
+ cardfix = cardfix * (100-tsd->subrace[RC_NONDEMIHUMAN]) / 100;
+
+ for( i = 0; i < ARRAYLENGTH(tsd->add_def) && tsd->add_def[i].rate;i++ ){
+ if( tsd->add_def[i].class_ == s_class )
+ {
+ cardfix = cardfix * (100 - tsd->add_def[i].rate) / 100;
+ break;
+ }
}
- }
- if( wflag&BF_SHORT )
- cardfix = cardfix * (100 - tsd->bonus.near_attack_def_rate) / 100;
- else // BF_LONG (there's no other choice)
- cardfix = cardfix * (100 - tsd->bonus.near_attack_def_rate) / 100;
+ if( wflag&BF_SHORT )
+ cardfix = cardfix * (100 - tsd->bonus.near_attack_def_rate) / 100;
+ else // BF_LONG (there's no other choice)
+ cardfix = cardfix * (100 - tsd->bonus.near_attack_def_rate) / 100;
- if( tsd->sc.data[SC_PROTECT_DEF] )
- cardfix = cardfix * (100 - tsd->sc.data[SC_PROTECT_DEF]->val1) / 100;
+ if( tsd->sc.data[SC_PROTECT_DEF] )
+ cardfix = cardfix * (100 - tsd->sc.data[SC_PROTECT_DEF]->val1) / 100;
- if( cardfix != 1000 )
- damage = damage * cardfix / 1000;
+ if( cardfix != 1000 )
+ damage = damage * cardfix / 1000;
+ }
}
break;
case BF_MISC:
@@ -1489,7 +1512,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
skillratio += 300 + 100 * skill_lv + status_get_int(src);
RE_LVL_DMOD(100);
break;
- case WL_FROSTMISTY: // MATK [{( Skill Level x 100 ) + 200 } x ( Caster�s Base Level / 100 )] %
+ case WL_FROSTMISTY: // MATK [{( Skill Level x 100 ) + 200 } x ( Caster?s Base Level / 100 )] %
skillratio += 100 + 100 * skill_lv;
RE_LVL_DMOD(100);
break;
@@ -2712,7 +2735,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
damage += damage / 2; // 1.5 times more damage while in Deep Sleep.
status_change_end(bl,SC_DEEP_SLEEP,INVALID_TIMER);
}
- if( tsd && sd && sc->data[SC_CRYSTALIZE] && flag&BF_WEAPON ){
+ if( tsd && sd && sc->data[SC_COLD] && flag&BF_WEAPON ){
switch(tsd->status.weapon){
case W_MACE:
case W_2HMACE:
@@ -3358,7 +3381,8 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
//Constant/misc additions from skills
if (skill_id == WZ_FIREPILLAR)
MATK_ADD(50);
- if( sd && (i=pc->checkskill(sd,AB_EUCHARISTICA)) > 0 &&
+ if( sd && ( sd->status.class_ == JOB_ARCH_BISHOP_T || sd->status.class_ == JOB_ARCH_BISHOP ) &&
+ (i=pc->checkskill(sd,AB_EUCHARISTICA)) > 0 &&
(tstatus->race == RC_DEMON || tstatus->def_ele == ELE_DARK) )
MATK_ADDRATE(i);
}
@@ -4377,20 +4401,21 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
ATK_ADD(-totaldef);
if( is_boss(target) )
ATK_RATE(50);
- flag.idef = 1;
}
break;
case NJ_SYURIKEN: // [malufett]
GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0) );
wd.damage += battle->calc_masteryfix(src, target, skill_id, skill_lv, 4 * skill_lv + (sd ? sd->bonus.arrow_atk : 0), wd.div_, 0, flag.weapon) - status_get_total_def(target);
- flag.idef = 1;
break;
case MO_EXTREMITYFIST: // [malufett]
- GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|8 );
- // first value is still not confirm.
- if( wd.damage )
- wd.damage = status_get_sp(src) + 10 * status_get_sp(src) * wd.damage / 100 + 8 * wd.damage + 250 + 150 * skill_lv;
- flag.tdef = 1;
+ {
+ short totaldef = status_get_total_def(target);
+ GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|8 );
+ if( wd.damage ){
+ wd.damage = (250 + 150 * skill_lv) + (10 * (status_get_sp(src)+1) * wd.damage / 100) + (8 * wd.damage);
+ ATK_ADD(-totaldef);
+ }
+ }
#endif
break;
#ifndef RENEWAL
@@ -4490,6 +4515,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if (sd->bonus.atk_rate)
ATK_ADDRATE(sd->bonus.atk_rate);
+#ifndef RENEWAL
if(flag.cri && sd->bonus.crit_atk_rate)
ATK_ADDRATE(sd->bonus.crit_atk_rate);
@@ -4497,6 +4523,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if( (i = party_foreachsamemap(party->sub_count, sd, 0)) > 1 ) // exclude the player himself [Inkfish]
ATK_ADDRATE(2*temp*i);
}
+#endif
}
break;
} //End default case
@@ -4595,14 +4622,6 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
ATK_ADD(4*skill_lv);
#endif
break;
- case HT_FREEZINGTRAP:
- if(sd)
- ATK_ADD( 40 * pc->checkskill(sd, RA_RESEARCHTRAP) );
- break;
- case RA_WUGDASH ://(Caster Current Weight x 10 / 8)
- if( sd && sd->weight )
- ATK_ADD( sd->weight / 8 );
- break;
case GC_COUNTERSLASH:
ATK_ADD( status_get_agi(src) * 2 + (sd?sd->status.job_level:0) * 4 );
break;
@@ -4797,8 +4816,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if( flag.lh)
wd.damage2 = battle->calc_masteryfix(src, target, skill_id, skill_lv, wd.damage2, wd.div_, 1, flag.weapon);
#else
- if( flag.cri )
- ATK_ADDRATE(40);
+ if( sd && flag.cri )
+ ATK_ADDRATE(sd->bonus.crit_atk_rate >= 100 ? sd->bonus.crit_atk_rate : 40);
#endif
} //Here ends flag.hit section, the rest of the function applies to both hitting and missing attacks
else if(wd.div_ < 0) //Since the attack missed...
@@ -4848,13 +4867,11 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
ATK_ADD(wd.div_*sd->spiritball*3);
}
//Card Fix, sd side
+
wd.damage = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, 2, wd.flag);
if( flag.lh )
wd.damage2 = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage2, 3, wd.flag);
-#ifdef RENEWAL
- if( flag.cri )
- ATK_ADDRATE(sd->bonus.crit_atk_rate>=100?sd->bonus.crit_atk_rate-60:40);
-#endif
+
if( skill_id == CR_SHIELDBOOMERANG || skill_id == PA_SHIELDCHAIN )
{ //Refine bonus applies after cards and elements.
short index= sd->equip_index[EQI_HAND_L];
diff --git a/src/map/battle.h b/src/map/battle.h
index 37968f53a..9a8c18fd7 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -556,7 +556,7 @@ struct battle_interface {
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;
diff --git a/src/map/battleground.c b/src/map/battleground.c
index 88cc323bf..4bf0843d5 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -21,12 +21,14 @@
#include "pet.h"
#include "homunculus.h"
#include "mercenary.h"
+#include "mapreg.h"
#include <string.h>
#include <stdio.h>
static DBMap* bg_team_db; // int bg_id -> struct battleground_data*
static unsigned int bg_team_counter = 0; // Next bg_id
+struct battleground_interface bg_s;
struct battleground_data* bg_team_search(int bg_id) { // Search a BG Team using bg_id
if( !bg_id ) return NULL;
@@ -254,7 +256,7 @@ void bg_config_read(void) {
config_setting_t *settings = config_setting_get_elem(data, 0);
config_setting_t *arenas;
const char *delay_var;
- int i, arena_count = 0, total = 0, offline = 0;
+ int i, arena_count = 0, offline = 0;
if( !config_setting_lookup_string(settings, "global_delay_var", &delay_var) )
delay_var = "BG_Delay_Tick";
@@ -264,7 +266,7 @@ void bg_config_read(void) {
config_setting_lookup_int(settings, "maximum_afk_seconds", &bg->mafksec);
config_setting_lookup_bool(settings, "feature_off", &offline);
-
+
if( offline == 0 )
bg->queue_on = true;
@@ -279,7 +281,7 @@ void bg_config_read(void) {
int prizeWin, prizeLoss, prizeDraw;
int minPlayers, maxPlayers, minTeamPlayers;
int maxDuration;
- int fillup_duration, pregame_duration;
+ int fillup_duration = 0, pregame_duration = 0;
bg->arena[i] = NULL;
@@ -305,7 +307,7 @@ void bg_config_read(void) {
maxLevel = MAX_LEVEL;
}
- if( !(reward = config_setting_get_member(settings, "reward")) ) {
+ if( !(reward = config_setting_get_member(arena, "reward")) ) {
ShowError("bg_config_read: failed to find 'reward' for arena '%s'/#%d\n",aName,i);
continue;
}
@@ -385,18 +387,16 @@ void bg_config_read(void) {
bg->arena[i]->min_team_players = minTeamPlayers;
safestrncpy(bg->arena[i]->delay_var, aDelayVar, NAME_LENGTH);
bg->arena[i]->maxDuration = maxDuration;
- bg->arena[i]->queue_id = -1;
+ bg->arena[i]->queue_id = script->queue_create();
bg->arena[i]->begin_timer = INVALID_TIMER;
bg->arena[i]->fillup_timer = INVALID_TIMER;
bg->arena[i]->pregame_duration = pregame_duration;
bg->arena[i]->fillup_duration = fillup_duration;
-
- total++;
+
}
bg->arenas = arena_count;
}
- ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' arenas in '"CL_WHITE"%s"CL_RESET"'.\n", total, config_filename);
config_destroy(&bg_conf);
}
}
@@ -425,17 +425,35 @@ void bg_queue_ready_ack (struct bg_arena *arena, struct map_session_data *sd, bo
bg->queue_pc_cleanup(sd);
return;
}
- if( response ) {
+ if( !response )
+ bg->queue_pc_cleanup(sd);
+ else {
+ struct hQueue *queue = &script->hq[arena->queue_id];
+ int i, count = 0;
sd->bg_queue.ready = 1;
+
+ for( i = 0; i < queue->items; i++ ) {
+ if( ( sd = iMap->id2sd(queue->item[i]) ) ) {
+ if( sd->bg_queue.ready == 1 )
+ count++;
+ }
+ }
/* check if all are ready then cancell timer, and start game */
- } else
- bg->queue_pc_cleanup(sd);
+ if( count == i ) {
+ iTimer->delete_timer(arena->begin_timer,bg->begin_timer);
+ arena->begin_timer = INVALID_TIMER;
+ bg->begin(arena);
+ }
+
+ }
+
}
void bg_queue_player_cleanup(struct map_session_data *sd) {
if ( sd->bg_queue.client_has_bg_data ) {
clif->bgqueue_notice_delete(sd,BGQND_CLOSEWINDOW, sd->bg_queue.arena ? sd->bg_queue.arena->id : 0);
}
- script->queue_remove(sd->bg_queue.arena->queue_id,sd->status.account_id);
+ if( sd->bg_queue.arena )
+ script->queue_remove(sd->bg_queue.arena->queue_id,sd->status.account_id);
sd->bg_queue.arena = NULL;
sd->bg_queue.ready = 0;
sd->bg_queue.client_has_bg_data = 0;
@@ -443,27 +461,27 @@ void bg_queue_player_cleanup(struct map_session_data *sd) {
}
void bg_match_over(struct bg_arena *arena, bool canceled) {
struct hQueue *queue = &script->hq[arena->queue_id];
- int i;//, count = 0;
-
- /* if( !canceled ) <check time/score> */
+ int i;
for( i = 0; i < queue->items; i++ ) {
struct map_session_data * sd = NULL;
if( ( sd = iMap->id2sd(queue->item[i]) ) ) {
bg->queue_pc_cleanup(sd);
- clif->colormes(sd->fd,COLOR_RED,"BG Match Cancelled: not enough players");
+ if( canceled )
+ clif->colormes(sd->fd,COLOR_RED,"BG Match Cancelled: not enough players");
}
}
bg->arena[i]->begin_timer = INVALID_TIMER;
bg->arena[i]->fillup_timer = INVALID_TIMER;
/* reset queue */
+ script->queue_clear(arena->queue_id);
}
void bg_begin(struct bg_arena *arena) {
struct hQueue *queue = &script->hq[arena->queue_id];
int i, count = 0;
-
+
for( i = 0; i < queue->items; i++ ) {
struct map_session_data * sd = NULL;
@@ -476,12 +494,14 @@ void bg_begin(struct bg_arena *arena) {
}
if( count < arena->min_players ) {
- bg_match_over(arena,true);
+ bg->match_over(arena,true);
} else {
- ;
+ mapreg_setreg(add_str("$@bg_queue_id"),arena->queue_id);/* TODO: make this a arena-independant var? or just .@? */
+ npc_event_do(arena->npc_event);
/* we split evenly? */
/* but if a party of say 10 joins, it cant be split evenly unless by luck there are 10 soloers in the queue besides them */
/* not sure how to split T_T needs more info */
+ /* currently running only on solo mode so we do it evenly */
}
}
int bg_begin_timer(int tid, unsigned int tick, int id, intptr_t data) {
@@ -599,11 +619,12 @@ void bg_queue_add(struct map_session_data *sd, struct bg_arena *arena, enum bg_q
clif->bgqueue_ack(sd,BGQA_SUCCESS,arena->id);
+ bg->queue_check(arena);
}
enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type) {
int tick;
unsigned int tsec;
- if ( sd->status.base_level > arena->max_level || sd->status.base_level < arena->max_level )
+ if ( sd->status.base_level > arena->max_level || sd->status.base_level < arena->min_level )
return BGQA_FAIL_LEVEL_INCORRECT;
if ( !(sd->class_&JOBL_2) ) /* TODO: maybe make this a per-arena setting, so users may make custom arenas like baby-only,whatever. */
@@ -633,6 +654,11 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
if( sd->bg_queue.arena != NULL )
return BGQA_DUPLICATE_REQUEST;
+
+ if( type != BGQT_INDIVIDUAL ) {/* until we get the damn balancing correct */
+ clif->colormes(sd->fd,COLOR_RED,"Queueing is only currently enabled only for Solo Mode");
+ return BGQA_FAIL_TEAM_COUNT;
+ }
switch(type) {
case BGQT_GUILD:
@@ -704,6 +730,7 @@ void do_init_battleground(void) {
bg_team_db = idb_alloc(DB_OPT_RELEASE_DATA);
iTimer->add_timer_func_list(bg_send_xy_timer, "bg_send_xy_timer");
iTimer->add_timer_interval(iTimer->gettick() + battle_config.bg_update_interval, bg_send_xy_timer, 0, 0, battle_config.bg_update_interval);
+ bg->config_read();
}
void do_final_battleground(void) {
@@ -738,6 +765,8 @@ void battleground_defaults(void) {
bg->queue_pregame = bg_queue_pregame;
bg->fillup_timer = bg_fillup_timer;
bg->queue_ready_ack = bg_queue_ready_ack;
+ bg->match_over = bg_match_over;
+ bg->queue_check = bg_queue_check;
/* */
bg->config_read = bg_config_read;
}
diff --git a/src/map/battleground.h b/src/map/battleground.h
index 030d13d90..88d75f953 100644
--- a/src/map/battleground.h
+++ b/src/map/battleground.h
@@ -97,9 +97,11 @@ struct battleground_interface {
void (*queue_pregame) (struct bg_arena *arena);
int (*fillup_timer) (int tid, unsigned int tick, int id, intptr_t data);
void (*queue_ready_ack) (struct bg_arena *arena, struct map_session_data *sd, bool response);
+ void (*match_over) (struct bg_arena *arena, bool canceled);
+ void (*queue_check) (struct bg_arena *arena);
/* */
void (*config_read) (void);
-} bg_s;
+};
struct battleground_interface *bg;
diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c
index 7041042df..73c50b0bf 100644
--- a/src/map/buyingstore.c
+++ b/src/map/buyingstore.c
@@ -37,7 +37,7 @@ enum e_buyingstore_failure
static unsigned int buyingstore_nextid = 0;
static const short buyingstore_blankslots[MAX_SLOTS] = { 0 }; // used when checking whether or not an item's card slots are blank
-
+struct buyingstore_interface buyingstore_s;
/// Returns unique buying store id
static unsigned int buyingstore_getuid(void)
diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h
index a416317be..ae5fcb9e5 100644
--- a/src/map/buyingstore.h
+++ b/src/map/buyingstore.h
@@ -29,7 +29,7 @@ struct buyingstore_interface {
void (*trade) (struct map_session_data* sd, int account_id, unsigned int buyer_id, const uint8* itemlist, unsigned int count);
bool (*search) (struct map_session_data* sd, unsigned short nameid);
bool (*searchall) (struct map_session_data* sd, const struct s_search_store_search* s);
-} buyingstore_s;
+};
struct buyingstore_interface *buyingstore;
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 9e8b18d3b..c2067dbd1 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -48,6 +48,8 @@ static const int packet_len_table[0x3d] = { // U - used, F - free
-1,10, 8, 2, 2,14,19,19, // 2b20-2b27: U->2b20, U->2b21, U->2b22, U->2b23, U->2b24, U->2b25, U->2b26, U->2b27
};
+struct chrif_interface chrif_s;
+
//Used Packets:
//2af8: Outgoing, chrif_connect -> 'connect to charserver / auth @ charserver'
//2af9: Incoming, chrif_connectack -> 'answer of the 2af8 login(ok / fail)'
@@ -456,7 +458,7 @@ int chrif_connectack(int fd) {
ShowStatus("Successfully logged on to Char Server (Connection: '"CL_WHITE"%d"CL_RESET"').\n",fd);
chrif_state = 1;
- chrif->chrif_connected = 1;
+ chrif->connected = 1;
chrif_sendmap(fd);
@@ -1331,9 +1333,9 @@ int chrif_char_online(struct map_session_data *sd) {
/// Called when the connection to Char Server is disconnected.
void chrif_on_disconnect(void) {
- if( chrif->chrif_connected != 1 )
+ if( chrif->connected != 1 )
ShowWarning("Connection to Char Server lost.\n\n");
- chrif->chrif_connected = 0;
+ chrif->connected = 0;
chrif->other_mapserver_count = 0; //Reset counter. We receive ALL maps from all map-servers on reconnect.
iMap->eraseallipport();
@@ -1544,7 +1546,7 @@ static int check_connect_char_server(int tid, unsigned int tick, int id, intptr_
realloc_fifo(char_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
chrif_connect(char_fd);
- chrif->chrif_connected = (chrif_state == 2);
+ chrif->connected = (chrif_state == 2);
srvinfo = 0;
} else {
if (srvinfo == 0) {
@@ -1657,7 +1659,7 @@ void chrif_defaults(void) {
/* vars */
- chrif->chrif_connected = 0;
+ chrif->connected = 0;
chrif->other_mapserver_count = 0;
/* funcs */
diff --git a/src/map/chrif.h b/src/map/chrif.h
index faabedeed..a6a5fc6bf 100644
--- a/src/map/chrif.h
+++ b/src/map/chrif.h
@@ -1,11 +1,15 @@
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
+
#ifndef _CHRIF_H_
#define _CHRIF_H_
+
#include "../common/cbasetypes.h"
#include <time.h>
+
enum sd_state { ST_LOGIN, ST_LOGOUT, ST_MAPCHANGE };
+
struct auth_node {
int account_id, char_id;
int login_id1, login_id2, sex, fd;
@@ -16,9 +20,6 @@ struct auth_node {
enum sd_state state; //To track whether player was login in/out or changing maps.
};
-
-
-
/*=====================================
* Interface : chrif.h
* Generated by HerculesInterfaceMaker
@@ -28,7 +29,7 @@ struct chrif_interface {
/* vars */
- int chrif_connected;
+ int connected;
int other_mapserver_count; //Holds count of how many other map servers are online (apart of this instance) [Skotlex]
/* funcs */
@@ -78,7 +79,7 @@ struct chrif_interface {
int (*flush_fifo) (void);
void (*skillid2idx) (int fd);
-} chrif_s;
+};
struct chrif_interface *chrif;
diff --git a/src/map/clif.c b/src/map/clif.c
index e5132a938..f925fcf55 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -53,6 +53,8 @@
#include <stdarg.h>
#include <time.h>
+struct clif_interface clif_s;
+
//#define DUMP_UNKNOWN_PACKET
//#define DUMP_INVALID_PACKET
@@ -545,8 +547,24 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target
}
break;
+ case BG_QUEUE:
+ if( sd && sd->bg_queue.arena ) {
+ struct hQueue *queue = &script->hq[sd->bg_queue.arena->queue_id];
+
+ for( i = 0; i < queue->items; i++ ) {
+ struct map_session_data * sd = NULL;
+
+ if( ( sd = iMap->id2sd(queue->item[i]) ) ) {
+ WFIFOHEAD(sd->fd,len);
+ memcpy(WFIFOP(sd->fd,0), buf, len);
+ WFIFOSET(sd->fd,len);
+ }
+ }
+ }
+ break;
+
default:
- ShowError("clif->send: Unrecognized type %d\n",type);
+ ShowError("clif_send: Unrecognized type %d\n",type);
return -1;
}
@@ -17317,7 +17335,6 @@ void clif_status_change_end(struct block_list *bl, int tid, enum send_target tar
}
void clif_bgqueue_ack(struct map_session_data *sd, enum BATTLEGROUNDS_QUEUE_ACK response, unsigned char arena_id) {
-
switch (response) {
case BGQA_FAIL_COOLDOWN:
case BGQA_FAIL_DESERTER:
@@ -17348,15 +17365,16 @@ void clif_bgqueue_notice_delete(struct map_session_data *sd, enum BATTLEGROUNDS_
}
void clif_parse_bgqueue_register(int fd, struct map_session_data *sd) {
- struct packet_bgqueue_register *p = P2PTR(fd, bgqueue_registerType);
+ struct packet_bgqueue_register *p = P2PTR(fd);
struct bg_arena *arena = NULL;
-
if( !bg->queue_on ) return; /* temp, until feature is complete */
if( !(arena = bg->name2arena(p->bg_name)) ) {
clif->bgqueue_ack(sd,BGQA_FAIL_BGNAME_INVALID,0);
return;
}
+ //debug
+ safestrncpy(arena->name, p->bg_name, sizeof(arena->name));
switch( (enum bg_queue_types)p->type ) {
case BGQT_INDIVIDUAL:
@@ -17387,7 +17405,6 @@ void clif_parse_bgqueue_checkstate(int fd, struct map_session_data *sd) {
//struct packet_bgqueue_checkstate *p = P2PTR(fd, bgqueue_checkstateType); /* TODO: bgqueue_notice_delete should use this p->bg_name */
if( !bg->queue_on ) return; /* temp, until feature is complete */
if ( sd->bg_queue.arena && sd->bg_queue.type ) {
- sd->bg_queue.client_has_bg_data = true;
clif->bgqueue_update_info(sd,sd->bg_queue.arena->id,bg->id2pos(sd->bg_queue.arena->queue_id,sd->status.account_id));
} else
clif->bgqueue_notice_delete(sd, BGQND_FAIL_NOT_QUEUING,0);/* TODO: wrong response, should respond with p->bg_name not id 0 */
@@ -17400,10 +17417,10 @@ void clif_parse_bgqueue_revoke_req(int fd, struct map_session_data *sd) {
}
void clif_parse_bgqueue_battlebegin_ack(int fd, struct map_session_data *sd) {
- struct packet_bgqueue_battlebegin_ack *p = P2PTR(fd, bgqueue_checkstateType);
+ struct packet_bgqueue_battlebegin_ack *p = P2PTR(fd);
struct bg_arena *arena;
if( !bg->queue_on ) return; /* temp, until feature is complete */
- if( ( arena = bg->name2arena(p->bg_name) ) ) {
+ if( ( arena = bg->name2arena(p->bg_name) ) ) {
bg->queue_ready_ack(arena,sd, ( p->result == 1 ) ? true : false);
} else {
clif->bgqueue_ack(sd,BGQA_FAIL_BGNAME_INVALID, 0);
@@ -17463,6 +17480,41 @@ void clif_package_item_announce(struct map_session_data *sd, unsigned short name
clif->send(&p,sizeof(p), &sd->bl, ALL_CLIENT);
}
+/* [Ind/Hercules] special thanks to Yommy~! */
+void clif_skill_cooldown_list(int fd, struct skill_cd* cd) {
+#if PACKETVER >= 20120604
+ const int offset = 10;
+#else
+ const int offset = 6;
+#endif
+ int i, count = 0;
+
+ WFIFOHEAD(fd,4+(offset*cd->cursor));
+
+#if PACKETVER >= 20120604
+ WFIFOW(fd,0) = 0x985;
+#else
+ WFIFOW(fd,0) = 0x43e;
+#endif
+
+ for( i = 0; i < cd->cursor; i++ ) {
+ if( cd->duration[i] < 1 ) continue;
+#if PACKETVER >= 20120604
+ WFIFOW(fd, 4 + (i*10)) = cd->nameid[i];
+ WFIFOL(fd, 6 + (i*10)) = cd->total[i];
+ WFIFOL(fd, 10 + (i*10)) = cd->duration[i];
+#else
+ WFIFOW(fd, 4 + (i*6)) = cd->nameid[i];
+ WFIFOL(fd, 6 + (i*6)) = cd->duration[i];
+#endif
+ count++;
+ }
+
+ WFIFOW(fd,2) = 4+(offset*count);
+
+ WFIFOSET(fd,4+(offset*count));
+}
+
/* */
unsigned short clif_decrypt_cmd( int cmd, struct map_session_data *sd ) {
if( sd ) {
@@ -17929,6 +17981,7 @@ void clif_defaults(void) {
clif->sc_load = clif_status_change2;
clif->sc_end = clif_status_change_end;
clif->initialstatus = clif_initialstatus;
+ clif->cooldown_list = clif_skill_cooldown_list;
/* player-unit-specific-related */
clif->updatestatus = clif_updatestatus;
clif->changestatus = clif_changestatus;
diff --git a/src/map/clif.h b/src/map/clif.h
index bea701223..a0946a48a 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -38,12 +38,13 @@ struct quest;
struct party_booking_ad_info;
struct view_data;
struct eri;
+struct skill_cd;
/**
* Defines
**/
#define packet_len(cmd) packet_db[cmd].len
-#define P2PTR(fd,cmd) RFIFO2PTR(fd,packet_db[cmd].len)
+#define P2PTR(fd) RFIFO2PTR(fd)
#define clif_menuskill_clear(sd) (sd)->menuskill_id = (sd)->menuskill_val = (sd)->menuskill_val2 = 0;
#define HCHSYS_NAME_LENGTH 20
@@ -632,6 +633,7 @@ struct clif_interface {
void (*sc_load) (struct block_list *bl, int tid, enum send_target target, int type, int val1, int val2, int val3);
void (*sc_end) (struct block_list *bl, int tid, enum send_target target, int type);
void (*initialstatus) (struct map_session_data *sd);
+ void (*cooldown_list) (int fd, struct skill_cd* cd);
/* player-unit-specific-related */
void (*updatestatus) (struct map_session_data *sd,int type);
void (*changestatus) (struct map_session_data* sd,int type,int val);
@@ -1147,7 +1149,7 @@ struct clif_interface {
void (*pPartyBookingRefuseVolunteer) (int fd, struct map_session_data *sd);
void (*pPartyBookingCancelVolunteer) (int fd, struct map_session_data *sd);
#endif
-} clif_s;
+};
struct clif_interface *clif;
diff --git a/src/map/guild.c b/src/map/guild.c
index e093fdf92..aa1d8c7a9 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <string.h>
+struct guild_interface guild_s;
static DBMap* guild_db; // int guild_id -> struct guild*
static DBMap* castle_db; // int castle_id -> struct guild_castle*
diff --git a/src/map/guild.h b/src/map/guild.h
index 9841f5451..1f61df09e 100644
--- a/src/map/guild.h
+++ b/src/map/guild.h
@@ -104,7 +104,7 @@ struct guild_interface {
void (*flags_clear) (void);
/* guild aura */
void (*aura_refresh) (struct map_session_data *sd, uint16 skill_id, uint16 skill_lv);
-} guild_s;
+};
struct guild_interface *guild;
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index efb5c0eb3..0d1b6ebcb 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -40,6 +40,8 @@
#include <string.h>
#include <math.h>
+struct homunculus_interface homunculus_s;
+
//Returns the viewdata for homunculus
struct view_data* homunculus_get_viewdata(int class_) {
if (homdb_checkid(class_))
diff --git a/src/map/homunculus.h b/src/map/homunculus.h
index 86d437e73..4b35c0992 100644
--- a/src/map/homunculus.h
+++ b/src/map/homunculus.h
@@ -133,7 +133,7 @@ struct homunculus_interface {
void (*exp_db_read) (void);
void (*addspiritball) (struct homun_data *hd, int max);
void (*delspiritball) (struct homun_data *hd, int count, int type);
-} homunculus_s;
+};
struct homunculus_interface *homun;
diff --git a/src/map/instance.c b/src/map/instance.c
index 6b80f5d75..9207c1d53 100644
--- a/src/map/instance.c
+++ b/src/map/instance.c
@@ -25,6 +25,8 @@
#include <stdarg.h>
#include <time.h>
+struct instance_interface instance_s;
+
/// Checks whether given instance id is valid or not.
bool instance_is_valid(int instance_id) {
if( instance_id < 0 || instance_id >= instance->instances ) {// out of range
diff --git a/src/map/instance.h b/src/map/instance.h
index e86586e44..164aaf662 100644
--- a/src/map/instance.h
+++ b/src/map/instance.h
@@ -62,7 +62,7 @@ struct instance_interface {
void (*check_kick) (struct map_session_data *sd);
void (*set_timeout) (int instance_id, unsigned int progress_timeout, unsigned int idle_timeout);
bool (*valid) (int instance_id);
-} instance_s;
+};
struct instance_interface *instance;
diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c
index 7f03ed8d4..0be8074c8 100644
--- a/src/map/irc-bot.c
+++ b/src/map/irc-bot.c
@@ -19,6 +19,8 @@
#include <stdlib.h>
#include <string.h>
+struct irc_bot_interface irc_bot_s;
+
char send_string[200];
int irc_connect_timer(int tid, unsigned int tick, int id, intptr_t data) {
diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h
index 911a15b0e..1fd4b58ab 100644
--- a/src/map/irc-bot.h
+++ b/src/map/irc-bot.h
@@ -52,7 +52,7 @@ struct irc_bot_interface {
void (*pong) (int fd, char *cmd, char *source, char *target, char *msg);
void (*join) (int fd, char *cmd, char *source, char *target, char *msg);
void (*privmsg) (int fd, char *cmd, char *source, char *target, char *msg);
-} irc_bot_s;
+};
struct irc_bot_interface *ircbot;
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 5fae29500..4e0477b75 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -24,6 +24,8 @@ static DBMap* itemdb_other;// int nameid -> struct item_data*
struct item_data dummy_item; //This is the default dummy item used for non-existant items. [Skotlex]
+struct itemdb_interface itemdb_s;
+
/**
* Search for item name
* name = item alias, so we should find items aliases first. if not found then look for "jname" (full name)
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 5e870a5f2..dcd0ae644 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -302,7 +302,7 @@ struct itemdb_interface {
int (*group_item) (struct item_group *group);
int (*chain_item) (unsigned short chain_id, int *rate);
void (*package_item) (struct map_session_data *sd, struct item_package *package);
-} itemdb_s;
+};
struct itemdb_interface *itemdb;
diff --git a/src/map/log.c b/src/map/log.c
index ae516b84e..79e3b87e6 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <string.h>
+struct log_interface log_s;
/// filters for item logging
typedef enum e_log_filter {
diff --git a/src/map/log.h b/src/map/log.h
index 462a12ff5..376483fe7 100644
--- a/src/map/log.h
+++ b/src/map/log.h
@@ -78,7 +78,7 @@ struct log_interface {
int (*config_read) (const char* cfgName);
void (*config_done) (void);
-} log_s;
+};
struct log_interface *logs;
diff --git a/src/map/mail.c b/src/map/mail.c
index 9a8d4e521..021a51cde 100644
--- a/src/map/mail.c
+++ b/src/map/mail.c
@@ -15,6 +15,8 @@
#include <time.h>
#include <string.h>
+struct mail_interface mail_s;
+
void mail_clear(struct map_session_data *sd)
{
sd->mail.nameid = 0;
diff --git a/src/map/mail.h b/src/map/mail.h
index 99742c7bd..b2b9048cb 100644
--- a/src/map/mail.h
+++ b/src/map/mail.h
@@ -17,7 +17,7 @@ struct mail_interface {
int (*openmail) (struct map_session_data *sd);
void (*deliveryfail) (struct map_session_data *sd, struct mail_message *msg);
bool (*invalid_operation) (struct map_session_data *sd);
-} mail_s;
+};
struct mail_interface *mail;
diff --git a/src/map/map.c b/src/map/map.c
index ee56f140f..10d413676 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -132,6 +132,8 @@ int enable_grf = 0; //To enable/disable reading maps from GRF files, bypassing m
struct eri *map_iterator_ers;
char *map_cache_buffer = NULL; // Has the uncompressed gat data of all maps, so just one allocation has to be made
+struct map_interface iMap_s;
+
/*==========================================
* server player count (of all mapservers)
*------------------------------------------*/
@@ -1647,6 +1649,7 @@ int map_quit(struct map_session_data *sd) {
if( sd->bg_id )
bg_team_leave(sd,1);
+ skill->cooldown_save(sd);
pc->itemcd_do(sd,false);
for( i = 0; i < sd->queues_count; i++ ) {
@@ -1657,7 +1660,8 @@ int map_quit(struct map_session_data *sd) {
}
/* two times, the npc event above may assign a new one or delete others */
for( i = 0; i < sd->queues_count; i++ ) {
- script->queue_remove(sd->queues[i],sd->status.account_id);
+ if( sd->queues[i] != -1 )
+ script->queue_remove(sd->queues[i],sd->status.account_id);
}
npc_script_event(sd, NPCE_LOGOUT);
diff --git a/src/map/map.h b/src/map/map.h
index 3b53b71cc..6002e56da 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -906,7 +906,7 @@ struct map_interface {
void (*clean) (int i);
void (*do_shutdown) (void);
-} iMap_s;
+};
struct map_interface *iMap;
diff --git a/src/map/npc.c b/src/map/npc.c
index 77758bc00..33d0c48f1 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1862,7 +1862,7 @@ int npc_unload(struct npc_data* nd, bool single) {
aFree(nd->u.scr.timer_event);
if (nd->src_id == 0) {
if(nd->u.scr.script) {
- script_stop_instances(nd->bl.id);
+ script_stop_instances(nd->u.scr.script);
script_free_code(nd->u.scr.script);
nd->u.scr.script = NULL;
}
@@ -2275,52 +2275,34 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
return strchr(start,'\n');// continue
}
-/**
- * NPC other label
- * Not sure, seem to add label in a chainlink
- * @see DBApply
- */
-int npc_convertlabel_db(DBKey key, DBData *data, va_list ap)
-{
- const char* lname = (const char*)key.str;
- int lpos = DB->data2i(data);
- struct npc_label_list** label_list;
- int* label_list_num;
- const char* filepath;
- struct npc_label_list* label;
- const char *p;
- int len;
-
- nullpo_ret(label_list = va_arg(ap,struct npc_label_list**));
- nullpo_ret(label_list_num = va_arg(ap,int*));
- nullpo_ret(filepath = va_arg(ap,const char*));
-
- // In case of labels not terminated with ':', for user defined function support
- p = lname;
- while( ISALNUM(*p) || *p == '_' )
- ++p;
- len = p-lname;
-
- // here we check if the label fit into the buffer
- if( len > 23 )
- {
- ShowError("npc_parse_script: label name longer than 23 chars! '%s'\n (%s)", lname, filepath);
- return 0;
- }
-
- if( *label_list == NULL )
- {
- *label_list = (struct npc_label_list *) aCalloc (1, sizeof(struct npc_label_list));
- *label_list_num = 0;
- } else
- *label_list = (struct npc_label_list *) aRealloc (*label_list, sizeof(struct npc_label_list)*(*label_list_num+1));
- label = *label_list+*label_list_num;
+void npc_convertlabel_db(struct npc_label_list* label_list, const char *filepath) {
+ int i;
+
+ for( i = 0; i < script->label_count; i++ ) {
+ const char* lname = get_str(script->labels[i].key);
+ int lpos = script->labels[i].pos;
+ struct npc_label_list* label;
+ const char *p;
+ int len;
+
+ // In case of labels not terminated with ':', for user defined function support
+ p = lname;
- safestrncpy(label->name, lname, sizeof(label->name));
- label->pos = lpos;
- ++(*label_list_num);
+ while( ISALNUM(*p) || *p == '_' )
+ ++p;
+ len = p-lname;
- return 0;
+ // here we check if the label fit into the buffer
+ if( len > 23 ) {
+ ShowError("npc_parse_script: label name longer than 23 chars! '%s'\n (%s)", lname, filepath);
+ return;
+ }
+
+ label = &label_list[i];
+
+ safestrncpy(label->name, lname, sizeof(label->name));
+ label->pos = lpos;
+ }
}
// Skip the contents of a script.
@@ -2388,7 +2370,7 @@ static const char* npc_skip_script(const char* start, const char* buffer, const
static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath, bool runOnInit) {
int x, y, dir = 0, m, xs = 0, ys = 0, class_ = 0; // [Valaris] thanks to fov
char mapname[32];
- struct script_code *script;
+ struct script_code *scriptroot;
int i;
const char* end;
const char* script_start;
@@ -2426,14 +2408,13 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
if( end == NULL )
return NULL;// (simple) parse error, don't continue
- script = parse_script(script_start, filepath, strline(buffer,script_start-buffer), SCRIPT_USE_LABEL_DB);
+ scriptroot = parse_script(script_start, filepath, strline(buffer,script_start-buffer), SCRIPT_USE_LABEL_DB);
label_list = NULL;
label_list_num = 0;
- if( script )
- {
- DBMap* label_db = script_get_label_db();
- label_db->foreach(label_db, npc_convertlabel_db, &label_list, &label_list_num, filepath);
- db_clear(label_db); // not needed anymore, so clear the db
+ if( script->label_count ) {
+ CREATE(label_list,struct npc_label_list,script->label_count);
+ label_list_num = script->label_count;
+ npc_convertlabel_db(label_list,filepath);
}
CREATE(nd, struct npc_data, 1);
@@ -2458,7 +2439,7 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
nd->bl.id = npc_get_new_npc_id();
nd->class_ = class_;
nd->speed = 200;
- nd->u.scr.script = script;
+ nd->u.scr.script = scriptroot;
nd->u.scr.label_list = label_list;
nd->u.scr.label_list_num = label_list_num;
@@ -3782,24 +3763,27 @@ int npc_reload(void) {
db_clear(npcname_db);
db_clear(ev_db);
+ npc_last_npd = NULL;
+ npc_last_path = NULL;
+ npc_last_ref = NULL;
+
//Remove all npcs/mobs. [Skotlex]
iter = mapit_geteachiddb();
for( bl = (struct block_list*)mapit->first(iter); mapit->exists(iter); bl = (struct block_list*)mapit->next(iter) ) {
switch(bl->type) {
- case BL_NPC:
- if( bl->id != fake_nd->bl.id )// don't remove fake_nd
- npc_unload((struct npc_data *)bl, false);
- break;
- case BL_MOB:
- unit_free(bl,CLR_OUTSIGHT);
- break;
+ case BL_NPC:
+ if( bl->id != fake_nd->bl.id )// don't remove fake_nd
+ npc_unload((struct npc_data *)bl, false);
+ break;
+ case BL_MOB:
+ unit_free(bl,CLR_OUTSIGHT);
+ break;
}
}
mapit->free(iter);
- if(battle_config.dynamic_mobs)
- {// dynamic check by [random]
+ if(battle_config.dynamic_mobs) {// dynamic check by [random]
for (m = 0; m < iMap->map_num; m++) {
for (i = 0; i < MAX_MOB_LIST_PER_MAP; i++) {
if (map[m].moblist[i] != NULL) {
@@ -3812,9 +3796,9 @@ int npc_reload(void) {
map[m].mob_delete_timer = INVALID_TIMER;
}
}
+ if (map[m].npc_num > 0)
+ ShowWarning("npc_reload: %d npcs weren't removed at map %s!\n", map[m].npc_num, map[m].name);
}
- if (map[m].npc_num > 0)
- ShowWarning("npc_reload: %d npcs weren't removed at map %s!\n", map[m].npc_num, map[m].name);
}
// clear mob spawn lookup index
@@ -3970,10 +3954,14 @@ int do_init_npc(void)
ev_db = strdb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA),2*NAME_LENGTH+2+1);
npcname_db = strdb_alloc(DB_OPT_BASE,NAME_LENGTH);
- npc_path_db = strdb_alloc(DB_OPT_BASE|DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA,80);
+ npc_path_db = strdb_alloc(DB_OPT_BASE|DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA,0);
timer_event_ers = ers_new(sizeof(struct timer_event_data),"clif.c::timer_event_ers",ERS_OPT_NONE);
+ npc_last_npd = NULL;
+ npc_last_path = NULL;
+ npc_last_ref = NULL;
+
// process all npc files
ShowStatus("Loading NPCs...\r");
for( file = npc_src_files; file != NULL; file = file->next ) {
@@ -3988,7 +3976,7 @@ int do_init_npc(void)
"\t-'"CL_WHITE"%d"CL_RESET"' Mobs Cached\n"
"\t-'"CL_WHITE"%d"CL_RESET"' Mobs Not Cached\n",
npc_id - START_NPC_NUM, npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob);
-
+
iMap->zone_init();
npc->motd = npc_name2id("HerculesMOTD"); /* [Ind/Hercules] */
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index d77784dc5..8e7506686 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -404,13 +404,13 @@ struct packet_maptypeproperty2 {
struct packet_bgqueue_ack {
short PacketType;
- short type;
+ unsigned char type;
char bg_name[NAME_LENGTH];
} __attribute__((packed));
struct packet_bgqueue_notice_delete {
short PacketType;
- short type;
+ unsigned char type;
char bg_name[NAME_LENGTH];
} __attribute__((packed));
@@ -438,7 +438,7 @@ struct packet_bgqueue_revoke_req {
struct packet_bgqueue_battlebegin_ack {
short PacketType;
- short result;
+ unsigned char result;
char bg_name[NAME_LENGTH];
char game_name[NAME_LENGTH];
} __attribute__((packed));
diff --git a/src/map/party.c b/src/map/party.c
index 154f84207..30740b058 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -33,6 +33,8 @@ static DBMap* party_db; // int party_id -> struct party_data* (releases data)
static DBMap* party_booking_db; // int char_id -> struct party_booking_ad_info* (releases data) // Party Booking [Spiria]
static unsigned long party_booking_nextid = 1;
+struct party_interface party_s;
+
int party_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data);
/*==========================================
diff --git a/src/map/party.h b/src/map/party.h
index f215baa56..3ce47141c 100644
--- a/src/map/party.h
+++ b/src/map/party.h
@@ -123,7 +123,7 @@ struct party_interface {
void (*booking_search) (struct map_session_data *sd, short level, short mapid, unsigned long lastindex, short resultcount);
#endif
bool (*booking_delete) (struct map_session_data *sd);
-} party_s;
+};
struct party_interface *party;
diff --git a/src/map/pc.c b/src/map/pc.c
index 3e823bb97..3ddae9222 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -89,6 +89,8 @@ struct item_cd {
short nameid[MAX_ITEMDELAYS];//skill id
};
+struct pc_interface pc_s;
+
//Converts a class to its array index for CLASS_COUNT defined arrays.
//Note that it does not do a validity check for speed purposes, where parsing
//player input make sure to use a pcdb_checkid first!
diff --git a/src/map/pc.h b/src/map/pc.h
index 442b55965..0bc1f7325 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -3,6 +3,7 @@
// 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
@@ -20,9 +21,11 @@
#include "mob.h"
#include "log.h"
#include "pc_groups.h"
+
#define MAX_PC_BONUS 10
#define MAX_PC_SKILL_REQUIRE 5
#define MAX_PC_FEELHATE 3
+
//Equip indexes constants. (eg: sd->equip_index[EQI_AMMO] returns the index
//where the arrows are equipped)
enum equip_index {
@@ -507,9 +510,6 @@ 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)
@@ -951,7 +951,7 @@ struct pc_interface {
#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;
+};
struct pc_interface *pc;
diff --git a/src/map/script.c b/src/map/script.c
index 4ceb32991..ee1143f05 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -97,10 +97,8 @@ int str_hash[SCRIPT_HASH_SIZE];
//#define SCRIPT_HASH_SDBM
#define SCRIPT_HASH_ELF
-static DBMap* scriptlabel_db=NULL; // const char* label_name -> int script_pos
static DBMap* userfunc_db=NULL; // const char* func_name -> struct script_code*
static int parse_options=0;
-DBMap* script_get_label_db(void){ return scriptlabel_db; }
DBMap* script_get_userfunc_db(void){ return userfunc_db; }
// important buildin function references for usage in scripts
@@ -178,6 +176,8 @@ int potion_hp=0, potion_per_hp=0, potion_sp=0, potion_per_sp=0;
int potion_target=0;
+struct script_interface script_s;
+
c_op get_com(unsigned char *script,int *pos);
int get_num(unsigned char *script,int *pos);
@@ -1650,7 +1650,7 @@ const char* parse_syntax(const char* p)
script->str_data[l].type = C_USERFUNC;
set_label(l, script_pos, p);
if( parse_options&SCRIPT_USE_LABEL_DB )
- strdb_iput(scriptlabel_db, get_str(l), script_pos);
+ script->label_add(l,script_pos);
}
else
disp_error_message("parse_syntax:function: function name is invalid", func_name);
@@ -2090,7 +2090,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
// who called parse_script is responsible for clearing the database after using it, but just in case... lets clear it here
if( options&SCRIPT_USE_LABEL_DB )
- db_clear(scriptlabel_db);
+ script->label_count = 0;
parse_options = options;
if( setjmp( error_jump ) != 0 ) {
@@ -2164,7 +2164,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
i=add_word(p);
set_label(i,script_pos,p);
if( parse_options&SCRIPT_USE_LABEL_DB )
- strdb_iput(scriptlabel_db, get_str(i), script_pos);
+ script->label_add(i,script_pos);
p=tmpp+1;
p=skip_space(p);
continue;
@@ -3286,7 +3286,7 @@ void run_script(struct script_code *rootscript,int pos,int rid,int oid) {
run_script_main(st);
}
-void script_stop_instances(int id) {
+void script_stop_instances(struct script_code *code) {
DBIterator *iter;
struct script_state* st;
@@ -3296,7 +3296,7 @@ void script_stop_instances(int id) {
iter = db_iterator(script->st_db);
for( st = dbi_first(iter); dbi_exists(iter); st = dbi_next(iter) ) {
- if( st->oid == id ) {
+ if( st->script == code ) {
script_free_state(st);
}
}
@@ -3308,17 +3308,19 @@ void script_stop_instances(int id) {
* Timer function for sleep
*------------------------------------------*/
int run_script_timer(int tid, unsigned int tick, int id, intptr_t data) {
- struct script_state *st = (struct script_state *)data;
- TBL_PC *sd = iMap->id2sd(st->rid);
+ struct script_state *st = idb_get(script->st_db,(int)data);
+ if( st ) {
+ TBL_PC *sd = iMap->id2sd(st->rid);
- if((sd && sd->status.char_id != id) || (st->rid && !sd)) { //Character mismatch. Cancel execution.
- st->rid = 0;
- st->state = END;
+ if((sd && sd->status.char_id != id) || (st->rid && !sd)) { //Character mismatch. Cancel execution.
+ st->rid = 0;
+ st->state = END;
+ }
+ st->sleep.timer = INVALID_TIMER;
+ if(st->state != RERUNLINE)
+ st->sleep.tick = 0;
+ run_script_main(st);
}
- st->sleep.timer = INVALID_TIMER;
- if(st->state != RERUNLINE)
- st->sleep.tick = 0;
- run_script_main(st);
return 0;
}
@@ -3514,7 +3516,7 @@ void run_script_main(struct script_state *st)
sd = iMap->id2sd(st->rid); // Get sd since script might have attached someone while running. [Inkfish]
st->sleep.charid = sd?sd->status.char_id:0;
st->sleep.timer = iTimer->add_timer(iTimer->gettick()+st->sleep.tick,
- run_script_timer, st->sleep.charid, (intptr_t)st);
+ run_script_timer, st->sleep.charid, (intptr_t)st->id);
} else if(st->state != END && st->rid){
//Resume later (st is already attached to player).
if(st->bk_st) {
@@ -3761,7 +3763,6 @@ void do_final_script(void) {
mapreg_final();
- db_destroy(scriptlabel_db);
userfunc_db->destroy(userfunc_db, db_script_free_code_sub);
autobonus_db->destroy(autobonus_db, db_script_free_code_sub);
@@ -3817,6 +3818,9 @@ void do_final_script(void) {
ers_destroy(script->stack_ers);
db_destroy(script->st_db);
+
+ if( script->labels != NULL )
+ aFree(script->labels);
}
/*==========================================
* Initialization
@@ -3824,7 +3828,6 @@ void do_final_script(void) {
void do_init_script(void) {
script->st_db = idb_alloc(DB_OPT_BASE);
userfunc_db = strdb_alloc(DB_OPT_DUP_KEY,0);
- scriptlabel_db = strdb_alloc(DB_OPT_DUP_KEY,50);
autobonus_db = strdb_alloc(DB_OPT_DUP_KEY,0);
script->st_ers = ers_new(sizeof(struct script_state), "script.c::st_ers", ERS_OPT_NONE);
@@ -3844,7 +3847,7 @@ int script_reload() {
struct script_state *st;
userfunc_db->clear(userfunc_db, db_script_free_code_sub);
- db_clear(scriptlabel_db);
+ script->label_count = 0;
for( i = 0; i < atcommand->binding_count; i++ ) {
aFree(atcommand->binding[i]);
@@ -17016,9 +17019,7 @@ struct hQueue *script_hqueue_get(int idx) {
return NULL;
return &script->hq[idx];
}
-/* set .@id,queue(); */
-/* creates queue, returns created queue id */
-BUILDIN(queue) {
+int script_hqueue_create(void) {
int idx = script->hqs;
int i;
@@ -17039,8 +17040,12 @@ BUILDIN(queue) {
script->hq[ idx ].onDeath[0] = '\0';
script->hq[ idx ].onLogOut[0] = '\0';
script->hq[ idx ].onMapChange[0] = '\0';
-
- script_pushint(st,idx);
+ return idx;
+}
+/* set .@id,queue(); */
+/* creates queue, returns created queue id */
+BUILDIN(queue) {
+ script_pushint(st,script->queue_create());
return true;
}
/* set .@length,queuesize(.@queue_id); */
@@ -17051,8 +17056,14 @@ BUILDIN(queuesize) {
if( idx < 0 || idx >= script->hqs || script->hq[idx].items == -1 ) {
ShowWarning("buildin_queuesize: unknown queue id %d\n",idx);
script_pushint(st, 0);
- } else
- script_pushint(st, script->hq[ idx ].items );
+ } else {
+ /* value of script->hq[].items isn't to be trusted for we dont reduce the size when members are removed to save on memory allocation */
+ int i, count = 0;
+ for( i = 0; i < script->hq[ idx ].items; i++ )
+ if( script->hq[ idx ].item[i] != -1 )
+ count++;
+ script_pushint(st, count);
+ }
return true;
}
@@ -17119,17 +17130,17 @@ bool script_hqueue_remove(int idx, int var) {
for(i = 0; i < script->hq[idx].items; i++) {
if( script->hq[idx].item[i] == var ) {
- return true;
+ break;
}
}
if( i != script->hq[idx].items ) {
struct map_session_data *sd;
- script->hq[idx].item[i] = 0;
+ script->hq[idx].item[i] = -1;
if( var >= START_ACCOUNT_NUM && (sd = iMap->id2sd(var)) ) {
for(i = 0; i < sd->queues_count; i++) {
- if( sd->queues[i] == var ) {
+ if( sd->queues[i] == idx ) {
break;
}
}
@@ -17231,7 +17242,33 @@ BUILDIN(queuedel) {
return true;
}
+void script_hqueue_clear(int idx) {
+ if( idx < 0 || idx >= script->hqs || script->hq[idx].items == -1 ) {
+ ShowWarning("script_hqueue_clear: unknown queue id %d\n",idx);
+ return;
+ } else {
+ struct map_session_data *sd;
+ int i, j;
+
+ for(i = 0; i < script->hq[idx].items; i++) {
+ if( script->hq[idx].item[i] != -1 ) {
+ if( script->hq[idx].item[i] >= START_ACCOUNT_NUM && (sd = iMap->id2sd(script->hq[idx].item[i])) ) {
+ for(j = 0; j < sd->queues_count; j++) {
+ if( sd->queues[j] == idx ) {
+ break;
+ }
+ }
+
+ if( j != sd->queues_count )
+ sd->queues[j] = -1;
+ }
+ script->hq[idx].item[i] = -1;
+ }
+ }
+ }
+ return;
+}
/* set .@id, queueiterator(.@queue_id); */
/* creates a new queue iterator, returns its id */
BUILDIN(queueiterator) {
@@ -17240,7 +17277,7 @@ BUILDIN(queueiterator) {
int idx = script->hqis;
int i;
- if( qid < 0 || qid >= script->hqs || script->hq[idx].items == -1 || !(queue = script->queue(qid)) ) {
+ if( qid < 0 || qid >= script->hqs || script->hq[qid].items == -1 || !(queue = script->queue(qid)) ) {
ShowWarning("queueiterator: invalid queue id %d\n",qid);
return true;
}
@@ -17258,8 +17295,8 @@ BUILDIN(queueiterator) {
idx = i;
RECREATE(script->hqi[ idx ].item, int, queue->items);
-
- memcpy(&script->hqi[idx].item, &queue->item, sizeof(int)*queue->items);
+
+ memcpy(script->hqi[idx].item, queue->item, sizeof(int)*queue->items);
script->hqi[ idx ].items = queue->items;
script->hqi[ idx ].pos = 0;
@@ -17275,7 +17312,7 @@ BUILDIN(qiget) {
if( idx < 0 || idx >= script->hqis ) {
ShowWarning("buildin_qiget: unknown queue iterator id %d\n",idx);
script_pushint(st, 0);
- } else if ( script->hqi[idx].pos == script->hqi[idx].items ) {
+ } else if ( script->hqi[idx].pos -1 == script->hqi[idx].items ) {
script_pushint(st, 0);
} else {
struct hQueueIterator *it = &script->hqi[idx];
@@ -17292,7 +17329,7 @@ BUILDIN(qicheck) {
if( idx < 0 || idx >= script->hqis ) {
ShowWarning("buildin_qicheck: unknown queue iterator id %d\n",idx);
script_pushint(st, 0);
- } else if ( script->hqi[idx].pos == script->hqi[idx].items ) {
+ } else if ( script->hqi[idx].pos -1 == script->hqi[idx].items ) {
script_pushint(st, 0);
} else {
script_pushint(st, 1);
@@ -17349,7 +17386,66 @@ BUILDIN(packageitem) {
return true;
}
+/* New Battlegrounds Stuff */
+/* bg_team_create(map_name,respawn_x,respawn_y) */
+/* returns created team id or -1 when fails */
+BUILDIN(bg_create_team) {
+ const char *map_name, *ev = "", *dev = "";//ev and dev will be dropped.
+ int x, y, mapindex = 0, bg_id;
+
+ map_name = script_getstr(st,2);
+ if( strcmp(map_name,"-") != 0 ) {
+ mapindex = mapindex_name2id(map_name);
+ if( mapindex == 0 ) { // Invalid Map
+ script_pushint(st,0);
+ return true;
+ }
+ }
+
+ x = script_getnum(st,3);
+ y = script_getnum(st,4);
+
+ if( (bg_id = bg_create(mapindex, x, y, ev, dev)) == 0 ) { // Creation failed
+ script_pushint(st,-1);
+ } else
+ script_pushint(st,bg_id);
+
+ return true;
+}
+/* bg_join_team(team_id{,optional account id}) */
+/* when account id is not present it tries to autodetect from the attached player (if any) */
+/* returns 0 when successful, 1 otherwise */
+BUILDIN(bg_join_team) {
+ struct map_session_data *sd;
+ int team_id = script_getnum(st, 2);
+
+ if( script_hasdata(st, 3) )
+ sd = iMap->id2sd(script_getnum(st, 3));
+ else
+ sd = script->rid2sd(st);
+
+ if( !sd )
+ script_pushint(st, 1);
+ else
+ script_pushint(st,bg_team_join(team_id, sd)?0:1);
+
+ return true;
+}
+/* bg_match_over( arena_name {, optional canceled } ) */
+/* returns 0 when successful, 1 otherwise */
+BUILDIN(bg_match_over) {
+ bool canceled = script_hasdata(st,3) ? true : false;
+ struct bg_arena *arena = bg->name2arena((char*)script_getstr(st, 2));
+
+ if( arena ) {
+ bg->match_over(arena,canceled);
+ script_pushint(st, 0);
+ } else
+ script_pushint(st, 1);
+
+ return true;
+}
// declarations that were supposed to be exported from npc_chat.c
#ifdef PCRE_SUPPORT
BUILDIN(defpattern);
@@ -17866,6 +17962,10 @@ void script_parse_builtin(void) {
BUILDIN_DEF(packageitem,"?"),
+ /* New BG Commands [Hercules] */
+ BUILDIN_DEF(bg_create_team,"sii"),
+ BUILDIN_DEF(bg_join_team,"i?"),
+ BUILDIN_DEF(bg_match_over,"s?"),
};
int i,n, len = ARRAYLENGTH(BUILDIN), start = script->buildin_count;
char* p;
@@ -17916,6 +18016,19 @@ void script_parse_builtin(void) {
}
}
+void script_label_add(int key, int pos) {
+ int idx = script->label_count;
+
+ if( script->labels_size == script->label_count ) {
+ script->labels_size += 1024;
+ RECREATE(script->labels, struct script_label_entry, script->labels_size);
+ }
+
+ script->labels[idx].key = key;
+ script->labels[idx].pos = pos;
+ script->label_count++;
+}
+
void script_defaults(void) {
script = &script_s;
@@ -17945,6 +18058,10 @@ void script_defaults(void) {
script->current_item_id = 0;
+ script->labels = NULL;
+ script->label_count = 0;
+ script->labels_size = 0;
+
script->init = do_init_script;
script->final = do_final_script;
@@ -17968,4 +18085,8 @@ void script_defaults(void) {
script->queue_add = script_hqueue_add;
script->queue_del = script_hqueue_del;
script->queue_remove = script_hqueue_remove;
+ script->queue_create = script_hqueue_create;
+ script->queue_clear = script_hqueue_clear;
+
+ script->label_add = script_label_add;
}
diff --git a/src/map/script.h b/src/map/script.h
index a047779a8..25a891897 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -191,14 +191,13 @@ int set_var(struct map_session_data *sd, char *name, void *val);
int run_script_timer(int tid, unsigned int tick, int id, intptr_t data);
void run_script_main(struct script_state *st);
-void script_stop_instances(int id);
+void script_stop_instances(struct script_code *code);
struct linkdb_node* script_erase_sleepdb(struct linkdb_node *n);
void script_free_code(struct script_code* code);
void script_free_vars(struct DBMap *storage);
struct script_state* script_alloc_state(struct script_code* rootscript, int pos, int rid, int oid);
void script_free_state(struct script_state* st);
-struct DBMap* script_get_label_db(void);
struct DBMap* script_get_userfunc_db(void);
void script_run_autobonus(const char *autobonus,int id, int pos);
@@ -231,6 +230,10 @@ struct str_data_struct {
int next;
};
+struct script_label_entry {
+ int key,pos;
+};
+
///////////////////////////////////////////////////////////////////////////////
//## TODO possible enhancements: [FlavioJS]
// - 'callfunc' supporting labels in the current npc "::LabelName"
@@ -359,6 +362,10 @@ struct script_interface {
int word_size;
/* */
unsigned short current_item_id;
+ /* */
+ struct script_label_entry *labels;
+ int label_count;
+ int labels_size;
/* */
void (*init) (void);
void (*final) (void);
@@ -378,12 +385,15 @@ struct script_interface {
void (*set_constant) (const char* name, int value, bool isparameter);
void (*set_constant2) (const char *name, int value, bool isparameter);
bool (*get_constant) (const char* name, int* value);
+ void (*label_add)(int key, int pos);
/* */
struct hQueue *(*queue) (int idx);
bool (*queue_add) (int idx, int var);
bool (*queue_del) (int idx);
bool (*queue_remove) (int idx, int var);
-} script_s;
+ int (*queue_create) (void);
+ void (*queue_clear) (int idx);
+};
struct script_interface *script;
diff --git a/src/map/searchstore.c b/src/map/searchstore.c
index d346a0de6..c7f4f9fed 100644
--- a/src/map/searchstore.c
+++ b/src/map/searchstore.c
@@ -39,6 +39,7 @@ enum e_searchstore_effecttype {
typedef bool (*searchstore_search_t)(struct map_session_data* sd, unsigned short nameid);
typedef bool (*searchstore_searchall_t)(struct map_session_data* sd, const struct s_search_store_search* s);
+struct searchstore_interface searchstore_s;
/// retrieves search function by type
static inline searchstore_search_t searchstore_getsearchfunc(unsigned char type) {
diff --git a/src/map/searchstore.h b/src/map/searchstore.h
index 61e65c7d2..42d47c7c0 100644
--- a/src/map/searchstore.h
+++ b/src/map/searchstore.h
@@ -52,7 +52,7 @@ struct searchstore_interface {
bool (*queryremote) (struct map_session_data* sd, int account_id);
void (*clearremote) (struct map_session_data* sd);
bool (*result) (struct map_session_data* sd, unsigned int store_id, int account_id, const char* store_name, unsigned short nameid, unsigned short amount, unsigned int price, const short* card, unsigned char refine);
-} searchstore_s;
+};
struct searchstore_interface *searchstore;
diff --git a/src/map/skill.c b/src/map/skill.c
index 1431d27a7..dc89f3170 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -46,7 +46,7 @@
#define SKILLUNITTIMER_INTERVAL 100
// ranges reserved for mapping skill ids to skilldb offsets
-#define HM_SKILLRANGEMIN 700
+#define HM_SKILLRANGEMIN 750
#define HM_SKILLRANGEMAX HM_SKILLRANGEMIN + MAX_HOMUNSKILL
#define MC_SKILLRANGEMIN HM_SKILLRANGEMAX + 1
#define MC_SKILLRANGEMAX MC_SKILLRANGEMIN + MAX_MERCSKILL
@@ -64,20 +64,6 @@ static struct eri *skill_timer_ers = NULL; //For handling skill_timerskills [Sko
DBMap* skillunit_db = NULL; // int id -> struct skill_unit*
/**
- * Skill Cool Down Delay Saving
- * Struct skill_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.
- **/
-DBMap* skillcd_db = NULL; // char_id -> struct skill_cd
-struct skill_cd {
- int duration[MAX_SKILL_TREE];//milliseconds
- short skidx[MAX_SKILL_TREE];//the skill index entries belong to
- short nameid[MAX_SKILL_TREE];//skill id
- unsigned char cursor;
-};
-
-/**
* Skill Unit Persistency during endack routes (mostly for songs see bugreport:4574)
**/
DBMap* skillusave_db = NULL; // char_id -> struct skill_usave
@@ -118,6 +104,9 @@ struct s_skill_unit_layout skill_unit_layout[MAX_SKILL_UNIT_LAYOUT];
int firewall_unit_pos;
int icewall_unit_pos;
int earthstrain_unit_pos;
+
+struct skill_interface skill_s;
+
//Since only mob-casted splash skills can hit ice-walls
static inline int splash_target(struct block_list* bl) {
#ifndef RENEWAL
@@ -851,11 +840,9 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
break;
case SM_BASH:
- if( sd && skill_lv > 5 && pc->checkskill(sd,SM_FATALBLOW)>0 ){
- //TODO: How much % per base level it actually is?
- sc_start(bl,SC_STUN,(5*(skill_lv-5)+(int)sd->status.base_level/10),
- skill_lv,skill->get_time2(SM_FATALBLOW,skill_lv));
- }
+ if( sd && skill_lv > 5 && pc->checkskill(sd,SM_FATALBLOW)>0 )
+ status_change_start(bl,SC_STUN,500*(skill_lv-5)*sd->status.base_level/50,
+ skill_lv,0,0,0,skill->get_time2(SM_FATALBLOW,skill_lv),0);
break;
case MER_CRASH:
@@ -949,8 +936,8 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
break;
case TF_THROWSTONE:
- sc_start(bl,SC_STUN,3,skill_lv,skill->get_time(skill_id,skill_lv));
- sc_start(bl,SC_BLIND,3,skill_lv,skill->get_time2(skill_id,skill_lv));
+ if( !sc_start(bl,SC_STUN,3,skill_lv,skill->get_time(skill_id,skill_lv)) )
+ sc_start(bl,SC_BLIND,3,skill_lv,skill->get_time2(skill_id,skill_lv));
break;
case NPC_DARKCROSS:
@@ -1182,7 +1169,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
sc_start4(bl,SC_BURNING,5+5*skill_lv,skill_lv,0,src->id,0,skill->get_time(skill_id,skill_lv));
break;
case RK_DRAGONBREATH_WATER:
- sc_start4(bl,SC_FROSTMISTY,5+5*skill_lv,skill_lv,0,src->id,0,skill->get_time(skill_id,skill_lv));
+ sc_start(bl,SC_FROSTMISTY,5+5*skill_lv,skill_lv,skill->get_time(skill_id,skill_lv));
break;
case AB_ADORAMUS:
if( tsc && !tsc->data[SC_DEC_AGI] ) //Prevent duplicate agi-down effect.
@@ -1344,7 +1331,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
rate = 5 + 5 * skill_lv;
if( sc && sc->data[SC_COOLER_OPTION] )
rate += rate * sc->data[SC_COOLER_OPTION]->val2 / 100;
- sc_start(bl, SC_CRYSTALIZE, rate, skill_lv, skill->get_time2(skill_id, skill_lv));
+ sc_start(bl, SC_COLD, rate, skill_lv, skill->get_time2(skill_id, skill_lv));
break;
case SO_VARETYR_SPEAR:
sc_start(bl, SC_STUN, 5 + 5 * skill_lv, skill_lv, skill->get_time2(skill_id, skill_lv));
@@ -7676,9 +7663,24 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case NPC_WIDESTUN:
case NPC_SLOWCAST:
case NPC_WIDEHELLDIGNITY:
- if (flag&1)
- sc_start2(bl,type,100,skill_lv,src->id,skill->get_time2(skill_id,skill_lv));
- else {
+ case NPC_WIDEHEALTHFEAR:
+ case NPC_WIDEBODYBURNNING:
+ case NPC_WIDEFROSTMISTY:
+ case NPC_WIDECOLD:
+ case NPC_WIDE_DEEP_SLEEP:
+ case NPC_WIDESIREN:
+ if (flag&1){
+ switch( type ){
+ case SC_BURNING:
+ sc_start4(bl,type,100,skill_lv,0,src->id,0,skill->get_time2(skill_id,skill_lv));
+ break;
+ case SC_SIREN:
+ sc_start2(bl,type,100,skill_lv,src->id,skill->get_time2(skill_id,skill_lv));
+ break;
+ default:
+ sc_start2(bl,type,100,skill_lv,src->id,skill->get_time2(skill_id,skill_lv));
+ }
+ }else {
skill_area_temp[2] = 0; //For SD_PREAMBLE
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
iMap->foreachinrange(skill->area_sub, bl,
@@ -7939,7 +7941,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case AB_LAUDAAGNUS:
if( flag&1 || sd == NULL ) {
if( tsc && (tsc->data[SC_FREEZE] || tsc->data[SC_STONE] || tsc->data[SC_BLIND] ||
- tsc->data[SC_BURNING] || tsc->data[SC_FROSTMISTY] || tsc->data[SC_CRYSTALIZE])) {
+ tsc->data[SC_BURNING] || tsc->data[SC_FROSTMISTY] || tsc->data[SC_COLD])) {
// Success Chance: (40 + 10 * Skill Level) %
if( rnd()%100 > 40+10*skill_lv ) break;
status_change_end(bl, SC_FREEZE, INVALID_TIMER);
@@ -7947,7 +7949,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
status_change_end(bl, SC_BLIND, INVALID_TIMER);
status_change_end(bl, SC_BURNING, INVALID_TIMER);
status_change_end(bl, SC_FROSTMISTY, INVALID_TIMER);
- status_change_end(bl, SC_CRYSTALIZE, INVALID_TIMER);
+ status_change_end(bl, SC_COLD, INVALID_TIMER);
}else //Success rate only applies to the curing effect and not stat bonus. Bonus status only applies to non infected targets
clif->skill_nodamage(bl, bl, skill_id, skill_lv,
sc_start(bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv)));
@@ -8037,9 +8039,6 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
else if(bl->type == BL_PC) rate += 20 + 10 * skill_lv; // On Players, (20 + 10 * Skill Level) %
else rate += 40 + 10 * skill_lv; // On Monsters, (40 + 10 * Skill Level) %
- if( sd )
- skill->blockpc_start(sd,skill_id,4000, false);
-
if( !(tsc && tsc->data[type]) ){
i = sc_start2(bl,type,rate,skill_lv,src->id,(src == bl)?5000:(bl->type == BL_PC)?skill->get_time(skill_id,skill_lv):skill->get_time2(skill_id, skill_lv));
clif->skill_nodamage(src,bl,skill_id,skill_lv,i);
@@ -8451,7 +8450,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case SC_BLOODING: case SC_CURSE:
case SC_CONFUSION: case SC_ILLUSION:
case SC_SILENCE: case SC_BURNING:
- case SC_CRYSTALIZE: case SC_FROSTMISTY:
+ case SC_COLD: case SC_FROSTMISTY:
case SC_DEEP_SLEEP: case SC_FEAR:
case SC_MANDRAGORA:
status_change_end(bl, (sc_type)i, INVALID_TIMER);
@@ -8556,7 +8555,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
status_change_end(bl, SC_POISON, INVALID_TIMER);
status_change_end(bl, SC_SILENCE, INVALID_TIMER);
status_change_end(bl, SC_BLIND, INVALID_TIMER);
- status_change_end(bl, SC_ILLUSION, INVALID_TIMER);
+ status_change_end(bl, SC_ILLUSION, INVALID_TIMER);
status_change_end(bl, SC_BURNING, INVALID_TIMER);
status_change_end(bl, SC_FROSTMISTY, INVALID_TIMER);
}
@@ -11801,7 +11800,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
if( battle->check_target(&src->bl,bl,BCT_ENEMY) > 0 ){
switch( sg->unit_id ){
case UNT_ZENKAI_WATER:
- sc_start(bl, SC_CRYSTALIZE, sg->val1*5, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
+ sc_start(bl, SC_COLD, sg->val1*5, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
sc_start(bl, SC_FREEZE, sg->val1*5, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
sc_start(bl, SC_FROSTMISTY, sg->val1*5, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
break;
@@ -16875,16 +16874,24 @@ int skill_blockpc_end(int tid, unsigned int tick, int id, intptr_t data) {
int i,cursor;
ARR_FIND( 0, cd->cursor+1, cursor, cd->skidx[cursor] == data );
cd->duration[cursor] = 0;
+#if PACKETVER >= 20120604
+ cd->total[cursor] = 0;
+#endif
cd->skidx[cursor] = 0;
cd->nameid[cursor] = 0;
+ cd->started[cursor] = 0;
// compact the cool down list
for( i = 0, cursor = 0; i < cd->cursor; i++ ) {
if( cd->duration[i] == 0 )
continue;
if( cursor != i ) {
cd->duration[cursor] = cd->duration[i];
+#if PACKETVER >= 20120604
+ cd->total[cursor] = cd->total[i];
+#endif
cd->skidx[cursor] = cd->skidx[i];
cd->nameid[cursor] = cd->nameid[i];
+ cd->started[cursor] = cd->started[i];
}
cursor++;
}
@@ -16920,7 +16927,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick,
return -1;
}
- if( battle_config.display_status_timers )
+ if( !load && battle_config.display_status_timers )
clif->skill_cooldown(sd, skill_id, tick);
if( !load ) {// not being loaded initially so ensure the skill delay is recorded
@@ -16931,8 +16938,12 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick,
// record the skill duration in the database map
cd->duration[cd->cursor] = tick;
+#if PACKETVER >= 20120604
+ cd->total[cd->cursor] = tick;
+#endif
cd->skidx[cd->cursor] = idx;
cd->nameid[cd->cursor] = skill_id;
+ cd->started[cd->cursor] = iTimer->gettick();
cd->cursor++;
}
@@ -17425,13 +17436,37 @@ int skill_get_elemental_type( uint16 skill_id , uint16 skill_lv ) {
}
/**
+ * update stored skill cooldowns for player logout
+ * @param sd the affected player structure
+ */
+void skill_cooldown_save(struct map_session_data * sd) {
+ int i;
+ struct skill_cd* cd = NULL;
+ unsigned int now = 0;
+
+ // always check to make sure the session properly exists
+ nullpo_retv(sd);
+
+ if( !(cd = idb_get(skillcd_db, sd->status.char_id)) ) {// no skill cooldown is associated with this character
+ return;
+ }
+
+ now = iTimer->gettick();
+
+ // process each individual cooldown associated with the character
+ for( i = 0; i < cd->cursor; i++ ) {
+ cd->duration[i] = DIFF_TICK(cd->started[i]+cd->duration[i],now);
+ }
+}
+
+/**
* reload stored skill cooldowns when a player logs in.
* @param sd the affected player structure
*/
-void skill_cooldown_load(struct map_session_data * sd)
-{
+void skill_cooldown_load(struct map_session_data * sd) {
int i;
struct skill_cd* cd = NULL;
+ unsigned int now = 0;
// always check to make sure the session properly exists
nullpo_retv(sd);
@@ -17440,8 +17475,13 @@ void skill_cooldown_load(struct map_session_data * sd)
return;
}
+ clif->cooldown_list(sd->fd,cd);
+
+ now = iTimer->gettick();
+
// process each individual cooldown associated with the character
for( i = 0; i < cd->cursor; i++ ) {
+ cd->started[i] = now;
// block the skill from usage but ensure it is not recorded (load = true)
skill->blockpc_start( sd, cd->nameid[i], cd->duration[i], true );
}
@@ -18132,5 +18172,6 @@ void skill_defaults(void) {
skill->elementalanalysis = skill_elementalanalysis;
skill->changematerial = skill_changematerial;
skill->get_elemental_type = skill_get_elemental_type;
+ skill->cooldown_save = skill_cooldown_save;
}
diff --git a/src/map/skill.h b/src/map/skill.h
index 921a682a2..fceef5556 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -1714,11 +1714,29 @@ struct s_skill_magicmushroom_db {
extern struct s_skill_magicmushroom_db skill_magicmushroom_db[MAX_SKILL_MAGICMUSHROOM_DB];
/**
+ * Skill Cool Down Delay Saving
+ * Struct skill_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 skill_cd {
+ int duration[MAX_SKILL_TREE];//milliseconds
+#if PACKETVER >= 20120604
+ int total[MAX_SKILL_TREE];
+#endif
+ short skidx[MAX_SKILL_TREE];//the skill index entries belong to
+ short nameid[MAX_SKILL_TREE];//skill id
+ unsigned int started[MAX_SKILL_TREE];
+ unsigned char cursor;
+};
+
+/**
* Vars
**/
extern int enchant_eff[5];
extern int deluge_eff[5];
DBMap* skilldb_name2id;
+DBMap* skillcd_db; // char_id -> struct skill_cd
/**
* Skill.c Interface
@@ -1917,7 +1935,8 @@ struct skill_interface {
int (*elementalanalysis) (struct map_session_data *sd, int n, uint16 skill_lv, unsigned short *item_list);
int (*changematerial) (struct map_session_data *sd, int n, unsigned short *item_list);
int (*get_elemental_type) (uint16 skill_id, uint16 skill_lv);
-} skill_s;
+ void (*cooldown_save) (struct map_session_data * sd);
+};
struct skill_interface *skill;
diff --git a/src/map/status.c b/src/map/status.c
index dc5d5c5bd..64c591b3b 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -214,7 +214,12 @@ void initChangeTables(void) {
add_sc( TF_POISON , SC_POISON );
set_sc( KN_TWOHANDQUICKEN , SC_TWOHANDQUICKEN , SI_TWOHANDQUICKEN , SCB_ASPD );
add_sc( KN_AUTOCOUNTER , SC_AUTOCOUNTER );
- set_sc( PR_IMPOSITIO , SC_IMPOSITIO , SI_IMPOSITIO , SCB_WATK );
+ set_sc( PR_IMPOSITIO , SC_IMPOSITIO , SI_IMPOSITIO ,
+#ifdef RENEWAL
+ SCB_NONE );
+#else
+ SCB_WATK );
+#endif
set_sc( PR_SUFFRAGIUM , SC_SUFFRAGIUM , SI_SUFFRAGIUM , SCB_NONE );
set_sc( PR_ASPERSIO , SC_ASPERSIO , SI_ASPERSIO , SCB_ATK_ELE );
set_sc( PR_BENEDICTIO , SC_BENEDICTIO , SI_BENEDICTIO , SCB_DEF_ELE );
@@ -427,10 +432,20 @@ void initChangeTables(void) {
add_sc( GS_CRACKER , SC_STUN );
add_sc( GS_DISARM , SC_NOEQUIPWEAPON );
add_sc( GS_PIERCINGSHOT , SC_BLOODING );
- set_sc( GS_MADNESSCANCEL , SC_GS_MADNESSCANCEL , SI_GS_MADNESSCANCEL , SCB_BATK|SCB_ASPD );
+ set_sc( GS_MADNESSCANCEL , SC_GS_MADNESSCANCEL , SI_GS_MADNESSCANCEL , SCB_ASPD
+#ifndef RENEWAL
+ |SCB_BATK );
+#else
+ );
+#endif
set_sc( GS_ADJUSTMENT , SC_GS_ADJUSTMENT , SI_GS_ADJUSTMENT , SCB_HIT|SCB_FLEE );
set_sc( GS_INCREASING , SC_GS_ACCURACY , SI_GS_ACCURACY , SCB_AGI|SCB_DEX|SCB_HIT );
- set_sc( GS_GATLINGFEVER , SC_GS_GATLINGFEVER , SI_GS_GATLINGFEVER , SCB_BATK|SCB_FLEE|SCB_SPEED|SCB_ASPD );
+ set_sc( GS_GATLINGFEVER , SC_GS_GATLINGFEVER , SI_GS_GATLINGFEVER , SCB_FLEE|SCB_SPEED|SCB_ASPD
+#ifndef RENEWAL
+ |SCB_BATK );
+#else
+ );
+#endif
set_sc( NJ_TATAMIGAESHI , SC_NJ_TATAMIGAESHI , SI_BLANK , SCB_NONE );
set_sc( NJ_SUITON , SC_NJ_SUITON , SI_NJ_SUITON , SCB_AGI|SCB_SPEED );
add_sc( NJ_HYOUSYOURAKU , SC_FREEZE );
@@ -691,7 +706,7 @@ void initChangeTables(void) {
set_sc( SO_FIREWALK , SC_PROPERTYWALK , SI_PROPERTYWALK , SCB_NONE );
set_sc( SO_ELECTRICWALK , SC_PROPERTYWALK , SI_PROPERTYWALK , SCB_NONE );
set_sc( SO_SPELLFIST , SC_SPELLFIST , SI_SPELLFIST , SCB_NONE );
- set_sc_with_vfx( SO_DIAMONDDUST , SC_CRYSTALIZE , SI_COLD , SCB_NONE ); // it does show the snow icon on mobs but doesn't affect it.
+ set_sc_with_vfx( SO_DIAMONDDUST , SC_COLD , SI_COLD , SCB_NONE ); // it does show the snow icon on mobs but doesn't affect it.
add_sc( SO_CLOUD_KILL , SC_POISON );
set_sc( SO_STRIKING , SC_STRIKING , SI_STRIKING , SCB_WATK|SCB_CRI );
set_sc( SO_WARMER , SC_WARMER , SI_WARMER , SCB_NONE );
@@ -759,6 +774,13 @@ void initChangeTables(void) {
add_sc( ALL_REVERSEORCISH , SC_ORCISH );
set_sc( ALL_ANGEL_PROTECT , SC_ANGEL_PROTECT , SI_ANGEL_PROTECT , SCB_REGEN );
+
+ add_sc( NPC_WIDEHEALTHFEAR , SC_FEAR );
+ add_sc( NPC_WIDEBODYBURNNING , SC_BURNING );
+ add_sc( NPC_WIDEFROSTMISTY , SC_FROSTMISTY );
+ add_sc( NPC_WIDECOLD , SC_COLD );
+ add_sc( NPC_WIDE_DEEP_SLEEP , SC_DEEP_SLEEP );
+ add_sc( NPC_WIDESIREN , SC_SIREN );
// Storing the target job rather than simply SC_SOULLINK simplifies code later on.
SkillStatusChangeTable[SL_ALCHEMIST] = (sc_type)MAPID_ALCHEMIST,
@@ -1019,7 +1041,7 @@ void initChangeTables(void) {
StatusDisplayType[SC_HALLUCINATIONWALK] = true;
StatusDisplayType[SC_ROLLINGCUTTER] = true;
StatusDisplayType[SC_BANDING] = true;
- StatusDisplayType[SC_CRYSTALIZE] = true;
+ StatusDisplayType[SC_COLD] = true;
StatusDisplayType[SC_DEEP_SLEEP] = true;
StatusDisplayType[SC_CURSEDCIRCLE_ATKER]= true;
StatusDisplayType[SC_CURSEDCIRCLE_TARGET]= true;
@@ -1533,7 +1555,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
//on dead characters, said checks are left to skill.c [Skotlex]
if (target && status_isdead(target))
return 0;
- if( src && (sc = status_get_sc(src)) && sc->data[SC_CRYSTALIZE] && src->type != BL_MOB)
+ if( src && (sc = status_get_sc(src)) && sc->data[SC_COLD] && src->type != BL_MOB)
return 0;
}
@@ -1653,7 +1675,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
sc->data[SC_OBLIVIONCURSE] ||
sc->data[SC_WHITEIMPRISON] ||
sc->data[SC__INVISIBILITY] ||
- (sc->data[SC_CRYSTALIZE] && src->type != BL_MOB) ||
+ (sc->data[SC_COLD] && src->type != BL_MOB) ||
sc->data[SC__IGNORANCE] ||
sc->data[SC_DEEP_SLEEP] ||
sc->data[SC_SATURDAY_NIGHT_FEVER] ||
@@ -3026,7 +3048,11 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
sd->subele[ELE_FIRE] += skill*10;
}
if((skill=pc->checkskill(sd,SA_DRAGONOLOGY))>0 ){
+#ifdef RENEWAL
+ skill = skill*2;
+#else
skill = skill*4;
+#endif
sd->right_weapon.addrace[RC_DRAGON]+=skill;
sd->left_weapon.addrace[RC_DRAGON]+=skill;
sd->magic_addrace[RC_DRAGON]+=skill;
@@ -4419,13 +4445,13 @@ static unsigned short status_calc_batk(struct block_list *bl, struct status_chan
#ifndef RENEWAL
if(sc->data[SC_PLUSATTACKPOWER])
batk += sc->data[SC_PLUSATTACKPOWER]->val1;
+ if(sc->data[SC_GS_MADNESSCANCEL])
+ batk += 100;
+ if(sc->data[SC_GS_GATLINGFEVER])
+ batk += sc->data[SC_GS_GATLINGFEVER]->val3;
#endif
if(sc->data[SC_BATKFOOD])
batk += sc->data[SC_BATKFOOD]->val1;
- if(sc->data[SC_GS_GATLINGFEVER])
- batk += sc->data[SC_GS_GATLINGFEVER]->val3;
- if(sc->data[SC_GS_MADNESSCANCEL])
- batk += 100;
if(sc->data[SC_FIRE_INSIGNIA] && sc->data[SC_FIRE_INSIGNIA]->val1 == 2)
batk += 50;
if(bl->type == BL_ELEM
@@ -4498,13 +4524,14 @@ static unsigned short status_calc_watk(struct block_list *bl, struct status_chan
watk += sc->data[SC_GENTLETOUCH_CHANGE]->val2;
return (unsigned short)cap_value(watk,0,USHRT_MAX);
}
-
+#ifndef RENEWAL
if(sc->data[SC_IMPOSITIO])
watk += sc->data[SC_IMPOSITIO]->val2;
- if(sc->data[SC_WATKFOOD])
- watk += sc->data[SC_WATKFOOD]->val1;
if(sc->data[SC_DRUMBATTLE])
watk += sc->data[SC_DRUMBATTLE]->val2;
+#endif
+ if(sc->data[SC_WATKFOOD])
+ watk += sc->data[SC_WATKFOOD]->val1;
if(sc->data[SC_VOLCANO])
watk += sc->data[SC_VOLCANO]->val2;
if(sc->data[SC_MER_ATK])
@@ -4525,19 +4552,18 @@ static unsigned short status_calc_watk(struct block_list *bl, struct status_chan
watk -= sc->data[SC_WATER_BARRIER]->val3;
if( sc->data[SC_PYROTECHNIC_OPTION] )
watk += sc->data[SC_PYROTECHNIC_OPTION]->val2;
+
+#ifndef RENEWAL
if(sc->data[SC_NIBELUNGEN]) {
if (bl->type != BL_PC)
watk += sc->data[SC_NIBELUNGEN]->val2;
else {
- #ifndef RENEWAL
TBL_PC *sd = (TBL_PC*)bl;
int index = sd->equip_index[sd->state.lr_flag?EQI_HAND_L:EQI_HAND_R];
if(index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->wlv == 4)
- #endif
watk += sc->data[SC_NIBELUNGEN]->val2;
}
}
-#ifndef RENEWAL
if(sc->data[SC_STRIKING])
watk += sc->data[SC_STRIKING]->val2;
if(sc->data[SC_GENTLETOUCH_CHANGE] && sc->data[SC_GENTLETOUCH_CHANGE]->val2)
@@ -6309,7 +6335,7 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti
break;
case SC_FROSTMISTY:
tick -= 1000 * ((status->vit + status->dex) / 20);
- tick = max(tick,6000); // Minimum Duration 10s.
+ tick = max(tick,6000); // Minimum Duration 6s.
break;
case SC_OBLIVIONCURSE: // 100% - (100 - 0.8 x INT)
sc_def = 100 - ( 100 - status->int_* 8 / 10 );
@@ -6323,9 +6349,13 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti
if( bl->type == BL_MOB )
tick -= 1000 * (status->agi/10);
break;
- case SC_CRYSTALIZE:
+ case SC_COLD:
tick -= (1000*(status->vit/10))+(status_get_lv(bl)/50);
break;
+ case SC_SIREN:
+ tick -= 1000 * ((status_get_lv(bl) / 10) + ((sd?sd->status.job_level:0) / 5));
+ tick = max(tick,10000);
+ break;
case SC_MANDRAGORA:
sc_def = (status->vit+status->luk)/5;
break;
@@ -6545,7 +6575,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_PYREXIA:
case SC_OBLIVIONCURSE:
case SC_LEECHESEND:
- case SC_CRYSTALIZE: ////08/31/2011 - Class Balance Changes
+ case SC_COLD: ////08/31/2011 - Class Balance Changes
case SC_DEEP_SLEEP:
case SC_MANDRAGORA:
return 0;
@@ -6612,10 +6642,10 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_SLEEP:
case SC_STUN:
case SC_FROSTMISTY:
- case SC_CRYSTALIZE:
+ case SC_COLD:
if (sc->opt1)
return 0; //Cannot override other opt1 status changes. [Skotlex]
- if((type == SC_FREEZE || type == SC_FROSTMISTY || type == SC_CRYSTALIZE) && sc->data[SC_WARMER])
+ if((type == SC_FREEZE || type == SC_FROSTMISTY || type == SC_COLD) && sc->data[SC_WARMER])
return 0; //Immune to Frozen and Freezing status if under Warmer status. [Jobbie]
break;
@@ -6903,7 +6933,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_ADORAMUS:
case SC_NEEDLE_OF_PARALYZE:
case SC_DEEP_SLEEP:
- case SC_CRYSTALIZE:
+ case SC_COLD:
// Exploit prevention - kRO Fix
case SC_PYREXIA:
@@ -7937,8 +7967,10 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
// gs_something1 [Vicious]
case SC_GS_GATLINGFEVER:
val2 = 20*val1; //Aspd increase
- val3 = 20+10*val1; //Batk increase
val4 = 5*val1; //Flee decrease
+#ifndef RENEWAL
+ val3 = 20+10*val1; //Batk increase
+#endif
break;
case SC_FLING:
@@ -8244,7 +8276,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
}
break;
case SC_ELECTRICSHOCKER:
- case SC_CRYSTALIZE:
+ case SC_COLD:
case SC_MEIKYOUSISUI:
val4 = tick / 1000;
if( val4 < 1 )
@@ -8331,7 +8363,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_WARMER:
status_change_end(bl, SC_FREEZE, INVALID_TIMER);
status_change_end(bl, SC_FROSTMISTY, INVALID_TIMER);
- status_change_end(bl, SC_CRYSTALIZE, INVALID_TIMER);
+ status_change_end(bl, SC_COLD, INVALID_TIMER);
break;
case SC_STRIKING:
val1 = 6 - val1;//spcost = 6 - level (lvl1:5 ... lvl 5: 1)
@@ -8805,7 +8837,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_WUGBITE:
case SC_THORNS_TRAP:
case SC__MANHOLE:
- case SC_CRYSTALIZE:
+ case SC_COLD:
case SC_CURSEDCIRCLE_ATKER:
case SC_CURSEDCIRCLE_TARGET:
case SC_FEAR:
@@ -8867,7 +8899,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_SLEEP: sc->opt1 = OPT1_SLEEP; break;
case SC_BURNING: sc->opt1 = OPT1_BURNING; break; // Burning need this to be showed correctly. [pakpil]
case SC_WHITEIMPRISON: sc->opt1 = OPT1_IMPRISON; break;
- case SC_CRYSTALIZE: sc->opt1 = OPT1_CRYSTALIZE; break;
+ case SC_COLD: sc->opt1 = OPT1_CRYSTALIZE; break;
//OPT2
case SC_POISON: sc->opt2 |= OPT2_POISON; break;
case SC_CURSE: sc->opt2 |= OPT2_CURSE; break;
@@ -9728,7 +9760,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
case SC_DEEP_SLEEP:
case SC_BURNING:
case SC_WHITEIMPRISON:
- case SC_CRYSTALIZE:
+ case SC_COLD:
sc->opt1 = 0;
break;
@@ -10613,7 +10645,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
}
break;
- case SC_CRYSTALIZE:
+ case SC_COLD:
if( --(sce->val4) > 0 )
{ // Drains 2% of HP and 1% of SP every seconds.
if( bl->type != BL_MOB) // doesn't work on mobs
@@ -11032,7 +11064,7 @@ int status_change_clear_buffs (struct block_list* bl, int type)
switch (i) {
case SC_DEEP_SLEEP:
case SC_FROSTMISTY:
- case SC_CRYSTALIZE:
+ case SC_COLD:
case SC_TOXIN:
case SC_PARALYSE:
case SC_VENOMBLEED:
diff --git a/src/map/status.h b/src/map/status.h
index a469dc71f..380b49879 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -462,7 +462,7 @@ typedef enum sc_type {
* Sorcerer
**/
SC_SPELLFIST,
- SC_CRYSTALIZE,
+ SC_COLD,
SC_STRIKING,
SC_WARMER,
SC_VACUUM_EXTREME,
diff --git a/src/map/storage.c b/src/map/storage.c
index 5b3c75d58..7a4649a98 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -24,6 +24,9 @@
#include <stdlib.h>
#include <string.h>
+struct storage_interface storage_s;
+struct guild_storage_interface gstorage_s;
+
/*==========================================
* Sort items in the warehouse
*------------------------------------------*/
diff --git a/src/map/storage.h b/src/map/storage.h
index fc05ef06c..83243a622 100644
--- a/src/map/storage.h
+++ b/src/map/storage.h
@@ -26,7 +26,7 @@ struct storage_interface {
int (*gettocart) (struct map_session_data *sd,int index,int amount);
void (*close) (struct map_session_data *sd);
void (*pc_quit) (struct map_session_data *sd, int flag);
-} storage_s;
+};
struct storage_interface *storage;
struct guild_storage_interface {
@@ -46,7 +46,7 @@ struct guild_storage_interface {
int (*pc_quit) (struct map_session_data *sd,int flag);
int (*save) (int account_id, int guild_id, int flag);
int (*saved) (int guild_id); //Ack from char server that guild store was saved.
-} gstorage_s;
+};
struct guild_storage_interface *gstorage;
diff --git a/src/map/trade.c b/src/map/trade.c
index c44f04884..13b5f5431 100644
--- a/src/map/trade.c
+++ b/src/map/trade.c
@@ -24,6 +24,8 @@
//Max distance from traders to enable a trade to take place.
#define TRADE_DISTANCE 2
+struct trade_interface trade_s;
+
/*==========================================
* Initiates a trade request.
*------------------------------------------*/
diff --git a/src/map/trade.h b/src/map/trade.h
index 8bf918ad2..e8ac4a8c4 100644
--- a/src/map/trade.h
+++ b/src/map/trade.h
@@ -17,7 +17,7 @@ struct trade_interface {
void (*ok) (struct map_session_data *sd);
void (*cancel) (struct map_session_data *sd);
void (*commit) (struct map_session_data *sd);
-} trade_s;
+};
struct trade_interface *trade;
diff --git a/src/map/unit.c b/src/map/unit.c
index 5e836dc2e..e5affb0c2 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -945,7 +945,7 @@ int unit_can_move(struct block_list *bl) {
|| sc->data[SC__MANHOLE]
|| sc->data[SC_CURSEDCIRCLE_ATKER]
|| sc->data[SC_CURSEDCIRCLE_TARGET]
- || (sc->data[SC_CRYSTALIZE] && bl->type != BL_MOB)
+ || (sc->data[SC_COLD] && bl->type != BL_MOB)
|| sc->data[SC_NETHERWORLD]
|| (sc->data[SC_CAMOUFLAGE] && sc->data[SC_CAMOUFLAGE]->val1 < 3 && !(sc->data[SC_CAMOUFLAGE]->val3&1))
|| sc->data[SC_MEIKYOUSISUI]
diff --git a/src/map/vending.c b/src/map/vending.c
index 898008a3a..2784d46a2 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -21,6 +21,8 @@
#include <stdio.h>
#include <string.h>
+struct vending_interface vending_s;
+
/// Returns an unique vending shop id.
static inline unsigned int getid(void) {
return vending->next_id++;
diff --git a/src/map/vending.h b/src/map/vending.h
index 0148deb71..1b4381ccd 100644
--- a/src/map/vending.h
+++ b/src/map/vending.h
@@ -29,7 +29,7 @@ struct vending_interface {
void (*purchase) (struct map_session_data* sd, int aid, unsigned int uid, const uint8* data, int count);
bool (*search) (struct map_session_data* sd, unsigned short nameid);
bool (*searchall) (struct map_session_data* sd, const struct s_search_store_search* s);
-} vending_s;
+};
struct vending_interface * vending;