From 97b6801abb61b12b36593fa0c38cdc7cdac7d413 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sat, 17 Aug 2019 21:19:58 -0300 Subject: Homunculus Dispatch core rules --- src/emap/init.c | 3 ++ src/emap/script_buildins.c | 70 ++++++++++++++++++++++++++++++++++++++++++---- src/emap/script_buildins.h | 3 ++ 3 files changed, 71 insertions(+), 5 deletions(-) diff --git a/src/emap/init.c b/src/emap/init.c index 76910fb..1ea0ae9 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -220,6 +220,9 @@ HPExport void plugin_init (void) addScriptCommand("setguildrole","iiiis",setguildrole); addScriptCommand("getguildmember","i?",getguildmember); addScriptCommand("gethomunexp","i",gethomunexp); + addScriptCommand("deployhomunculus","",deployhomunculus); + addScriptCommand("recallhomunculus","",recallhomunculus); + addScriptCommand("homstatus","",homstatus); do_init_langs(); diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c index 01982a8..99bae19 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -2556,16 +2556,76 @@ BUILDIN(gethomunexp) if (base < 0) return true; - // Cannot give EXP to inactive homunculus + // Cannot give EXP to inactive or dead homunculus + if (!homun_alive(sd->hd)) + return true; + + homun->gainexp(sd->hd, base); + return true; +} + +/*========================================== + * Send resting homunculus in a mission + * Homun must be resting. Returns true on success. + *------------------------------------------*/ +BUILDIN(deployhomunculus) +{ + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL || sd->hd == NULL) + return true; + /* - if (sd->hd->homunculus.vaporize == HOM_ST_ACTIVE) + // Homunculus must be resting + if (sd->hd->homunculus.vaporize != HOM_ST_REST) return true; + + // Add morph state. + //sd->hd->homunculus.vaporize=HOM_ST_MORPH; */ - //pc->gainexp(sd, &sd->bl, base, job, true); - homun->gainexp(sd->hd, base); - // send_homun_exp(sd->hd, base); + // Using the function, I don't need it resting + homun->vaporize(sd, HOM_ST_MORPH); + + // Return true + script_pushint(st,true); + return true; +} + +/*========================================== + * Returns the Homunculus from a mission + * Homun must be morph. Returns true on success. + *------------------------------------------*/ +BUILDIN(recallhomunculus) +{ + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL || sd->hd == NULL) + return true; + + // Homunculus must be vapor + if (sd->hd->homunculus.vaporize != HOM_ST_MORPH) + return true; + + // Remove morph state. + sd->hd->homunculus.vaporize=HOM_ST_REST; + homun->call(sd); // Respawn homunculus. + + // Return true + script_pushint(st,true); + return true; +} + + +/*========================================== + * Returns the Homunculus sleep status + *------------------------------------------*/ +BUILDIN(homstatus) +{ + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL || sd->hd == NULL) + return true; + // Return the status (0 - active; 1 - resting ; 2 - mission) + script_pushint(st,sd->hd->homunculus.vaporize); return true; } diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h index 19c3b30..269df3a 100644 --- a/src/emap/script_buildins.h +++ b/src/emap/script_buildins.h @@ -109,5 +109,8 @@ BUILDIN(getguildnxp); BUILDIN(setguildrole); BUILDIN(getguildmember); BUILDIN(gethomunexp); +BUILDIN(deployhomunculus); +BUILDIN(recallhomunculus); +BUILDIN(homstatus); #endif // EVOL_MAP_SCRIPT_BUILDINS -- cgit v1.2.3-60-g2f50