-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New feature: effect #67
Comments
How effects are implemented in gamesRegardless of our game and evm characters, this would be good effect system to me. 1. effects can have attribute modifier, special process triggered by specific event or both of two.
interface ATTRIBUTE_MODIFIER {
bytes4 constant ATTRIBUTE_MODIFIER_ID = byte4(keccak256(bytes("ATTRIBUTE_MODIFIER")));
function applyAttributeModifier(ENTITY memory _entity) external {}
}
interface ON_RECEIVE_DAMAGE {
bytes4 constant ON_RECEIVE_DAMAGE_ID = byte4(keccak256(bytes("ON_RECEIVE_DAMAGE")));
function onReceiveDamage(ENTITY memory _entity, uint _damage) external {}
}
interface ON_ATTACK {
bytes4 constant ON_ATTACK_ID = byte4(keccak256(bytes("ON_ATTACK")));
function onAttack(ENTITY memory _entity) external {}
}
abstract BASE_EFFECT {
mapping[] INTERFACE_IDENTIFIER
function supports(byte4 _id) public virtual return (bool) {}
}
contract EFFECT_1 is ATTRIBUTE_MODIFIER, BASE_EFFECT;
contract EFFECT_2 is ON_RECEIVE_DAMAGE, BASE_EFFECT;
contract EFFECT_3 is ATTRIBUTE_MODIFIER, ON_RECEIVE_DAMAGE, BASE_EFFECT;
contract EFFECT_3 is ATTRIBUTE_MODIFIER, ON_RECEIVE_DAMAGE, BASE_EFFECT; 2. effects have durations.interface BASE_EFFECT {
function isAlive() external returns (bool) {}
} (optional)3. effects need a remove method if we cache the modified value instead of regenerating the exact value each time
interface ATTRIBUTE_MODIFIER {
function applyAttributeModifier(ENTITY memory _entity) external {}
function removeAttributeModifier(ENTITY memory _entity) external {}
} Then if an entity wants to attack another entity, we would process like this: function doAttack(ENTITY memory _attacker, ENTITY memory _target) public {
// check buff supports ON_ATTACK
for (uint i; i < _attacker.buffs.length; ++i) {
address buff = _attacker.buffs[i];
if (buff.supports(ON_ATTACK_ID)) {
ON_ATTACK(buff).onAttack(_attacker);
}
}
uint damage = calculateDamage(_attacker, _target);
// trigger receiveDamage
doReceiveDamage(_target, damage);
}
function doReceiveDamage(ENTITY memory _target, uint _damage) public {
// check buff supports ON_RECEIVE_DAMAGE
for (uint i; i < _target.buffs.length; ++i) {
address buff = _target.buffs[i];
if (buff.supports(ON_RECEIVE_DAMAGE_ID)) {
ON_RECEIVE_DAMAGE(buff).onReceiveDamage(_target, _damage);
}
}
} |
Effects in AutochessiaBefore discussing the exact implementation, let me remind you how does one turn be processed in our game.
At first we should define how effects are described or stored in our game.
effect index
modifier
We now have 6 kinds of attribute. Considering scalability, I think 4 bits assigned to
trigger
9.2 update
So there are two different types of trigger, one is to apply at most two effects to whatever target. This type of trigger is mainly used for modifying pieces' attribute including current health(it means dealing real damage). The other one is to do one sub-action( We need to allocate a space for describing how we use the value returned by env extractor. If it's a possibility checker, the value returned will be 0/1. If it's an extractor about how many allies locate around this entity, the value returned would be the exact number of adjacent allies. An effect can choose to how to use the value, maybe like the more allies surrounded, the more damage the entity can deal, or do whatever thing that has no relationship with the value.
9.7 update
At present, only an Piece.effects
I want to limit the maximum total effect number of a
How we generate an effect from an hero ability or an equipment?
Come back to the question about how we describe that an equipment or an hero ability has an effect. The answer is quite simple. Just like how we represent the effects applied to a |
purpose
In order to realize more complex battle system that supports skills, buffs and debuffs.
Future features like hero abilities, equipment, racial effects would heavily rely on this.
The text was updated successfully, but these errors were encountered: