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

Auto-Cast error...

Status
Not open for further replies.
Ok here is the rundown of the issue. Im making a game in which the attacks arent like normal. each unit has 4 universal skills. Morale, Experience, Weapons, and Training. When a unit uses its attack ability, a dummy spell based off slow which can be set to autocast, it calculates based off the level of these abilities and how many ppl are left in the unit, hp how much damage they should do. Problem is they arent auto 'attacking'.

For the attack ability I set both Durations to 0.01 Cooldown to 3.00 priority to 1 but i dont think those effect the autocast.

What I need to know is why the autocast isnt working. Also the units run because the dont have a normal attack so they run like they were peons, is there a way to stop this?

---------------

Also I need triggers to make all selected units use thier attack ability on an enemy unit that is right clicked on. Is this possible?
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Yes everything you want is possible.
In a few, I will edit this.
First of all note that the "autocasts" blizzard made are not really autocasts as you know them.
When something happens(a unit with searing arrows attacks and etc) units are ordered to cast their spell.
When you remove the normal attack, you remove the event which makes units cast slow(for example; you can try and see if a sorceress would cast slow on a unit that does not attack(or whatever the event that fires slow is)).

Disabling "running" is easy - in the object editor disable unit flee or something.

For the autocasts. The way I can think of is rather simple.
Every few seconds(0.5 for example) order every unit with one of it's autocast abilities turned on to cast it.
For finding which unit has some autocast ability turned on, you should put units in a group when they activate an autocast and remove them when they deactivate it. Meaning you will have 4 groups(for morale, for experience, for weapons, for training, for attack).
So every few seconds you pick all units in some group.
Depending on the targeting of the spells you will have a different number of "pick up and order" triggers.
If it is attack, you will have to order the unit to cast it's attack autocast ability on some unit(if there is a unit curently "attacked" by the unit you want to order to "attack", you should order it to "attack" that unit).
This a what I thought of, but "attacking" like this is tricky, but about the other stuff will work easy.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
That is what I meant by tricky as attacking usually requires a target.
Simplest thing - pick a random unit from units within range.
NO, it better be First unit of unit group ( units within range).
I am not too sure about this one, but I think that will make the unit attack one unit continuously.
The range should be equal to the acquisition range(750 for example) casting range of the autocast spell should be 600(for example; or 130-200 for a melee range attacl) so that it would look like a normal attack.
But when you are ordering some unit to "attack" you should check the current order to see if it is not moving to "attack" at the moment.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
You can set the attack to 0-0 ( base damage: -1 (shift click), dice: 1, sides per die: 1).
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Yes you can by holding shift(not sure which one) and then clicking on the filed(double click or enter).
That is normal - you based it on slow. Base it on searing arrows.
Not too sure if you could set" 'attack' starts on auto" from the object editor(I kinda doubt it).
But you can make a trigger similar to this:
Event
A unit enters playable map area
Conditions
Triggering unit has "attack"
Actions
Order triggering unit to night elf P.o.t.m. activate searing arrows
(I am not using trigger tags, as I am just writing this)
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Cast what !??
I also have an issue the spell I made does not work!
Can you find out what the problem is with that much info.
P.s. Double posting is "bad"
 
ok... When you click on searing arrows and then click on a target searing arrows goes green until the target is in range then the button is pressed and the ability is cast. When the ability is done casting the button is depressed and stops being green. According to the triggers this ability has just been cast.

When using autocast on searing arrows the button never goes green or presses and depresses but it still takes mana and effects projectiles. According to the triggers this ability was never cast.

That clairify?

----------------

Perhaps there is a different event besides "when unit begins effect of spell" that could be used to solve problem?
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
That has issues - (the whole abusable, attack detection systems routine goes here).
Using a searing arrows based spell to do the damage without any triggers for the damage is preferable. But you will be confined to a couple of amounts of damage.
I guess the problem was caused by you.
 
You seemed not to understand, I was using triggers from the begining.

Here is the function that would calculate damage based on what abilities they had
JASS:
function CalcHit takes unit A, unit D, boolean r returns real
    local integer Alvl = GetUnitAbilityLevelSwapped('A000', A)
    local integer Dlvl = GetUnitAbilityLevelSwapped('A000', D)
    local integer Amor = GetUnitAbilityLevelSwapped('A001', A)
    local integer Dmor = GetUnitAbilityLevelSwapped('A001', D)
    local integer Aexp = GetUnitAbilityLevelSwapped('A002', A)
    local integer Dexp = GetUnitAbilityLevelSwapped('A002', D)
    local integer Awep = GetUnitAbilityLevelSwapped('A003', A)
    local integer Apop = R2I(GetUnitStateSwap(UNIT_STATE_LIFE, A))
    local integer Arol = (((GetRandomInt(1, 10) + Alvl)*5) + Aexp) + Amor
    local integer Drol = (((GetRandomInt(1, 10) + Dlvl)*5) + Dexp) + Dmor
    local integer dmg = 0
    local integer Amin = 0
    local integer Amax = 0
    local integer Dmin = 0
    local integer Dmax = 0
    local texttag ae = CreateTextTag()
    local texttag de = CreateTextTag()
    if r then
        set dmg = ((GetRandomInt((Apop / 6), (Apop / 4))-(Apop / 8)) + Awep) + (Amor - Dmor)
        set Amin = (25-(Alvl*2)) - Amor
        set Amax = (105-Alvl) - Amor
        set Dmin = (35+(Dlvl*2)) + Dmor
        set Dmax = (105-Dlvl) - Dmor
    else
        set dmg = (GetRandomInt((Apop / 6), (Apop / 4)) + Awep) + (Amor - Dmor)
        set Amin = (20-(Alvl*2)) - Amor
        set Amax = (100-Alvl) - Amor
        set Dmin = (30+(Dlvl*2)) + Dmor
        set Dmax = (100-Dlvl) - Dmor
    endif
    if (Alvl > 0)then
    if (Arol <= Amin) then
       set dmg = 0
       call SetTextTagText(ae,"Miss!", 0.024)
       call SetTextTagPos(ae, GetUnitX(A), GetUnitY(A), 0.00)
       call SetTextTagColor(ae, 255, 0, 0, 255)
       call SetTextTagVelocity(ae, 0, 0.04)
       call SetTextTagVisibility(ae, true)
       call SetTextTagFadepoint(ae, 2)
       call SetTextTagLifespan(ae, 5)
       call SetTextTagPermanent(ae, false)
    endif
    if (Arol >= Amax) then
       set dmg = dmg * 2
       call SetTextTagText(ae,"Crit!", 0.024)
       call SetTextTagPos(ae, GetUnitX(A), GetUnitY(A), 0.00)
       call SetTextTagColor(ae, 255, 0, 0, 255)
       call SetTextTagVelocity(ae, 0, 0.04)
       call SetTextTagVisibility(ae, true)
       call SetTextTagFadepoint(ae, 2)
       call SetTextTagLifespan(ae, 5)
       call SetTextTagPermanent(ae, false)
    endif
    endif
    if (Dlvl > 0) then
    if (Drol <= Dmin) then
       set dmg = dmg / 2
       call SetTextTagText(de,"Block!", 0.024)
       call SetTextTagPos(de, GetUnitX(D), GetUnitY(D), 0.00)
       call SetTextTagColor(de, 0, 0, 255, 255)
       call SetTextTagVelocity(de, 0, 0.04)
       call SetTextTagVisibility(de, true)
       call SetTextTagFadepoint(de, 2)
       call SetTextTagLifespan(de, 5)
       call SetTextTagPermanent(de, false)
    endif
    if (Drol >= Dmax) then
       set dmg = 0
       call SetTextTagText(de,"Dodge!", 0.024)
       call SetTextTagPos(de, GetUnitX(D), GetUnitY(D), 0.00)
       call SetTextTagColor(de, 0, 0, 255, 255)
       call SetTextTagVelocity(de, 0, 0.04)
       call SetTextTagVisibility(de, true)
       call SetTextTagFadepoint(de, 2)
       call SetTextTagLifespan(de, 5)
       call SetTextTagPermanent(de, false)
    endif
    endif
    set ae = null
    set de = null
    set A = null
    set D = null
    return I2R(dmg)
endfunction

here is the trigger I made to check if they had the ability in the first place.

JASS:
function Trig_Attacks_Conditions takes nothing returns boolean
    if ( ( GetUnitAbilityLevelSwapped('A006', GetAttacker()) > 0 ) ) then
        return true
    endif
    if ( ( GetUnitAbilityLevelSwapped('A007', GetAttacker()) > 0 ) ) then
        return true
    endif
    return false
endfunction

function Trig_Attacks_Actions takes nothing returns nothing
     local unit u = GetAttacker()
     local unit t = GetAttackedUnitBJ()
     local real dmg = 0
     if ( ( GetUnitAbilityLevelSwapped('A006', GetAttacker()) > 0 ) ) then
         set dmg = CalcHit( u, t, false)
         call UnitDamageTargetEx(u, t, dmg, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ATTACK, true)
     endif
     if ( ( GetUnitAbilityLevelSwapped('A007', GetAttacker()) > 0 ) ) then
         set dmg = CalcHit( u, t, true)
         call UnitDamageTargetEx(u, t, dmg, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ATTACK, true)
     endif
endfunction

//===========================================================================
function InitTrig_Attacks takes nothing returns nothing
    set gg_trg_Attacks = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Attacks, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Attacks, Condition( function Trig_Attacks_Conditions ) )
    call TriggerAddAction( gg_trg_Attacks, function Trig_Attacks_Actions )
endfunction
----
Wow just noticed I have an info leak there.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
I understood, but using a trigger like that, will damage the target before the projectile hits the target.
Using an autocastable dummy spell is still preferable, since the damaging will be done only when the spell is activated, not every time you press stop.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
There are always the attack detection systems.
But a major reason for people to use them is to prevent abusal.
 
Status
Not open for further replies.
Top