Modding monster to make monster friendly to player

I have been having difficulty with creating a faction of monsters that is friendly towards the player, yet still openly hostile towards other factions. I could either set the aggression to 0, and have this group of monsters attack nobody (including enemies that attack them), or I could set the aggression above 0. If aggression is above 0, then the monsters from the supposedly friendly faction will attack me on sight.

I’ve tried to add the “player” faction as a friendly faction towards this group of monsters, yet the attacks still persist. Is there a particular flag or spawning method that I’m missing for this group, or is something else amiss?

Did you add "friendly": [ "player"] to the monster’s faction? That should be enough to work, but there might be some hardcoded player-specific weirdness still going on under the hood.

Aggression needs to tick up to 10 by anger triggers to flip a mob to hostile. Check out from the docs, I updated it recently to make it a bit clearer how those work.

I tried using this coding format

“name”: “ban_guard”,
“friendly”: [ “small_animal”, “ban_guard”, “player” ]

and set their aggression to 5, yet they still attack me. If I make the aggression number negative, then they don’t seem to attack anything, even when their own faction is attacked.

Upon more testing, it seems as though these monsters do fight back, but only after getting repeatedly attacked time and time again. Does suffering from repeated attacks increase aggression threshold towards a faction, or is the entire thing a fixed rate?

That depends on their anger triggers. HURT.increments proportional to damage done, PLAYER_CLOSE always ticks by 5 etc.
They don’t have any faction memory, the moment they flip to hostile they start attacking all critters without friendly/neutral faction relation to them.
You could try settinf their aggression to 100 and see if they attack small animals, if they don’t then the player relations get overwritten by aggression (hopefully that’s not the case, but I haven’t tested that yet), if they attack then something is wrong with your faction or monster definition since there are functioning “friendly” factions in game.

Hm, did you recheck in the monster definition if the "default_faction" is set to the right value? It might be just a small typo (like assigning “ban_guards” instead of “ban_guard”).

Also, the self reference in the faction is not needed - a faction is always friendly towards itself. I don’t think that this screws it up, but you might want to remove it just to be sure.

Upon your suggestion, I tested to see if the monsters would attack small animals while they had an aggression value of 100. Much to my own surprise, they did not attack small animals, but still attacked the player when they came into view of the monster. So it seems as though the friendly tag works for other factions, but not for a defined player faction?

That’s…unfortunate. If you don’t mind doing some more !science!!! could you check if they attack chicken you tamed? If they attack them then the problem is player faction-specific (I don’t think that’s the case, but it will be a while before I can poke at it myself), if they stay friendly to them but attack you it’s player character-specific - in that case the implementation of monster factions doesn’t overwrite their basic morale stuff.

Just for clarification, I’m using the last stable version of the game, version 0.E-3. I didn’t want to try modding on more experimental versions due to changes that could occur in the base game. Do you think the issue has to do with the version I’m using?

Unlikely, but possible.

Could you post the monster definition so we can take a closer look?

“type”: “MONSTER”,
“id”: “mon_normal_guard”,
“name”: “Normal Guard”,
“default_faction”: “ban_guard”,
“symbol”: “S”,
“color”: “blue”,
“volume”: “52500 ml”,
“weight”: 61500,
“material”: “flesh”,
“diff”: 20,
“aggression”: 100,
“morale”: 100,
“regen_morale”: true,
“speed”: 125,
“melee_skill”: 4,
“melee_dice”: 2,
“melee_dice_sides”: 6,
“melee_cut”: 5,
“dodge”: 4,
“armor_bash”: 5,
“armor_cut”: 12,
“armor_stab”: 5,
“armor_acid”: 2,
“vision_day”: 35,
“vision_night”: 30,
“death_drops”: { “subtype”: “collection”, “groups”: [ [ “itemdrop_guard”, 100 ] ] },
“hp”: 65,
“death_function”: [ “NORMAL” ],
“special_attacks”: [
“type”: “gun”,
“cooldown”: 4,
“gun_type”: “m249”,
“ammo_type”: “223”,
“max_ammo”: 100,
“fake_str”: 4,
“fake_dex”: 3,
“fake_per”: 3,
“fake_int”: 1,
“fake_skills”: [ [ “gun”, 4 ], [ “rifle”, 3 ] ],
“move_cost”: 150,
“targeting_cost”: 120,
“targeting_volume”: 20,
“ranges”: [ [ 4, 17, “DEFAULT” ], [ 3, 17, “BURST” ], [ 4, 20, “AUTO” ] ],
“require_targeting_player”: true,
“require_targeting_npc”: true,
“require_targeting_monster”: true,
“description”: “CRACK!!”,
“no_ammo_sound”: “chk!”
“starting_ammo”: { “223”: 150 },
“description”: “Deployed to the New England from a far-off place, guards are one of a few welcome sights. They are fast enough to cut down most assailants and monsters with ease, and are generally friendly.”,
“flags”: [
“anger_triggers”: [ “HURT”, “FRIEND_ATTACKED”, “FRIEND_DIED” ],
“fear_triggers”: [ “FIRE” ],
“placate_triggers”: [ “PLAYER_WEAK”, “SOUND”, “MEAT” ],
“categories”: [ “CLASSIC” ]

And the faction identity for further clarification:

“name”: “ban_guard”,
“neutral”: [ “cop_bot”, “military”, “utility_bot”, “science”, “small_animal”, “player” ]

might need a bit more detail on what you’re planning to do here
what faction are you thinking about?

A group of guards that will be neutral or friendly towards the player, but vigorously attack all other factions besides small animals. I can get their aggression low enough to not attack the player, but then they seemingly don’t attack anything at all.