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

Monster Passive Monsters

Marcelo Druida

Intermediate OT User
Joined
Nov 17, 2014
Messages
429
Solutions
1
Reaction score
134
Location
Brazil
Hello!


Require:
TFS 1.x
https://otland.net/threads/monster-onselecttarget-self-target.234915/


Passive monster:
Code:
function onSelectTarget(self, target)
    if target:getTarget() == self then
        return true
    end  
    return false
end


Monster that attack only strong players
Code:
function onSelectTarget(self, target)
    if target:getLevel() >= 100 then
        return true
    end  
    return false
end

Create a lua file in data/monster/scripts
Insert into monster XML after manacost
script="file.lua"

Enjoy!
 
Last edited:
Could you post the code on the forum here because on the other site it is in another language and you need to login in order to view the content.

Also this could have been written as
Code:
function onSelectTarget(self, target, level)
    if level then
        return (target:getLevel() >= level)
    end
    return (target:getTarget() == self) 
end
 
fixed the link

Please visit the page to understand the function.
You cant do that unless you insert this param in the callback
 
Last edited:
For Area Spells Add:

Code:
local damageMap = self:getDamageMap()
   for creatureId, damage in pairs(damageMap) do
  local thing = Creature(creatureId)
   if target == thing or master ==  thing then
   return true
   end
 
Works Perfectly, nice Tutorial, Very complete =) thx for sharing! you are awsome ;p saved me a lot of time :D <3
 
Back
Top