summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-11-08 16:17:30 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-11-08 16:17:30 +0000
commit7c8e1245438b395d5742b936372fb55e3150b53c (patch)
treef7bb1598c829f199fba3240632c88af2aacc4ff5 /src/map/pc.c
parentab522d194a3ee70758bab2113d2b34f34706f24f (diff)
downloadhercules-7c8e1245438b395d5742b936372fb55e3150b53c.tar.gz
hercules-7c8e1245438b395d5742b936372fb55e3150b53c.tar.bz2
hercules-7c8e1245438b395d5742b936372fb55e3150b53c.tar.xz
hercules-7c8e1245438b395d5742b936372fb55e3150b53c.zip
- Moved the duel functions to pc.c since they are so totally out of place in atcommand.c
- Fixed Spider Web not ending when hit by a fireelemental attack. - Cast-time reductions from status changes will not be executed until right before casting, to prevent status changes from ending when attempting to cast and the attempt fails (invalid cells, not enough sp, wrong target, etc, etc) - Added check to prevent Wand of Hermod from seeking for a partner to encore, since the partner is supposed to be the warp. - Moved the duel auto-reject on logout from map_quit to unit_free - Corrected the mob spawn reading code so that the event-name can be up to 50 characters long (which is the actual event length) and so that it can read spaces within them, it will also strip the leading/trailing quotes if you use them so that the event is actually found on mob-death (so you can do stuff like "My NPC::OnDead" as a valid event). - Moved the homunc inherit speed from the master from status_calc_pc to LoadEndAck, since the hom's speed matches that of the master each time the master changes maps. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9173 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c171
1 files changed, 171 insertions, 0 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 07b387d1f..c68b5b2ff 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -7006,6 +7006,177 @@ 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), (unsigned char *)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));
+ clif_foreachclient(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_set0199(sd->fd, 1);
+ //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];
+
+ sprintf(output, msg_txt(373), // " -- Player %s invites %s to duel --"
+ (unsigned char *)sd->status.name, (unsigned char *)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), (unsigned char *)sd->status.name);
+ clif_GMmessage((struct block_list *)target_sd, output, strlen(output)+1, 3);
+ 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), (unsigned char *)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) {
+ clif_foreachclient(duel_leave_sub, did);
+ duel_count--;
+ }
+
+ sd->duel_group = 0;
+ duel_savetime(sd);
+ clif_set0199(sd->fd, 0);
+ 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), (unsigned char *)sd->status.name);
+ clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
+
+ clif_set0199(sd->fd, 1);
+ //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), (unsigned char *)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;