• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua [TFS 1.x] Registering creatureevents to monsters in XML

Glecko

Veteran OT User
Joined
Aug 21, 2007
Messages
1,054
Reaction score
270
Location
Spain
Hello again :)

I am currently experimenting with TFS 1.1, and I noticed that it is no longer possible to do this in the monsters XML files:

Code:
<script>
<event name="creature event 1"/>
<event name="creature event 2"/>
</script>

I noticed that it is possible to register a script in the first line of the XML, like this:

Code:
<monster name="Undead cavebear" nameDescription="a undead cavebear" race="undead" experience="595" speed="230" manacost="0" script="creature event 1">

However, as far as I can tell, this only allows to reference script files with creature events that are located in /monsters/scripts, and, most importantly, only the first script I declare seems to work (like, adding script="creature event 1" script="creature event 2" script="creature event 3" etc. won't work).

My question: Isn't it possible to register creature events to monsters through the XML file anymore? If yes, how? :P

Any information will be greatly appreciated :D
 
Nothing has changed, you are still able to register a script, and creature events to monsters through their XML file. There might have been a misconfiguration on your end.

Here is a sample:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<monster name="Rotworm" nameDescription="a rotworm" race="blood" experience="40" speed="150" manacost="305" script="someScriptName.lua">
    <health now="65" max="65" />
    <look type="26" corpse="5967" />
    <targetchange interval="4000" chance="0" />
    <flags>
        <flag summonable="0" />
        <flag attackable="1" />
        <flag hostile="1" />
        <flag illusionable="0" />
        <flag convinceable="1" />
        <flag pushable="0" />
        <flag canpushitems="0" />
        <flag canpushcreatures="0" />
        <flag targetdistance="1" />
        <flag staticattack="70" />
        <flag runonhealth="0" />
    </flags>
    <attacks>
        <attack name="melee" interval="2000" min="0" max="-40" />
    </attacks>
    <defenses armor="10" defense="10" />
    <loot>
        <item name="gold coin" countmax="17" chance="71760" />
        <item id="2376" chance="3000" /><!-- sword -->
        <item name="mace" chance="4500" />
        <item name="meat" chance="20000" />
        <item name="ham" chance="20120" />
        <item name="worm" countmax="3" chance="3000" />
        <item name="lump of dirt" chance="10000" />
    </loot>
    <script>
        <event name="someEventName" />
    </script>
</monster>
 
Nothing has changed, you are still able to register a script, and creature events to monsters through their XML file. There might have been a misconfiguration on your end.

Here is a sample:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<monster name="Rotworm" nameDescription="a rotworm" race="blood" experience="40" speed="150" manacost="305" script="someScriptName.lua">
    <health now="65" max="65" />
    <look type="26" corpse="5967" />
    <targetchange interval="4000" chance="0" />
    <flags>
        <flag summonable="0" />
        <flag attackable="1" />
        <flag hostile="1" />
        <flag illusionable="0" />
        <flag convinceable="1" />
        <flag pushable="0" />
        <flag canpushitems="0" />
        <flag canpushcreatures="0" />
        <flag targetdistance="1" />
        <flag staticattack="70" />
        <flag runonhealth="0" />
    </flags>
    <attacks>
        <attack name="melee" interval="2000" min="0" max="-40" />
    </attacks>
    <defenses armor="10" defense="10" />
    <loot>
        <item name="gold coin" countmax="17" chance="71760" />
        <item id="2376" chance="3000" /><!-- sword -->
        <item name="mace" chance="4500" />
        <item name="meat" chance="20000" />
        <item name="ham" chance="20120" />
        <item name="worm" countmax="3" chance="3000" />
        <item name="lump of dirt" chance="10000" />
    </loot>
    <script>
        <event name="someEventName" />
    </script>
</monster>

Oh I just discovered what the problem was! While in TFS 0.4 it was possible to do this:

Code:
<script>
<event name="event 1"/>
</script>
<script>
<event name="event 2"/>
</script>

In TFS 1.x this is no longer possible, only the first "script" child is read for creature events (which makes a lot of sense haha). Thanks a lot! :)
 
Back
Top