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

Monsters attack each other

AkaneTendo

New Member
Joined
Oct 27, 2016
Messages
2
Reaction score
0
Hello, i'm new at OTLAND :oops: <3

Also i ain't pretty good with english but i get the basics

I hope you guys can help me n_n

Issue: I'm making this project for a 8.6 OT but i want my monsters not to hit each other
Example: i made a annihilator with undead dragons instead of demons but they end up killing each other because of the physical waves, i don't want to make them inmune to physical so...

this is just one example, i want all my monsters to be inmune to other monsters, except ofc when it's being attacked by a summoned monster.


Thanks :p
 
Welcome to OtLand.

To do this you need to make a creaturescript with the function onCombat(cid, target)
in the function check if cid is & target is not a player. If both cid and target are not players return false
don't forget to register it in creaturescripts.xml & login.lua
after that you will need to register it to every monster you want it to work for using the <script> tag
Code:
<script>
    <event name="noFriendlyFire"/>
</script>
I personally like to put it right below </flag> but you can place it anywhere inside the xml file
note that event name must be the the same as you put in creaturescripts.xml & login.lua

In the future when you make a thread in the support or request board don't forget to add which engine you are using.
A bunch of people ignore threads where you don't add it.
 
Welcome to OtLand.

To do this you need to make a creaturescript with the function onCombat(cid, target)
in the function check if cid is & target is not a player. If both cid and target are not players return false
don't forget to register it in creaturescripts.xml & login.lua
after that you will need to register it to every monster you want it to work for using the <script> tag
Code:
<script>
    <event name="noFriendlyFire"/>
</script>
I personally like to put it right below </flag> but you can place it anywhere inside the xml file
note that event name must be the the same as you put in creaturescripts.xml & login.lua

In the future when you make a thread in the support or request board don't forget to add which engine you are using.
A bunch of people ignore threads where you don't add it.

Thanks a lot, it's fixed now!

:):):):):):):):)
 
So how it was fixed?? I need this script please, some like this?: [Not working]

Lua:
function onCombat(cid, target)
   if isPlayer(cid) and not isPlayer(target) then
   end
      return true
   end
 
So how it was fixed?? I need this script please, some like this?: [Not working]

Lua:
function onCombat(cid, target)
   if isPlayer(cid) and not isPlayer(target) then
   end
      return true
   end
Lua:
if isMonster(cid) and isMonster(target) then
    return false
end
 
Lua:
if isMonster(cid) and isMonster(target) then
    return false
end
Hello, thanks for answer Xeraphus, your script works the first part, also i have added the second part because the player don't make damage to monster and monster don't make damage to the player. [Working 100% tested]
Lua:
function onCombat(cid, target)
   if isMonster(target) and isMonster(cid) then
       return false
   elseif isMonster(target) and isPlayer(cid) then
       return true
   end
   return TRUE
end
 
Hello, thanks for answer Xeraphus, your script works the first part, also i have added the second part because the player don't make damage to monster and monster don't make damage to the player. [Working 100% tested]
Lua:
function onCombat(cid, target)
   if isMonster(target) and isMonster(cid) then
       return false
   elseif isMonster(target) and isPlayer(cid) then
       return true
   end
   return TRUE
end
that script doesn't make sense.
if you're returning true by default the only thing you need is the code i gave you to return false for monster->monster combat
any other combat will work
 
CreatureScripts:
Code:
<event type="statschange" name="noattack" event="script" value="noattack.lua"/>

Scripts:
Code:
function onStatsChange(cid, attacker, type, combat, value)
    -- This should block all damage monster cause on eachother expect player summons
    if isMonster(cid) and isMonster(attacker) then
        local master = getCreatureMaster(cid)
        if not master or not isPlayer(master) then
            return false
        end
    end

    return true
end

In monster, you dont want attack the other, put this line after </elements>
Code:
<script>
<event name="NAME"/>
</script>
For TFS 0.4
 
Back
Top