GGO16 - Day 21
Unfortunately tonight the time I had to spend on this project was limited to a short hour and the 5 minutes it takes to write this update. Work kept me busy until 18:30 and even that didn’t feel enough today…
Outcomes
I’ve started along the path to implementing violence in my game! Hacking will help you win fights, but taking the other guy out of the fight permanently isn’t going to stop being a feature of competitive conflict resolution anytime soon…
The first part of that is that the agent now has a body:
public class Agent {
public Body body { get; private set; }
public Agent() {
body = new Body();
}
public int calculateBaseMaintenanceCost() {
return 500;
}
public float getHealthPercentage() {
return body.getHealthPercentage();
}
}
The body is composed of some body parts:
public class Body {
Dictionary<BodyPartType, int> health = new Dictionary<BodyPartType, int>();
public Body() {
health.Add(BodyPartType.HEAD, BodyPartType.HEAD.hp);
health.Add(BodyPartType.TORSO, BodyPartType.TORSO.hp);
health.Add(BodyPartType.LEFT_ARM, BodyPartType.LEFT_ARM.hp);
health.Add(BodyPartType.RIGHT_ARM, BodyPartType.RIGHT_ARM.hp);
health.Add(BodyPartType.LEFT_LEG, BodyPartType.LEFT_LEG.hp);
health.Add(BodyPartType.RIGHT_LEG, BodyPartType.RIGHT_LEG.hp);
}
public int getHealth(BodyPartType bodyPartType) {
return health[bodyPartType];
}
public int getMaxHealth(BodyPartType bodyPartType) {
return bodyPartType.hp;
}
public float getHealthPercentage(BodyPartType bodyPartType) {
return health[bodyPartType] / (float) bodyPartType.hp;
}
public float getHealthPercentage() {
int hp = 0;
int hpMax = 0;
foreach (BodyPartType bodyPartType in health.Keys) {
hp += health[bodyPartType];
hpMax += bodyPartType.hp;
}
return hp / (float) hpMax;
}
public void damage(int dmg) {
// TODO: Random damage assignment...
// TODO: Events triggered in the event of destruction of body parts...
// TODO: Possible overflow of damage to arms to torso...
}
}
With the body parts defining the maximum health of that part:
// Head calculated to have a 12.5% chance of taking full damage from a pistol that does an exploding D2 of damage
// Best layman's explanation I could find: http://www.insomnihack.com/?p=495
public static BodyPartType HEAD = new BodyPartType("Head", 5);
public static BodyPartType TORSO = new BodyPartType("Torso", 15);
public static BodyPartType LEFT_ARM = new BodyPartType("Left Arm", 10);
public static BodyPartType RIGHT_ARM = new BodyPartType("Right Arm", 10);
public static BodyPartType LEFT_LEG = new BodyPartType("Left Leg", 10);
public static BodyPartType RIGHT_LEG = new BodyPartType("Left Leg", 10);
Likely changes I’ll include before this is done are:
- Body parts should define how hard they are to hit.
- Body parts should provide certain bonuses to the performance of an agent - these can then be revoked when the body parts are destroyed.
- Body parts should be moddable in the near future using cybernetic modifications - these will add larger or additional bonuses.
- Modded body parts should also contribute to the cost of maintenance of an agent.