# Tame Guild Wars
### Created by WackyMole and Meldurson

 </br>

![Tamed Wolf](https://wackymole.com/hosts/guardWolf.png)

 </br>

**Tame Guild Wars** is a mod for Valheim that integrates with the Guilds mod and API to create dynamic tamed mob factions. By assigning tamed creatures to your guild's faction, you can coordinate large-scale mob battles, defend your territory, and conquer your enemies! </br>
This mod has been crafted by us with performance in mind and hope that you battle with and against your friends to victory for your guild! We hope to have good intergration with all of Meldursons other mods and perhaps some Wards mods to create real guild fights. 


## Recommended Additional Mods
https://thunderstore.io/c/valheim/p/Meldurson/LetMeTameYou/ — Allows you to tame pretty much all of the mobs. Perfect for expanding your guild's forces with unique creatures! </br>
https://thunderstore.io/c/valheim/p/Meldurson/TamingTools/ — Provides additional tools, potions, foods for taming.  </br>
https://thunderstore.io/c/valheim/p/Meldurson/PortablePals/ — Lets you carry a tamed mob in a portable container. (API integration for tamed guild support!) </br>

Less Recommended but still fun:
https://thunderstore.io/c/valheim/p/OdinPlus/TeleportEverything/ — Teleport your tamed mobs around the world to wherever you need them!

## Core Features

- **Faction-Based Combat**: Tamed mobs assigned to opposing factions will actively seek out and fight each other.
- **Cooperative Allies**: Mobs within the same faction will work together, protecting each other and ignoring friendly fire.
- **Player Interaction**: Mobs will target players from opposing factions while completely ignoring players within their own faction.
- **Visual Feedback**: Hover text color-codes your relationship with tamed mobs, shows the original tamer, and can display guild icons on enemy HUD nameplates. See the color code quick reference below.
- **Neutrality Mechanics**: Players not affiliated with any faction are treated as neutral. However, if a neutral player attacks a faction mob, that mob (and its nearby allies) will turn aggressive.
- **Command & Control**: Claim unowned tames for your guild using `Alt + E`. Cycle their defensive stances using `Alt + E`. Owners can **Lock** a mob's current stance using `Ctrl + E`, preventing anyone (including guild mates) from changing its orders until obedience runs out or it is unlocked. Pressing `E` alone safely pets the creature without disrupting their assigned orders. Provide bulk stance orders using `guild_order [stance] [radius]` in the console. 
- **Admin Skip Decay**: Admins can use `O + E` to toggle **Skip Obedience Decay** for a specific mob. This allows for permanent guard mobs in special locations like hubs or arenas.
- **Static Stance**: A **Static** stance has been added, which completely freezes the mob's AI, making it immobile—ideal for statuesque guardians or display pets.
- **Guild Allies (Request Flow)**: Alliances use a request/confirm flow. Use `guild_ally add [NameOrGuild]` to send a request, then the receiving side can `accept` or `deny` from command or popup. Your guild's mobs will not attack accepted allies. If an allied player/guild attacks, the alliance is broken immediately.
- **Shared Chat Announcements**: High-value guild mob deaths are announced in the owning guild's `/g` guild chat. Alliance formed and broken events are announced in global shout chat.
- **Obedience Mechanics**: Tames require you to maintain presence. Their obedience drops faster if non-guild members are near and no friendly members are around, and drops massively if the owner leaves their guild. If obedience reaches 0, they remain tamed but stop defending, stop following guild combat orders, and will not accept new orders until obedience recovers. These decay values are configurable.
- **Confusion Bombs**: The mod introduces craftable `Confusion Bomb I/II/III` items. Tossing one into a pack of tamed mobs applies a Confusion status (random percentage per blast). If a mob's confusion exceeds 50%, they will turn purple, break formation, and randomly attack anything nearby (or run away in panic) until the effect wears off. During this frenzy, friendly fire is disabled, allowing you to deal with your own confused tames if necessary.
  - Boss immunity: By default, boss-class enemies are immune to Confusion Bombs. This can be toggled in the config (see Config Options).

## Mob Stances & Behaviors
- **Guard**: Defends the immediate area and returns to its spot after a fight. Will participate in Swarming.
- **Stay**: Pacifist mode. The mob will hold its ground and will *not* fight or swarm.
- **GuardWard**: Patrols the perimeter of the nearest friendly Ward, hunting intruders and actively swarming.
- **Follow**: Passive bodyguard mode. Prioritizes staying close to you. Will only attack if provoked (you or the mob takes damage). It will *not* raise or respond to Swarm alarms to prevent being dragged away by random enemies.
- **FollowAttack**: Aggressive vanguard mode. Actively hunts enemies along the path, attacks opposing guilds on sight, and actively shares Swarm aggro.
- **Static**: Complete immobilization. The mob will not move, rotate, or respond to any external stimuli via AI.

## Color Code Quick Reference

- **Green**: You are the original owner/tamer.
- **Light Blue**: Same guild.
- **Pink**: Allied guild.
- **Orange**: Opposing guild or hostile guild-controlled tame.
- **Red**: Actively targeting you, swarming, or alarmed.
- **Yellow**: Obedience is broken.
- **Bright Green**: Unclaimed tame that can be claimed.
- **Purple/Magenta**: Highly confused tame.

## Stealth & Swarm Systems
- **Base Infiltration**: If an enemy guild member wanders into your base, guards will notice and attack them individually (their hover name appearing Orange).
- **Raising the Alarm**: If a guard takes damage from a player and **survives** the hit, they will raise an alarm. Every allied mob nearby will enter a Swarming state and immediately rush the attacker. The hover text of swarming mobs will flash stark **Red**. Alarm states decay over time and can also clear if the attacker gets far enough away.
- **Stealth Strikes**: Careful assassins who can one-shot a guard with a sneak attack or sniper shot will kill the guard *without* raising the alarm, allowing them to quietly dismantle base defenses one by one!

## Console Commands
- `guild_order [stance] [radius]` — Order all tamed guild mobs within a specified radius to adopt a specific stance (e.g., `guild_order guard 20` or `guild_order follow 50`). Valid stances are: `guard`, `stay`, `ward`, `follow`, `attack`, `static`.

- `guild_ally [add/remove/list/accept/deny] ...` — Manage alliance requests and active allies.
  - `guild_ally add [PlayerOrGuildName]` sends an alliance request.
  - `guild_ally accept [RequesterGuild] [TargetNameOrGuild]` accepts a pending request.
  - `guild_ally deny [RequesterGuild] [TargetNameOrGuild]` denies a pending request.
  - `guild_ally remove [PlayerOrGuildName]` removes an active alliance.
  - `guild_ally list` lists your current allies.

## Advantages & Gameplay Ideas

- **Base Defense**: Deploy a garrison of tamed wolves or lox around your base. Assign them to the **GuardWard** stance, and they will intelligently patrol the outer circumference bounds of your ward, automatically engaging any enemy guild members or opposing faction mobs that approach, before returning to patrol.
- **Siege Warfare**: Rally an army of tamed creatures to march on an enemy guild's stronghold, using commands to orchestrate your assault.
- **Resource Protection**: Leave a patrol of tamed mobs at high-value resource nodes to ward off rival guilds.

## Known Challenges & Counters

- **Collateral Damage**: Neutral players might accidentally trigger a massive mob retaliation by hitting a tame mob with an errant arrow. Careful targeting is required!
- **Counter-Tactics**: Enemy guilds can attempt to kite hostile faction mobs into environmental hazards (like Fuling villages or boss spawns) to thin out your ranks without directly engaging.
- **Command Overhead**: Managing large groups of mobs might require swift usage of commands. Players who master the command window will hold a significant advantage.
- **Confusion Attacks**: Enemy players can toss Confusion Bombs into your ranks, weaponizing your own pack against you. Keep your beasts spread out to minimize the explosive AOE!

## Items & Craftables

- `Confusion Bomb I/II/III` (`tgw_confusionbomb1/2/3`) — Area-effect items that apply a variable amount of Confusion to nearby tamed mobs. Higher tiers apply larger potential confusion.
- `Command Horn` (`tgw_command`) — Cycle nearby tamed guild mob orders when used. Plays a horn SFX (configurable sound name).

### Command Horn Recipe

- `Command Horn`
  - `FineWood` x10
  - `LeatherScraps` x4
  - `Bronze` x2

### Confusion Bomb Recipes

- `Confusion Bomb I`
  - `Resin` x8
  - `Coal` x4
  - `LeatherScraps` x3
  - `Ooze` x2
- `Confusion Bomb II`
  - `Resin` x10
  - `Ooze` x4
  - `Obsidian` x3
  - `Crystal` x6
- `Confusion Bomb III`
  - `Resin` x12
  - `Ooze` x6
  - `Bilebag` x2
  - `BlackCore` x1

## Configuration Options

The mod exposes several config entries (server-synced where noted):

- General
  - `Obedience Decay Rate` — Base obedience loss per update tick. [Synced]
  - `Non-Guild Member Decay Multiplier` — Multiplier applied to obedience decay when near non-guild members. [Synced]
  - `No Guild Decay Multiplier` — Multiplier applied to obedience decay when the owner has no guild. [Synced]
  - `Hostile To Neutral Players` — If On, guild mobs will attack players who are not in any guild. [Synced]
  - `Confusion Duration` — Time in seconds for maximum confusion (100%) to wear off. [Synced]
  - `Command Horn Radius` — Radius for the command horn to affect tamed guild mobs. [Synced]
  - `Command Horn Sound` — Sound effect name used for the command horn. [Synced]
  - `Death Notifications` — Enables `/g` guild chat notifications when high-value guild mobs are killed by enemy players. [Synced]
  - `Show Guild Icon` — Displays the owning guild's icon on mob HUD plates when available. [Synced]
  - `Guild Icon Offset X/Y` — Fine-tunes the guild icon placement on the HUD. [Synced]
  - `Alarm Duration` — How long a mob remembers a hostile player before calming down. [Synced]
  - `Alarm Leash Distance` — How far the alarmed player can move from the mob before the alarm is cleared. [Synced]
  - `Ally Add Cooldown Seconds` — Cooldown before adding the same ally target again. [Synced]
  - `Guard Leash Distance` — How far a mob in Guard stance can travel from its anchor before returning. [Synced]
  - `Swarm Radius` — Radius for nearby same-guild mobs to join swarm response. [Synced]
  - `Swarm Check Interval` — How often idle mobs scan for nearby swarm targets. [Synced]
  - `Mob Action Logging` — Enables detailed debug logs for major mob actions. [Local debug]

- Confusion
  - `Resistance Min Health` — Max health where confusion resistance begins to scale. [Synced]
  - `Resistance Max Health` — Health at which resistance reaches its configured max. [Synced]
  - `Resistance Max Value` — Maximum confusion resistance applied at or above `Resistance Max Health` (0 = none, 1 = full immunity). [Synced]
  - `Resistance At 0% Health Multiplier` — How much baseline resistance remains when the mob is near 0 health. [Synced]
  - `Bomb Tier 1/2/3 Min/Max` — Min/max confusion values applied by each Confusion Bomb tier before resistance. [Synced]
  - `Allow Boss Confusion` — If `On`, boss-class enemies can be affected by Confusion Bombs. Default: `Off` (bosses immune). [Synced]


### Github:
https://github.com/Wacky-Mole/TameGuildWars

Contact Us:

### Meldurson 
<a href="https://discord.gg/valheimmodding">Valheim Modding Discord</a> under @Meldurson. or dm him on Discord.

<a href="https://ko-fi.com/B0B3NARM0">Ko-fi</a>

### WackyMole

My discord at [Wolf Den](https://discord.gg/uPjjH8y52j)
 https://www.buymeacoffee.com/WackyMole  or https://ko-fi.com/wackymole


 ### Notes
 WackyMole oringally had this idea about 2 years ago after the Guilds was just in the planning phase. After a while I contacted Meldurson and we have fine-tuned this mod for performance over the course of months. Mobs are huge FPS drains in Valheim, but this mod performance impact should be very low on it's own.
 We have done our best to make sure the mod is balanced and fun, but we are open to feedback and suggestions! We hope you enjoy it as much as we enjoyed making it!
