• 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!

Remove a stone when you kill a monster

Imfreezing

Krossa Kapitalismen
Joined
Jun 7, 2012
Messages
1,009
Solutions
1
Reaction score
88
Location
Edron
Hey otland I got this script, it is suppose to remove a stone when i kill a boss, well it doesn't
here is the script
Code:
local function moveStone(p)
    if isPlayer(getThingfromPos(p.stonePosition).uid) == TRUE then
        doMoveCreature(cid, 2)
    end
    doSendMagicEffect(p.stonePosition, 13)
    doCreateItem(p.stoneid, 1, p.stonePosition)
end

function onKill(cid, target)
    local timeLimit = 1000 * 60 * 2 -- Minutes
    local stonePosition = {x=1384, y=1806, z=9, stackpos=1}
    local stoneid = 7825
    local stone = getTileItemById(stonepos, stoneid)

    if stone.uid ~= 0 then
        doRemoveItem(stone.uid, 1)
        doSendMagicEffect(stonePosition, 13)
        addEvent(moveStone, timeLimit, {stonePosition = stonePosition, stoneid = stoneid})
    end

    return TRUE
end
and yep, i have it registred in the monster and in the creatureevent.xml
Error
:
qS-NLzfex.png

and
OEPPrb9dw.png

0.4 3777
thank you :D
 
I dont know much about 0.4

But why you have onDeath function shown in error and in the script you use onKill?
 
Really cant u read the Error on ur console log?
Ur monster says u have a event type = "death"
Us script dont have any onDeath, but onKill.
 
Post your monster file here please
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Souleater" nameDescription="a Souleater" race="venom" experience="900" speed="220" manacost="0">
<health now="455555" max="455555"/>
<look type="355" corpse="8593"/>
<targetchange interval="5000" chance="12"/>
<strategy attack="100" defense="0"/>
<flags>
<flag summonable="1"/>
<flag attackable="1"/>
<flag hostile="1"/>
<flag illusionable="1"/>
<flag convinceable="0"/>
<flag pushable="0"/>
<flag canpushitems="1"/>
<flag canpushcreatures="0"/>
<flag targetdistance="1"/>
<flag staticattack="90"/>
<flag runonhealth="0"/>
</flags>
<attacks>
<attack name="melee" interval="2000" skill="30" attack="360"/>
<attack name="poison" interval="1000" chance="12" range="1" radius="1" target="1" min="-2215" max="-3535">
<attribute key="areaEffect" value="fire"/>
</attack>
    <attack script="flamera/souleater/ice.lua" interval="4500" target="0" direction="1" chance="63" min="-1230" max="-2300">
    <attribute key="shootEffect" value="whirlwindsword"/>
    </attack>
        <attack script="flamera/souleater/fire.lua" interval="7500" target="1" range="0" chance="63" min="-2230" max="-2300">
    <attribute key="shootEffect" value="whirlwindsword"/>
    </attack>
        <attack script="flamera/souleater/fire2.lua" interval="4320" chance="30" length="8" spread="3" min="-3230" max="-4300">
    <attribute key="shootEffect" value="whirlwindsword"/>
    </attack>
</attacks>
    <defenses armor="25" defense="18">
        <defense name="healing" interval="1000" chance="13" min="3400" max="5006">
            <attribute key="areaEffect" value="blueshimmer"/>
        </defense>
    </defenses>
<elements>
<element physicalPercent="1"/>
<element holyPercent="1"/>
<element deathPercent="10"/>
<element firePercent="-1"/>
<element energyPercent="-1"/>
<element icePercent="15"/>
<element earthPercent="1"/>
</elements>
<immunities>
<immunity invisible="1"/>
</immunities>
<voices interval="5000" chance="10">
<voice sentence="Zrp zrp!"/>
</voices>
<script>
<event name="BossDeath"/>
<event name="souleater"/>
</script>
<loot>
<item id="2148" countmax="25" chance="36500"/><!-- gold coin -->
<item id="11365" chance="5000"/><!-- terramite legs -->
<item id="11364" chance="5000"/><!-- terramite eggs -->
<item id="11363" chance="1000"/><!-- terramite shell -->
</loot>
</monster>
 
You should add a script tag right after </flag> tag.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Souleater" nameDescription="a Souleater" race="venom" experience="900" speed="220" manacost="0">
<health now="455555" max="455555"/>
<look type="355" corpse="8593"/>
<targetchange interval="5000" chance="12"/>
<strategy attack="100" defense="0"/>
<flags>
<flag summonable="1"/>
<flag attackable="1"/>
<flag hostile="1"/>
<flag illusionable="1"/>
<flag convinceable="0"/>
<flag pushable="0"/>
<flag canpushitems="1"/>
<flag canpushcreatures="0"/>
<flag targetdistance="1"/>
<flag staticattack="90"/>
<flag runonhealth="0"/>
</flags>
<script>
<event name="BossDeath"/>
<event name="souleater"/>
</script>
<attacks>
<attack name="melee" interval="2000" skill="30" attack="360"/>
<attack name="poison" interval="1000" chance="12" range="1" radius="1" target="1" min="-2215" max="-3535">
<attribute key="areaEffect" value="fire"/>
</attack>
    <attack script="flamera/souleater/ice.lua" interval="4500" target="0" direction="1" chance="63" min="-1230" max="-2300">
    <attribute key="shootEffect" value="whirlwindsword"/>
    </attack>
        <attack script="flamera/souleater/fire.lua" interval="7500" target="1" range="0" chance="63" min="-2230" max="-2300">
    <attribute key="shootEffect" value="whirlwindsword"/>
    </attack>
        <attack script="flamera/souleater/fire2.lua" interval="4320" chance="30" length="8" spread="3" min="-3230" max="-4300">
    <attribute key="shootEffect" value="whirlwindsword"/>
    </attack>
</attacks>
    <defenses armor="25" defense="18">
        <defense name="healing" interval="1000" chance="13" min="3400" max="5006">
            <attribute key="areaEffect" value="blueshimmer"/>
        </defense>
    </defenses>
<elements>
<element physicalPercent="1"/>
<element holyPercent="1"/>
<element deathPercent="10"/>
<element firePercent="-1"/>
<element energyPercent="-1"/>
<element icePercent="15"/>
<element earthPercent="1"/>
</elements>
<immunities>
<immunity invisible="1"/>
</immunities>
<voices interval="5000" chance="10">
<voice sentence="Zrp zrp!"/>
</voices>

<loot>
<item id="2148" countmax="25" chance="36500"/><!-- gold coin -->
<item id="11365" chance="5000"/><!-- terramite legs -->
<item id="11364" chance="5000"/><!-- terramite eggs -->
<item id="11363" chance="1000"/><!-- terramite shell -->
</loot>
</monster>
 
You should add a script tag right after </flag> tag.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Souleater" nameDescription="a Souleater" race="venom" experience="900" speed="220" manacost="0">
<health now="455555" max="455555"/>
<look type="355" corpse="8593"/>
<targetchange interval="5000" chance="12"/>
<strategy attack="100" defense="0"/>
<flags>
<flag summonable="1"/>
<flag attackable="1"/>
<flag hostile="1"/>
<flag illusionable="1"/>
<flag convinceable="0"/>
<flag pushable="0"/>
<flag canpushitems="1"/>
<flag canpushcreatures="0"/>
<flag targetdistance="1"/>
<flag staticattack="90"/>
<flag runonhealth="0"/>
</flags>
<script>
<event name="BossDeath"/>
<event name="souleater"/>
</script>
<attacks>
<attack name="melee" interval="2000" skill="30" attack="360"/>
<attack name="poison" interval="1000" chance="12" range="1" radius="1" target="1" min="-2215" max="-3535">
<attribute key="areaEffect" value="fire"/>
</attack>
    <attack script="flamera/souleater/ice.lua" interval="4500" target="0" direction="1" chance="63" min="-1230" max="-2300">
    <attribute key="shootEffect" value="whirlwindsword"/>
    </attack>
        <attack script="flamera/souleater/fire.lua" interval="7500" target="1" range="0" chance="63" min="-2230" max="-2300">
    <attribute key="shootEffect" value="whirlwindsword"/>
    </attack>
        <attack script="flamera/souleater/fire2.lua" interval="4320" chance="30" length="8" spread="3" min="-3230" max="-4300">
    <attribute key="shootEffect" value="whirlwindsword"/>
    </attack>
</attacks>
    <defenses armor="25" defense="18">
        <defense name="healing" interval="1000" chance="13" min="3400" max="5006">
            <attribute key="areaEffect" value="blueshimmer"/>
        </defense>
    </defenses>
<elements>
<element physicalPercent="1"/>
<element holyPercent="1"/>
<element deathPercent="10"/>
<element firePercent="-1"/>
<element energyPercent="-1"/>
<element icePercent="15"/>
<element earthPercent="1"/>
</elements>
<immunities>
<immunity invisible="1"/>
</immunities>
<voices interval="5000" chance="10">
<voice sentence="Zrp zrp!"/>
</voices>

<loot>
<item id="2148" countmax="25" chance="36500"/><!-- gold coin -->
<item id="11365" chance="5000"/><!-- terramite legs -->
<item id="11364" chance="5000"/><!-- terramite eggs -->
<item id="11363" chance="1000"/><!-- terramite shell -->
</loot>
</monster>
Same problem :Z
 
Did you change the event on creatureevents? You need to declare your event on CreatureEvents, then you register it on the monsters u want to.
 
Did you change the event on creatureevents? You need to declare your event on CreatureEvents, then you register it on the monsters u want to.
Code:
    <event type="kill" name="souleater" event="script" value="souleater.lua"/>
you mean like this?
 
Yes, that what i mean. So now, if you are using TFS 1.X, the onKill function should be declared as
Code:
function onKill(player, target, lastHit)
and use target as ur creature identifier.

btw, im not sure if thats the way of achieving it. May you have to use onDeath, cause you register it in the creature, so you want this to happens when the monster dies, not when the monster kill.

You should make the function based on onDeath, i guess.
 
I would love to make the script for you, but you won't learn anything that way. So, here's an example I made a couple years ago that creates a teleport:

https://otland.net/threads/kill-a-monster-to-create-a-portal-with-optional-countdown.190235/

Use that brain and figure out how to remove a stone. ;) It's easier than it looks.
That's what i meant. You can reach it by onKill, by checking the monster name, and registering event on the players, or by onDeath, registering the event on the creature.
 
The script doesn't work at 0.4 3777 though :Z that's sad

@J.Dre It can't load function createpos.

Would love to figure out how to change from tp to remove stone, would be an fun task!
 
Last edited:
Back
Top