Alliance
From NetGore Wiki
|
This page contains orphaned content! |
Alliances are used by NetGore to determine the rules for who is allowed to attack who, along with the behavior of NPCs, such as who they will attack on sight.
Contents |
Relationship to characters
Every character must have an alliance, even if it is just an alliance saying ""nobody may attack this character, and this character may not attack anybody."" There must also be only once alliance for each character since it simply makes no sense to have any number of alliances other than 1.
Changing a character's alliance
A character's alliance is allowed to change. However, make sure you change their alliance for the correct reason. The following examples describe cases where it would and would not be appropriate to change alliance:
Example 1
Appropriate: Your game is divided into two major groups that are at war with each other. New players start out neutral, and decide later on which group they wish to join. When they join a group, you change their alliance to that of the group they joined.
Inappropriate: Two players enter an arena, where everyone is allowed to attack each other. You set their alliance to a generic ""attack anybody"" alliance while they are in the arena.
Correct approach: There is a huge number of things that can happen could result in the user leaving the arena, but their alliance value not being reset. You also will have to keep track of what their previous alliance state was to be able to reset it properly. This can easily lead to players who are allowed to kill anyone they want, but people wont be able to fight back. Instead, program a conditional branch into the user's attacking that will, if they are in an arena, always return ""true"" for checking if they can attack another alliance. This way, the alliance never changes, and the arena check is done before every attack.
Example 2
Appropriate: You have a temperamental NPC who just wanders around minding their own business. Once someone attacks it, it gets angry and will attack any user on-sight until someone kills it.
Inappropriate: Same as the above, but the NPC will also calm down after 2 minutes.
Correct approach: Like in example 1, you will have to keep track of their previous alliance for this to work. While this could work for non-persistent NPCs, it won't for persistent NPCs. Instead, you should implement this directly into the AI. Set their alliance to able to attack anyone, but are not hostile by default. Their AI should contain a counter to determine if they are current ""enraged"". If they are, treat everyone attackable as hostile. When they are no longer ""enraged"", use whatever is defined by their alliance value like normal.
In content design
It is important you establish what alliances you will have early on. When in doubt, it is better to use many specific alliances instead of a few vague ones. For instance, do not give ""non-hostile townsperson NPC"" the same alliance. Create one for shopkeepers, one for guards, and one for townspeople. Better yet, the townspeople can even be split up into women, men, and children. The reason behind this is for future expansion. For instance, you may in the future decide to allow players to kill townspeople. However, to prevent excessive abuse, you don't want them to kill shopkeepers, just everyone else. Once someone gains a bad reputation, guards can then attack on-sight, children run away, men and women ignore you, women run away when attacked, and men fight back when attacked.
The above mildly-sexist example may be something you never, ever plan to implement. But keep in mind how much work is involved in creating alliances - very little. You have to select a NPCs alliance when you create them, so we can pretty much consider that a free cost. So adding these extra alliances may take about 10 extra minutes. Now imagine what kind of pain it would be to look up every single NPC in the game to update their alliance. At least when you create a NPC, you know what they will be for. But it can be tough to remember what some obscure NPC's purpose a year or two after you created them.
Do yourself a favor - just do it.