• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

[MOD] Friendly Animals - Friendly animals united against the zombie hordes!

Sweet. Though I'm curious, I thought TFP patch notes say that the zombies now fight back against the animals, but they don't seem to do so with this mod? Is that intended?

 
Sweet. Though I'm curious, I thought TFP patch notes say that the zombies now fight back against the animals, but they don't seem to do so with this mod? Is that intended?
I'm trying to fix animaltemplatehostile zombies so that they will seek out and attack the player. Right now in 3.0 it's broken. So here's the scoop on that. I'm trying to figure out this code:

Code:
	<property name="AITarget-2" value="BlockIf" data="condition=alert e 0"/>
<property name="AITarget-3" value="BlockingTargetTask"/>
I'm playing with it now to try to figure it out. What I think the behaviour should be is zombies don't seek to attack non-zombies, but will attack once attacked. My reasoning is:

  1. One non-zombie could stop a whole horde of zombies that seek them rather than continuing on towards the player, and that would be too game-breaking and powerful I think.
  2. It looks silly if zombies never fight back once attacked though, so I figure having them at least respond is fine. This way, single zombies in a horde will turn around and attack the non-zombie, but the rest of the zombie horde will continue forward possibly towards the player.


So I want zombies to seek the player, not other non-zombies, but respond to attacks (SetAsTargetIfHurt). It looks like the above code is the problem and is indeed causing some task/behaviours to be blocked such as making them not fight back when attacked, and preventing them from ever seeking out the player.

Once I got that corrected, I'll release 3.1.

 
I couldn't get

Code:
	<property name="AITarget-2" value="BlockIf" data="condition=alert e 0"/>
to stop throwing the error "Specified cast is not valid" so I gave up and removed that code, so now it's just:

Code:
		<property name="AITask-1" value="BreakBlock"/>
	<property name="AITask-2" value="DestroyArea"/>
	<property name="AITask-3" value="Territorial"/>
	<property name="AITask-4" value="ApproachDistraction"/>
	<property name="AITask-5" value="ApproachAndAttackTarget" data="class=EntityPlayer,0,EntityNPC,0"/>
	<property name="AITask-6" value="ApproachSpot"/>
	<property name="AITask-7" value="Look"/>
	<property name="AITask-8" value="Wander"/>
	<property name="AITarget-1" value="SetAsTargetIfHurt" data="class=EntityPlayer,EntityNPC,EntityAnimalStag"/>
	<property name="AITarget-2" value="BlockingTargetTask"/>
	<property name="AITarget-3" value="SetNearestEntityAsTarget" data="class=EntityPlayer,18,13,EntityAnimalStag,0,0"/>
The only problem is that I can't get zombies to attack back when being attacked by non-zombies. Even though "SetAsTargetIfHurt" contains "EntityAnimalStag" which is the class that non-zombies are, zombies won't fight back. If they're set in "ApproachAndAttackTarget" then, as THAT one suggests, zombies will approach and attack EntityAnimalStags. So there's no happy medium. Either zombies all-out attack non-zombies, or they completely ignore non-zombies even when non-zombies are attacking them which makes no sense. Maybe "SetAsTargetIfHurt" is bugged.

Regardless, this code fixes the bug where EntityEnemyAnimals won't attack the player like normal which is kind of game breaking, so I'm releasing it.

 
Friendly Animals 3.1 released!

Change Log:

3.1:

* Fixed bug preventing zombie bears, zombie vultures, and zombie dogs from attacking players.

* Zombies still not attacking back after being attacked by non-zombies other than the player as "SetAsTargetIfHurt" won't behave, but once that is figured out, that feature will return.

 
I think the EXP 152 that was release a couple days ago fixed the issue of zombies not attacking back, at least that's what their patch note says.

 
I think the EXP 152 that was release a couple days ago fixed the issue of zombies not attacking back, at least that's what their patch note says.
Nope, still won't attack back even in b152. Oh well!

 
It looks like they have a new code type since a17. Attackifhurt-animals,30,30 or something like that in the entityclasses.xml
There is no "attackif" in the latest entityclasses.xml, and instead this exists:

Code:
	<property name="AITarget-1" value="SetAsTargetIfHurt"/>
or

Code:
	<property name="AITarget-1" value="SetAsTargetIfHurt" data="class=EntityNPC,EntityPlayer"/>
FriendlyAnimals does this for all zombies:

Code:
	<property name="AITask-1" value="BreakBlock" />
<property name="AITask-2" value="DestroyArea" />
<property name="AITask-3" value="Territorial" />
<property name="AITask-4" value="ApproachDistraction" />
<property name="AITask-5" value="ApproachAndAttackTarget" data="class=[b][color="#FF0000"]EntityPlayer,0,EntityNPC,0[/color][/b]"><!--Attribute "data" replaced by: "Friendly Animals"--></property> <!-- class,maxChaseTime (return home) -->
<property name="AITask-6" value="ApproachSpot" />
<property name="AITask-7" value="Look" />
<property name="AITask-8" value="Wander" />
<property name="AITarget-1" value="SetAsTargetIfHurt" data="class=[b][color="#FF0000"]EntityPlayer,EntityNPC,EntityAnimalStag[/color][/b]"><!--Attribute "data" replaced by: "Friendly Animals"--></property>
<property name="AITarget-2" value="BlockingTargetTask" />
<property name="AITarget-3" value="SetNearestCorpseAsTarget" data="class=EntityPlayer" />
<property name="AITarget-4" value="SetNearestEntityAsTarget" data="class=[b][color="#FF0000"]EntityPlayer,0,0,EntityNPC,0,0,EntityAnimalStag,0,0[/color][/b]"><!--Attribute "data" replaced by: "Friendly Animals"--></property> <!-- class, hear distance, see dist (checked left to right, 0 dist uses entity default) -->
instead of the default:

Code:
	<property name="AITask-1" value="BreakBlock"/>
<property name="AITask-2" value="DestroyArea"/>
<property name="AITask-3" value="Territorial"/>
<property name="AITask-4" value="ApproachDistraction"/>
<property name="AITask-5" value="ApproachAndAttackTarget" data="class=[b][color="#FF0000"]EntityNPC,0,EntityEnemyAnimal,0,EntityPlayer,0[/color][/b]"/> <!-- class,maxChaseTime (return home) -->
<property name="AITask-6" value="ApproachSpot"/>
<property name="AITask-7" value="Look"/>
<property name="AITask-8" value="Wander"/>
<property name="AITarget-1" value="SetAsTargetIfHurt" data="class=[b][color="#FF0000"]EntityNPC,EntityEnemyAnimal,EntityPlayer[/color][/b]"/>
<property name="AITarget-2" value="BlockingTargetTask"/>
<property name="AITarget-3" value="SetNearestCorpseAsTarget" data="class=EntityPlayer"/>
<property name="AITarget-4" value="SetNearestEntityAsTarget" data="class=[b][color="#FF0000"]EntityPlayer,0,0,EntityNPC,0,0[/color][/b]"/> <!-- class, hear distance, see dist (checked left to right, 0 dist uses entity default) -->
This way, zombies won't attack "EntityEnemyAnimal" because they are zombies too, and this mod isn't zombie vs. zombie, it's zombie vs. living.

If I put "EntityAnimalStag" for "ApproachAndAttackTarget" too, then the zombies always will attack friendlies which isn't what I want since that means one coyote can attract and hold off an entire horde of zombies instead of only stopping one of the zombies by them turning and hitting back once attacked like I'm wanting. Not stopping any of them until this gets fixed is fine too though, but I just wish I knew if this was a bug in the game or a bug in my code!

 
Hmmm, that's interesting. Seems odd that if you are trying to make it "stag" that it seems to mean "anything", lol. I would assume that it's a bug on their end, especially if they are still having issues with zombies fighting back if attacked by wildlife.

Currently working on this to only have wolves and dire wolves friendly, everything else still hostile. More of wolves/humans vs everything (basically the same idea when wolves were first animal to be partners with humans to survive).

Also, I found a mod that allows you to summon huskies as well, so got me thinking on if it's possible to make it as a perk, and essentially turn that into being a pet. This way you can summon your own wolf to follow and fight with you, or maybe just be able to summon it like any other item that's static (campfire, forge, etc) and have it guard say a 10x10 block area where placed. Possibly both? One schematic for "war" wolf and one for "guard" wolf? I have a lot more that I want to do with it, but that alone would be cool and a starting point for full-blown pets.

Sadly I now have less time than I did at the beginning of the year, so less free time and rather play than research this atm :p

 
I could easily add more species to the game such as huskies if there is a mod out there which contains a husky entity. If that mod also had them spawning under special situations I could add that feature too if it fit properly with FA, but making them spawn randomly just like all other friendlies should be easy enough.

 
I just witnessed this morning, a zombie and a wolf were fighting (and the zombie actually won, too). Have you tried leaving the zombie AI at default?

(This was without the friendly animals modlet, btw.)

 
What you saw was the result of zombies seeking out EntityEnemyAnimal:

Code:
	<property name="AITask-5" value="ApproachAndAttackTarget" data="class=EntityNPC,0,EntityEnemyAnimal,0,EntityPlayer,0"/> <!-- class,maxChaseTime (return home) -->
I can easily replicate that behavior where zombies seek FAs like that, but again as I mentioned earlier in the thread, that means all zombies in a horde seeking FAs instead of the player which is game breaking as that makes it too easy.

 
Last edited by a moderator:
I could easily add more species to the game such as huskies if there is a mod out there which contains a husky entity. If that mod also had them spawning under special situations I could add that feature too if it fit properly with FA, but making them spawn randomly just like all other friendlies should be easy enough.
I've been curious since I saw a mod to summon a husky. Is it possible to have pets now?

  • Maybe bear (go strength or fortitude, tanky), wolf (maybe for perception, avg stats), mountain lion (say agility cause stealthy, more atk, lower hp).
  • Have it like a perk, so start weak at rank 1, stronger at rank 5, maybe add bleed or stuff as well. Of course make it like a craft-able idea (quality 1-5).
    I think it would be cool if you could have gear for it as well that could be crafted or found. I'd figure by making it work like mods would be best way for it to work.

[*]Maybe have it also be an inventory? If the pet dies, drop it's inventory in a bag for you to pick up, but you'd have to "craft" another.

[*]Only can use 1 at a time. So even though you can craft each kind, based on what you want to use at the time, once you use one, you can't use another till the other dies. This would be so you can't have tons to become op or to have more or less massive inventory

[*]Probably have it only attack something if you get hit, if you hit something, or if it gets hit, then it goes into an "attack" mode then just back to your side in a "passive" mode


This would just be the simplist way to do it. I would like more in-depth, but even this would be crazy and cool to have.

 
Last edited by a moderator:
You could do something like that yes. You can summon/spawn entities. I'm sure you could do it with a buff or item or like the HighHope Husky Friend Pet mod does makes them spawn from a quest. However, there is no new husky model as you'll see if you download it, they just summon a dire wolf.

As for a mod that would summon friendlies if you level up or maybe a certain skill/perk or whatnot would give you that ability, yeah that'd be cool I think. I think I'd have that be a side option or different mod, though. I'd probably like it to be a perk, and since you can't "cast spells" or use an ability off of a perk that you gain, my guess is you'd either need it to be a buff that would spawn a friendly now and then, or the ability to craft an item that would give you a buff and cause a spawn.

As for inventory, that'd require making them be an NPC I would imagine as I don't think there are clickable traits defined in entityclasses, so I don't know how easy to mod that would be.

As for staying by your side, no such logic exists to my knowledge so again not sure easy to mod that would be.

I can only mod what the game allows, so unless there are examples of that out there or some way to do it, you got me. HuskyPet just spawns a friendly wolf after you fulfil a "quest", that's it. Certainly cool though and something to perhaps include as an ability or something as an optional feature.

 
That's what I was thinking... so maybe it can be a perk, make it basically placed down like a bike or some such, then guard a certain area. could it basically just stay in a spot, if something comes within a 10 block range, it goes to attack, then after it is done, go back to where it was placed? have a bear that basically like a guardian for defense, wolf to do damage in said area as bear tanks the zombies (zombies go after bear as a higher priority), etc. I think that'd be an awesome "side pack" to go with this, hehe. Guard Pets for now. then expand as stuff changes.

as for the husky, I figured it was a wolf, they just called the mod that so I kept saying that for an easy find if went searching for it again :p . the wolf is better, personally, hehe. Btw, if I somehow get you the changes I did for wolves only as friends, could you help me with it... it keeps saying it can't find "extends animalWolf", so I'm a bit confused, lol. It looks correct though, and I made sure to not comment out anything that pertained to that, or at least I thought I did...

Also, since you have dug into this a lot more over the months than I've been able to :p , what does this mean "InvalidOperationException: Cannot call Invoke or BeginInvoke on a control until the window handle is created"... it randomly popped up on my startDedicatedServer.bat... frustrating

 
Last edited by a moderator:
BTW, can you make these things know to not run into spikes... a wolf literally is just walking into them and destroyed about 100 of my spikes I had set up for zombies... screwed me over bad... they actually are targeting the spikes...

update:: so i got around it by building a wall around my spikes. at least they don't target walls, lol.

 
Last edited by a moderator:
Not sure if this has been asked already, but do you have the knowledge of making a separate modlet that allows animals such as coyotes, wolves, and possibly dire wolves to be tamed, and then be able have them follow you and not despawn? Not sure how difficult this would be, but I'm sure there are multiple people who'd love to see this.

 
Not sure if this has been asked already, but do you have the knowledge of making a separate modlet that allows animals such as coyotes, wolves, and possibly dire wolves to be tamed, and then be able have them follow you and not despawn? Not sure how difficult this would be, but I'm sure there are multiple people who'd love to see this.
The follow code was removed a16 unfortunately. Dmt it would be possible but vanilla not so until tfp add npcs and bandits etc.

Making friendly animals is the best that vanilla can do atm. Where they won't attack you but attack other enemies of yours.

 
The follow code was removed a16 unfortunately. Dmt it would be possible but vanilla not so until tfp add npcs and bandits etc.
Making friendly animals is the best that vanilla can do atm. Where they won't attack you but attack other enemies of yours.
Well I'm not sure if SDX adds code to the game, so maybe that's an option. But there was code that allowed for tamable animals in A16? For what and why, if you know?

 
Back
Top