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

Any way to make monster stop following player?

Baneczek

うさちゃん
Joined
Nov 13, 2013
Messages
70
Reaction score
4
Location
Pila, Poland
Hello guys.
I need some help with a creaturescript.
I have a script that allows player attack a monster ONLY when the player has required storage value.
The same is with the monster, When player has different storage value than required monster won't attack the player.
The problem i need to fix is, the monster won't attack the player, and player can't attack the monster, but even when player has different storage value than required, monster still follows him (not attacks). I tried to do it with doCreatureSetNoMove(cid, 1) but it doesn't work. Is there any way to change it?

EDIT: It's TFS 0.3.6pl1

EDIT2: Here is monster.xml file
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Mutated Demon" nameDescription="a Mutated Demon" race="blood" experience="0" speed="250" manacost="290">
<health now="6000" max="6000"/>
<look type="160" corpse="2836"/>
<targetchange interval="2000" chance="0"/>
<strategy attack="100" defense="0"/>
<flags>
<flag summonable="1"/>
<flag attackable="1"/>
<flag hostile="1"/>
<flag illusionable="1"/>
<flag convinceable="1"/>
<flag pushable="1"/>
<flag canpushitems="0"/>
<flag canpushcreatures="0"/>
<flag targetdistance="1"/>
<flag staticattack="90"/>
<flag runonhealth="5"/>
</flags>
<script>
    <event name="MutatedDemonCombat"/>
</script>
<attacks>
<attack name="melee" interval="2000" min="-4000" max="-9000"/>

</attacks>
<defenses armor="50" defense="0"/>
<voices interval="2000" chance="10">

</voices>
<loot>
</loot>

</monster>

And here is the creaturescript
Code:
local monster = 'Mutated Demon'
local stor = 8000

function onCombat(cid, target)
    if (isPlayer(cid)) then
        if (isMonster(target) and (getCreatureName(target) == monster and (getPlayerStorageValue(cid, stor) ~= 2))) then return false end
    elseif (isMonster(cid)) then
        if (isPlayer(target) and (getPlayerStorageValue(target, stor) ~= 2)) then doCreatureSetNoMove(cid, 1) return false end
    end
  
    return true
end

function onKill(cid, target)
    if isMonster(target) and getCreatureName(target) == monster and getPlayerStorageValue(cid, stor) == 2 then
        setPlayerStorageValue(cid, stor, 3)
    end
  
    return true
end
 
Last edited:
im no good with TFS 0.3.6, but people who are would still like to see the "monsterName".xml file (if its anything similar to TFS 1.0 maybe i know whats the issue)
 
im no good with TFS 0.3.6, but people who are would still like to see the "monsterName".xml file (if its anything similar to TFS 1.0 maybe i know whats the issue)
I edited the post, you can check if it's similar (i don't really think it is, but still would be great if you could check it)
 
<flag hostile="1"/>
<flag targetdistance="1"/>

Combination of these flags will make it so that monster will attack you in the distance of 1.
But finally when monster reaches you, the script will make it so that he wont attack you. But since his stupit he tries to attack you again.. and scrpt again says "DONT ATTACK THIS DUDE". a cycle what a poor monster cant break free from.

If you change hostile="0"
Does it work on TFS 0.3.6?

Else there should be some way to make monsters ignore players like NPC's but i have no idea how do that.

When you change targetDistance, it will still make him follow you but he wont be at your face.
If you make him runOnHealth (max hp creature has) then creature will always run away.

And last.
Change monster with NPC with same name and look.
And when something should happen (creature attacks or not attacks or creature is attacked and he should do something)
Remove the NPC and replace it with original monster (hope you understood what i just said xD)
 
It looks like this now, i also added event into monster.xml file. He still follows me, but doesn't attack.
Changing hostile to 0 also changes nothing.
Code:
function onCombat(cid, target)
    if (isPlayer(cid)) then
        if (isMonster(target) and (getCreatureName(target) == monster and (getPlayerStorageValue(cid, stor) ~= 2))) then return false end
    elseif (isMonster(cid)) then
        if (isPlayer(target) and (getPlayerStorageValue(target, stor) ~= 2)) then doCreatureSetNoMove(cid,1) return false end
    end
 
    return true
end

function onKill(cid, target)
    if isMonster(target) and getCreatureName(target) == monster and getPlayerStorageValue(cid, stor) == 2 then
        setPlayerStorageValue(cid, stor, 3)
    end
 
    return true
end

function onTarget(cid, target)
    if (isPlayer(cid)) then
        if (isMonster(target) and (getCreatureName(target) == monster and (getPlayerStorageValue(cid, stor) ~= 2))) then return false end
    elseif (isMonster(cid)) then
        if (isPlayer(target) and (getPlayerStorageValue(target, stor) ~= 2)) then doCreatureSetNoMove(cid,1) return false end
    end
 
    return true
end

EDIT: Tried with doCreatureSetNoMove(cid,1) and without doCreatureSetNoMove(cid,1), changes nothing.

EDIT 2: Sorry, but i also didn't get what you meant here:
And last.
Change monster with NPC with same name and look.
And when something should happen (creature attacks or not attacks or creature is attacked and he should do something)
Remove the NPC and replace it with original monster (hope you understood what i just said xD)
 
Last edited:
Isn't there a possibility to make it w/out source editing? Sadly, i don't have source for my OT.
EDIT: Sorry, i already have hostile in my monster.xml. That was really stupid question.
 
he says how to do it without sourceedit xD

sadly i dont have example scripts, because this issue is not critical and simply in my Todo list.
 
Back
Top