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?
 
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.
 
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
 
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.
 
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.
 
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.
 
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
 
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 The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/

      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