SphereCommunity
Npcs attacking each other - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: Npcs attacking each other (/Thread-Npcs-attacking-each-other)



Npcs attacking each other - Gil Amarth - 09-24-2014 02:09 AM

I´m thinking about a faction system that allow npcs player attack other npcs, even if there is no player near around.

I had used till now the @NpcSeeNewTrigger to see if there is any enemy nearby, but this is a bit expensive if every npc has to trigger that script every 5 seconds.

What trigger or system would you use to attack npcs with one specified Tag:

For example, how to attack every npc who has TAG.Faction not equal the npc TAG.Faction,
and in a cheap way of course. Tongue

Thanks in advance.


RE: Npcs attacking each other - Skul - 09-24-2014 03:46 AM

best option i can provide is a timerf function that loops every minute or two, example:
Code:
[function f_faction_npcattack]
local.uid=<uid>
forchars <serv.distancetalk>
  if (<npc>)
    if (<tag0.faction>)
      uid.<local.uid>.attack=<uid>
      break
    endif
  endif
endfor
timerf 60, f_faction_npcattack
You can chance the interval of timerf to a higher amount to use less resources.


RE: Npcs attacking each other - Gil Amarth - 09-24-2014 05:05 PM

Finally I did it with @NPCLookAtChar trigger.

This trigger fires a lot, but it fires every time a npc look other npc, so it is pretty fast in combat situations. But cheap... it is not cheap in resources. Smile