From 14d0fb868e86c676cdf70dfacaf33d4330d5f011 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 21 Dec 2014 14:36:11 +0300 Subject: Add script function for change per character gender. New script function: changecharsex --- src/map/script.c | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'src/map') diff --git a/src/map/script.c b/src/map/script.c index c7b1ae849..031dfc21b 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -10639,26 +10639,50 @@ BUILDIN(changebase) { return true; } +static TBL_PC *prepareChangeSex(struct script_state* st) +{ + int i; + TBL_PC *sd = script->rid2sd(st); + + if (sd == NULL) + return NULL; + + pc->resetskill(sd, 4); + // to avoid any problem with equipment and invalid sex, equipment is unequiped. + for (i=0; iequip_index[i] >= 0) pc->unequipitem(sd, sd->equip_index[i], 3); + return sd; +} + /*========================================== * Unequip all item and request for a changesex to char-serv *------------------------------------------*/ BUILDIN(changesex) { - int i; - TBL_PC *sd = NULL; - sd = script->rid2sd(st); - - if( sd == NULL ) + TBL_PC *sd = prepareChangeSex(st); + if (sd == NULL) return false; - - pc->resetskill(sd,4); - // to avoid any problem with equipment and invalid sex, equipment is unequiped. - for( i=0; iequip_index[i] >= 0 ) pc->unequipitem(sd, sd->equip_index[i], 3); chrif->changesex(sd); return true; } +/*========================================== + * Unequip all items and change character sex [4144] + *------------------------------------------*/ +BUILDIN(changecharsex) +{ + TBL_PC *sd = prepareChangeSex(st); + if (sd == NULL) + return false; + if (sd->status.sex == 99) + sd->status.sex = 0; + sd->status.sex = sd->status.sex ? 0 : 1; + chrif->save(sd, 0); + if (sd->fd) + clif->authfail_fd(sd->fd, 15); + return true; +} + /*========================================== * Works like 'announce' but outputs in the common chat window *------------------------------------------*/ @@ -19302,6 +19326,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(skillpointcount,""), BUILDIN_DEF(changebase,"i?"), BUILDIN_DEF(changesex,""), + BUILDIN_DEF(changecharsex,""), // [4144] BUILDIN_DEF(waitingroom,"si?????"), BUILDIN_DEF(delwaitingroom,"?"), BUILDIN_DEF2(waitingroomkickall,"kickwaitingroomall","?"), -- cgit v1.2.3-70-g09d2