rschurade / Ingnomia

GNU Affero General Public License v3.0
240 stars 47 forks source link

Homicidal military kills all farm animals including the cat and dog. #146

Open comaldave opened 3 years ago

comaldave commented 3 years ago

Expected behaviour

Rancher put animals in the pasture while military eliminates threats

Bad behaviour

The military went on a rampage and killed all farm animals.

rschurade commented 3 years ago

You paying them enough?

Ext3h commented 3 years ago

Are you sure they haven't been set to "Attack" behavior? That has been (at last) enabled with the last update, so squads which had been primed did not do their job previously.

If you mean to say that they also killed animals which already were assigned to a pasture, that would be unintended.

Mind that an animal might be on a pasture (but not belong to it), or have escaped a pasture, but still is assigned to it.

comaldave commented 3 years ago

Well, this was a brand new start, the game was unpaused, so no animals were in the pasture. My current workaround is to not form squads until the animals are pastured. At Sierra Online we would not classify this as a bug, but rather an undocumented feature.

Ext3h commented 3 years ago

We will need to make sure that squads are initially configured as "passive".

rschurade commented 3 years ago

Don't like that solution. The problem here and question in general is should the military be able to attack and kill non-aggressive and farm animals.

Ext3h commented 3 years ago

Yes, must be able to as they can as well count as pests (think exploded chicken farms etc., something apparently every player is bound to encounter eventually).

Just must not do that as default, and just double check we don't kill tame animals.

comaldave commented 3 years ago

I have never had an exploding chicken farm but then again I always set a limit of three roosters.

We could perhaps have an open hunting season for select animals that become a pest. Check Wild chickens and the guards will kill the wild chickens, but only if it is open season.

With Gnomoria, I would put my extra bulls at the entrance early in the game, they would sometimes take out one or two of the goblins while my security was getting organized.

CptVolkow commented 3 years ago

At first they assaulted a crowded pasture, went from +5 over limit to 0/22 They stacked on one spot and killed everything Screenshot 2021-01-13 165903

After that they would occasionally kill on mass strays from a open pasture Stretchleopard.zip

Ext3h commented 3 years ago

That's a bug in the "defend" behavior then. It's currently implemented as "attack targets if they can be reached without moving", but is lacking the prerequisite that the target should be hostile.

condac commented 3 years ago

I have this behavoir also, Have some cows and all of the sudden my squad that i set up with default "defend" settings started to kill all cows.

gloowa commented 2 years ago

I believe this problem is caused in

https://github.com/rschurade/Ingnomia/blob/f578cf47d63e45f195b012dc64472ba4485d9a5d/src/game/gnomeconditions.cpp#L303-L306

It seems that the only condition to attack when DEFEND option is selected is dist < 4. No checks on target hostility are made. Perhaps someone can figure something out here (add additional check to see if target is attacking another gnome or something).

[EDIT] Perhaps a simple solution/temporary workaround would be to add a new option IGNORE, which would simply always return BT_RESULT::FAILURE?

Ext3h commented 2 years ago

MilAttitude::FLEE is effectively that IGNORE option.

This logic here is missing the concept of "aggression" in general. The idea was to extend the instance of each monsters with a flag of "creature classes it's hostile to", defined by having attempted at least a single attack at that class or having received one. Without that logic, there is nothing which would define a creature as hostile at all. Aggression is part of the behavior tree after all.

gloowa commented 2 years ago

I think more robust solution would be to have to consist of sort of factions (fox faction, goblin faction, cow faction, tamed animals faction) and 2 types of agression

1) I don't know how to name it, but sort of "political stance": for instance, goblin faction should be understood as being hostile to all gnome faction and tamed animals faction, etc

2) Active hostility: whenever any actor (monster, goblin, etc) is engaging another in combat, they should mark themselves as being in combat with its target. Then other actors could do stuff like check both engaged actors and their faction, and then based on relation of actor's own faction and its relation to the factions of parties involved in combat choose to ignore, or join the combat on either side. Or to engage both sides i guess.

It would also allow for differentiation on behaviour based on just encountering hostile actor or encountering hostile actor that is in combat with friendly/allied actor etc.

Ext3h commented 2 years ago

@gloowa Take a look at https://github.com/rschurade/Ingnomia/projects/4 , future AI improvements are being planed over there.

Factions are superseded by that per-species stance system as is.

Active hostility is what we actually need to be able to implement a "defend" option. I expect it makes most sense to flag the attacker as hostile towards the entire target species (counter with decay, not just boolean). In that case, "being flagged at all" makes you eligible to be counter-attacked from the Defend stance.

Having a higher counter opens up more options in the behavior tree.

gloowa commented 2 years ago

Oh, i haven't checked the projects page. What is described there, is pretty much what i had in mind, just expressed way better.

That looks awesome, i will be anticipating the changes.