Triggered Crit

Stringel

New Member
Reaction score
12
Has been searching this forum but no hits, the thing is that I need a triggered critical hit but I dont want to use buff placers and I'm not very familiar with JASS systems. The reason I want it triggered is that I want spells and abilities to be able to interfere with crit damage and chance.

So my question is: is it possible to make a triggered critical hit without buff placers and in that case how would the code look if I used damage for example?

Thanks on forehand

edit: also I was thinking, if I use damage or something similar it would be a great idea to be able to assign crit chance to every unit in the map using AIDS, is that possible?
 

hgkjfhfdsj

Active Member
Reaction score
55
The reason I want it triggered is that I want spells and abilities to be able to interfere with crit damage and chance.
could you give an example of this

well using damage, something like this might work
JASS:
if Damage_IsAttack() and GetEventDamage() > 0. then
     if /* other conditions, eg chance, evasion modifiers */ then
          call Damage_BlockAll() //wc3 critical strike fires damage event twice: one with 0 damage, the other the multiplied one
          call DisableTrigger(GetTriggeringTrigger())
          call Damage_Physical(GetEventDamageSource(), GetTriggerUnit(), GetEventDamage()*multiplier, ATTACK_TYPE_NORMAL, true, false)
          call EnableTrigger(GetTriggeringTrigger())  
          //red floating text thing
 
     endif
endif

extending this to include external triggered damages, eg from a passive spell, would be a little more difficult, and as i was saying, an example would show us how this triggered critical strike would be used.

as for using AIDS, your suggestion is possible. however, unless every unit is guaranteed to have critical strike, unused structs is pointless and inefficient. i would suggest you use the index as per normal, and attach structs only to units that learn/have it, eg on 'Learns a skill' event.
 

Synthetics

New Member
Reaction score
7
If you wanted to use triggers i could suggest a way

just by using variables, if you wanted it for each player make it variable with an index. im at work at the mo so i cant put screen shots in and the trigger coding may be slightly different as im doing this from memory.

but i'd say use an integer variable Crit_chance_percent[index] & Crit_chance[index] damage_done[index] (it wont look like that when you've set it up ill write more on that shortly

create a trigger

Event

a unit attacks a unit (generic unit event) <---- for melee or
unit starts the effect of an ability <---single tasget spells

conditions - nothing <-- for melee
or ability being cast = to your spell (single target only)

Actions

Set varialbe - damage_done[owneroftriggering unit] = damage done by unit (this only works for single target spells/attacks)

Set variable - Crit_chance[owneroftriggeringunit] random number between 1-100



If/then/else multiple

If

if crit_chance[owneroftriggeringunit] is = or less than Crit_chance_percent[owneroftriggeringunit]

then
damage unit - what ever damage and damage type (for example lets pretend that a crit strike is x 2 damage factor - damage unit (arithatic damage_done[index] x 2)

floating text - show text moving up or down, variable damage_done[owneroftriggering unit]

else
do nothing

the floating text is just for show and can ready whatever you like

for AoE abilities

you'd need a group variable i.e aoe_group_damage[index]

and add each unit damaged to the group the trigger will look alot different than the on above you'd also need some extra variables,

Caster[index] this is a point variable which would be used for stuff like thunder clap and target_point[index] this would be use for spells like blizzard
you'd also need the above variables aswell

so the trigger would roughly look like


events

unit casts ability (generic)

condtion

ability being cast = your spell

action

set variable caster[index] position of casting units
or
set variable target_point[index] target point of ability being cast

set variable crit_chance[index] random number between 1-100

create variable aoe_group_damage[index]

if/them/else

if crit_chance[index] is = or less than crit_chance_percent

do actions
pick evey unit pointwith polar offset 300(for example we have a blizzard spell and its aoe range is 300,) that would be targer_point[index] and 300
loop
add picked unit to aoe_group_damage

set variable damage_done[index] - damage done to a random unit in unit group (they all take the same damage so this should take the damge of 1 unit affected by the ability)
pick every unit in group aoe_group_damage[index] and do actions
loop
damage picked unit for damage_done[index] x 2

then you need a custom script to remove the group to stop memory leaks
Custom script: call DestroyGroup (udg_Temp_Group)
Custom script: call RemoveLocation (udg_Temp_Point)

(udge_temp_Group) would be the name of group in this case aoe_group_damge[index] same goes for temp point

now i've swiped that bit of coding from emjlr3's memory leak tutorial (check it out, its really worth a read) and its essential to have it when using group variables and points to avoid memory leaks

now because im jass illiterate (and generally :p) to get a group which uses indexs i simply copy part of the trigger with the variable in it in to another trigger on its own then convert that to custom script and copy the names and brackets which has the name of my group and place it where

else
do nothing

for the thunder clap version jsut replace target_point[index] with caster and set caster point to position of casting unit


there may be some flaws with this again im at work (as you can see im very busy :) ) if anyone can spot anything that isnt right pls write something constructive rather than flame me :p)

hope this helps
 

Ayanami

칼리
Reaction score
288
If you wanted to use triggers i could suggest a way

just by using variables, if you wanted it for each player make it variable with an index. im at work at the mo so i cant put screen shots in and the trigger coding may be slightly different as im doing this from memory.

but i'd say use an integer variable Crit_chance_percent[index] & Crit_chance[index] damage_done[index] (it wont look like that when you've set it up ill write more on that shortly

create a trigger

Event

a unit attacks a unit (generic unit event) <---- for melee or
unit starts the effect of an ability <---single tasget spells

conditions - nothing <-- for melee
or ability being cast = to your spell (single target only)

Actions

Set varialbe - damage_done[owneroftriggering unit] = damage done by unit (this only works for single target spells/attacks)

Set variable - Crit_chance[owneroftriggeringunit] random number between 1-100



If/then/else multiple

If

if crit_chance[owneroftriggeringunit] is = or less than Crit_chance_percent[owneroftriggeringunit]

then
damage unit - what ever damage and damage type (for example lets pretend that a crit strike is x 2 damage factor - damage unit (arithatic damage_done[index] x 2)

floating text - show text moving up or down, variable damage_done[owneroftriggering unit]

else
do nothing

the floating text is just for show and can ready whatever you like

for AoE abilities

you'd need a group variable i.e aoe_group_damage[index]

and add each unit damaged to the group the trigger will look alot different than the on above you'd also need some extra variables,

Caster[index] this is a point variable which would be used for stuff like thunder clap and target_point[index] this would be use for spells like blizzard
you'd also need the above variables aswell

so the trigger would roughly look like


events

unit casts ability (generic)

condtion

ability being cast = your spell

action

set variable caster[index] position of casting units
or
set variable target_point[index] target point of ability being cast

set variable crit_chance[index] random number between 1-100

create variable aoe_group_damage[index]

if/them/else

if crit_chance[index] is = or less than crit_chance_percent

do actions
pick evey unit pointwith polar offset 300(for example we have a blizzard spell and its aoe range is 300,) that would be targer_point[index] and 300
loop
add picked unit to aoe_group_damage

set variable damage_done[index] - damage done to a random unit in unit group (they all take the same damage so this should take the damge of 1 unit affected by the ability)
pick every unit in group aoe_group_damage[index] and do actions
loop
damage picked unit for damage_done[index] x 2

then you need a custom script to remove the group to stop memory leaks
Custom script: call DestroyGroup (udg_Temp_Group)
Custom script: call RemoveLocation (udg_Temp_Point)

(udge_temp_Group) would be the name of group in this case aoe_group_damge[index] same goes for temp point

now i've swiped that bit of coding from emjlr3's memory leak tutorial (check it out, its really worth a read) and its essential to have it when using group variables and points to avoid memory leaks

now because im jass illiterate (and generally :p) to get a group which uses indexs i simply copy part of the trigger with the variable in it in to another trigger on its own then convert that to custom script and copy the names and brackets which has the name of my group and place it where

else
do nothing

for the thunder clap version jsut replace target_point[index] with caster and set caster point to position of casting unit


there may be some flaws with this again im at work (as you can see im very busy :) ) if anyone can spot anything that isnt right pls write something constructive rather than flame me :p)

hope this helps

There's no way to detect damage dealt by doing it your way. If you use the event "Unit is attacked", there's no "Damage Taken" event response as that event response is for another event.
 

Stringel

New Member
Reaction score
12
Thanks for all replies, will +rep when I get time.

The reason I want to interfere with crit is that I want to create a crit and a parry that (almost) every unit has. The crit is... well yeah a regular crit, and the parry chance makes the unit able to parry the crit thus saving it from the damage. Parry would be increased by strength, items and some abilities; crit by agility, items and abilities. I don't think more details are necessairy since I believe I can solve the mathimatical formulas when I've got the crit triggered.

I was thinking about using AIDS to assign crit chance and parry chance to every unit on the map but I'm afraid my JASS experiance is extremely limited.

Furthermore the crit only implies to melee hits thus making any "takes damage" event not working since I don't want to use buff placers.
The reason I want it triggered is that I want spells and abilities to be able to interfere with crit damage and chance.
could you give an example of this

well using damage, something like this might work
JASS:
if Damage_IsAttack() and GetEventDamage() &gt; 0. then
     if /* other conditions, eg chance, evasion modifiers */ then
          call Damage_BlockAll() //wc3 critical strike fires damage event twice: one with 0 damage, the other the multiplied one
          call DisableTrigger(GetTriggeringTrigger())
          call Damage_Physical(GetEventDamageSource(), GetTriggerUnit(), GetEventDamage()*multiplier, ATTACK_TYPE_NORMAL, true, false)
          call EnableTrigger(GetTriggeringTrigger())  
          //red floating text thing
 
     endif
endif

extending this to include external triggered damages, eg from a passive spell, would be a little more difficult, and as i was saying, an example would show us how this triggered critical strike would be used.

as for using AIDS, your suggestion is possible. however, unless every unit is guaranteed to have critical strike, unused structs is pointless and inefficient. i would suggest you use the index as per normal, and attach structs only to units that learn/have it, eg on 'Learns a skill' event.
 

hgkjfhfdsj

Active Member
Reaction score
55
Furthermore the crit only implies to melee hits thus making any "takes damage" event not working since I don't want to use buff placers.
buff placer??? damage doesnt use buff placer :), unless i misunderstood :O. the Damage_IsAttack() will only work properly if all damage is done by the system.
 

Stringel

New Member
Reaction score
12
Furthermore the crit only implies to melee hits thus making any "takes damage" event not working since I don't want to use buff placers.
buff placer??? damage doesnt use buff placer :), unless i misunderstood :O. the Damage_IsAttack() will only work properly if all damage is done by the system.

I was not adressing you when I said that, regarding your code I'm still not sure how it works and what system it uses (damage?) and how do I modify it to work like I've explained?

thanks on forehand
 

Ayanami

칼리
Reaction score
288
I was not adressing you when I said that, regarding your code I'm still not sure how it works and what system it uses (damage?) and how do I modify it to work like I've explained?

thanks on forehand

If you're planning to use damage, only downside is that you'll have trigger all your spell's damage using the function UnitDamageTargetEx. Basically, all non-triggered damage is treated as your normal physical attack damage.

And for your chance thing, you can use Hashtable too.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top