summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-21 14:36:11 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-26 21:39:47 +0300
commit14d0fb868e86c676cdf70dfacaf33d4330d5f011 (patch)
treebec5166f62872cc0ec07e2615bf730eb966a589f /src/map/script.c
parent7f1e2ded0ac8b756347a1a3a3165f1a48fcdaa7a (diff)
downloadhercules-14d0fb868e86c676cdf70dfacaf33d4330d5f011.tar.gz
hercules-14d0fb868e86c676cdf70dfacaf33d4330d5f011.tar.bz2
hercules-14d0fb868e86c676cdf70dfacaf33d4330d5f011.tar.xz
hercules-14d0fb868e86c676cdf70dfacaf33d4330d5f011.zip
Add script function for change per character gender.
New script function: changecharsex
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c45
1 files changed, 35 insertions, 10 deletions
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,27 +10639,51 @@ 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; i<EQI_MAX; i++)
+ if (sd->equip_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; i<EQI_MAX; i++ )
- if( sd->equip_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
*------------------------------------------*/
BUILDIN(globalmes) {
@@ -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","?"),