summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c268
1 files changed, 83 insertions, 185 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 7ee8bec90..f55a77b6a 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -18,6 +18,7 @@
#include "chrif.h"
#include "clif.h"
#include "date.h" // is_day_of_*()
+#include "duel.h"
#include "intif.h"
#include "itemdb.h"
#include "log.h"
@@ -63,9 +64,6 @@ static unsigned short equip_pos[EQI_MAX]={EQP_ACC_L,EQP_ACC_R,EQP_SHOES,EQP_GARM
#define MOTD_LINE_SIZE 128
static char motd_text[MOTD_LINE_SIZE][CHAT_SIZE_MAX]; // Message of the day buffer [Valaris]
-struct duel duel_list[MAX_DUEL];
-int duel_count = 0;
-
//Links related info to the sd->hate_mob[]/sd->feel_map[] entries
const struct sg_data sg_info[MAX_PC_FEELHATE] = {
{ SG_SUN_ANGER, SG_SUN_BLESS, SG_SUN_COMFORT, "PC_FEEL_SUN", "PC_HATE_MOB_SUN", is_day_of_sun },
@@ -3271,13 +3269,37 @@ int pc_payzeny(struct map_session_data *sd,int zeny)
void pc_paycash(struct map_session_data *sd, int price, int points)
{
char output[128];
- int cash = price - points;
+ int cash;
nullpo_retv(sd);
- pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints - cash);
- pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints - points);
- sprintf(output, "Used %d kafra points and %d cash points. %d kafra and %d cash points remaining.", points, cash, sd->kafraPoints, sd->cashPoints);
- clif_disp_onlyself(sd, output, strlen(output));
+ if( price < 0 || points < 0 )
+ {
+ ShowError("pc_paycash: Paying negative points (price=%d, points=%d, account_id=%d, char_id=%d).\n", price, points, sd->status.account_id, sd->status.char_id);
+ return;
+ }
+
+ if( points > price )
+ {
+ ShowWarning("pc_paycash: More kafra points provided than needed (price=%d, points=%d, account_id=%d, char_id=%d).\n", price, points, sd->status.account_id, sd->status.char_id);
+ points = price;
+ }
+
+ cash = price-points;
+
+ if( sd->cashPoints < cash || sd->kafraPoints < points )
+ {
+ ShowError("pc_paycash: Not enough points (cash=%d, kafra=%d) to cover the price (cash=%d, kafra=%d) (account_id=%d, char_id=%d).\n", sd->cashPoints, sd->kafraPoints, cash, points, sd->status.account_id, sd->status.char_id);
+ return;
+ }
+
+ pc_setaccountreg(sd, "#CASHPOINTS", sd->cashPoints-cash);
+ pc_setaccountreg(sd, "#KAFRAPOINTS", sd->kafraPoints-points);
+
+ if( battle_config.cashshop_show_points )
+ {
+ sprintf(output, msg_txt(504), points, cash, sd->kafraPoints, sd->cashPoints);
+ clif_disp_onlyself(sd, output, strlen(output));
+ }
}
void pc_getcash(struct map_session_data *sd, int cash, int points)
@@ -3287,18 +3309,44 @@ void pc_getcash(struct map_session_data *sd, int cash, int points)
if( cash > 0 )
{
- pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints + cash);
+ if( cash > MAX_ZENY-sd->cashPoints )
+ {
+ ShowWarning("pc_getcash: Cash point overflow (cash=%d, have cash=%d, account_id=%d, char_id=%d).\n", cash, sd->cashPoints, sd->status.account_id, sd->status.char_id);
+ cash = MAX_ZENY-sd->cashPoints;
+ }
- sprintf(output, "Gained %d cash points. Total %d points", cash, sd->cashPoints);
- clif_disp_onlyself(sd, output, strlen(output));
+ pc_setaccountreg(sd, "#CASHPOINTS", sd->cashPoints+cash);
+
+ if( battle_config.cashshop_show_points )
+ {
+ sprintf(output, msg_txt(505), cash, sd->cashPoints);
+ clif_disp_onlyself(sd, output, strlen(output));
+ }
+ }
+ else if( cash < 0 )
+ {
+ ShowError("pc_getcash: Obtaining negative cash points (cash=%d, account_id=%d, char_id=%d).\n", cash, sd->status.account_id, sd->status.char_id);
}
if( points > 0 )
{
- pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints + points);
+ if( points > MAX_ZENY-sd->kafraPoints )
+ {
+ ShowWarning("pc_getcash: Kafra point overflow (points=%d, have points=%d, account_id=%d, char_id=%d).\n", points, sd->kafraPoints, sd->status.account_id, sd->status.char_id);
+ points = MAX_ZENY-sd->kafraPoints;
+ }
- sprintf(output, "Gained %d kafra points. Total %d points", points, sd->kafraPoints);
- clif_disp_onlyself(sd, output, strlen(output));
+ pc_setaccountreg(sd, "#KAFRAPOINTS", sd->kafraPoints+points);
+
+ if( battle_config.cashshop_show_points )
+ {
+ sprintf(output, msg_txt(506), points, sd->kafraPoints);
+ clif_disp_onlyself(sd, output, strlen(output));
+ }
+ }
+ else if( points < 0 )
+ {
+ ShowError("pc_getcash: Obtaining negative kafra points (points=%d, account_id=%d, char_id=%d).\n", points, sd->status.account_id, sd->status.char_id);
}
}
@@ -4386,6 +4434,7 @@ int pc_checkallowskill(struct map_session_data *sd)
SC_SPEARQUICKEN,
SC_ADRENALINE,
SC_ADRENALINE2,
+ SC_DANCING,
SC_GATLINGFEVER
};
const enum sc_type scs_list[] = {
@@ -4703,7 +4752,7 @@ int pc_mapid2jobid(unsigned short class_, int sex)
/*====================================================
* This function return the name of the job (by [Yor])
*----------------------------------------------------*/
-char* job_name(int class_)
+const char* job_name(int class_)
{
switch (class_) {
case JOB_NOVICE:
@@ -5809,7 +5858,7 @@ void pc_respawn(struct map_session_data* sd, clr_type clrtype)
{
if( !pc_isdead(sd) )
return; // not applicable
- if( sd->state.bg_id && bg_member_respawn(sd) )
+ if( sd->bg_id && bg_member_respawn(sd) )
return; // member revived by battleground
pc_setstand(sd);
@@ -5900,10 +5949,10 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
pc_setglobalreg(sd,"PC_DIE_COUNTER",sd->die_counter+1);
pc_setparam(sd, SP_KILLERRID, src?src->id:0);
- if( sd->state.bg_id )
+ if( sd->bg_id )
{
struct battleground_data *bg;
- if( (bg = bg_team_search(sd->state.bg_id)) != NULL && bg->die_event[0] )
+ if( (bg = bg_team_search(sd->bg_id)) != NULL && bg->die_event[0] )
npc_event(sd, bg->die_event, 0);
}
npc_script_event(sd,NPCE_DIE);
@@ -6147,9 +6196,9 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
add_timer(tick+1000, pc_respawn_timer, sd->bl.id, 0);
return 1|8;
}
- else if( sd->state.bg_id )
+ else if( sd->bg_id )
{
- struct battleground_data *bg = bg_team_search(sd->state.bg_id);
+ struct battleground_data *bg = bg_team_search(sd->bg_id);
if( bg && bg->mapindex > 0 )
{ // Respawn by BG
add_timer(tick+1000, pc_respawn_timer, sd->bl.id, 0);
@@ -6627,6 +6676,7 @@ int pc_equiplookall(struct map_session_data *sd)
clif_changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
clif_changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
clif_changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
+ clif_changelook(&sd->bl, LOOK_ROBE, sd->status.robe);
return 0;
}
@@ -6683,6 +6733,9 @@ int pc_changelook(struct map_session_data *sd,int type,int val)
break;
case LOOK_SHOES:
break;
+ case LOOK_ROBE:
+ sd->status.robe = val;
+ break;
}
clif_changelook(&sd->bl,type,val);
return 0;
@@ -7413,6 +7466,11 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
}
if(pos & EQP_SHOES)
clif_changelook(&sd->bl,LOOK_SHOES,0);
+ if( pos&EQP_GARMENT )
+ {
+ sd->status.robe = id ? id->look : 0;
+ clif_changelook(&sd->bl, LOOK_ROBE, sd->status.robe);
+ }
pc_checkallowskill(sd); //Check if status changes should be halted.
@@ -7483,7 +7541,6 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag)
sd->status.weapon = sd->weapontype2;
pc_calcweapontype(sd);
clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
- status_change_end(&sd->bl, SC_DANCING, INVALID_TIMER); //When unequipping, stop dancing. [Skotlex]
}
if(sd->status.inventory[n].equip & EQP_HAND_L) {
sd->status.shield = sd->weapontype2 = 0;
@@ -7504,6 +7561,11 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag)
}
if(sd->status.inventory[n].equip & EQP_SHOES)
clif_changelook(&sd->bl,LOOK_SHOES,0);
+ if( sd->status.inventory[n].equip&EQP_GARMENT )
+ {
+ sd->status.robe = 0;
+ clif_changelook(&sd->bl, LOOK_ROBE, 0);
+ }
clif_unequipitemack(sd,n,sd->status.inventory[n].equip,1);
@@ -7963,168 +8025,6 @@ void pc_setstand(struct map_session_data *sd){
sd->state.dead_sit = sd->vd.dead_sit = 0;
}
-/*==========================================
- * Duel organizing functions [LuzZza]
- *------------------------------------------*/
-void duel_savetime(struct map_session_data* sd)
-{
- time_t timer;
- struct tm *t;
-
- time(&timer);
- t = localtime(&timer);
-
- pc_setglobalreg(sd, "PC_LAST_DUEL_TIME", t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min);
- return;
-}
-
-int duel_checktime(struct map_session_data* sd)
-{
- int diff;
- time_t timer;
- struct tm *t;
-
- time(&timer);
- t = localtime(&timer);
-
- diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min - pc_readglobalreg(sd, "PC_LAST_DUEL_TIME");
-
- return !(diff >= 0 && diff < battle_config.duel_time_interval);
-}
-static int duel_showinfo_sub(struct map_session_data* sd, va_list va)
-{
- struct map_session_data *ssd = va_arg(va, struct map_session_data*);
- int *p = va_arg(va, int*);
- char output[256];
-
- if (sd->duel_group != ssd->duel_group) return 0;
-
- sprintf(output, " %d. %s", ++(*p), sd->status.name);
- clif_disp_onlyself(ssd, output, strlen(output));
- return 1;
-}
-
-int duel_showinfo(const unsigned int did, struct map_session_data* sd)
-{
- int p=0;
- char output[256];
-
- if(duel_list[did].max_players_limit > 0)
- sprintf(output, msg_txt(370), //" -- Duels: %d/%d, Members: %d/%d, Max players: %d --"
- did, duel_count,
- duel_list[did].members_count,
- duel_list[did].members_count + duel_list[did].invites_count,
- duel_list[did].max_players_limit);
- else
- sprintf(output, msg_txt(371), //" -- Duels: %d/%d, Members: %d/%d --"
- did, duel_count,
- duel_list[did].members_count,
- duel_list[did].members_count + duel_list[did].invites_count);
-
- clif_disp_onlyself(sd, output, strlen(output));
- map_foreachpc(duel_showinfo_sub, sd, &p);
- return 0;
-}
-
-int duel_create(struct map_session_data* sd, const unsigned int maxpl)
-{
- int i=1;
- char output[256];
-
- while(duel_list[i].members_count > 0 && i < MAX_DUEL) i++;
- if(i == MAX_DUEL) return 0;
-
- duel_count++;
- sd->duel_group = i;
- duel_list[i].members_count++;
- duel_list[i].invites_count = 0;
- duel_list[i].max_players_limit = maxpl;
-
- strcpy(output, msg_txt(372)); // " -- Duel has been created (@invite/@leave) --"
- clif_disp_onlyself(sd, output, strlen(output));
-
- clif_map_property(sd, MAPPROPERTY_FREEPVPZONE);
- //clif_misceffect2(&sd->bl, 159);
- return i;
-}
-
-int duel_invite(const unsigned int did, struct map_session_data* sd, struct map_session_data* target_sd)
-{
- char output[256];
-
- // " -- Player %s invites %s to duel --"
- sprintf(output, msg_txt(373), sd->status.name, target_sd->status.name);
- clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
-
- target_sd->duel_invite = did;
- duel_list[did].invites_count++;
-
- // "Blue -- Player %s invites you to PVP duel (@accept/@reject) --"
- sprintf(output, msg_txt(374), sd->status.name);
- clif_broadcast((struct block_list *)target_sd, output, strlen(output)+1, 0x10, SELF);
- return 0;
-}
-
-static int duel_leave_sub(struct map_session_data* sd, va_list va)
-{
- int did = va_arg(va, int);
- if (sd->duel_invite == did)
- sd->duel_invite = 0;
- return 0;
-}
-
-int duel_leave(const unsigned int did, struct map_session_data* sd)
-{
- char output[256];
-
- // " <- Player %s has left duel --"
- sprintf(output, msg_txt(375), sd->status.name);
- clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
-
- duel_list[did].members_count--;
-
- if(duel_list[did].members_count == 0) {
- map_foreachpc(duel_leave_sub, did);
- duel_count--;
- }
-
- sd->duel_group = 0;
- duel_savetime(sd);
- clif_map_property(sd, MAPPROPERTY_NOTHING);
- return 0;
-}
-
-int duel_accept(const unsigned int did, struct map_session_data* sd)
-{
- char output[256];
-
- duel_list[did].members_count++;
- sd->duel_group = sd->duel_invite;
- duel_list[did].invites_count--;
- sd->duel_invite = 0;
-
- // " -> Player %s has accepted duel --"
- sprintf(output, msg_txt(376), sd->status.name);
- clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
-
- clif_map_property(sd, MAPPROPERTY_FREEPVPZONE);
- //clif_misceffect2(&sd->bl, 159);
- return 0;
-}
-
-int duel_reject(const unsigned int did, struct map_session_data* sd)
-{
- char output[256];
-
- // " -- Player %s has rejected duel --"
- sprintf(output, msg_txt(377), sd->status.name);
- clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
-
- duel_list[did].invites_count--;
- sd->duel_invite = 0;
- return 0;
-}
-
int pc_split_str(char *str,char **val,int num)
{
int i;
@@ -8486,8 +8386,6 @@ int do_init_pc(void)
pc_readdb();
pc_read_motd(); // Read MOTD [Valaris]
- memset(&duel_list[0], 0, sizeof(duel_list));
-
add_timer_func_list(pc_invincible_timer, "pc_invincible_timer");
add_timer_func_list(pc_eventtimer, "pc_eventtimer");
add_timer_func_list(pc_inventory_rental_end, "pc_inventory_rental_end");