From 1c6f15feae59ae309033c46e722dcd620e3be48a Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Tue, 13 Jul 2021 00:01:46 -0300 Subject: New NPC Utility: spawndummy() - Spawns a monster without params for script use. It returns the spawned monster GID so setunitdata() can configure it properly --- npc/functions/main.txt | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/npc/functions/main.txt b/npc/functions/main.txt index 4a0c9c22..bf69551e 100644 --- a/npc/functions/main.txt +++ b/npc/functions/main.txt @@ -748,3 +748,37 @@ function script learnskill { return; } +function script spawndummy { + // spawndummy(map, x, y, ID{, name{, event}}) + .@m$=getarg(0); + .@x=getarg(1); + .@y=getarg(2); + .@id=getarg(3); + .@n$=getarg(4, strmobinfo(1, .@id)); + .@e$=getarg(5, ""); + // Create monster, with optional event + if (.@e$ == "") + .@u=monster(.@m$, .@x, .@y, .@n$, .@id, 1); + else + .@u=monster(.@m$, .@x, .@y, .@n$, .@id, 1, .@e$); + // Reset unit data for script use + setunitdata(.@u, UDT_LEVEL, 1); + setunitdata(.@u, UDT_HP, 1); + setunitdata(.@u, UDT_MAXHP, 1); + setunitdata(.@u, UDT_SP, 1); + setunitdata(.@u, UDT_MAXSP, 1); + setunitdata(.@u, UDT_MODE, 0); // Stoic mode + setunitdata(.@u, UDT_ATKRANGE, 1); + setunitdata(.@u, UDT_ATKMIN, 1); + setunitdata(.@u, UDT_ATKMAX, 1); + setunitdata(.@u, UDT_MATKMIN, 1); + setunitdata(.@u, UDT_MATKMAX, 1); + setunitdata(.@u, UDT_DEF, 1); + setunitdata(.@u, UDT_MDEF, 1); + setunitdata(.@u, UDT_HIT, 1); + setunitdata(.@u, UDT_FLEE, 1); + setunitdata(.@u, UDT_CRIT, 1); + setunitdata(.@u, UDT_LOOKDIR, DOWN); + return .@u; +} + -- cgit v1.2.3-60-g2f50