Ideas for Stendhal/Effects: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
imported>AntumDeluge
m AntumDeluge moved page Ideas for Stendhal/Effects to Stendhal/ideas/Effects: Trying to consolidate pages into sub-pages of "Stendhal"
imported>Madmetzger
Line 195: Line 195:


= Possible Implementation =
= Possible Implementation =

==Needed Changes To Entities==
Some spell like Freeze or Weaken Creature temporarily affect specific attributes of an entity. As it is reasonable not to change the attributes themselves, it is necessary to add attribute modifiers to an entity.

A first approach would store the modifier factors in a class and the entity classes compute an attribute's value by summing up all modifiers and applying it to the actual attribute's value. To reflect the temporal nature of a modifier it is capable of determining its validity based on a timestamp within the method ''isValid''. This approach has the obvious disadvantage, that within ''GuidedEntity'' the modifiers for not existing attributes are available.

The second approach uses an additional layer of indirection to hide the modifiers for not existing attributes. On each level of the entity inheritance hierarchy is a specific modifier defined that is called to calculate the modified value.

The TurnNotifier is used to clean up expired modifiers. As a modifier is able to distinguish between being valid and not, it is not necessary, that this clean up helper runs every second or even more frequently.

<gallery caption="Attribute modifiers variants">
File:Modifier-idea-01.png|Simple modifier
File:Modifier-idea-02.png|Modifier concept hiding the "full" modifiers
</gallery>

The second option has been implemented. It has been removed later due to compatibility reasons.


== Player Resistance & Status ==
== Player Resistance & Status ==