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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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