-
Notifications
You must be signed in to change notification settings - Fork 9
Effects
Effects are temporal data which can be attached to any object which implements EffectConsumer interface. All effects are handled by the EffectService. You should never ever need to call method EffectConsumer.addEffect. Effects are not persistant between server restarts, unless you serialize them with your own business logic.
`
public class DamageBonus extends EffectBase {
public static final String name = "BonusDamage";
float bonusDamage;
public DamageBonus(IEffectConsumer consumer, long duration, float bonusDamage) {
super(name, consumer);
setDuration(duration);
setBonusDamage(bonusDamage);
}
public float getBonusDamage() {
return bonusDamage;
}
public void setBonusDamage(float bonusDamage) {
this.bonusDamage = bonusDamage;
}
@Override
public void onApply() {
super.onApply();
IActiveCharacter character = (IActiveCharacter) getConsumer();
character.setCharacterProperty(DefaultProperties.weapon_damage_bonus, character.getCharacterProperty(DefaultProperties.weapon_damage_bonus) + getBonusDamage());
getGlobalScope().damageService.recalculateCharacterWeaponDamage(character);
}
@Override
public void onRemove() {
super.onRemove();
IActiveCharacter character = (IActiveCharacter) getConsumer();
character.setCharacterProperty(DefaultProperties.weapon_damage_bonus, character.getCharacterProperty(DefaultProperties.weapon_damage_bonus) - getBonusDamage());
getGlobalScope().damageService.recalculateCharacterWeaponDamage(character);
}
}
IActiveCharacter entity = ...
DamageBonus damagebonu = new DamageBonus(entity,10L,10f);
effectService.addEffect(damagebonu,entity)
`
If you would like to access this effect from command, or as an item echantment you have to either create a new class which implements from IGlobalEffect, or use @Generate
annotation
Each property is a single-value data represented as a float and stored in a primitive float array. Its guaranteed every player has all properties.
@PropertyContainer
public class SomeProperties {
@Property(name = "max_mana")
public static int max_mana;
}
That's it. Each field annotated with @Property
represents an index of property in the array. Type of the field must be static and either int or short. If "name" attribute is specified the property will be accessible from configuration files (such as class configs) or commands. All properties are printed into a file properties_dump.info
IActiveCharacter c = ...
float maxmana = c.getCharacterProperty(SomeProperties.max_mana);
todo
todo