diff options
author | zephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-09-01 12:53:43 +0000 |
---|---|---|
committer | zephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-09-01 12:53:43 +0000 |
commit | 98a86ba4488440b4f26594ad1921a03df46a6889 (patch) | |
tree | 9321ea27fa440b3986475c27e84267e1e4fa384b /src | |
parent | f23871e476379621ce21fd95486391155e9aa628 (diff) | |
download | hercules-98a86ba4488440b4f26594ad1921a03df46a6889.tar.gz hercules-98a86ba4488440b4f26594ad1921a03df46a6889.tar.bz2 hercules-98a86ba4488440b4f26594ad1921a03df46a6889.tar.xz hercules-98a86ba4488440b4f26594ad1921a03df46a6889.zip |
- Mercenary Loyalty Updates.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13176 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r-- | src/map/mercenary.c | 55 | ||||
-rw-r--r-- | src/map/mercenary.h | 1 | ||||
-rw-r--r-- | src/map/mob.c | 15 |
3 files changed, 54 insertions, 17 deletions
diff --git a/src/map/mercenary.c b/src/map/mercenary.c index bcc5cda9b..b06cf89bb 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -117,7 +117,7 @@ int mercenary_get_faith(struct mercenary_data *md) int mercenary_set_faith(struct mercenary_data *md, int value) { struct map_session_data *sd; - int class_; + int class_, *faith; if( md == NULL || md->db == NULL || (sd = md->master) == NULL ) return 0; @@ -125,11 +125,15 @@ int mercenary_set_faith(struct mercenary_data *md, int value) class_ = md->db->class_; if( class_ >= 6017 && class_ <= 6026 ) - sd->status.arch_faith += value; + faith = &sd->status.arch_faith; else if( class_ >= 6027 && class_ <= 6036 ) - sd->status.spear_faith += value; + faith = &sd->status.spear_faith; else if( class_ >= 6037 && class_ <= 6046 ) - sd->status.sword_faith += value; + faith = &sd->status.sword_faith; + + *faith += value; + *faith = cap_value(*faith, 0, SHRT_MAX); + clif_mercenary_updatestatus(sd, SP_MERCFAITH); return 0; } @@ -157,7 +161,7 @@ int mercenary_get_calls(struct mercenary_data *md) int mercenary_set_calls(struct mercenary_data *md, int value) { struct map_session_data *sd; - int class_; + int class_, *calls; if( md == NULL || md->db == NULL || (sd = md->master) == NULL ) return 0; @@ -165,11 +169,14 @@ int mercenary_set_calls(struct mercenary_data *md, int value) class_ = md->db->class_; if( class_ >= 6017 && class_ <= 6026 ) - sd->status.arch_calls += value; + calls = &sd->status.arch_calls; else if( class_ >= 6027 && class_ <= 6036 ) - sd->status.spear_calls += value; + calls = &sd->status.spear_calls; else if( class_ >= 6037 && class_ <= 6046 ) - sd->status.sword_calls += value; + calls = &sd->status.sword_calls; + + *calls += value; + *calls = cap_value(*calls, 0, INT_MAX); return 0; } @@ -215,8 +222,14 @@ int merc_delete(struct mercenary_data *md, int reply) if( !sd ) return unit_free(&md->bl, 0); + + switch( reply ) + { + case 0: mercenary_set_faith(md, 1); break; // +1 Loyalty on Contract ends. + case 1: mercenary_set_faith(md, -1); break; // -1 Loyalty on Mercenary killed + } + clif_mercenary_message(sd->fd, reply); - return unit_remove_map(&md->bl, 0); } @@ -251,9 +264,7 @@ int merc_data_received(struct s_mercenary *merc, bool flag) return 0; } - sd->status.mer_id = merc->mercenary_id; db = &mercenary_db[i]; - if( !sd->md ) { sd->md = md = (struct mercenary_data*)aCalloc(1,sizeof(struct mercenary_data)); @@ -281,9 +292,15 @@ int merc_data_received(struct s_mercenary *merc, bool flag) merc_contract_init(md); } else + { memcpy(&sd->md->mercenary, merc, sizeof(struct s_mercenary)); + md = sd->md; + } + + if( sd->status.mer_id == 0 ) + mercenary_set_calls(md, 1); + sd->status.mer_id = merc->mercenary_id; - md = sd->md; if( md && md->bl.prev == NULL && sd->bl.prev != NULL ) { map_addblock(&md->bl); @@ -314,6 +331,20 @@ int mercenary_dead(struct mercenary_data *md, struct block_list *src) return 0; } +int mercenary_kills(struct mercenary_data *md) +{ + md->mercenary.kill_count++; + md->mercenary.kill_count = cap_value(md->mercenary.kill_count, 0, INT_MAX); + + if( (md->mercenary.kill_count % 50) == 0 ) + mercenary_set_faith(md, 1); + + if( md->master ) + clif_mercenary_updatestatus(md->master, SP_MERCKILLS); + + return 0; +} + int read_mercenarydb(void) { FILE *fp; diff --git a/src/map/mercenary.h b/src/map/mercenary.h index 2a2e17cfa..21cdf9245 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -55,6 +55,7 @@ int mercenary_get_faith(struct mercenary_data *md); int mercenary_set_faith(struct mercenary_data *md, int value); int mercenary_get_calls(struct mercenary_data *md); int mercenary_set_calls(struct mercenary_data *md, int value); +int mercenary_kills(struct mercenary_data *md); int do_init_mercenary(void); diff --git a/src/map/mob.c b/src/map/mob.c index 5c8875f88..6d340b14a 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1921,16 +1921,18 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) if(src && src->type == BL_MOB) mob_unlocktarget((struct mob_data *)src,tick); - if(sd) { + if( sd ) + { int sp = 0, hp = 0; sp += sd->sp_gain_value; sp += sd->sp_gain_race[status->race]; sp += sd->sp_gain_race[status->mode&MD_BOSS?RC_BOSS:RC_NONBOSS]; hp += sd->hp_gain_value; - if (hp||sp) + if( hp || sp ) status_heal(src, hp, sp, battle_config.show_hp_sp_gain?2:0); - if (sd->mission_mobid == md->class_) { //TK_MISSION [Skotlex] - if (++sd->mission_count >= 100 && (temp = mob_get_random_id(0, 0xE, sd->status.base_level))) + if( sd->mission_mobid == md->class_) + { //TK_MISSION [Skotlex] + if( ++sd->mission_count >= 100 && (temp = mob_get_random_id(0, 0xE, sd->status.base_level)) ) { pc_addfame(sd, 1); sd->mission_mobid = temp; @@ -1940,6 +1942,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) } pc_setglobalreg(sd,"TK_MISSION_COUNT", sd->mission_count); } + if( sd->md && (md->level > sd->status.base_level / 2) ) + mercenary_kills(sd->md); } // filter out entries not eligible for exp distribution @@ -3501,7 +3505,8 @@ static bool mob_parse_dbrow(char** str) db->dropitem[i].p = mob_drop_adjust(rate, rate_adjust, ratemin, ratemax); //calculate and store Max available drop chance of the item - if (db->dropitem[i].p && (class_ < 1324 || class_ > 1363) && (class_ < 1938 || class_ > 1946) { //Skip treasure chests. + if( db->dropitem[i].p && (class_ < 1324 || class_ > 1363) && (class_ < 1938 || class_ > 1946) ) + { //Skip treasure chests. id = itemdb_search(db->dropitem[i].nameid); if (id->maxchance == 10000 || (id->maxchance < db->dropitem[i].p) ) { id->maxchance = db->dropitem[i].p; //item has bigger drop chance or sold in shops |