# Guildcraft Guilds, factions and reputation for multiplayer games. Four core components, two more when you want them (ownership, GAS), replicated and saved, with every function as a Blueprint node and no other plugin needed.  - **Reputation** with factions and characters: stages, gated stages, perks, relations between factions, recovery over time. Per player or shared by the guild. - **Factions**: NPCs and players belong to a faction, factions like or hate each other, and an AI controller turns that into friend or enemy for AI Perception. A player who falls to a hostile stage gets attacked. - **Guilds**: found, join, leave, disband, invite. Public or private with requests to join. Announcement, emblem, levels by experience, members who stay members while offline. - **Diplomacy**: guilds propose and accept alliances, declare war and make peace. Access rules and **Get Attitude Between Players** read it. - **Roles and permissions**: roles in a table, each with its permissions. Kicking and promoting only go down the ranks. - **Vault**: items by tag and count, deposit and withdraw by permission, slots by guild level, a log of who moved what. - **Access rule**: one struct and one node for a door, a shop or a quest. "In a guild", "has this permission", "Friendly or better with this faction", in any combination. - **Screens**: reputation list with a detail panel, change message, and the guild screen. Logic in C++, look in Widget Blueprints you can replace. Windows and Linux, client and dedicated server. Unreal Engine 5.6, 5.7 and 5.8. The server changes everything. Clients read and ask. ## Start in 5 steps 1. On your **PlayerState**, add **Guildcraft Reputation** and **Guildcraft Guild Member**. 2. On your **GameState**, add **Guildcraft Reputation** (it holds the reputations a guild shares) and **Guildcraft Guild Manager**. 3. Create a Data Table with the row struct **GDCReputationRow** (one row per faction or character) and one with **GDCActionRow** (one row per thing a player does). Set both in **Project Settings > Plugins > Guildcraft**. 4. On the server, call **Apply Reputation Action** with the player's pawn, the action and the target. 5. Add `WBP_GDCReputationList`, `WBP_GDCToast` and `WBP_GDCGuild` to the viewport. Guilds work with no table at all: you get the roles Leader, Officer and Member and one level of 20 members. The demo level is `/Guildcraft/Demo/L_GDCDemo`. Its tables (`DT_GDCDemoReputations`, `DT_GDCDemoActions`, `DT_GDCDemoGuildLevels`) show every field in use, and the classes in the `GuildcraftExample` module are the smallest working setup: a PlayerState and a GameState with the components, pads that call the server nodes, and an NPC that reacts to reputation. ## Reputation  ### The reputation table | Field | What it does | |---|---| | Reputation Tag | Identifies the faction or character everywhere. Use your own tags. | | Display Name, Description, Icon | Shown by the widgets. | | Scope | Player: each player has their own value. Team: one value for the guild. | | Known At Start | The player sees it from the first second. The others appear on the first change or on Discover Reputation. | | Base Value, Min Value, Max Value | Where it starts and the limits it never passes. | | Stages | The ladder. Each stage starts at its Min Value and ends where the next begins. Sort them from the lowest to the highest. | | Relations | Other reputations that move when this one does. Factor 0.5 gives half, -0.5 takes half away. One step only: a relation of a relation does not move. | | Recovery Per Minute | Points per minute the value walks back toward Base Value by itself. 0 keeps it where the player left it. | | Attitude To Factions, Default Attitude To Factions | How members of this faction treat members of other factions, whatever any player did. | Each stage has a tag, a title, a color, an **Attitude** (Hostile, Neutral or Friendly), a **Gated** flag and a map of **Perks** (tag to number, such as a price multiplier). ### The action table | Field | What it does | |---|---| | Action Tag | Identifies the action. | | Delta | Added to the target. Negative takes away. | | Spill To Relations | The target's relations move too. | | Client May Request | A client can ask for this action with Request Action. Leave it off for anything a cheater would abuse. | | Client Cooldown Seconds | With Client May Request: how long a player waits between two asks of this action, so a greeting cannot be farmed. | | Client Targets | With Client May Request: the reputations a client may aim it at. A parent tag (`Reputation.Village`) allows all under it. Empty refuses every client ask, so a forgotten list never opens a hole. | ### Nodes Server only: **Apply Reputation Action** (from any player actor), **Apply Action**, **Modify Reputation**, **Set Reputation**, **Discover Reputation**, **Open Stage Gate**, **Set Team Id**, **Recover Reputations**. Any machine: **Request Action**, **Get Reputation**, **Is Known**, **Get Stage**, **Get Stage Index**, **Is At Least Stage**, **Get Attitude**, **Get Perk**, **Get Progress To Next Stage**, **Is Waiting On Gate**, **Get Known Reputations**, **Get Reputation Info**. Events, on the server and on every client: **On Reputation Changed**, **On Stage Changed**, **On Reputation Discovered**, and **On Team Changed** when the player enters or leaves a guild and the shared values are other ones. ## Factions and AI  Add **Guildcraft Faction Member** to an NPC and pick its faction, which is a row of the reputation table. Then: | Node | What it answers | |---|---| | Get Attitude Toward (Observer, Target) | How the observer treats the target. A target with a reputation (a player) is judged by their reputation with the observer's faction. A target with only a faction is judged by the table. Members of the same faction are Friendly. | | Get Attitude Between Factions | The table alone, with no player involved. | | Get Actor Faction | The faction of an actor, its pawn or its controller. | For AI Perception, use **GDCAIController** as the parent of your AI controller. Perception asks the controller whether each sensed actor is an enemy, a friend or neutral ("Detect Enemies", "Detect Friendlies", "Detect Neutrals"), and this controller answers with Get Attitude Toward. Nothing else to set up: when a player's reputation drops to a stage whose Attitude is Hostile, your behavior tree sees an enemy. The sight sense asks once, when it starts looking at someone. A reputation or a war that changes while it looks would not be seen, so GDCAIController checks every **Perception Refresh Seconds** (1 by default) whether anything that sets its own faction's attitude changed (a stage with that faction, a war or truce that faction declared, an attack on one of its NPCs) and only then makes perception ask again. A bandit's grudge does not wake the town guards. A player changing faction or team wakes every NPC, and so does any change when the project has its own Attitude Solver, since a solver can judge by anything. In a quiet town each NPC rebuilds its senses once every 5 checks at most (to catch an attack wearing off), instead of every second. The demo's **GDCDemoNpcController** is a child of it with sight, Detect Enemies on and Detect Neutrals off: open it to see the settings. When your AI controller must keep another parent (a crowd controller, a plugin's own), the engine only lets C++ answer this question. One override in your controller's class does it: ```cpp // YourAIController.h virtual ETeamAttitude::Type GetTeamAttitudeTowards(const AActor& Other) const override; // YourAIController.cpp ETeamAttitude::Type AYourAIController::GetTeamAttitudeTowards(const AActor& Other) const { return UGDCLibrary::GetTeamAttitude(GetPawn(), &Other); } ``` Add `"Guildcraft"` to your module's dependencies. In Blueprint only, call Get Attitude Toward wherever your AI picks targets. ### More than one faction **Also Counts As** on the faction component gives an actor more factions besides its own: a bandit spy who also counts as a villager, a mercenary of two companies. Whoever shares any of its factions sees it as Friendly; anyone else takes the worst attitude among its factions, so the spy's bandit side shows to the bandits' enemies. Reputation still counts against its own faction. **Set Also Counts As** changes them in play, and the AI looks again; **Get All Factions** lists them. ### Who attacked it The faction component remembers who hurt its actor: anything that reaches it through Apply Damage marks the attacker (the instigator's pawn, or the damage causer) hostile to it for **Aggression Memory Seconds** (30 by default), whatever the tables say. Members of the same faction within **Alert Allies Radius** (15 m) remember it too, so hitting one guard turns the guards around him. Damage from a member of the same faction is not remembered (Ignore Same Faction). **Remember Aggressor** does the same from your own combat code when you do not use Apply Damage, **Forget Aggressor** forgives, **On Aggressor Remembered** fires on the server. The list replicates, so a client that has the attacker in view gets the same answer as the server; the AI that acts on it runs on the server anyway. More hits from someone already remembered only keep the memory fresh, so a long fight does not make every NPC look again. ### The project's own rule The order of the answer is: the tables, then the project's **Attitude Solver**, then who attacked, then the actor's own **Filter Attitude**. The solver is a Blueprint child of **GDCAttitudeSolver** with one function, Solve Attitude (Observer, Target, Table Attitude), picked in Project Settings > Plugins > Guildcraft. Monsters hostile to everyone at night, a truce inside the town walls, players of the same party always friendly: one place, every NPC, AI Perception included. Filter Attitude on a single actor stays the last word (a disguise, a charmed pet). ### Behavior Tree and State Tree  | Node | Kind | What it does | |---|---|---| | Guildcraft Attitude | Decorator | Passes when the AI's pawn sees the actor in Target Key with the attitude you pick. With Observer Aborts it checks again every Check Interval, and at once when Target Key changes, and aborts when the answer changes: the guard drops the patrol the moment you turn hostile. With no aborts it does not tick at all. | | Guildcraft Find Target | Service | Writes the closest actor with that attitude into Target Key, or clears it, and with Attitude Key set, how the pawn sees it. From what AI Perception senses, or the faction members and players' pawns within Radius when the controller has no perception. | | Guildcraft Apply Action | Task | Applies a reputation action to the player in Target Key: the guard who catches a thief applies Steal. Server only. | | Guildcraft Attitude | State Tree condition | The same test for State Tree, with Invert. | | Guildcraft Find Target | State Tree task | Finds the closest actor with that attitude. With Keep Looking it stays running and keeps Target current every Interval, for the child states to bind; without, it succeeds or fails once. | | Guildcraft Apply Action | State Tree task | Applies a reputation action to the Target player. Server only. | The State Tree nodes live in the GuildcraftStateTree module, which turns on the engine's State Tree and Gameplay State Tree plugins. They stay on in every project: the editor module (the tests and the demo's builders) uses them, and a plugin installed from Fab comes built. Nothing runs unless you use a State Tree. Both kinds are in the demo, running: the bandit guard thinks with `Demo/AI/BT_GDCDemoGuard` (Find Target on the root, a chase branch behind the Attitude decorator with Observer Aborts set to Both, home otherwise), the village guard with `Demo/AI/ST_GDCDemoGuard` (Find Target on the root state, a Home and a Chase state that hand over to each other through Guildcraft Attitude conditions). Open either one to see the nodes wired; copy it as the start of your own. The walking itself is the demo's own task, Guildcraft Demo Walk: your AI moves the way your game moves. The tests in the editor module run both trees on a guard and check that it chases who it is hostile to and goes home after. ### Gameplay Debugger  Press the apostrophe key in play, look at an NPC or a player and open the **Guildcraft** category: its faction, how it sees you and what the tables alone say, your reputation and stage with it, who it remembers attacking it, and the guild and role of a player. Development builds only, like the debugger itself. The same lines come from **Get Debug Lines** (Viewer, Subject), for a debug widget of your own or a log; With Colors keeps the debugger's colour marks. ### War and peace in play The table gives how factions see each other. On the GameState's reputation component, **Set Faction Attitude** (From, To, Attitude, Both Ways) changes it while the game runs: a war, a truce, an alliance. It wins over the table, is saved with the shared reputations, reaches every client, and Get Attitude Toward and the AI controller use it at once. **Clear Faction Attitude** goes back to the table. **On Faction Attitude Changed** fires on every machine. ## Guilds ### What a player can ask for On the player's **Guildcraft Guild Member** component, from any machine. The server decides and answers with **On Request Result**, which says why when it refuses (name taken, guild full, role does not allow). | Node | Who may | |---|---| | Request Create Guild (name, private) | Anybody in no guild. | | Request Join Guild (guild, message) | Anybody in no guild. A public guild takes them in. A private one keeps the request. | | Request Leave Guild | Any member. The leader leaving hands the guild to the highest role left. The last member leaving ends it. | | Request Disband Guild | The leader. | | Request Resolve Join Request | Roles with Manage Requests. | | Request Kick Member | Roles with Kick, on members of a lower rank. | | Request Set Member Role | Roles with Set Roles, on members of a lower rank, up to one rank below their own. | | Request Transfer Ownership | The leader. The two swap roles. | | Request Set Announcement, Request Set Private, Request Rename Guild | Roles with Edit Info. A new name follows the founding rules. | | Request Invite Player (player) | Roles with Invite, on a player in no guild. The invite waits 2 minutes (Invite Seconds in the project settings) and lets them into a private guild too. | | Request Invite Player By Key (key, name) | The same for a player who may be offline, by the key your game knows them by (a friends list, a past member). Offline, it waits **Offline Invite Days** (7) on the guild and comes up as a normal invite when they log in. A guild keeps 50 at most. | | Request Claim, Request Release (thing) | Roles with the thing's Claim Permission, standing within its Max Use Distance (5 m). See Things a guild owns. | | Request Set Emblem (symbol, color, icon) | Roles with Edit Info. | | Request Propose Alliance, Request Answer Alliance, Request Declare War, Request End Relation | Roles with Diplomacy, the leader by default. An offer waits in the offering guild's Alliance Offers Sent and the other guild's Alliance Proposals; End Relation on a guild you only offered to takes the offer back. | | Request Answer Invite (guild, accept) | The invited player. **Get Pending Invites** and **On Invites Changed** on their component; `WBP_GDCInviteNotice` shows it on the HUD. | | Request Deposit To Vault, Request Withdraw From Vault (item, count) | Roles with the vault permissions, and only with **Client May Use Vault** on in the project settings (off by default). Turn it on once Can Do Guild Request checks the inventory, see Vault. | Every request that went through is written in the guild's **Activity Log** (who, what, on whom, when; the last 30, Activity Log Length): "Ana kicked Bob", "Ana declared war on Red Fang". Members only, like the vault log. The guild screen shows the last lines, and Get Guild gives the whole list. The same things exist as server nodes on the **Guildcraft Guild Manager** (Create Guild, Join Guild, Kick Member and so on), for a game that drives guilds from its own logic. ### Roles and permissions The leader edits each role of their guild on the guild screen (Roles, at the bottom of the members card): a new title and the most its members take from the vault in a day. The same from Blueprint with Edit Guild Role, which can also change the role's permissions, but only to permissions in **Editable Permissions** (project settings; empty means Guildcraft's own `Guildcraft.Permission.*`). The leader replaces the editable ones only: a tag your doors check stays on the role as the table set it, and out of a player's hands. **Rejoin Wait Minutes** (project settings, 0 by default) makes a player who left or was kicked wait before joining another guild, so nobody hops between guilds to use each one's shared reputations. Founding a guild is never held back. A Data Table with the row struct **GDCGuildRoleRow**, set in the project settings: a tag, a title, a **Rank** (a higher rank commands a lower one), the **Permissions** the role has, and two flags. Exactly one role is the **Leader Role**, which can do everything, and exactly one is the **Role For New Members**. The built in permissions are `Guildcraft.Permission.EditInfo`, `Invite`, `Diplomacy`, `ManageRequests`, `Kick`, `SetRoles`, `VaultDeposit` and `VaultWithdraw`. Add your own tags to a role for anything else, and check them with **Has Permission** or an access rule. **Withdraw Per Day** on a role caps the items its members take out of the vault in a day (UTC), all kinds together; past it a withdrawal answers Limit Reached. 0 has no cap, and the leader has none. **A guild's own roles.** The leader of each guild can rename a role, change what it can do and its daily limit, for their guild only: **Edit Guild Role** on the manager, **Request Edit Guild Role** from the player's component. Each edit starts from the role as the guild has it: an empty title keeps the title, permissions change only with **Change Permissions** on, a limit below 0 keeps the limit (0 means none), and **Back To Table** drops the guild's changes. Rank and the leader role stay the table's, so nobody climbs above the leader. **Get Guild Role** reads a role as a guild sees it. Members get their guild's roles with the private part. **New roles.** The leader can also make roles of their own, on the guild screen (Add role, under the role list) or with **Create Guild Role**: a title, a rank under the leader's, permissions from Editable Permissions and a daily limit. The screen gives a new role the permissions of the role for new members and, with the rank left empty, the rank halfway between that role and the one above it. **Max Created Roles Per Guild** (project settings, 4 by default, 8 at most) caps how many. Each one takes a tag from `Guildcraft.Role.Created.1` to `8`, so Set Member Role, Edit Guild Role, access rules and the promote and demote buttons treat it like a table role. **Delete Guild Role** removes one; its members go back to the role for new members. **Get Guild Roles** lists every role of a guild, from the highest rank down. The roles a guild made are saved with it. ### Levels A Data Table with the row struct **GDCGuildLevelRow**, from the first level to the last: title, **Experience Required**, **Max Members**, **Vault Slots** and **Perks**. Call **Add Guild Experience** on the server when the guild earns it: a quest, a donation, a kill. Pass the player and their contribution is counted on their member entry. Read with **Get Guild Level**, **Get Progress To Next Level** and **Get Guild Perk**. ### Vault  The vault counts items by Gameplay Tag. It does not know your inventory, so the inventory half of a transfer is yours, on the server, in two steps that never let an item exist twice: 1. In **Can Do Guild Request**, for Vault Deposit, answer Not Enough Items when the player does not hold `Context.Count` of `Context.Tag`; for Vault Withdraw, refuse when the inventory has no room for them. Nothing has changed yet. 2. In **On Guild Request Succeeded**, take `Context.Count` of `Context.Tag` out of the inventory (deposit) or give them (withdraw): the event carries the request as it was done. It runs right after the vault changed, on the same frame, so nothing can spend the items in between. Calling Deposit To Vault from your own Server RPC and reading its answer works the same way: check first, change the inventory only on Success. The vault and your inventory are two saves. Guildcraft writes a guild's file 2 seconds after a change; if the server crashes in between and your inventory was already written, an item is in both places or in neither. Where that matters, call **Save Guild Now** (the guild's file, written at once) in On Guild Request Succeeded together with your own inventory save. **On Guild Request Succeeded** on the manager fires on the server after any request went through (founding, a request to join sent or answered, a deposit, a war, an alliance offer sent) with the player who asked and the guild. It is the place to charge a founding cost: it only fires when every rule passed. **On Member Joined** fires once for each new member, whatever the way in: founding, a public guild, a request accepted by an officer (the player may be offline then, and Player is empty), an invite. It is the one place for an entry fee or a welcome. **On Member Left** is its other half: left, kicked, removed by the game, or the guild disbanded, with the reason. **The game's own hand.** For quests, admins, taxes and guilds gone quiet, with no player and no permission in between: **Force Change Vault** (a reward in, a tax out, written in the vault log under the name you give), **Force Remove Member**, **Force Set Member Role**, **Force Transfer Leadership** and **Force Disband Guild**. They work on members who are offline. **Gold and the daily limit.** A role's daily limit counts every item taken, all kinds together. Put gold (or anything counted in hundreds) in **Items Outside Daily Limit** in the project settings, and it no longer uses the limit up. **Items with their own data.** A sword at 72% durability with a fire mod is not just `Item.Sword`. **Deposit Item To Vault** and **Withdraw Item From Vault** take an **Item Data** text next to the tag (up to 256 characters: your JSON, a Base64 of your item struct, anything your inventory can read back; every member online gets the whole vault, so it is kept short). The vault keeps it as it is and gives it back on the way out: each different item is its own stack, two identical ones stack, Get Vault Count counts every stack of a tag. Can Do Guild Request and On Guild Request Succeeded get the data in `Context.Text`, so the inventory half works the same as for plain items, and the vault log keeps it too. The vault row's On Setup has the stack with its data, to show the item's real name and icon. The plain Deposit and Withdraw never touch an item with data, and neither does Force Change Vault. With Client May Use Vault on, the item data comes from the client: in Can Do Guild Request compare `Context.Text` with the item the player really holds, not only its tag and count, or a cheater deposits a common sword with the data of a legendary one. Building the data on the server from the real item, and calling Deposit Item To Vault from your own Server RPC, avoids the question. The vault row shows the item's own name when its data is JSON with a `name` field ("Iron Sword, 72%" with a `durability` too), the tag's last part otherwise. Deposit and withdraw check the role's permission and answer Not Allowed, Vault Full or Not Enough Items. Each guild remembers its last 20 movements (who, what, how many), shown on the guild screen. ### Diplomacy Guilds can be allied or at war. An alliance needs both: one guild offers (**Propose Alliance**), the other accepts; two offers that cross make it at once. A war needs only one side (**Declare War**), and **End Relation** goes back to neutral. Every client sees alliances and wars; offers waiting for an answer go only to the guild's members. For the game's own logic, **Set Guild Relation** sets it with nobody asking. **Get Guild Attitude** and **Get Attitude Between Players** answer Friendly for the same guild or allies, Hostile at war, Neutral otherwise: friendly fire, PvP zones, nameplates. An access rule with Only Guild Id and **Allies Too** lets allies through the guild's door. ### Guild chat Members write to their guild on the guild screen (Guild Chat card; Enter sends) or with **Request Send Guild Chat**. The server cleans the line (control and invisible characters out, cut to **Guild Chat Max Length**, 200), asks **Can Do Guild Request** with Chat and the text, so your game can mute a player, then **Filter Guild Chat**, which returns the text to post: override it for stars over a bad word, or return empty to drop the line. One player sends a line every **Guild Chat Cooldown Seconds** (0.5) at most. A line goes straight to each member online with a client call, not through the guild's private part, so a busy chat never copies the guild to everybody. The guild keeps the last **Guild Chat History Length** lines (50; 0 keeps none) and saves them: a member gets them at login and on joining, and loses them on leaving. On the player's component, **Get Guild Chat** has the lines, **On Guild Chat** fires for each new one (a HUD line, a sound) and **On Guild Chat History** when the whole list came again. **Post Guild Chat Message** writes as the game, with a name of your choice: "The raid starts in 5 minutes". Chat lines stay out of the activity log, but On Guild Request Succeeded fires for each, for a moderation log of your own. ### Emblem A guild has a symbol (2 characters, the first letter of the name when empty), a color from **Emblem Colors** and, when your project lists **Emblem Icons** (textures) in the project settings, a picture. `WBP_GDCEmblem` draws it, and every guild screen row has one. ### Guild reputation A reputation row with Scope set to Team is shared by the guild: what one member earns, every member has. A player in no guild has their own value. To drive teams from your own system instead, turn off **Guild Shares Reputation** in the project settings and call Set Team Id yourself. ## Access rule **GDCAccessRule** is a struct of optional conditions: must be in a guild, only this guild (and its allies, with Allies Too), a permission, a minimum guild level, a reputation with a minimum stage, and **More Minimum Stages** for several reputations at once. **Passes Access Rule** answers true when every condition that is set holds. **Passes Any Access Rule** takes a list and answers true when one of them holds, which is the "or": officers of the guild, or anyone Honored with the villagers. Put it on a door, a vendor or a quest giver and one node covers "guild members only", "officers only" and "friends of the village only". ### Things a guild owns **Guildcraft Guild Ownership** on any actor gives it to a guild: a chest, a door, a base, a flag to capture. **Claim For Guild** (needs **Claim Permission** on the player's role: Diplomacy by default, so the leader and officers; empty lets any member; from a client, Request Claim on the Guild Member component, which also checks the player stands within **Max Use Distance**) and **Release** go through the player; **Set Owner Guild** sets it with no checks, for a capture or a load from your save. **Can Use** answers whether a player may use it now and which guild's vault or room it opens: the owner's members, its allies with Allies May Use, anyone while nobody owns it with Unowned Is Open, and on top of that **Any Of Rules** when you add some. Which guild owns what is saved in the owner guild's own file under the thing's **Save Key** (the actor's name when empty, which holds for an actor placed in the level), and comes back after a restart. An actor your game spawns while playing (a base a player built) gets a new name each run, so it has to have a Save Key of its own before a guild can claim it: set one from your building system, then call **Restore Saved Owner**. A thing destroyed in play gives its claim back. With **Capture Seconds** above 0 another guild takes it by holding it: a claim from a guild that is not the owner and not its ally starts a capture, which fills while its members stand within Max Use Distance with nobody of the owner there, waits while a defender stands there, and drains back when they leave. A crowd goes faster: each attacker past the first adds **Speed Per Extra Attacker** (0.5 by default, up to **Max Capture Speed**), and with **Defenders Push Back** more defenders than attackers drain it while it stays open. With **Allies Count** the owner's allies defend and the capturing guild's allies help; **Get Capture Crowd** gives both numbers for a "3 against 1" on screen. **Capture Radius** sets how near a player stands to count (Max Use Distance when 0), and **Can Count For Capture**, overridden in a Blueprint child, leaves out whoever your game says: the dead, the invisible, someone mounted. **On Capture Changed** gives the progress on every machine for a bar. Claim, Release and the end of a capture go through Can Do Guild Request and the activity log like any request. A guild that is disbanded owns nothing any more, so its things can be claimed again. **One player as owner.** With **Allow Personal Owner** a thing can belong to a single player instead: **Claim For Player** (or Request Claim from a player in no guild) when nobody owns it, **Set Player Allowed** for the owner to let up to 20 others use it, Release to give it up. A guild cannot claim or capture a player's thing. It is saved in a small file of its own (`<Prefix>_Thing_<Save Key>`), and Can Use answers for the owner and the players allowed. Can Use gives the guild whose vault the actor opens; the vault requests themselves always use the player's own guild, so an ally's chest opens to look, and your game moves items into the owner's vault with Force Change Vault when it wants that. The owner replicates and **On Owner Guild Changed** fires on every machine. Saving which guild owns which actor is your game's, with the actor. ### Guild tag on a nameplate **Get Guild Tag** gives a player's guild symbol (the emblem symbol, or the first two letters of the name), the guild name and the emblem colour, on any machine. With **Get Attitude Between Players** for the colour it is a nameplate: the demo's players show `[IR] Ana` over their heads, green for the same guild or an ally, red at war. ## Save **By itself.** With Auto Save on (the default), the server loads a player's reputations when they join and the guilds when the game starts, and writes them 2 seconds after a change and again on leaving. Every write goes to a spare copy first and to the slot after it, so a crash or a full disk in the middle leaves one whole copy, and loading falls back to the spare. A save that does not read at all (edited by hand, cut short, from a newer version) is never written over: its bytes are kept as `<slot>_Unreadable_<date>` and a new save starts, with an error in the log. A save that is on disk but cannot be opened (locked by another program, a disk error) after three tries is not written at all until the server restarts. The guild list and each guild's file look after each other. A list that is missing or does not read is rebuilt from the guild files, so no new guild ever takes an old one's id and file. A guild whose file does not read stays named in the list and its id is never given again: once the file reads, a restart brings it back. Files are `<Prefix>_Guilds` (the list of guilds), `<Prefix>_Guild_<id>` for each guild, `<Prefix>_Shared` and `<Prefix>_Player_<name>_<checksum>` for each player: a player named "Guilds" never lands on a server file, and two names the file system writes the same way stay apart. A change writes only the file of the guild that changed. A save from an earlier version, every guild in one file, loads and is split on the next write. To erase a save, call **Delete Save Slot** on the component: it removes the slot and its spare. Delete Game In Slot alone leaves the spare, which brings the save back on the next load. **Who is who.** Players are identified by their store account (Steam, EOS), fixed at login. A dedicated server never takes a typed name as a key: a player with no account id there gets no key, so no guild and no saved reputation, until Set Player Key gives one (**Allow Name Keys On Dedicated Server** turns names on for a test server with no online subsystem). A listen server falls back to the typed name, for friends playing together, and the log says so once; **Require Account Key** refuses names there too. With your own login system, call **Set Player Key** in your GameMode's On Post Login, or when your login answers: a key set later reloads the player's reputation and guild under it, and drops what they earned before (so let nobody act until it is set). Keys stay with the player's controller, so a seamless travel brings everybody back with the same key, in any order. **Save Key Source: Player Name** is for games with no accounts at all (LAN, tests, the demo): the name a player types is who they are, so somebody can come back later under the leader's name. The key a player has reaches every client (it is how members are told apart on screen): with your own login, use an id that means nothing outside your game, not an e-mail. While a player is online, a second one with the same name gets another key (`Ana#2`) and nothing of the first, and a name change after login changes nothing. With store accounts there is no `#2`: a player who drops and comes back before the old connection times out is the same player, and the new connection takes the key. **In your own save.** Turn Auto Save off on the components and call **Save To Bytes** and **Load From Bytes** on each. Load From Bytes answers false and changes nothing when the bytes are not its own. A reputation or a role removed from a table since the save was written is handled on load: the reputation is dropped, the member goes back to the role for new members. ## Widgets | Widget Blueprint | Parent class | What it is | |---|---|---| | WBP_GDCReputationList | GDCListWidget | Every reputation the player knows. Clicking a row opens its detail. | | WBP_GDCReputationEntry | GDCEntryWidget | One row: name, stage, value, bar. | | WBP_GDCReputationDetail | GDCReputationDetailWidget | Description, the ladder of stages, perks, relations. | | WBP_GDCToast | GDCToastWidget | "Villagers +50" when a value moves. | | WBP_GDCGuild | GDCGuildWidget | The guild screen. Out of a guild: invites, guilds to join with a search by name, founding. In one: members, requests, vault and its log, activity, guild chat, diplomacy, emblem editor, players to invite, and for the leader the role editor with Add role. | | WBP_GDCGuildRow, WBP_GDCGuildMemberRow, WBP_GDCJoinRequestRow, WBP_GDCVaultRow, WBP_GDCRoleRow | the matching row classes | The rows of the guild screen. The vault row has **On Setup** for your item icon, and Take and +1 buttons when Client May Use Vault is on. The role row is the leader's role editor. | | WBP_GDCInviteRow, WBP_GDCPlayerRow, WBP_GDCRelationRow | the matching row classes | An invite to answer, a player to invite, another guild with its alliance and war buttons. | | WBP_GDCInviteNotice | GDCInviteNoticeWidget | The invite on the HUD, with accept and refuse. | | WBP_GDCEmblem | GDCEmblemWidget | The emblem: color, symbol or your icon. Used on the rows and the screen header. | The plugin ships the widgets in three looks. `Content/UI` is **Ember** (warm dark, amber), the one the demo uses. `Content/UI/Skins/Slate` (neutral dark) and `Content/UI/Skins/Signal` (blue) are the same 15 widgets in the other two: point your HUD at those to switch, or copy the folder into your project and edit it. To restyle, open the Widget Blueprint and change anything. To start over, make a new Widget Blueprint with the same parent class and name your widgets like the ones the class looks for. They are listed in each class as Bind Widget Optional properties, and every one is optional: a screen with no vault text is a screen with no vault. Each class also has Blueprint events (**On Refreshed**, **On Result Shown** and others) for anything else you want to show or play. The widgets find the owning player's components by themselves, including on a client where they arrive a moment after the HUD. Buttons a player's role does not allow are hidden, and the server checks again anyway. ## Make it yours  Nothing here needs C++. The components are Blueprintable: make a Blueprint child, put it where ours was, and override what you want. | Override | On | What it decides | |---|---|---| | **Can Do Guild Request** | Guild Manager | Your rule on top of ours for every guild request. The context has what the player typed (name, announcement, emblem), the target (kicked, promoted, invited), the item and count, and the other guild: a banned word, a founding cost, a minimum level to invite, "does the player hold the items". Anything but Success refuses with that answer | | **Filter Guild Experience** | Guild Manager | Changes experience before it is added: double experience, a cap. 0 gives none | | **Filter Reputation Change** | Reputation | Sees every gain and loss before it lands, relations included: a perk that doubles gains, a cap per day. 0 cancels it. It runs on the component Modify Reputation was called on, so a player's filter covers the values their guild shares too | | **Can Client Request Action** | Reputation | The last word on a client's Request Action, after the table allowed it: is the player near the NPC | | **Filter Attitude** | Faction Member | The last word on how an NPC sees someone: a disguise, a charm, a pet that never turns. **Get Attitude From Tables** gives the answer before it | Your own data goes on the guild with **Set Guild Custom Value** and **Get Guild Custom Value**: a home, a tax, a banner of your own. It is saved and sent to every client with the guild. **Set Guild Private Value** and **Get Guild Private Value** do the same for values only the guild's members receive: a stash, a raid plan. **Money.** The vault counts anything by tag, so gold is one more tag (`Item.Gold`): deposits, withdrawals, the daily limit, the log, Force Change Vault for a quest reward or a tax all work on it the same way. The widgets take your look the same way: every Widget Blueprint can be edited, and the screen asks for its rows by class (Guild Row Class, Member Row Class, Vault Row Class and so on), so a row of yours goes in without touching the screen. ## The demo `/Guildcraft/Demo/L_GDCDemo` is one room with 12 pads in 3 rows, two NPCs of rival factions, a merchant whose price follows your guild's standing, and an officers' room whose door opens only for officers. Two guilds are there from the start, Silver Hand and Red Fang, at war with each other: found yours and offer one an alliance. The player is **GDCDemoCharacter**, a third person character: WASD, mouse, Space, G for the guild screen. None of Guildcraft is on it, the components are on the PlayerState, so your own pawn works the same. The guards walk at a player they are hostile to and hit him every 1.5 s once in reach (Hit Damage, through Apply Damage, with a push back so the hit shows), the bandit through his Behavior Tree and the village guard through his State Tree, and the ring at their feet shows how they see you: green, grey or red. `BP_GDCDemoGuildRules` is a guild manager Blueprint with its own rule in Can Do Guild Request: no kicks while Raid Active is on. The bodies are the Unreal Engine template mannequins, kept apart in `Content/Demo/Epic`. It is Epic's content, not ours, and nothing in the plugin depends on it: delete the folder and the demo still runs, with capsules that walk. The village around the pads is built from the Medieval Village MegaKit by Quaternius (quaternius.com), released under CC0, in `Content/Demo/Village`. Its license is in `Docs/Licenses/Quaternius_CC0.txt`. Delete the folder and the demo runs on the plain floor, with the hall's grey walls back. `/Guildcraft/Demo/L_GDCBase` is the same room with only the engine's basic shapes: blocks where the village has its houses, the wagon and the bandits' fence, in colours made from `BasicShapeMaterial` (`Content/Demo/Base`). Start from it when your project leaves the village out, or as a level to test your own art in. ## Gameplay Ability System The GuildcraftGAS module puts the reputation and the guild into GAS. Add **Guildcraft Ability System Bridge** to the PlayerState: it finds the Ability System Component on the PlayerState or on the pawn, and on the server keeps **Stage Effects** (a Gameplay Effect while a reputation is at a stage or above: Honored with the merchants gives a discount attribute) and **Guild Level Effects** (a Gameplay Effect for members of a guild at a level or above) applied exactly while they hold. Abilities, attributes and cues read them the usual GAS way. One effect can climb: **Level By Stage** applies it at level 1 on its lowest stage, 2 on the next and so on, and **Level By Guild Level** does the same with the guild's level, so magnitudes set by level give Honored more than Friendly. **Reputation Set By Caller Tag** puts the reputation value itself into the effect and keeps it current point by point; **Guild Level Set By Caller Tag** does the same with the guild's level. Use Infinite effects for something that holds while the stage holds: an Infinite effect that something cleared (a death) goes back on at the next refresh. An instant effect, or one with a duration, is applied once when the stage (or the level) is reached and again only when it changes, never on every refresh. The other way, **Event Actions** map a Gameplay Event to a reputation action: an ability that kills sends Event.Kill to the player's ability system, and the bridge applies Kill against the faction of the event's Target (or the reputation you name). **Match Child Events** takes Event.Kill.Bandit and Event.Kill.Wolf for an entry on Event.Kill, and **Magnitude Is Count** counts the event's Event Magnitude as how many times the action happens: five wolves in one event, five kills. The module turns on the engine's Gameplay Abilities plugin, which stays on in every project for the same reason; a game without GAS simply never adds the bridge, and nothing of it runs. ## Tests The GuildcraftEditor module carries the automation tests (46 of them): Tools > Session Frontend > Automation, filter **Guildcraft**, or `UnrealEditor-Cmd.exe YourProject.uproject -ExecCmds="Automation RunTests Guildcraft; Quit" -nullrhi -unattended`. They build their own worlds and tables, and touch the disk only in save slots that start with GDCTest. The module is editor only and never goes into a packaged game. ## Console commands In development builds, on the server: `gdc.Rep.Add <Reputation> <Amount> [Player]`, `gdc.Rep.Action <Action> <Reputation> [Player]`, `gdc.Rep.List [Player]`, `gdc.Guild.List`, `gdc.Guild.XP <Amount> [Player]`, `gdc.Faction.Set <Faction> <Faction> <Hostile|Neutral|Friendly|Clear>`. A tag can be written by its last part (`Villagers`). Player is the index in the GameState's player list, 0 when left out. ## Your own backend With Auto Save off, the save is yours. **Save To Bytes** on the GameState's Guild Manager and reputation component, and on each player's reputation component, then **Bytes To Base64** gives text a web service or a database column takes. Back the other way: **Base64 To Bytes**, then **Load From Bytes** on the server. With many guilds, keep a row per guild: **Save Guild To Bytes** after On Guild Changed for that guild, and **Load Guild From Bytes** for each row at start. A few rules that keep it right: - Load the guilds before players act (Begin Play of the GameState is fine), and a player's reputations when they log in. - Save after **On Guild Changed** or **On Reputation Changed**, and wait a second or two so a burst of changes is one call. - Key players by **Get Player Key**: the store account, the same one the built in save uses. - Load From Bytes answers false and changes nothing when the bytes are not its own, so a broken row in the database never wipes a guild. ## Network  - Reputations and guilds travel as replicated lists that only send what changed. A lost packet delays a value and never leaves a client with a different one. - Clients never change anything. Requests go to the server, which checks them and drops anything past 10 requests a second per player. Requests that other players or every client see (found, disband, invite, ask to join, answer an invite, leave, alliance and its answer, war, peace, rename, announcement, emblem, privacy) wait 2 seconds between two of the same kind (Social Request Cooldown Seconds). - A PlayerState sends once a second by default. Guildcraft asks for an update right after each change on it, so the guild, the vault and a reputation gain reach the player with the answer to their request, not a second later. - A player's reputations replicate to every client, so a nameplate or an inspect screen can read them. - A request's answer (On Request Result) reaches the player a frame after what it changed, so reading the guild inside it shows the new state. - **Is Guild List Complete** is true once every guild of the server has arrived: with a thousand guilds a joining client gets them over some seconds, so a guild browser can say "loading" until then. - Each guild's public part (name, announcement, level, experience, member count, privacy, emblem, alliances and wars, and the guild's shared reputations) travels on an actor of its own that every client gets. It sleeps on the network and wakes only when its guild changes, so a thousand quiet guilds cost the server nothing, and a player who joins gets them one actor at a time instead of one packet. A shared reputation walking back to its base reaches clients every 30 seconds; a gain, a loss or a new stage goes at once. - The private part (members, requests to join, vault, its logs, alliance offers) goes on each member's own Guild Member component, sent to its owner only. That is the engine's own rule, so it holds with the default network, the Replication Graph and Iris alike. It carries the guild's public part too: a member sees their own guild at once, before the other guilds arrive. - With the Replication Graph, route `GDCGuildActor` to the always relevant node, as its `bAlwaysRelevant` asks (Lyra's graph does it from that flag). With Iris, the shared reputations also travel on the GameState as one list, so keep their count well under a thousand. - A member logging in or out, a deposit or a new role sends nothing to the other guilds. - On a client, **Get Member**, **Has Permission** and an access rule with a permission answer for the local player's own guild only: the other guilds' members are not on that machine. Ask the server for anything about another guild's members. - A seamless travel brings players over with no PostLogin: the components find them within a second and load them with the key they had before the travel. - The guild screen redraws once per frame at most, and not at all while it is hidden. Its lists scroll and fill the rows they already have instead of making new ones. Past 20 guilds, diplomacy lists allies, wars and offers, and a search finds any other guild. - The game thread copies what is to be saved; the text and the disk are a worker thread's job. Each file has its own lock, so one save never holds up another, a login or a logout, and of two saves of one file the newer always wins. A player logging in or out schedules their guild's file for a minute later instead of 2 seconds. - Measured: a dedicated server with 1000 guilds, each with a 280 character announcement in accented letters, 4 custom values and a shared reputation. A client joining late over 150 ms and 5% packet loss had every guild, announcement and reputation within 23 to 32 seconds of starting (three runs), with no engine size limit hit (`Tools/scale_test.py`). Saving every guild at once (1000 guilds of 50 members, 8.4 MB) costs the game thread 5 ms; a normal write is one guild's file. - Reputations shared by a guild are kept by the GameState's reputation component and travel with the guild's public actor, so every client sees them, like the player's own reputations. Keep secret standings in your own data. With Guild Shares Reputation off, they travel on the GameState as before. A reputation walks back to its base (Recovery Per Minute) only while its owner is in the game: a player's own, while they are online. - A big guild: with 500 members online, a change (a deposit, a log line) costs the server 0.83 ms. The changes of a frame go to the members once, and only the lists that moved are copied: a deposit sends the vault, not the member list. The member list fits the engine's default array limit up to about 900 members; a guild level that allows more logs a warning. - What is not measured: hundreds of real players connected at once (the network test runs 4 clients, the crowd test 16; the 500 member guild is measured on the server). - Measured: 300 guards on the demo's Behavior Tree packed around a hostile player cost 3.4 ms a frame on the server all together, about 11 microseconds each (Find Target, the Attitude decorator and the walk), and 1000 guards spread over 300 m cost 3.5 ms (the tests `What 300 guards on a Behavior Tree cost` and `What 1000 guards in a town 300 m across cost`). Find Target never walks every actor of the world: without perception it looks at the faction members and players' pawns in the cells of a 20 m grid that its radius touches, built once a frame. - Measured: one guild with every player in it, each depositing 40 times, so every deposit goes to every member online. With 16 clients on a dedicated server, 847 bytes per deposit per member, everything included (the vault, the member's contribution, the log line, the guild's experience); the vault and activity logs travel as rings, so a full log that gains a line sends that line and not all of it (1268 bytes before). Every client ended with the server's vault, members and logs in the same order (`Tools/crowd_test.py`). The cost grows with members online times deposits: at 100 members, about 85 KB per deposit across the server, before Unreal's own compression. - Tested with 4 clients at 150 ms and 5% packet loss, on a listen server and on a dedicated server, including a restart from the save. ## Cases worth knowing - Can Do Guild Request answers; it must not change guilds itself. A change made there is caught, logged, and the request that asked goes on with what it checked before. Change guilds in On Guild Request Succeeded. - **The value passes a gated stage.** It keeps counting. The stage waits for Open Stage Gate, and Is Waiting On Gate is true meanwhile. - **A tag that is not in the table.** The node does nothing and logs a warning in `LogGuildcraft`. - **A member who is offline.** Still a member: they can be promoted, kicked or made leader, and find it so when they come back. - **A request to join while the guild fills up.** Accepting it answers Guild Full and the request is removed. Requests nobody answers go away after 7 days (Join Request Days). - **An invite while the player is in a guild.** Accepting answers Already In Guild and the invite keeps waiting until it runs out, so the player can leave and say yes. - **The game's rule and a cost.** Can Do Guild Request is asked after every rule of Guildcraft passed, and On Guild Request Succeeded fires only when the request went through (an alliance offer sent counts): charge there, and a refused request never costs anything. - **Two factions that relate to each other.** Each change spills once. A to B does not come back to A. - **A reputation with recovery and the change message.** The message ignores changes smaller than 5 points (Smallest Change Shown on the widget), so a slow recovery does not talk every few seconds. - **Guild names.** Trimmed, unique whatever the case, 3 to 24 characters by default (Guild Name Min Length and Max Length in the project settings). - **Text from a player.** Announcements, join messages and names are cut on the server to Guild Text Max Length (names to 64), whatever a client sends. The activity log keeps who and whom, never a message. - **The demo in your game.** The demo's classes live in the GuildcraftExample module, a DeveloperTool module: it loads in the editor and in Development builds, and a Shipping build of your game leaves it out with no change to the .uplugin. Its 20 `GuildcraftDemo.*` tags are declared in the Guildcraft module so the demo tables load in any project. Delete `Content/Demo` too when you no longer need the examples. - **A role table with two leaders, or a role ranked above the leader.** The first leader role is the leader and is raised above every other rank, with an error in the log. - **More than 31 stages in one reputation.** Gates work on the first 31. ## Support contato@tessaroapps.com, answered within 24 hours on business days. ## Changelog ## 1.0 (first release) Unreal Engine 5.6, 5.7 and 5.8, Windows and Linux, client and dedicated server. **Reputation** - Factions and characters in a Data Table: stages, gated stages, perks, relations between factions, recovery over time. - Per player, or shared by the whole guild. - Actions with a fixed cost, and a list of the actions and targets a client may ask for. - A project rule class (Attitude Solver) and a per actor Filter Attitude for the last word. **Factions and AI** - Faction attitudes in a table, and war and truce in play (Set Faction Attitude). - An AI controller that turns attitudes into friend or enemy for AI Perception, and Get Team Attitude for a controller that keeps another parent. - Memory of who attacked an NPC (30 s), shared with its allies within 15 m. - Also Counts As: an actor in more than one faction. - Behavior Tree and State Tree nodes (attitude, find target, apply action), and both kinds running in the demo: the bandit guard on a Behavior Tree, the village guard on a State Tree. The guards hit what they reach through Apply Damage, so the one hit remembers who did it. - A Gameplay Debugger category, and Get Debug Lines for the same lines in your own UI. **Guilds** - Found, join, leave, disband, invite, requests to join for private guilds. - Roles and permissions in a table, and each guild's leader can rename a role, change what it can do and its daily vault limit. - Levels by experience, a vault counted by tag with a log, a daily withdrawal limit per role. - Items with their own data in the vault (256 characters: durability, mods), and Take and +1 on the vault row. - Up to 4 roles a guild makes itself, edited on the guild screen. - Guild chat with history, a cooldown, a mute rule and a filter hook. - Invites to players who are offline, waiting for their next login. - Console commands for testing, listed in the README. - Alliances and wars between guilds, emblems, an activity log, rename, private values only members receive. - Nodes for the game's own hand: vault rewards and taxes, remove, promote, hand the lead, disband. - On Member Joined, On Member Left and On Guild Request Succeeded, with the whole request. **Things a guild owns** - Chests, doors and bases owned by a guild or by one player with friends, saved with the guild, and one node for who may use them. - Captures by holding: a crowd takes it faster, allies join either side, more defenders push it back, and Get Capture Crowd gives the count. - Access rules that combine guild, role, guild level and several reputations, with an "or" between rules. **Gameplay Ability System** - Gameplay Effects by reputation stage and by guild level, with the level climbing per stage and the value carried by Set By Caller. - Gameplay Events that count as reputation actions, child events and event magnitude included. **Network** - The server decides everything. Text from clients is cut, requests are rate limited, requests other players see wait 2 seconds. - Each guild travels on its own actor, asleep until it changes. Measured: 1000 guilds reach a client that joins late in 23 to 32 seconds over 150 ms and 5% packet loss. - The private part of a guild goes to its members only, once per frame and only the lists that changed. Measured: a guild of 500 online costs the server under 1 ms per change. - The vault and activity logs travel as rings: a deposit sends its one line, not the whole log. Measured with 16 clients in one guild: 847 bytes per deposit per member, everything included (1268 before). - AI Perception asks again only on the NPCs whose faction is touched by the change. **Save** - One file per guild and per player, each with a spare copy and a checksum. A file that does not read is kept aside and never written over. - A lost list of guilds is rebuilt from the guild files. - Save To Bytes and Save Guild To Bytes for your own backend. **Screens** - Reputation list with detail, change message, guild screen with browser, search, members, vault, activity, diplomacy and emblem editor. 15 Widget Blueprints with the logic in C++, in 3 looks.