1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  5. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  6. The Secrets of Warcraft 3 have revealed interesting works. The RESULTS for Abelhawk's Mini-Mapping Contest #15 have come out!
    Dismiss Notice
  7. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  8. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  9. Night Rider gained several songs for his journey. The poll for the 12th Music Contest has started. Check it out!
    Dismiss Notice
  10. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  11. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Enhanced Critical Strike v.61

Submitted by 1)ark_NiTe
This bundle is marked as approved. It works and satisfies the submission rules.
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.

Enhanced Critical Strike code
Code (vJASS):
////////////////////////////////////////////////////////////////////
//  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
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...
  1. old review
    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
    Code (vJASS):
    if GetWidgetLife(t) <= 0 then


    3. Use a local trigger.

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


    old review(2)

    14:07, 8th Jun 2010
    The_Reborn_Devil:
    You're still using some BJ's, but it's better now.
    Code (vJASS):

    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
     
  2. aaron

    aaron

    Joined:
    Oct 18, 2008
    Messages:
    512
    Resources:
    6
    Maps:
    2
    Spells:
    4
    Resources:
    6
    cool thats really nice for a hero arena type map.
     
  3. -Berz-

    -Berz-

    Joined:
    Mar 5, 2008
    Messages:
    3,203
    Resources:
    123
    Icons:
    111
    Packs:
    1
    Skins:
    1
    Spells:
    10
    Resources:
    123
    Now, this is a nice spell =)

    I like it because it's simple, and really useful.

    I'm just wondering if just those 3 conditions prevents passive spell to be abused? :D

    Also i wonder why did you put that wait 1 second... UnitApplyTimedLife should work ^^

    Get rid of that wait and 5/5 =)
     
  4. Kingz

    Kingz

    Joined:
    Jun 5, 2008
    Messages:
    2,470
    Resources:
    6
    Spells:
    5
    Tutorials:
    1
    Resources:
    6
    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.
     
  5. -Berz-

    -Berz-

    Joined:
    Mar 5, 2008
    Messages:
    3,203
    Resources:
    123
    Icons:
    111
    Packs:
    1
    Skins:
    1
    Spells:
    10
    Resources:
    123
    It doesn't have any effect, but why use wait since its evil? ^^
     
  6. Kingz

    Kingz

    Joined:
    Jun 5, 2008
    Messages:
    2,470
    Resources:
    6
    Spells:
    5
    Tutorials:
    1
    Resources:
    6
    Local variables and normal ones aren't same, i think wait doesn't have any influence on local variables and therefore when using only local variables you can use wait.
     
  7. Ranger21

    Ranger21

    Joined:
    Dec 19, 2008
    Messages:
    273
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Make it with vJass please and don't use locations

    If you make that, will be best passive critical strike:)
     
  8. 1)ark_NiTe

    1)ark_NiTe

    Joined:
    Nov 1, 2006
    Messages:
    1,680
    Resources:
    5
    Maps:
    1
    Spells:
    3
    Tutorials:
    1
    Resources:
    5
    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.
     
  9. Ranger21

    Ranger21

    Joined:
    Dec 19, 2008
    Messages:
    273
    Resources:
    1
    Maps:
    1
    Resources:
    1
    If there's any way to remove event's when unit die?
     
  10. 1)ark_NiTe

    1)ark_NiTe

    Joined:
    Nov 1, 2006
    Messages:
    1,680
    Resources:
    5
    Maps:
    1
    Spells:
    3
    Tutorials:
    1
    Resources:
    5
    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: Apr 27, 2009
  11. Kingz

    Kingz

    Joined:
    Jun 5, 2008
    Messages:
    2,470
    Resources:
    6
    Spells:
    5
    Tutorials:
    1
    Resources:
    6
    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.
     
  12. Deuterium

    Deuterium

    Joined:
    Mar 17, 2009
    Messages:
    1,301
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    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?
     
  13. -Berz-

    -Berz-

    Joined:
    Mar 5, 2008
    Messages:
    3,203
    Resources:
    123
    Icons:
    111
    Packs:
    1
    Skins:
    1
    Spells:
    10
    Resources:
    123
    Because that's uber pro h4x0r style :p

    Hehe :D
     
  14. Malcous

    Malcous

    Joined:
    Apr 2, 2008
    Messages:
    1,196
    Resources:
    0
    Resources:
    0
    Very useful :)
     
  15. 1)ark_NiTe

    1)ark_NiTe

    Joined:
    Nov 1, 2006
    Messages:
    1,680
    Resources:
    5
    Maps:
    1
    Spells:
    3
    Tutorials:
    1
    Resources:
    5
    Exactly.

    Haha no it's actually because I consider this still to be in beta so it's in the .00's not 1.00's.
     
  16. Deuterium

    Deuterium

    Joined:
    Mar 17, 2009
    Messages:
    1,301
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    Dark Nite, why didn't you do it JASS at once?
    there's only like 3 actions which are GUI, along side with conditions and events :p
     
  17. 1)ark_NiTe

    1)ark_NiTe

    Joined:
    Nov 1, 2006
    Messages:
    1,680
    Resources:
    5
    Maps:
    1
    Spells:
    3
    Tutorials:
    1
    Resources:
    5
    Now I have :smile:
     
  18. RaedoN

    RaedoN

    Joined:
    Jul 24, 2008
    Messages:
    106
    Resources:
    0
    Resources:
    0
    Nice ability. Good for arena-type maps :grin:
     
  19. 1)ark_NiTe

    1)ark_NiTe

    Joined:
    Nov 1, 2006
    Messages:
    1,680
    Resources:
    5
    Maps:
    1
    Spells:
    3
    Tutorials:
    1
    Resources:
    5
    Just wondering why it's not approved yet o_O