Any way to test for Attack Type?

gref

New Member
Reaction score
33
The Premise->
All damage a unit does has a chance to crit.
The chance to crit depends on what type of attack it was:
A Spell: dependent on intelligence
A Melee/Range attack: dependent on agility

So I need something that will detect whether the damage taken by a unit was done by a spell (Magic or Spells attack) or done by a unit's default attack (Normal, Piercing, Hero etc.) so I can determine whether I use Agility or Intelligence to determine the chance for a crit.

Code:
//Obviously pseudo code.
Events
    Unit - ArbitraryUnit Takes damage
Conditions...
Actions...

    If (Attack type = BLAH)
        Then 
            If Agility/ Random(0 -> 500) > 1
                Do crit damage 
        Else
            If Intelligence/ Random(0 -> 500) > 1
                Do crit damage 
//Numbers are arbitrary




Old:
"I'm wanting to implement a system that gives spell crits depending on intelligence, melee crits depending on agility and crit-resistance depending on strength.
To do this I need to know what type of Attack the Damage Source implies on the Triggering unit in the Event:
Code:
Events
    Unit - ArbitraryUnit Takes damage
Conditions...
Actions...

Does anyone know how to do this?
(+Rep of course will be awarded. (But helping people is good anyway))"
 
I

IKilledKEnny

Guest
Not without advance JASS as far as I know. But for one target spells it's easy.

Code:
Unit starts the effect of an ability
if target of ability being cast !=null and
random number between 1 and 100 >= 20 then
cause triggering unit to damage target of ability being cast
 

gref

New Member
Reaction score
33
Aye, that will work for spells.
But the reason I'm using the Damage events is its for all abilities, and so the critical can be proportional to the damage done. I can make the critical etc, I just don't know how to detect if its a spell or a melee/ranged attack. --

Thanks anyway IKilledKEnny
 
I

IKilledKEnny

Guest
Well if the spell has buff on his enemy targets you can check if the unit have the buff.
 

Sooda

Diversity enchants
Reaction score
318
I maybe know the answer to this...

EDIT: You can and should shange event to takes damage:
Code:
Attack Type
    Events
        Unit - A unit Is attacked
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Attacking unit) is A melee attacker) Equal to True
            Then - Actions
                -------- Attack was melee --------
                -------- Add here your melee actions. --------
                -------- On last line we don' t have to check other possibilities because it was melee attack so skip all future actions. --------
                Skip remaining actions
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Attacking unit) is A ranged attacker) Equal to True
                    Then - Actions
                        -------- Attacker was ranged. --------
                        -------- On last line we don' t have to check other possibilities because it was ranged attack so skip all future actions. --------
                        Skip remaining actions
                    Else - Actions
                        -------- If it wasn' t melee nor ranged it has to be spell attack. --------
 

gref

New Member
Reaction score
33
I maybe know the answer to this...

Oh? *Waiting expectantly*


-> IKilledKEnny
That works... but what if its a spell with a duration? etc.
I was think that perhaps as a unit casts a spell, I add it to a Unit Group called SpellDamageGroup or something, then check in the damage event if the damage source is in SpellDamageGroup, and if it is, do spell damage, remove from group. If not, do normal damage.
But that means I'd have to add that to every spell that does damage as an event, and not to the ones that don't do damage. And I don't have any idea how that will work with aoe. :(
 

denmax

You can change this now in User CP.
Reaction score
155
I don't really quite understand..
So you want to make a criticalization of your attack with the attack type of the attacker?

Type of attack is Element, Type of damage is Pierce, Hero, Chaos. So is it the element thing?
 
I

IKilledKEnny

Guest
Sooda your way won't work (even if you change the event) becuase the trigger would run and return yes on the last condition even if the spell-caster attacked normally and not only casted a spell.

Gref, I will ook into it in more depth I'll try to find a boolean that retunrs wether the damage source was a spell or not.

A month ago I could say with confidence if it's possible or not, but since I started learning JASS my GUI knowledge is fading away. :p

Edit:

I looked into some JASS functions (I wasn't able to find any GUI functions that will ehlp: I found this:

GetEventDamage

takes nothing returns real, I'm not sure what it does but I would suggest checking out.
 

gref

New Member
Reaction score
33
I don't really quite understand..
So you want to make a criticalization of your attack with the attack type of the attacker?

Type of attack is Element, Type of damage is Pierce, Hero, Chaos. So is it the element thing?

->
All damage a unit does has a chance to crit.
The chance to crit depends on what type of attack it was:
A Spell: dependent on intelligence
A Melee/Range attack: dependent on agility

So I need something that will detect whether the damage taken by a unit was done by a spell (Magic or Spells attack) or done by a unit's default attack (Normal, Piercing, Hero etc.) so I can determine whether I use Agility or Intelligence to determine the chance for a crit.
 

denmax

You can change this now in User CP.
Reaction score
155
Then create 2 different triggers.. One for melee, range and magic, another one for spells..
Now the other problem..
How do you create a criticalization of the spells if it is not one target only? (Breath of Fire, War Stomp, Fan of knives etc.)

EDIT: For the crit resistance. I don't get it, resistance xSTR? so it means it can be any attacks right?
 

gref

New Member
Reaction score
33
Well thats simple and not something I'm having a trouble with conceptionally.

Example: Agi based crit.
Code:
If ((Agility/Random(0 -> 500))>1)
    Then
        If ((Strength/Random(0 -> 500))>1)
            Then
                Crit cancelled.
            Else
                Crit Happens
    Else
        Crit doesnt happen.

Edit: You mean the group triggers? Yeah...it's a great idea till only one person in an Area of Effect gets the spell chance, and the others all get the agi chance.
 

denmax

You can change this now in User CP.
Reaction score
155
What about cleave? What will happen? The critical damage cannot be divided because its a trigger, not from the attacking Hero.
I think there is no such condition as attack type = Normal/Piercing/Hero/etc. The only condition that is possible is the Boolean Condition which has melee attacker and ranged attacker.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top