• 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.

Creep Control

Status
Not open for further replies.
Level 12
Joined
Mar 13, 2012
Messages
1,121
You should stop wandering and get on your computer!
Use a simple stop command when your hero begins an attack on a disallowed target.
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
That should work, but requires JPNG because of scope and the private keyword.

JASS:
scope FriendlyAttackSystem initializer init
    private function Conditions takes nothing returns boolean
        local unit a = GetAttacker()
        local unit u = GetTriggerUnit()        
        /*
        *   TriggerPlayer is the owner of the attacked unit.
        */
        if IsUnitAlly(a, GetTriggerPlayer()) then
            /*
            *   Is current life > 40%?
            */
            if ((GetWidgetLife(u)/GetUnitState(u, UNIT_STATE_MAX_LIFE)) > 0.4) then
                /*
                *   Not much of a difference to "stop".
                *       - If the previous order was a no target order, it will keep it, for instance "holdposition"
                *       - easy to detect/filter because a unit can't get this order, except via trigger.
                *
                *   Use whatever you like.
                */
                //call IssueImmediateOrder(a, "stop")
                call IssueImmediateOrderById(a, 851973)
            endif

        endif
        set a = null
        set u = null
        return false
    endfunction

    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED)
        call TriggerAddCondition(t, Condition(function Conditions))
        //set t = null
    endfunction
endscope
 
Level 10
Joined
Mar 17, 2012
Messages
582
- When a unit is attacked.
- If the attacked's owner is the same as the attacker's owner and the health of the attacked is more or equal than 40%
- order stop to the attacker

:thumbs_up:

That should work, but requires JPNG because of scope and the private keyword.

JASS:
scope FriendlyAttackSystem initializer init
    private function Conditions takes nothing returns boolean
        local unit a = GetAttacker()
        local unit u = GetTriggerUnit()        
        /*
        *   TriggerPlayer is the owner of the attacked unit.
        */
        if IsUnitAlly(a, GetTriggerPlayer()) then
            /*
            *   Is current life > 40%?
            */
            if ((GetWidgetLife(u)/GetUnitState(u, UNIT_STATE_MAX_LIFE)) > 0.4) then
                /*
                *   Not much of a difference to "stop".
                *       - If the previous order was a no target order, it will keep it, for instance "holdposition"
                *       - easy to detect/filter because a unit can't get this order, except via trigger.
                *
                *   Use whatever you like.
                */
                //call IssueImmediateOrder(a, "stop")
                call IssueImmediateOrderById(a, 851973)
            endif

        endif
        set a = null
        set u = null
        return false
    endfunction

    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED)
        call TriggerAddCondition(t, Condition(function Conditions))
        //set t = null
    endfunction
endscope

No jass please :ogre_rage:

You should stop wandering and get on your computer!
Use a simple stop command when your hero begins an attack on a disallowed target.

:goblin_yeah:


Thank to all) now I know that I was right) I had my doubts about that but now I'm sure =)
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
You can use this. It is excacly the same as the vJass code I've posted.

  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Custom script: local unit a = GetAttacker()
      • Custom script: local unit u = GetTriggerUnit()
      • Custom script: if IsUnitAlly(a, GetTriggerPlayer()) then
      • Custom script: if ((GetWidgetLife(u)/GetUnitState(u, UNIT_STATE_MAX_LIFE)) > 0.4) then
      • Custom script: call IssueImmediateOrderById(a, 851973)
      • Custom script: endif
      • Custom script: endif
      • Custom script: set a = null
      • Custom script: set u = null
This one is also the same, I guess it looks the most familiar to you.
Note that it is slower in execution then the upper two are.
Because:
1. The way the condition is checked in GUI
2. The way the if then else is checked in GUI
3. The precent life calculation in GUI
4. The unit order in GUI
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) belongs to an ally of (Triggering player)) Equal to True
    • Actions
      • Set Attacker = (Attacking unit)
      • Set Attacked = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Percentage life of Attacked) Greater than or equal to 40.00
        • Then - Actions
          • Unit - Order Attacker to Stop
        • Else - Actions
 
Level 10
Joined
Mar 17, 2012
Messages
582
You can use this. It is excacly the same as the vJass code I've posted.

  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Custom script: local unit a = GetAttacker()
      • Custom script: local unit u = GetTriggerUnit()
      • Custom script: if IsUnitAlly(a, GetTriggerPlayer()) then
      • Custom script: if ((GetWidgetLife(u)/GetUnitState(u, UNIT_STATE_MAX_LIFE)) > 0.4) then
      • Custom script: call IssueImmediateOrderById(a, 851973)
      • Custom script: endif
      • Custom script: endif
      • Custom script: set a = null
      • Custom script: set u = null
This one is also the same, I guess it looks the most familiar to you.
Note that it is slower in execution then the upper two are.
Because:
1. The way the condition is checked in GUI
2. The way the if then else is checked in GUI
3. The precent life calculation in GUI
4. The unit order in GUI
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) belongs to an ally of (Triggering player)) Equal to True
    • Actions
      • Set Attacker = (Attacking unit)
      • Set Attacked = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Percentage life of Attacked) Greater than or equal to 40.00
        • Then - Actions
          • Unit - Order Attacker to Stop
        • Else - Actions

already done it) thanks)
 
Status
Not open for further replies.
Top