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

[System] Unit Attack

Here is some test code ^)^

JASS:
struct Tester extends array
    private static method onInit takes nothing returns nothing
        local integer i = 1
        local unit u1
        local unit u2
        local unit u3
        local unit u4
        
        loop
            exitwhen 0 == i
            set i = i - 1
            //set u1 = CreateUnit(Player(2), 'hfoo', GetStartLocationX(0), GetStartLocationY(0) - 512, 270)
            set u2 = CreateUnit(Player(2), 'hrif', GetStartLocationX(0), GetStartLocationY(0) - 512, 270)
            //set u3 = CreateUnit(Player(0), 'hgtw', GetStartLocationX(0), GetStartLocationY(0), 270)
            set u4 = CreateUnit(Player(0), 'hfoo', GetStartLocationX(0), GetStartLocationY(0), 270)
            
            set UnitAttack[u4].maxRange = 128 + 64
            set UnitAttack[u2].maxRange = 550
            set UnitAttack[u2].minRange = 300
            set UnitAttack[u4].cooldown = 5
            set UnitAttack[u2].cooldown = 5
        
            //call PhysicalDamageModifier[u4].apply(-10, true)        //-10 to incoming damage
            //call WeaponSourceEvasionModifier[u2].apply(.5)          //50% chance to evade
        endloop
        
        set u1 = null
        set u2 = null
        set u3 = null
        set u4 = null
    endmethod
endstruct

My footman ended up chasing the rifleman all over the map ;D.
 
Level 10
Joined
May 27, 2009
Messages
495
yeah it fires an order on spell cast then holds it up until the duration ends

perhaps a test? lol not really sure, channels vary like casting time or the channel ability itself...

pretty sure casting time can be detected.. i'm not sure about during the channeling stage
 
Level 10
Joined
May 27, 2009
Messages
495
btw
will the attack damage take effect in a normal attack? Since it needs some 9k attack range and 0.1 attack speed... or this system will block that damage and instead only the damage coming from this system will be dealt to the enemy?

and how about spamming the stop command? will it affect this system? o.o
yeah you know... the ATTACK event will still fire while spamming the stop command
 
It does not block damage, it blocks attack orders from going through. It will only allow attacks to go through if the unit is in the proper range and has 0 cooldown left and has a target. The unit's target is removed every time it is issued an order by a player or any other resource, so telling it to stop will prevent the attack from going through.


So essentially if the unit still has time remaining before it is allowed to attack or it is not in the proper range, its attack will be canceled. The cancellation does not issue the unit to stop, rather it makes the unit follow its target (which is normal wc3 behavior).

If the unit is too close (like in my example with the rifleman), the unit will run away in order to increase its distance from the target so that it can attack. Sadly, the unit will not run away until it is prepared to attack, but I can fix that.



But yea, you can still do anything you want with this. It does not issue its own damage, it runs completely off of wc3. You don't have to do anything special in order to use this. Changing a unit's range with this is exactly like changing it with a native. It will not break any of your things (unless you are using onAttack events, those will break, lol).


Writing a note to myself so that I don't forget
On attack, if the distance < min range, make attacker retreat
On cooldown expiration, if there is a target and the distance < min range, make attacker retreat


Also, with retreating stuff, I can open the retreat function up so that you can use it. Actually, I'll probably make the retreat command its own resource ^)^.
 
It doesn't support multishot or barrage. I mean, it will, it's just that your multishot/barrage will have the incorrect range. Blame this on wc3 for making the abilities incorrectly.


If you want multishot/barrage, you have to code it yourself.

edit
btw, as this is meant to replace wc3 attacks, if you want to do on attack event, you should be using DamageQueue and what not. If the depth == 1, then run your creators. In the creators, you'd do your projectiles =).


This really is not meant to run with standard wc3 damage stuff as obviously thinks like multishot and barrage will not work =).
 
Last edited:
Level 17
Joined
Apr 27, 2008
Messages
2,455
But using upgrades, even negatives ones make the number of the modifications available not really reasonable, comparing to the needed object editor stuff.
Since when an upgrade is applied, it is forever, or i'm missing something.
 
This is sooooo limited.
You can't do any spell auto cast with this system anymore (since acquisition range is used for attack range).
This will fire an overhead of events that are proceeded and ignored.
A very limited amount of users may be able to use this since this wont work on a lot of maps.
This will not work if you use other movement system that are out here for AOS Maps.

I know it's a good system, but sadly it's not flexible enough for many purposes.
 
Top