• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Enhanced Critical Strike v.61

Before viewing the code, note that this is for the spell only. There are two triggers that add the "Unit Takes Damage" events to this trigger. You will find these when you open the map.

JASS:
////////////////////////////////////////////////////////////////////
//  Enhanced Critical Strike by 1)ark_NiTe                        //
//                                                                //
//  i = Level of Enhanced Critical Strike                         //
//  r = Extra Damage Dealt (Real Damage * Level of Ability)       //
//                                                                //
////////////////////////////////////////////////////////////////////

//==================================================================================================================================
// Start of constants. These will need to be changed by you. They provide the user with easier implementing//changing of the spell's rawcodes and effects.
//==================================================================================================================================

constant function Crit_Strike_ID takes nothing returns integer
    return 'A001' // Enhanced Critical Strike ability rawcode.
endfunction

constant function Crit_Struck_ID takes nothing returns integer
    return 'A000' // Critically Struck (Dummy) ability rawcode.
endfunction

constant function Dummy_Unit_ID takes nothing returns integer
    return 'h002' // Dummy Unit rawcode.
endfunction

//==================================================================================================================================
// End of constants. Do not touch anything below this unless you are familiar with JASS.
//==================================================================================================================================

function Enhanced_Critical_Strike_Conds takes nothing returns boolean
    return GetOwningPlayer(GetTriggerUnit()) != GetOwningPlayer(GetEventDamageSource()) and GetUnitAbilityLevel(GetEventDamageSource(), 'A001') >=1 and IsUnitInGroup(GetEventDamageSource(), udg_JustCastSpell) == false and GetRandomInt(1, 100) <= 15
endfunction

function Trig_Enhanced_Critical_Strike takes nothing returns nothing
    // Declares Local Variables
    local unit e
    local unit d = GetEventDamageSource()
    local unit t = GetTriggerUnit()
    local force f = CreateForce()
    local force g = CreateForce()
    local texttag tag
    local integer i = GetUnitAbilityLevel(d, Crit_Strike_ID())
    local real dmg = ( GetEventDamage() * i )
    local real a
    local real fd
    local real r
    local trigger trig = GetTriggeringTrigger()
    call DisableTrigger(trig)
    set a = GetUnitArmor(t)
    set fd = GetFullDamage(dmg, a)
    set r = GetReducedDamage(fd, a)
    call UnitDamageTarget(d, t, r, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
    call EnableTrigger(trig)
    // Creates Floating Text showing the Damage Dealt (dmg+r)
    set tag = CreateTextTagUnitBJ( ( "|cffFF0000" + ( I2S(R2I(( ( r / i ) + r ))) + "|r" ) ), d, 0, 10, 100, 100, 100, 0 )
    if (IsPlayerInForce(GetLocalPlayer(), bj_FORCE_ALL_PLAYERS))then
        call SetTextTagVisibility(tag, false)
    endif
    call ForceEnumAllies(f, GetOwningPlayer(d), null)
    call ForceEnumAllies(g, GetOwningPlayer(t), null)
    if (IsPlayerInForce(GetLocalPlayer(), f)) or (IsPlayerInForce(GetLocalPlayer(), g)) then
        call SetTextTagVisibility(tag, true)
    endif
    call SetTextTagVelocity(tag, 0, 0.04)
    call SetTextTagPermanent(tag, false)
    call SetTextTagFadepoint(tag, 2.00)
    call SetTextTagLifespan(tag, 3.00)
    if GetWidgetLife(t) > 0 then
        set e = CreateUnit(GetOwningPlayer(d), Dummy_Unit_ID(), GetUnitX(t), GetUnitY(t), 0)
        call UnitApplyTimedLife(e, 'BTLF', 1.00)
        call UnitAddAbility(e, Crit_Struck_ID())
        call IssueTargetOrder( e, "drunkenhaze", t )
    else
        // Does not create dummy unit because unit has died   
    endif
    set tag = null
    set trig = null
    set f = null
    set g = null
    set e = null
    set d = null
    set t = null
endfunction

//===========================================================================
function InitTrig_Enhanced_Critical_Strike takes nothing returns nothing
    set gg_trg_Enhanced_Critical_Strike = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_Enhanced_Critical_Strike, Condition( function Enhanced_Critical_Strike_Conds ) )
    call TriggerAddAction( gg_trg_Enhanced_Critical_Strike, function Trig_Enhanced_Critical_Strike )
endfunction

Gives a 15% chance to do more damage on an attack and causes the damaged unit to have a 35% chance to miss on attacks for 3 seconds.

This spell was originally created for FatBobb per his request. The spell was created with the intentions of being put into a melee-type game, but can be easily modified to fit otherwise.

Note: The evasion aspect of the spell will not work on magic immune units.

Known Error: This spell will trigger from Immolation damage. If anyone knows of a way to fix this then let me know.

+Multi-Instanceable
+Leakless
+No Imports
+Easily Transferable

Updates - Recent to Past:

v.61 (current):

-Removed two instances of I2R() that were unnecessary
-Fixed a tool tip

v.60:

-Added Rising_Dusk's ArmorUtils system to very accurately damage units.
-Removed all but one BJ

v.55:

-Changed GetUnitAbilityLevelSwapped() to native GetUnitAbilityLevel()
-Changed Picked Unit to Matching Unit in Units Matching Condition function
-Changed GetPlayersAll() to native bj_FORCE_ALL_PLAYERS
-Created local variable "tag" to replace use of GetLastCreatedTextTag()
-Added a trigger that prevents Enhanced Critical Strike from triggering when any negative ability is cast by the Hero.

v.50:

-Changed UnitAddAbilityBJ to UnitAddAbility
-Changed if statement to "if GetWidgetLife(t) > 0 then"

v.44:

-Important (but not at all crucial) comment added to Conditions.

v.43:

-locals nulled in proper place, they had accidentally been nulled only if the unit hadn't died.
-GetTriggerUnit() that I had missed replaced with local variable.

v.42:

-Tool tip fix
-Spelling error fix

v.41:

-Optimized conditions

v.4:

-Completed main ability fully in JASS.

v.32:

-Fixed mathematical error in Floating Text displayed
-Fixed mathematical error in damage done.

v.3
-Removed extra global variable that wasn't used.
-Removed wait
-Replaced texttag BJ's with natives.

Keywords:
Critical Strike, Miss, Enhanced, ability, spell
Contents

Enhanced Critical Strike (Map)

Reviews
20:51, 8th Jun 2009 hvo-busterkomo: A decent JASS spell, although quite basic. Here's my improvements: 1. Remove the unnecessary BJs. The texttag ones are fine and can be ignored, but you should remove things like UnitAddAbilityBJ. 2. Your if...

Moderator

M

Moderator

20:51, 8th Jun 2009
hvo-busterkomo: A decent JASS spell, although quite basic. Here's my improvements:

1. Remove the unnecessary BJs. The texttag ones are fine and can be ignored, but you should remove things like UnitAddAbilityBJ.

2. Your if statement is needlessly complicated. Just do something like
JASS:
if GetWidgetLife(t) <= 0 then

3. Use a local trigger.

4. The spell ID should be configurable as a constant/constant function.



14:07, 8th Jun 2010
The_Reborn_Devil:
You're still using some BJ's, but it's better now.
JASS:
x1 CreateTextTagUnitBJ
x3 ShowTextTagForceBJ
x1 SetTextTagVelocityBJ
x2 GetForceOfPlayer

Other than that I guess the spell is ok.


12:06, 9th May 2011
The_Reborn_Devil:
The triggering looks ok, but you can use null instead of WEAPON_TYPE_WHOKNOWS ^^


Status: Approved
Rating: Useful
 
Level 25
Joined
Jun 5, 2008
Messages
2,572
Well after looking at it i must say that this is one of the rare GUI spells that uses only 1 editor variable^^
Nice work on the local variables, though i would make a global block in a separate trigger, let's call it setup:
  • Setup
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • -------- To view ID's press CTRL + D in the object editor --------
      • -------- Settings for the spell --------
      • Custom script: globals
      • Custom script: constant integer Spellid = 'A001'
      • -------- True spell ID --------
      • -------- --- --------
      • Custom script: constant integer Dspellid = 'A000'
      • -------- Dummy spell ID --------
      • -------- --- --------
      • Custom script: constant integer Dummyid = 'h002'
      • -------- Dummy Unit ID --------
      • Custom script: endglobals
      • -------- --- --------
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())
And then you could simply use those globals in the triggering later.
Also i don't know what effect does wait have on local variables, i think it is MUI but not sure.
 
Level 18
Joined
Nov 1, 2006
Messages
1,612
Well after looking at it i must say that this is one of the rare GUI spells that uses only 1 editor variable^^

Actually the editor variable isn't even there and isn't meant to be used. I'm uploading v.03 that contains no waits and that has removed that extra variable.

Thanks for catching it. And thank you everyone else for the feedback. I'll continue to work on this one to make it more efficient, and possibly make in complete JASS soon as I learn a little more about creating JASS functions.

Updates:

v.03
-Removed extra global variable that wasn't used.
-Removed wait
-Replaced texttag BJ's with natives.
 
Level 18
Joined
Nov 1, 2006
Messages
1,612
If there's any way to remove event's when unit die?

Yeah I could easily. It shows the critical strike text so you know that it was the critical blow that killed them. However I creating the dummy unit is somewhat inefficient... yes. I'll look into working with that later today.

edit: Unfortunately the only way I can find through GUI without using a global variable to check if the unit has died is by using (Triggering Unit). Is this really inefficient or does it matter much?
 
Last edited:
Level 25
Joined
Jun 5, 2008
Messages
2,572
I would leave it GUI, why?
Because if you want to make it in JASS you have to destroy things like Boolexpresions and stuff, in GUI you can just leave those things.
In GUI it can get only a little more efficent, while in JASS you would need to do a bunch of stuff more and it would still be not that efficent for a JASS version.
 
Level 17
Joined
Mar 17, 2009
Messages
1,349
I consider Local Variables to be very important indeed.

Using them is the only way I know how to make a spell MUI :p I'm still troubling with Indexing
It should have been the other way round true?

And for as much as I know, it doesn't ruin MUI if Waits are used ;)

EDIT:

Btw, Dark Night I'm just curious to know:
Why did you use something like v.032 instead of something more simple v3.2 or whatever?
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
if u already made it jass so why not make it completely leakless?
it's still leaking the events every time a unit enters the map
you could counter that by destroying the trigger every time a unit dies but it would be laggy
maybe destroy it every 20 seconds or something like that
however i don't know a lot about jass but even i managed to make a leakless floating text damage show thing system
you shouldnt have any problems with that ;)
 
If you made it in jass then why is it categorized in GUI Triggers?
I also was inspired by this resource so I decided to make my own:

It basically is a critical that deals an additional 40/50/60 damage but
it will deal an extra 400 damage if the attacked unit has a life of 600/500/400.
I finished it but I don't know how to upload screen shots so I'll just upload it
in epicwar.com tomorrow. Made in GUI! (I hate jass, no offense jass users)
 
Last edited:
Level 11
Joined
Feb 11, 2010
Messages
199
This spell simply doesn't work, and I'm surprised it got past approval. It's MUI, sure, but it doesn't accomplish its basic function! Upon testing, I found that the Demon Hunter would critical strike not just on attacks, but with absolutely any kind of damage from any source, such as if he used Immolation, or an item. Since I'm sure this isn't intended (from the creator's own descriptions, not to mention the fact that this doesn't work anything like critical strike), I just can't give this a favorable rating since it doesn't work. Attached map file easily demonstrates the glitch: Just run around with Immolation on (no triggers or anything are changed, I just added Immolation to the demo hero).

If this issue is fixed, I will of course change my rating.
 

Attachments

  • EnhancedCriticalStrikeby1)ark_NiTev.50.w3x
    26.7 KB · Views: 51
Last edited:
I am suprised no one noticed this:
  • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Owner of (Picked unit)) Not equal to Neutral Passive)) and do (Actions)
    • Loop - Actions
      • Trigger - Add to Enhanced Critical Strike <gen> the event (Unit - (Picked unit) Takes damage)
It should be "Owner of (Matching unit)" Not Equal to Neutral Passive, not "Owner of (Picked unit)".
 
Level 18
Joined
Nov 1, 2006
Messages
1,612
This spell simply doesn't work, and I'm surprised it got past approval.

Yeah this is a problem. What I've used in Against the Darkness is a system where you add any casting unit to a group for .15 seconds and then in your damage detection triggers you make sure to check if the unit is in that group or not. If it is then the spell wont execute. If the unit is not then the spell will execute. However that wont work with Immolation (I don't use Immolation in my map at all :p). Is there a better way than this?

*EDIT* sorry for the double post, I didn't even think about it.
 
Yeah this is a problem. What I've used in Against the Darkness is a system where you add any casting unit to a group for .15 seconds and then in your damage detection triggers you make sure to check if the unit is in that group or not. If it is then the spell wont execute. If the unit is not then the spell will execute. Is there a better way than this?

*EDIT* sorry for the double post, I didn't even think about it.

I believe this is the best way to accomplish it :)
Other ways are buff status of 0.01 second duration, but Purge might just... purge the effects wanted!
 
Okay sweet. If you just downloaded the map, redownload it. I had to fix something quickly.

It should work fine now except for the fact that it will trigger with Immolation damage which I don't know how to fix!

Come again? What do you mean by that? It didn't trigger any immolation damage for me. When does it happen? How do you understand it?
 
Level 18
Joined
Nov 1, 2006
Messages
1,612
Come again? What do you mean by that? It didn't trigger any immolation damage for me. When does it happen? How do you understand it?

Read Caedrus' post. He said that this spell would trigger from Immolation damage. I fixed the spell from executing on any other type of negative spell damage but I don't know how to keep it from triggering from Immolation damage.
 
Top