diff options
author | Jesusaves <cpntb1@ymail.com> | 2024-07-27 18:35:49 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2024-07-27 18:35:49 -0300 |
commit | d2e83a44a737ebb92be16516a588e4ee0da04d3f (patch) | |
tree | be3a76286a01341e64dd05153f548d6336141c84 | |
parent | fed63bcb154f827a7b9af9532e82158461465a15 (diff) | |
download | evol-hercules-d2e83a44a737ebb92be16516a588e4ee0da04d3f.tar.gz evol-hercules-d2e83a44a737ebb92be16516a588e4ee0da04d3f.tar.bz2 evol-hercules-d2e83a44a737ebb92be16516a588e4ee0da04d3f.tar.xz evol-hercules-d2e83a44a737ebb92be16516a588e4ee0da04d3f.zip |
Homunculus evolution or swapping framework
-rw-r--r-- | src/emap/init.c | 2 | ||||
-rw-r--r-- | src/emap/script_buildins.c | 72 | ||||
-rw-r--r-- | src/emap/script_buildins.h | 2 |
3 files changed, 76 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c index 9f0a9a0..ccbe8b0 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -236,6 +236,8 @@ HPExport void plugin_init (void) addScriptCommand("recallhomunculus","",recallhomunculus); addScriptCommand("homstatus","",homstatus); addScriptCommand("gethomunid","",gethomunid); + addScriptCommand("sethomunclass","i",sethomunclass); + addScriptCommand("sethomunlevel","i",sethomunlevel); addScriptCommand("readparam2","i?",readparam2); addScriptCommand("npcshopattach","s?",npcshopattach); addScriptCommand("instanceowner", "i", InstanceOwner); diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c index 0f56ee4..e9b8006 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -3004,6 +3004,78 @@ BUILDIN(gethomunid) /*========================================== + * Modify the Homunculus Class + * 0 = success + * 1 = no homunculus found + * 2 = homunculus dead or resting + * 3 = invalid arguments + * 4 = Failed to change class + *------------------------------------------*/ +BUILDIN(sethomunclass) +{ + int base=0; + struct map_session_data *sd = script->rid2sd(st); + + // Player and Homunculus exist? + if (sd == NULL || sd->hd == NULL) { + script_pushint(st, -1); + return true; + } + + // Argument parsing + base = script_getnum(st,2); + if (base < 1) { + script_pushint(st, -3); + return true; + } + + // Is the homunculus active? + if (sd->hd->homunculus.vaporize || !homun_alive(sd->hd)) { + script_pushint(st, -2); + return true; + } + + // Attempt to change class + if (!homun->change_class(sd->hd, base)) { + script_pushint(st, -4); + return true; + } + + // Everything went fine! + script_pushint(st, 0); + return true; +} + + +/*========================================== + * Modify the Homunculus Level + * Shuffle status afterwards. + *------------------------------------------*/ +BUILDIN(sethomunlevel) +{ + int base=0; + struct map_session_data *sd = script->rid2sd(st); + + // Player and Homunculus exist? + if (sd == NULL || sd->hd == NULL) + return true; + + // Argument parsing + base = script_getnum(st,2); + if (base < 1) + return true; + + // Modify the level + sd->hd->homunculus.level = base; + + // Shuffle status afterwards + homun->shuffle(sd->hd); + + return true; +} + + +/*========================================== * return the updated stats of sd (use bonus constants) * Supported values: bStr~bLuk, bMaxHP, bMaxSP, bDef, bMdef, bAtk *------------------------------------------*/ diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h index 1105207..29eefe0 100644 --- a/src/emap/script_buildins.h +++ b/src/emap/script_buildins.h @@ -121,6 +121,8 @@ BUILDIN(deployhomunculus); BUILDIN(recallhomunculus); BUILDIN(homstatus); BUILDIN(gethomunid); +BUILDIN(sethomunclass); +BUILDIN(sethomunlevel); BUILDIN(readparam2); BUILDIN(InstanceOwner); BUILDIN(aggravate); |