• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Snippet] DamageType

Level 31
Joined
Jul 10, 2007
Messages
6,306
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