• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Snippet] DamageType

See Damage Text for a good demonstration.

JASS:
library DamageType /* v1.0.0.0
*************************************************************************************
*
*   Creates custom damage types of priorities. Priority determines in what order to
*   display the damage in a of different damage types.
*
************************************************************************************
*
*   struct DamageType extends array
*
*       readonly string color
*       readonly integer invPriority
*           -   inverse priority means that the lower priorities run first
*
*       static method create takes string color, integer priority returns thistype
*
************************************************************************************/
    struct DamageType extends array
        private static integer instanceCount = 0
    
        readonly string color
        readonly integer invPriority
        
        static method create takes string color, integer invPriority returns thistype
            local thistype this = instanceCount + 1
            set instanceCount = this
            
            set this.color = color
            set this.invPriority = invPriority
            
            return this
        endmethod
    endstruct
endlibrary

Demonstration
JASS:
library DamageTypes uses DamageType
    private module DamageTypes_mod
        readonly static DamageType NULL = 0
        readonly static DamageType PHYSICAL
        
        private static method onInit takes nothing returns nothing
            /*                                Color    Inv Priority     */
            set PHYSICAL = DamageType.create("ffffff", 0)
        endmethod
    endmodule
    
    struct DamageTypes extends array
        implement DamageTypes_mod
    endstruct
endlibrary
 
Last edited:
Top