• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.
Resource icon

[TFS 1.X] Monsters fighting each other (monster vs. monster)

Unknown Soldier

Mapping a map
Premium User
Joined
Oct 30, 2010
Messages
365
Solutions
14
Reaction score
850
Unknown Soldier submitted a new resource:

[TFS 1.X] Monsters fighting each other (monster vs. monster) - Monsters fighting each other (monster vs. monster)

Hello,

out of curiosity I made a script that allows monsters to fight other monsters, it is fully lua, and has seweral drawbacks, in general it shouldn't be used to some more complex fights, rather to make some tiny addition to the game, like making an orc kill a pig. Whatever.

So the drawbacks are: monsters don't use their xml/lua specified attacks and spells, they just damage each other with doTargetCombatHealth(). They ignore any resistances and thigns like that. They fight each other...

Read more about this resource...
 
I think it could be done with changes in Monster::isOpponent:
Maybe add some callback to Lua event to check, if given creature is an opponent.
That way you could define in data/events/scripts/monster.lua that Pig is opponent of Orc:
LUA:
function Monster:isOpponent(self, creature)
  if self:getName() == 'Orc' and Monster(creature) and creature:getName() == 'Pig' then
    return true
  end

  return false
end
Of course calling some Lua event everytime any creature enters "view range" of any other monster would heavily increase CPU usage, but it's code for some custom OTSes, not typical RL map/evo OTS.
 
I think it could be done with changes in Monster::isOpponent:
Maybe add some callback to Lua event to check, if given creature is an opponent.
That way you could define in data/events/scripts/monster.lua that Pig is opponent of Orc:
LUA:
function Monster:isOpponent(self, creature)
  if self:getName() == 'Orc' and Monster(creature) and creature:getName() == 'Pig' then
    return true
  end

  return false
end
Of course calling some Lua event everytime any creature enters "view range" of any other monster would heavily increase CPU usage, but it's code for some custom OTSes, not typical RL map/evo OTS.
Thats deffinitely things to use in small amounts to avoid performance troubles. Your solution looks way better, just learned something new, thanks!
 
I've been busy with this as well, its something I find so immersive in any game, where certain creatures may attack one another, this small change brings so much immersion into the game.

I will play around with the script and upload my version here if correct, good job!
I eventually want it to be working on "races" so that different races may attack one another.

Again good work on making a OTS better with immersive features
 
Back
Top