Prologue
Im quite new to data oriented programming and my goal is to implement a runescape stats & damage mechanic.This is quite a pretty complex topic : [Runescape-Mechanics][1] and i havent found any ECS related sources on that topic yet.
In the following example we see a bunch of items which modify the weares stats based on a few conditions. This happens in two different variants, either for the damage calculation only, or as a buff.
Brine sabre and Brackish blade increase damage against crabs.
or
Silverlight and Darklight increase ability damage by a scaling of 25-124% against most demons. The exact damage bonus is based on your base Attack and Strength, and the monster's base Defence.
The problem
Such a RPG system is very complex. There different damage types, different resistences and other stats. Having a strong OOP background and no real experience in DOP, i cant find a suitable architecture to fill those needs.
In my current approach every stat is a component. Items and Buffs are structs. A item "buffs" its owner and the buff modifies his stats. This works so far, but i have no idea how i could realise the damage calculation, while still keeping it that flexible as it is in runescape.
This little example would just be able to buff the stats... not deal, receive or modify the damage itself.
// The stats
public struct Health{
float max;
float value;
}
public struct MeeleDamage{
float base;
float value;
}
public struct MeeleResistence{
float base;
float value;
}
// Item & Buffs
public struct Item{
string name;
int amount;
bool equipable;
List<Buff> buffs;
}
public struct Buff{
string name;
float duration;
Condition applyable;
ToBuff stat;
float value;
}
Its also important that an entity can also deal damage to multiple other entities in one frame. How would you implement such an complex mechanic ? Any examples are appreciated !