Narks
Vastly intelligent whale-like being from the stars
- Reaction score
- 90
Originally, I was going to use Event like this:
- a custom damage event is triggered
- all modifying functions for that event are fired in the correct order
- the damage is dealt
eg.
- an effect Shield reduces damage by 50%, so Shield is attached to the custom damage Event, and has a priority of 10
- an effect Stoneskin reduces damage by 5, so Stoneskin is attached to the custom damage Event, and has a priority of 1
- a unit casts a spell on Bob, dealing x damage, which fires the damage Event
- since the Shield trigger has the highest priority, the Shield trigger is fired first, which reduces the value of x by 50%
- since the Stoneskin trigger has the second highest priority, the Stoneskin trigger reduces the value of x by 5
- finally, x damage is dealt to Bob (which could be considered a trigger with a priority of 0)
Unfortunately, looking at the Event system, I realized that its not capable of doing this - mostly the lack of a priority system to control the order that triggers are fired in.
I want to write my own system to do this, similar to Event, except instead of a linked list, an ordered linked list. Problem is, I don't understand how internally Event works, apart from that it is a linked list - like what's the purpose of the EventStack...
- a custom damage event is triggered
- all modifying functions for that event are fired in the correct order
- the damage is dealt
eg.
- an effect Shield reduces damage by 50%, so Shield is attached to the custom damage Event, and has a priority of 10
- an effect Stoneskin reduces damage by 5, so Stoneskin is attached to the custom damage Event, and has a priority of 1
- a unit casts a spell on Bob, dealing x damage, which fires the damage Event
- since the Shield trigger has the highest priority, the Shield trigger is fired first, which reduces the value of x by 50%
- since the Stoneskin trigger has the second highest priority, the Stoneskin trigger reduces the value of x by 5
- finally, x damage is dealt to Bob (which could be considered a trigger with a priority of 0)
Unfortunately, looking at the Event system, I realized that its not capable of doing this - mostly the lack of a priority system to control the order that triggers are fired in.
I want to write my own system to do this, similar to Event, except instead of a linked list, an ordered linked list. Problem is, I don't understand how internally Event works, apart from that it is a linked list - like what's the purpose of the EventStack...