• 🏆 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!

Unit Blind Target_1.0.0

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
Copy trigger
Copy ability
Copy buff
Copy unit
Requires any Unit indexer

credits: Vexorian = dummy.mdx

I have no idea...inside the map


GUI - friendly


JASS:
library UnitBlindTarget
    globals
        private constant integer DUMMY_ID         = 'e000'
        private constant integer ABIL_ID          = 'A002'
        private constant integer BUFF_ID          = 'B001'
        private          integer UNSELECTABLE     = 'Aloc'
        private constant integer ORDER_ID         = 852190
        private constant timer   TIMER            = CreateTimer()
        private constant group   GROUP            = CreateGroup()
        private constant real    TIME             = .031250000
        private          unit    DUMMY
        real array               BLIND_RESISTANCE
    endglobals
 
    private struct BlindTarget
       static integer i1 = 0
        static integer i2 = 0
        static integer i3 = 0
        static integer array i4
        static unit array u
        static real array d

        static method callback takes nothing returns boolean
           local integer i = 1
            loop
                exitwhen i > i1
                set .i3 = .i4[i]
                if .d[.i3] <= 0.0 or IsUnitType(.u[.i3],UNIT_TYPE_DEAD) then
                    call UnitRemoveAbility(.u[.i3],BUFF_ID)
                    call GroupRemoveUnit(GROUP,.u[.i3])
                    set .i4[i] = .i4[.i1]
                    set .i4[.i1] = i3
                    set .i1 = .i1 - 1
                    set i = i - 1
                    if .i1 == 0 then
                        call PauseTimer(TIMER)
                   endif
                else
                   set .d[.i3] = .d[.i3] - TIME
                endif
                set i = i + 1
            endloop
           return false
        endmethod
  
        static method Exe takes unit target,real duration,boolean stack returns boolean
           local integer i = 0
            local integer id = GetUnitUserData(target)
            local real r = (duration/100.0)*BLIND_RESISTANCE[id]
           if IsUnitInGroup(target,GROUP)then
               set i = 1
                loop
                    exitwhen i > .i1
                    set .i3 = .i4[i]
                    if target == .u[.i3] then
                       if stack then
                           set .d[.i3] = .d[.i3] + duration-r
                        else
                           set .d[.i3] = duration-r
                        endif
                    endif
                    set i = i + 1
                endloop
            else
               if .i1 == 0 then
                   call TimerStart(TIMER,TIME,true,function BlindTarget.callback)
                endif
                set .i1 = .i1 + 1
                if .i1 > .i2 then
                    set .i4[.i1] = .i1
                    set .i2 = .i1
                endif
                set .i3 = .i4[.i1]
                set .u[.i3] = target
                set .d[.i3] = duration-r
                call SetUnitX(DUMMY,GetUnitX(target))
                call SetUnitY(DUMMY,GetUnitY(target))
                call IssueTargetOrderById(DUMMY,ORDER_ID,target)
                call GroupAddUnit(GROUP,target)
            endif
           return false
        endmethod
  
        static method onInit takes nothing returns nothing
           set DUMMY = CreateUnit(Player(15),DUMMY_ID,0.,0.,0.)
           call UnitAddAbility(DUMMY,ABIL_ID)
            if 0 == GetUnitAbilityLevel(DUMMY,UNSELECTABLE) then
                call UnitAddAbility(DUMMY,UNSELECTABLE)
            endif
        endmethod
    endstruct
 
    function IsUnitBlinded takes unit target returns boolean
        return IsUnitInGroup(target,GROUP)
    endfunction
 
    function UnitBlindTargetStack takes unit target,real duration returns nothing
       call BlindTarget.Exe(target,duration,true)
    endfunction
 
    function UnitBlindTargetNonStack takes unit target,real duration returns nothing
       call BlindTarget.Exe(target,duration,false)
    endfunction
endlibrary
Contents

Just another Warcraft III map (Map)

Reviews
MyPad
System: Notes: The system could use some documentation as to what each exposed function does. This is crucial in making the system easy-to-use for users, so that they would not need to constantly check which functions are exposed by the system...
Level 5
Joined
May 2, 2015
Messages
109
A simple description about how your system works will make this thread better.

I have look over the code and I have to say,

-
JASS:
        static method onInit takes nothing returns nothing
           set DUMMY = CreateUnit(Player(15),DUMMY_ID,0.,0.,0.)
           call UnitAddAbility(DUMMY,ABIL_ID)
            if 0 == GetUnitAbilityLevel(DUMMY,UNSELECTABLE) then
                call UnitAddAbility(DUMMY,UNSELECTABLE)
            endif
        endmethod
Would be better like this,
JASS:
        static method onInit takes nothing returns nothing
           set DUMMY = CreateUnit(Player(15),DUMMY_ID,0.,0.,0.)
           call UnitAddAbility(DUMMY,ABIL_ID)
        endmethod
the 'Aloc' ability should initially added to the dummy in Object Editor,

-What's the point of using private struct BlindTarget if its method/member works like private function

I haven't check the system to the fullest yet, and I'm going to try it. :)
 
Level 10
Joined
Aug 21, 2010
Messages
316
A simple description about how your system works will make this thread better.

I have look over the code and I have to say,

-
JASS:
        static method onInit takes nothing returns nothing
           set DUMMY = CreateUnit(Player(15),DUMMY_ID,0.,0.,0.)
           call UnitAddAbility(DUMMY,ABIL_ID)
            if 0 == GetUnitAbilityLevel(DUMMY,UNSELECTABLE) then
                call UnitAddAbility(DUMMY,UNSELECTABLE)
            endif
        endmethod
Would be better like this,
JASS:
        static method onInit takes nothing returns nothing
           set DUMMY = CreateUnit(Player(15),DUMMY_ID,0.,0.,0.)
           call UnitAddAbility(DUMMY,ABIL_ID)
        endmethod
the 'Aloc' ability should initially added to the dummy in Object Editor,

-What's the point of using private struct BlindTarget if its method/member works like private function

I haven't check the system to the fullest yet, and I'm going to try it. :)

The point is that you can not use "call BlindTarget.Exe(unit,real,boolean)" which means that you have to use functions outside of the struct.Example: call UnitBlindTargetStack(unit,real) or call UnitBlindTargetNonStack(unit,real).

But if you want this feature to be public, just remove the prefix "private".In this case, you'll be able to use the BlindTarget.Exe(unit,real,boolean) outside the struct.

Why would someone want to use BlindTarget.Exe when this(UnitBlindTargetStack) is easier.

I do not see any need to describe how this works because it is obvious.
Simply call UnitBlindTargetStack or UnitBlindTargetNonStack.Very simple, right?
Only,hmm... perhaps to explain how to use BLIND_RESISTANCE.

After all, there is a test trigger inside the map.
 
Last edited:
Level 10
Joined
Sep 16, 2016
Messages
269
If you want to call it GUI-Friendly, you shoud add the comments to the top, describing what this is for and how to use it with the APIs. New and average GUI-users really don't want to browse through a long line of hard-to-understand things to find out what it it for or how to use it.

Ps: This part looks kinda redundant, and your Variable naming is generic to me.
JASS:
private         integer UNSELECTABLE     = 'Aloc'
     
static method onInit takes nothing returns nothing
           set DUMMY = CreateUnit(Player(15),DUMMY_ID,0.,0.,0.)
           call UnitAddAbility(DUMMY,ABIL_ID)
            if 0 == GetUnitAbilityLevel(DUMMY,UNSELECTABLE) then
                call UnitAddAbility(DUMMY,UNSELECTABLE)
            endif
        endmethod

Edit: Is your "BLIND" removable buff? How about when it is purged?
 
Last edited:
Level 5
Joined
May 2, 2015
Messages
109
The point is that you can not use "call BlindTarget.Exe(unit,real,boolean)" which means that you have to use functions outside of the struct.Example: call UnitBlindTargetStack(unit,real) or call UnitBlindTargetNonStack(unit,real).

But if you want this feature to be public, just remove the prefix "private".In this case, you'll be able to use the BlindTarget.Exe(unit,real,boolean) outside the struct.
That's not the answer that I expecting.
I'm talking about changing this,
JASS:
static method Exe takes unit target,real duration,boolean stack returns boolean
into this,
JASS:
private function BlindTargetExe takes unit target,real duration,boolean stack returns boolean
Declare this
JASS:
       static integer i1 = 0
        static integer i2 = 0
        static integer i3 = 0
        static integer array i4
        static unit array u
        static real array d
variable in globals
struct is used when you want to create something that has its own attribute for each instance, like a object.
I hope you understand what I'm saying 0:)

I would suggest you to
  • replace the struct with function
  • rename the variables into something more descriptive
  • add some comment above codes that you think user takes time to understand
  • add a little documentation below library about credits, APIs, and simple how to import
  • fix the indentions, make it looks neat.
 
Last edited:
Level 10
Joined
Aug 21, 2010
Messages
316
That's not the answer that I expecting.
I'm talking about changin this,
JASS:
        static method Exe takes unit target,real duration,boolean stack returns boolean
           local integer i = 0
            local integer id = GetUnitUserData(target)
            local real r = (duration/100.0)*BLIND_RESISTANCE[id]
           if IsUnitInGroup(target,GROUP)then
               set i = 1
                loop
                    exitwhen i > .i1
                    set .i3 = .i4[i]
                    if target == .u[.i3] then
                       if stack then
                           set .d[.i3] = .d[.i3] + duration-r
                        else
                           set .d[.i3] = duration-r
                        endif
                    endif
                    set i = i + 1
                endloop
            else
               if .i1 == 0 then
                   call TimerStart(TIMER,TIME,true,function BlindTarget.callback)
                endif
                set .i1 = .i1 + 1
                if .i1 > .i2 then
                    set .i4[.i1] = .i1
                    set .i2 = .i1
                endif
                set .i3 = .i4[.i1]
                set .u[.i3] = target
                set .d[.i3] = duration-r
                call SetUnitX(DUMMY,GetUnitX(target))
                call SetUnitY(DUMMY,GetUnitY(target))
                call IssueTargetOrderById(DUMMY,ORDER_ID,target)
                call GroupAddUnit(GROUP,target)
            endif
           return false
        endmethod
should be like this,
JASS:
        private function BlindTargetExe takes unit target,real duration,boolean stack returns boolean
           local integer i = 0
            local integer id = GetUnitUserData(target)
            local real r = (duration/100.0)*BLIND_RESISTANCE[id]
           if IsUnitInGroup(target,GROUP)then
               set i = 1
                loop
                    exitwhen i > .i1
                    set .i3 = .i4[i]
                    if target == .u[.i3] then
                       if stack then
                           set .d[.i3] = .d[.i3] + duration-r
                        else
                           set .d[.i3] = duration-r
                        endif
                    endif
                    set i = i + 1
                endloop
            else
               if .i1 == 0 then
                   call TimerStart(TIMER,TIME,true,function BlindTarget.callback)
                endif
                set .i1 = .i1 + 1
                if .i1 > .i2 then
                    set .i4[.i1] = .i1
                    set .i2 = .i1
                endif
                set .i3 = .i4[.i1]
                set .u[.i3] = target
                set .d[.i3] = duration-r
                call SetUnitX(DUMMY,GetUnitX(target))
                call SetUnitY(DUMMY,GetUnitY(target))
                call IssueTargetOrderById(DUMMY,ORDER_ID,target)
                call GroupAddUnit(GROUP,target)
            endif
           return false
        endfunction
Declare this
JASS:
       static integer i1 = 0
        static integer i2 = 0
        static integer i3 = 0
        static integer array i4
        static unit array u
        static real array d
variable in globals
struct is used when you want to create something that has its own attribute for each instance, like a object.
I hope you understand what I'm saying 0:)
I understand what you mean.
But really it's just a matter of access, nothing more.If you want, feel free to change.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485

Needs Fixed

  • Spell Submission Rule: The documentation for systems must at least contain a listing of the API, external library requirements and importing instructions.
  • Alongside with documentation, please put down a description of what the system does and it's features. As of right now, I have absolutely no idea what it does.

Suggestions

  • Nothing

Status

Awaiting Update
 

System:

Notes:

  • The system could use some documentation as to what each exposed function does. This is crucial in making the system easy-to-use for users, so that they would not need to constantly check which functions are exposed by the system.

  • JPAG - JASS Proper Application Guide

    variableNames and methodNames should begin with a
    lowercase letter and each new word seperated by a new capitalized
    letter.

    In the privatized struct, the static method Exe does not follow camelCasing.

  • In the creation of the dummy caster for the system, an arbitrary number 15 has been chosen as the parameter for the native Player. Though it is understood to be PLAYER_NEUTRAL_PASSIVE, the parameter should refer to it directly, instead of an arbitrary number.

  • As it has been a considerable amount of time after the previous review, where it has still remained as Awaiting Update, it shall be sent to Substandard.

Status:

  • Substandard
 
Top