Snippet IsUnitDummy

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Short library with only one function: IsUnitDummy()

Just implement it into your map, change the config and whenever
you need to damage units in an AoE with a custom spell,
use isUnitDummy() to check if the unit is a dummy caster, missle or whatever...

JASS:
// *******************************************************
// *******************************************************
// **                                                   **
// **             IsUnitDummy() By Magentix             **
// **                                                   **
// *******************************************************
// *******************************************************
// **                                                   **
// ** Allows you to easily check if a unit is           **
// ** a dummy caster, missile or effect unit.           **
// **                                                   **
// ** Common use would be in custom spells              **
// ** when validating which units to damage             **
// **                                                   **
// ** Configure the dummies below:                      **
// **                                                   **
//! textmacro SetDummyCheckerData

    set DUMMY_AMOUNT    = 3                            
        
    set DUMMY_ID[0]     = 'n000'
    set DUMMY_ID[1]     = 'n001'
    set DUMMY_ID[2]     = 'n002'
    // etc.
    
//! endtextmacro
// **                                                   **
// ** Don't change anything past this point.            **
// ** Credit isn't required, but would be appreciated.  **
// **                                                   **
// *******************************************************
// *******************************************************

library DummyChecker initializer Init
    globals
        private integer array DUMMY_ID
        private integer DUMMY_AMOUNT
    endglobals
    
    function IsUnitDummy takes unit u returns boolean
        local integer i = 0
        local integer UnitID = GetUnitTypeId(u)
        
        loop
        exitwhen i > DUMMY_AMOUNT
            
            if UnitID == DUMMY_ID<i> then
                return true
            endif
            
            set i = i + 1
        endloop
        
        return false
    endfunction
    
    private function Init takes nothing returns nothing
        //! runtextmacro SetDummyCheckerData()
    endfunction
endlibrary
</i>
 

Cohadar

master of fugue
Reaction score
209
JASS:
    function IsUnitDummy takes unit u returns boolean
        local integer i = 0
        local integer UnitID = GetUnitTypeId(u)
        
        loop
            exitwhen i &gt; DUMMY_AMOUNT
            
            if UnitID == DUMMY_ID<i> then
                return true
            endif
            
            set i = i + 1
        endloop
        
        return false
    endfunction
</i>


You suck at programming you know....
 

darkRae

Ueki Fan (Ueki is watching you)
Reaction score
173
So from what I can understand, it checks if a unit is a Dummy Unit (Dummies needed for spells)
By looping through dummy unit types and checking them if they're the same.

Quite simple and useful, although I would check whether the unit has the Locust ability :)
 

Cohadar

master of fugue
Reaction score
209
Quite simple and useful, although I would check whether the unit has the Locust ability :)

And what if you have locust swarm or some similar spell?

Meh this whole thread is silly, but hay at least we learned something about programming ;)
 

darkRae

Ueki Fan (Ueki is watching you)
Reaction score
173
^That would mean the same, since we wouldn't want to do the same to Locust Swarm units, right? ;)

Example : (as if needed, I know you get what I meant)
A knockback spell.
We don't want to knockback dummies.
Well, we don't want to knockback locusts, too.

^True.
I'm currently learning JASS (still don't understand ABC Structs)
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Not every custom spell uses locust on it's units.
If you need to target a locust for example...

Anyhow, small and useful snippet in my opinion, which is exactly why I put it here: so others don't have to write it themselves. (Just like simError, etc.)
 

darkRae

Ueki Fan (Ueki is watching you)
Reaction score
173
> If you need to target a locust for example...

The same. Take the unit and check if it has the Locust ability.

Well, for the second reason, it's true :D
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
Somehow funny this little function ^^. But you're right, it may help in some cases, therefore why not? :O
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top