Jump to content

How to have both neutral mobs and monsters aggressive to character?


Recommended Posts

unfortunately, it looks like spider's targeting ignores anything with the tag "monster."

Unless you wanted to try some weird method of flipping the monster tag on/off every 1 second, since they check their surroundings every 1 second, I can't think of an easy way to keep natural agro against both spiders and pigs at the same time. Unless you mod the spiders themselves too and alter their targeting behavior

Link to comment
Share on other sites

To be honest I am surprised the spiders findtarget code specifies monster and not spider/spiderwhisperer tags to exclude.

That would explain why spiders seem to always be the first victims in the spider wars against tentacles and merms.

Considering hounds for example specify {hounds, houndfriend, houndmound and walls} as their target exclusion

It feels like a hindsight that could easily be rectified by the devs.

Other than what pickleplayer suggested which seems to be the simplest or least intrusive options.
One option is you can suggest yourself as a target if they don't have one via a periodic task instead. Kind of like a bait mechanic I used for a hat.
It does have the side effect of making you the number one target in most circumstances.

Link to comment
Share on other sites

6 minutes ago, IronHunter said:

It does have the side effect of making you the number one target in most circumstances.

The character in question is written to be an instigator to keep his friends safe during fights. Your method seems to fit the bill. Mind if I see the hat you mentioned?

Link to comment
Share on other sites

--"This is the basic gist of the code, it is modified to be used for a player character rather than a hat."
--"Every 3 seconds I scan for all prefabs in a 12 unit radius about 3 pitchfork tiles, and find all entities with the combat component. Except for shadow creatures"
--"I then check if they have the follower component is on them and if they are currently following somebody if they are we don't suggest us as a target."
--"It is easy to modify however you like"
if not inst.aggro_task then
  inst.aggro_task = inst:DoPeriodicTask(3, function()
      local x,y,z = inst.Transform:GetWorldPosition()
      --TheSim:FindEntities(x, y, z, radius, musttags, canttags, mustoneoftags)
      for k, v in pairs(TheSim:FindEntities(x, y, z, 12, {"_combat"}, {"shadow", "player","INLIMBO"})) do
        if not (v.components.follower and v.components.follower:GetLeader())then
          v.components.combat:SuggestTarget(inst)--"could also use SetTarget to force them to target us, suggest means if they aren't targeting something already we will become their target."
        end
      end
    end)
end
--"To disable the task"
if inst.aggro_task then
  inst.aggro_task:Cancel()
  inst.aggro_task = nil
end

This is pretty much the code, simplified so it can be easily adapted to w.e. you want it to draw aggro from etc.

Link to comment
Share on other sites

This code is meant to work in your characters prefab file. No additional tags are neccesary, it is simplified for legibility, so it is easier to tweak existing variables like the interval or radius.

Also you can't just copy paste this as is. You will need to place the code properly in an area to call them.

A easy way of enabling it is placing them in the onbecomehuman and onbecomeghost sections of the template. Or some other method to toggle this feature on and off like equipping or unequipping a hat. Read the comments as there are two seperate pieces of code.

Edited by IronHunter
Typographical errors
Link to comment
Share on other sites

On 12/22/2018 at 6:40 AM, IronHunter said:

A easy way of enabling it is placing them in the onbecomehuman and onbecomeghost sections of the template.

Now the whole world hates my character's guts. Neat. Though, I don't want beefs and cats going after him when he shows up. Anything I can do to have that not happen? I'll try to root around for the answers on my own in the mean time.

Nevermind, did it. Thanks for making it easy.

Link to comment
Share on other sites

Add your own if statements to exclude or include mobs by prefabs/tags however you like. This is just a simple template to start from.

Edit:

I don't have access to the code at this time but their is probably a tag like animal or something that might be used by most passive large mobs.

Edited by IronHunter
See above
Link to comment
Share on other sites

On 12/23/2018 at 6:40 PM, IronHunter said:

Add your own if statements to exclude or include mobs by prefabs/tags however you like. This is just a simple template to start from.

Edit:

I don't have access to the code at this time but their is probably a tag like animal or something that might be used by most passive large mobs.

20190307200426_1.thumb.jpg.42370ca6ff62f9a8d2a7544f03546a0d.jpg

Yer code's so good, Winona's catapult already hates my character. Doesn't hurt him though. 'Less PvP is on, I guess.

I'm definitely am going to keep it like that.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...