summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorsmokexyz <sagunkho@hotmail.com>2018-06-30 04:20:03 +0100
committerAsheraf <acheraf1998@gmail.com>2018-07-24 21:41:20 +0100
commit19aa33a5f61f0996d76d19db7dbe9d81f5daa090 (patch)
treeb54e07d42a58e34820e3131f750b56b7130cb461 /src/map/pc.c
parent78c75cade7f445231f11395a6faef9b0a55568dc (diff)
downloadhercules-19aa33a5f61f0996d76d19db7dbe9d81f5daa090.tar.gz
hercules-19aa33a5f61f0996d76d19db7dbe9d81f5daa090.tar.bz2
hercules-19aa33a5f61f0996d76d19db7dbe9d81f5daa090.tar.xz
hercules-19aa33a5f61f0996d76d19db7dbe9d81f5daa090.zip
Implementation of the official Achievement System.
Source: http://ro.gnjoy.com/news/update/View.asp?seq=163&curpage=1 Script Commands - ``` achievement_progress(<ach_id>,<obj_idx>,<progress>,<incremental?>{,<char_id>}); ``` Includes an achievement_db.conf generator that reads from the item_db, mob_db (server side) and achievement_list.lub files to determine valid achievement entries based on item/monster availability. Achievements containing unsupported entries are commented out. This feature, although renewal-only in official servers, is capable of being used in pre-renewal mode on Hercules. Does not include the title system yet. A big thanks to - @MishimaHaruna for constantly reviewing. @4144 for all the support. @Asheraf for a lot of official information. Co-authored-by: "Dastgir" <dastgirp@gmail.com>
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index f2cff8ab3..6f9347113 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -55,6 +55,7 @@
#include "map/skill.h"
#include "map/status.h" // struct status_data
#include "map/storage.h"
+#include "map/achievement.h"
#include "common/cbasetypes.h"
#include "common/conf.h"
#include "common/core.h" // get_svn_revision()
@@ -1053,6 +1054,11 @@ static bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data
pc->skill(p1_sd, WE_CALLBABY, 1, SKILL_GRANT_PERMANENT);
pc->skill(p2_sd, WE_CALLBABY, 1, SKILL_GRANT_PERMANENT);
+ // Achievements [Smokexyz/Hercules]
+ achievement->validate_adopt(p1_sd, true); // Parent 1
+ achievement->validate_adopt(p2_sd, true); // Parent 2
+ achievement->validate_adopt(b_sd, false); // Baby
+
return true;
}
@@ -1325,6 +1331,7 @@ static bool pc_authok(struct map_session_data *sd, int login_id2, time_t expirat
sd->bg_queue.type = 0;
VECTOR_INIT(sd->script_queues);
+ VECTOR_INIT(sd->achievement); // Achievements [Smokexyz/Hercules]
VECTOR_INIT(sd->storage.item); // initialize storage item vector.
VECTOR_INIT(sd->hatEffectId);
@@ -1384,6 +1391,7 @@ static bool pc_authok(struct map_session_data *sd, int login_id2, time_t expirat
" Group '"CL_WHITE"%d"CL_RESET"').\n",
sd->status.name, sd->status.account_id, sd->status.char_id,
CONVIP(ip), sd->group_id);
+
// Send friends list
clif->friendslist_send(sd);
@@ -1474,7 +1482,6 @@ static int pc_reg_received(struct map_session_data *sd)
nullpo_ret(sd);
sd->vars_ok = true;
-
sd->change_level_2nd = pc_readglobalreg(sd,script->add_str("jobchange_level"));
sd->change_level_3rd = pc_readglobalreg(sd,script->add_str("jobchange_level_3rd"));
sd->die_counter = pc_readglobalreg(sd,script->add_str("PC_DIE_COUNTER"));
@@ -1593,6 +1600,9 @@ static int pc_reg_received(struct map_session_data *sd)
if( npc->motd ) /* [Ind/Hercules] */
script->run(npc->motd->u.scr.script, 0, sd->bl.id, npc->fake_nd->bl.id);
+ // Achievements [Smokexyz/Hercules]
+ intif->achievements_request(sd);
+
return 1;
}
@@ -4500,6 +4510,8 @@ static int pc_payzeny(struct map_session_data *sd, int zeny, enum e_log_pick_typ
sd->status.zeny -= zeny;
clif->updatestatus(sd,SP_ZENY);
+ achievement->validate_zeny(sd, -zeny); // Achievements [Smokexyz/Hercules]
+
if(!tsd) tsd = sd;
logs->zeny(sd, type, tsd, -zeny);
if( zeny > 0 && sd->state.showzeny ) {
@@ -4636,6 +4648,8 @@ static int pc_getzeny(struct map_session_data *sd, int zeny, enum e_log_pick_typ
sd->status.zeny += zeny;
clif->updatestatus(sd,SP_ZENY);
+ achievement->validate_zeny(sd, zeny); // Achievements [Smokexyz/Hercules]
+
if(!tsd) tsd = sd;
logs->zeny(sd, type, tsd, zeny);
if( zeny > 0 && sd->state.showzeny ) {
@@ -4760,6 +4774,7 @@ static int pc_additem(struct map_session_data *sd, struct item *item_data, int a
sd->status.inventory[i].amount = amount;
sd->inventory_data[i] = data;
clif->additem(sd,i,amount,0);
+
}
if( ( !itemdb->isstackable2(data) || data->flag.force_serial || data->type == IT_CASH) && !item_data->unique_id )
@@ -4767,6 +4782,8 @@ static int pc_additem(struct map_session_data *sd, struct item *item_data, int a
logs->pick_pc(sd, log_type, amount, &sd->status.inventory[i],sd->inventory_data[i]);
+ achievement->validate_item_get(sd, sd->status.inventory[i].nameid, sd->status.inventory[i].amount); // Achievements [Smokexyz/Hercules]
+
sd->weight += w;
clif->updatestatus(sd,SP_WEIGHT);
//Auto-equip
@@ -6879,11 +6896,15 @@ static int pc_checkbaselevelup(struct map_session_data *sd)
clif->misceffect(&sd->bl,0);
npc->script_event(sd, NPCE_BASELVUP); //LORDALFA - LVLUPEVENT
- if(sd->status.party_id)
+ if (sd->status.party_id)
party->send_levelup(sd);
pc->baselevelchanged(sd);
+
quest->questinfo_refresh(sd);
+
+ achievement->validate_stats(sd, SP_BASELEVEL, sd->status.base_level);
+
return 1;
}
@@ -6946,7 +6967,11 @@ static int pc_checkjoblevelup(struct map_session_data *sd)
clif->status_change(&sd->bl,SI_DEVIL1, 1, 0, 0, 0, 1); //Permanent blind effect from SG_DEVIL.
npc->script_event(sd, NPCE_JOBLVUP);
+
quest->questinfo_refresh(sd);
+
+ achievement->validate_stats(sd, SP_BASELEVEL, sd->status.job_level);
+
return 1;
}
@@ -7243,6 +7268,8 @@ static int pc_setstat(struct map_session_data *sd, int type, int val)
return -1;
}
+ achievement->validate_stats(sd, type, val); // Achievements [Smokexyz/Hercules]
+
return val;
}
@@ -7974,6 +8001,14 @@ static void pc_damage(struct map_session_data *sd, struct block_list *src, unsig
if (battle_config.prevent_logout_trigger & PLT_DAMAGE)
sd->canlog_tick = timer->gettick();
+
+ // Achievements [Smokexyz/Hercules]
+ if (src != NULL) {
+ if (src->type == BL_PC)
+ achievement->validate_pc_damage(BL_UCAST(BL_PC, src), sd, hp);
+ else if (src->type == BL_MOB)
+ achievement->validate_mob_damage(sd, hp, true);
+ }
}
/*==========================================
@@ -8124,6 +8159,8 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src)
pc->setparam(ssd, SP_KILLEDRID, sd->bl.id);
npc->script_event(ssd, NPCE_KILLPC);
+ achievement->validate_pc_kill(ssd, sd); // Achievements [Smokexyz/Hercules]
+
if (battle_config.pk_mode&2) {
ssd->status.manner -= 5;
if(ssd->status.manner < 0)
@@ -9042,6 +9079,8 @@ static int pc_jobchange(struct map_session_data *sd, int class, int upper)
}
quest->questinfo_refresh(sd);
+ achievement->validate_jobchange(sd); // Achievements [Smokexyz/Hercules]
+
return 0;
}
@@ -10682,6 +10721,11 @@ static int pc_marriage(struct map_session_data *sd, struct map_session_data *dst
return -1;
sd->status.partner_id = dstsd->status.char_id;
dstsd->status.partner_id = sd->status.char_id;
+
+ // Achievements [Smokexyz/Hercules]
+ achievement->validate_marry(sd);
+ achievement->validate_marry(dstsd);
+
return 0;
}