summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/emap/init.c2
-rw-r--r--src/emap/script_buildins.c72
-rw-r--r--src/emap/script_buildins.h2
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);