Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Achievement update #2470

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions db/constants.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3949,54 +3949,6 @@ constants_db: {
HAT_DIGITAL_SPACE: 87
HAT_EF_SLEIPNIR: 88

comment__: "Achievement Types"
ACH_QUEST: 0
ACH_KILL_PC_TOTAL: 1
ACH_KILL_PC_JOB: 2
ACH_KILL_PC_JOBTYPE: 3
ACH_KILL_MOB_CLASS: 4
ACH_DAMAGE_PC_MAX: 5
ACH_DAMAGE_PC_TOTAL: 6
ACH_DAMAGE_PC_REC_MAX: 7
ACH_DAMAGE_PC_REC_TOTAL: 8
ACH_DAMAGE_MOB_MAX: 9
ACH_DAMAGE_MOB_TOTAL: 10
ACH_DAMAGE_MOB_REC_MAX: 11
ACH_DAMAGE_MOB_REC_TOTAL: 12
ACH_JOB_CHANGE: 13
ACH_STATUS: 14
ACH_STATUS_BY_JOB: 15
ACH_STATUS_BY_JOBTYPE: 16
ACH_CHATROOM_CREATE_DEAD: 17
ACH_CHATROOM_CREATE: 18
ACH_CHATROOM_MEMBERS: 19
ACH_FRIEND_ADD: 20
ACH_PARTY_CREATE: 21
ACH_PARTY_JOIN: 22
ACH_MARRY: 23
ACH_ADOPT_BABY: 24
ACH_ADOPT_PARENT: 25
ACH_ZENY_HOLD: 26
ACH_ZENY_GET_ONCE: 27
ACH_ZENY_GET_TOTAL: 28
ACH_ZENY_SPEND_ONCE: 29
ACH_ZENY_SPEND_TOTAL: 30
ACH_EQUIP_REFINE_SUCCESS: 31
ACH_EQUIP_REFINE_FAILURE: 32
ACH_EQUIP_REFINE_SUCCESS_TOTAL: 33
ACH_EQUIP_REFINE_FAILURE_TOTAL: 34
ACH_EQUIP_REFINE_SUCCESS_WLV: 35
ACH_EQUIP_REFINE_FAILURE_WLV: 36
ACH_EQUIP_REFINE_SUCCESS_ID: 37
ACH_EQUIP_REFINE_FAILURE_ID: 38
ACH_ITEM_GET_COUNT: 39
ACH_ITEM_GET_COUNT_ITEMTYPE: 40
ACH_ITEM_GET_WORTH: 41
ACH_ITEM_SELL_WORTH: 42
ACH_PET_CREATE: 43
ACH_ACHIEVE: 44
ACH_ACHIEVEMENT_RANK: 45

comment__: "inventory expansion"
INVENTORY_INCREASE_STEP: 10
}
2 changes: 2 additions & 0 deletions db/pre-re/achievement_db.conf
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ achievement_db: (
ACH_ZENY_GET_TOTAL: (Accumulative) Gain a specific amount of zeny in total. (Gain Zeny)
ACH_ZENY_SPEND_ONCE: Spend a specific amount of zeny in one transaction. (Pay Zeny)
ACH_ZENY_SPEND_TOTAL: (Accumulative) Spend a specific amount of zeny in total. (Pay Zeny)
ACH_ZENY_SPEND_VENDING: Spend a specific amount of zeny in one transaction to a vending player
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look like formatting different. Other lines using spaces but new lines using tabs

ACH_ZENY_SPEND_VENDING_TOTAL: (Accumulative) Spend a specific amount of zeny in one transaction to a vending player
ACH_EQUIP_REFINE_SUCCESS: Refine an item to +N. (Successful Refine)
ACH_EQUIP_REFINE_FAILURE: Fail to refine an item of +N refine. (Failed Refine)
ACH_EQUIP_REFINE_SUCCESS_TOTAL: (Accumulative) Refine an item successfully N times. (Success Refine)
Expand Down
2 changes: 2 additions & 0 deletions db/re/achievement_db.conf
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ achievement_db: (
ACH_ZENY_GET_TOTAL: (Accumulative) Gain a specific amount of zeny in total. (Gain Zeny)
ACH_ZENY_SPEND_ONCE: Spend a specific amount of zeny in one transaction. (Pay Zeny)
ACH_ZENY_SPEND_TOTAL: (Accumulative) Spend a specific amount of zeny in total. (Pay Zeny)
ACH_ZENY_SPEND_VENDING: Spend a specific amount of zeny in one transaction to a vending player
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

ACH_ZENY_SPEND_VENDING_TOTAL: (Accumulative) Spend a specific amount of zeny in total to a vending player
ACH_EQUIP_REFINE_SUCCESS: Refine an item to +N. (Successful Refine)
ACH_EQUIP_REFINE_FAILURE: Fail to refine an item of +N refine. (Failed Refine)
ACH_EQUIP_REFINE_SUCCESS_TOTAL: (Accumulative) Refine an item successfully N times. (Success Refine)
Expand Down
24 changes: 24 additions & 0 deletions src/map/achievement.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,29 @@ static void achievement_validate_zeny(struct map_session_data *sd, int amount)
}
}

/**
* Validates zeny type objectives.
* @types ACH_ZENY_SPEND_VENDING
* ACH_ZENY_SPEND_VENDING_TOTAL
* @param[in] sd pointer to session data.
* @param[in] amount (goal) amount of zeny spent.
* @see achievement_validate_type()
*/
static void achievement_validate_zeny_vending(struct map_session_data *sd, int amount)
{
nullpo_retv(sd);
Assert_retv(amount > 0);

if (!sd->achievements_received)
return;

struct achievement_objective criteria = {0};
criteria.goal = amount;

achievement->validate_type(sd, ACH_ZENY_SPEND_VENDING, &criteria, false);
achievement->validate_type(sd, ACH_ZENY_SPEND_VENDING_TOTAL, &criteria, true);
}

/**
* Validates equipment refinement type objectives.
* @types ACH_EQUIP_REFINE_SUCCESS
Expand Down Expand Up @@ -1991,6 +2014,7 @@ void achievement_defaults(void)
achievement->validate_marry = achievement_validate_marry;
achievement->validate_adopt = achievement_validate_adopt;
achievement->validate_zeny = achievement_validate_zeny;
achievement->validate_zeny_vending = achievement_validate_zeny_vending;
achievement->validate_refine = achievement_validate_refine;
achievement->validate_item_get = achievement_validate_item_get;
achievement->validate_item_sell = achievement_validate_item_sell;
Expand Down
3 changes: 3 additions & 0 deletions src/map/achievement.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ enum achievement_types {
// Achievement
ACH_ACHIEVE,
ACH_ACHIEVEMENT_RANK,
ACH_ZENY_SPEND_VENDING,
ACH_ZENY_SPEND_VENDING_TOTAL,
ACH_TYPE_MAX
};

Expand Down Expand Up @@ -266,6 +268,7 @@ struct achievement_interface {
void (*validate_marry) (struct map_session_data *sd);
void (*validate_adopt) (struct map_session_data *sd, bool parent);
void (*validate_zeny) (struct map_session_data *sd, int amount);
void (*validate_zeny_vending) (struct map_session_data *sd, int amount);
void (*validate_refine) (struct map_session_data *sd, unsigned int idx, bool success);
void (*validate_item_get) (struct map_session_data *sd, int nameid, int amount);
void (*validate_item_sell) (struct map_session_data *sd, int nameid, int amount);
Expand Down
50 changes: 50 additions & 0 deletions src/map/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -26600,6 +26600,56 @@ static void script_hardcoded_constants(void)
script->set_constant("UDT_BODY2", UDT_BODY2, false, false);
script->set_constant("UDT_GROUP", UDT_GROUP, false, false);

script->constdb_comment("Achievement Types");
script->set_constant("ACH_QUEST", ACH_QUEST, false, false);
script->set_constant("ACH_KILL_PC_TOTAL", ACH_KILL_PC_TOTAL, false, false);
script->set_constant("ACH_KILL_PC_JOB", ACH_KILL_PC_JOB, false, false);
script->set_constant("ACH_KILL_PC_JOBTYPE", ACH_KILL_PC_JOBTYPE, false, false);
script->set_constant("ACH_KILL_MOB_CLASS", ACH_KILL_MOB_CLASS, false, false);
script->set_constant("ACH_DAMAGE_PC_MAX", ACH_DAMAGE_PC_MAX, false, false);
script->set_constant("ACH_DAMAGE_PC_TOTAL", ACH_DAMAGE_PC_TOTAL, false, false);
script->set_constant("ACH_DAMAGE_PC_REC_MAX", ACH_DAMAGE_PC_REC_MAX, false, false);
script->set_constant("ACH_DAMAGE_PC_REC_TOTAL", ACH_DAMAGE_PC_REC_TOTAL, false, false);
script->set_constant("ACH_DAMAGE_MOB_MAX", ACH_DAMAGE_MOB_MAX, false, false);
script->set_constant("ACH_DAMAGE_MOB_TOTAL", ACH_DAMAGE_MOB_TOTAL, false, false);
script->set_constant("ACH_DAMAGE_MOB_REC_MAX", ACH_DAMAGE_MOB_REC_MAX, false, false);
script->set_constant("ACH_DAMAGE_MOB_REC_TOTAL", ACH_DAMAGE_MOB_REC_TOTAL, false, false);
script->set_constant("ACH_JOB_CHANGE", ACH_JOB_CHANGE, false, false);
script->set_constant("ACH_STATUS", ACH_STATUS, false, false);
script->set_constant("ACH_STATUS_BY_JOB", ACH_STATUS_BY_JOB, false, false);
script->set_constant("ACH_STATUS_BY_JOBTYPE", ACH_STATUS_BY_JOBTYPE, false, false);
script->set_constant("ACH_CHATROOM_CREATE_DEAD", ACH_CHATROOM_CREATE_DEAD, false, false);
script->set_constant("ACH_CHATROOM_CREATE", ACH_CHATROOM_CREATE, false, false);
script->set_constant("ACH_CHATROOM_MEMBERS", ACH_CHATROOM_MEMBERS, false, false);
script->set_constant("ACH_FRIEND_ADD", ACH_FRIEND_ADD, false, false);
script->set_constant("ACH_PARTY_CREATE", ACH_PARTY_CREATE, false, false);
script->set_constant("ACH_PARTY_JOIN", ACH_PARTY_JOIN, false, false);
script->set_constant("ACH_MARRY", ACH_MARRY, false, false);
script->set_constant("ACH_ADOPT_BABY", ACH_ADOPT_BABY, false, false);
script->set_constant("ACH_ADOPT_PARENT", ACH_ADOPT_PARENT, false, false);
script->set_constant("ACH_ZENY_HOLD", ACH_ZENY_HOLD, false, false);
script->set_constant("ACH_ZENY_GET_ONCE", ACH_ZENY_GET_ONCE, false, false);
script->set_constant("ACH_ZENY_GET_TOTAL", ACH_ZENY_GET_TOTAL, false, false);
script->set_constant("ACH_ZENY_SPEND_ONCE", ACH_ZENY_SPEND_ONCE, false, false);
script->set_constant("ACH_ZENY_SPEND_TOTAL", ACH_ZENY_SPEND_TOTAL, false, false);
script->set_constant("ACH_EQUIP_REFINE_SUCCESS", ACH_EQUIP_REFINE_SUCCESS, false, false);
script->set_constant("ACH_EQUIP_REFINE_FAILURE", ACH_EQUIP_REFINE_FAILURE, false, false);
script->set_constant("ACH_EQUIP_REFINE_SUCCESS_TOTAL", ACH_EQUIP_REFINE_SUCCESS_TOTAL, false, false);
script->set_constant("ACH_EQUIP_REFINE_FAILURE_TOTAL", ACH_EQUIP_REFINE_FAILURE_TOTAL, false, false);
script->set_constant("ACH_EQUIP_REFINE_SUCCESS_WLV", ACH_EQUIP_REFINE_SUCCESS_WLV, false, false);
script->set_constant("ACH_EQUIP_REFINE_FAILURE_WLV", ACH_EQUIP_REFINE_FAILURE_WLV, false, false);
script->set_constant("ACH_EQUIP_REFINE_SUCCESS_ID", ACH_EQUIP_REFINE_SUCCESS_ID, false, false);
script->set_constant("ACH_EQUIP_REFINE_FAILURE_ID", ACH_EQUIP_REFINE_FAILURE_ID, false, false);
script->set_constant("ACH_ITEM_GET_COUNT", ACH_ITEM_GET_COUNT, false, false);
script->set_constant("ACH_ITEM_GET_COUNT_ITEMTYPE", ACH_ITEM_GET_COUNT_ITEMTYPE, false, false);
script->set_constant("ACH_ITEM_GET_WORTH", ACH_ITEM_GET_WORTH, false, false);
script->set_constant("ACH_ITEM_SELL_WORTH", ACH_ITEM_SELL_WORTH, false, false);
script->set_constant("ACH_PET_CREATE", ACH_PET_CREATE, false, false);
script->set_constant("ACH_ACHIEVE", ACH_ACHIEVE, false, false);
script->set_constant("ACH_ACHIEVEMENT_RANK", ACH_ACHIEVEMENT_RANK, false, false);
script->set_constant("ACH_ZENY_SPEND_VENDING", ACH_ZENY_SPEND_VENDING, false, false);
script->set_constant("ACH_ZENY_SPEND_VENDING_TOTAL", ACH_ZENY_SPEND_VENDING_TOTAL, false, false);

script->constdb_comment("Renewal");
#ifdef RENEWAL
script->set_constant("RENEWAL", 1, false, false);
Expand Down
3 changes: 3 additions & 0 deletions src/map/vending.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "vending.h"

#include "map/achievement.h"
#include "map/atcommand.h"
#include "map/battle.h"
#include "map/chrif.h"
Expand Down Expand Up @@ -184,6 +185,8 @@ static void vending_purchasereq(struct map_session_data *sd, int aid, unsigned i
}

pc->payzeny(sd, (int)z, LOG_TYPE_VENDING, vsd);
achievement->validate_zeny_vending(sd, (int)z);

if( battle_config.vending_tax )
z -= apply_percentrate64(z, battle_config.vending_tax, 10000);
pc->getzeny(vsd, (int)z, LOG_TYPE_VENDING, sd);
Expand Down