• 🏆 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!

[Solved] AoE Critical Strike

Status
Not open for further replies.
Level 17
Joined
Feb 11, 2011
Messages
1,860
Hello guys,

For my map I would like to make a spell which gives a 20% chance to deal 1.25/1.50/1.75/2.00/2.25x normal damage (yes, there are five levels for the spell). The thing is that I would like this damage to be dealt to all enemies within 200 range of the target (they receive 100% of the crit amount). I have the GDD system, but I just can't seem to get it right.

Example: My hero has Critical Strike on level 4. His base damage is 50, so the critical amount would be 100. I would like to deal this damage to all enemies within 200 range. Floating text should appear above the attacker, like the normal Critical Strike text.

I am average with JASS (still learning). Any help will be appreciated.
Thanks! :grin:
 
Level 14
Joined
Sep 28, 2011
Messages
968
it is simple if you have damage detection system just make a 100 percent scripted critical who make at each time the hero deal damage without ability and if he have that ability we detect the damage multiply this damage per critical factor-1 and deal this damage to target and make a group pick where the caster deal attack damage*critical damage to all ennemies who are not the target in range of 200 and make a text above the caster with text actions.
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
I have already tried to make a script. Here it is (please don't laugh):

  • Thief Skills
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (Unit-type of GDD_DamageSource) Equal to Thief
      • (Level of 2.2 Thief Skills for GDD_DamageSource) Greater than 0
    • Actions
      • Set Temp_Real = GDD_Damage
      • Custom script: call Thief_Skills(udg_GDD_DamageSource)
JASS:
function Cond_Thief_Skills takes nothing returns boolean
    return (GetOwningPlayer(GetFilterUnit()) == Player(11))
endfunction

function Act_Thief_Skills takes nothing returns nothing
    local unit u = udg_GDD_DamageSource
    call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodRifleman.mdl", GetEnumUnit(), "chest"))
    call DisableTrigger(gg_trg_GUI_Friendly_Damage_Detection)
    call UnitDamageTarget(u, GetEnumUnit(), udg_Temp_Real, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
    call EnableTrigger(gg_trg_GUI_Friendly_Damage_Detection)
    set u = null
endfunction

function Thief_Skills takes unit u returns nothing
    local integer i = GetRandomInt(1, 1)
    local group ug = CreateGroup()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local texttag t = CreateTextTag()
    local unit u2 = udg_GDD_DamageSource
    if (i == 1) then
        set udg_Temp_Real = ((0.25 * (GetUnitAbilityLevel(u2, 'A007')) + 1) * udg_GDD_Damage)
        call GroupEnumUnitsInRange(ug, x, y, 200, Condition(function Cond_Thief_Skills))
        call ForGroup(ug, function Act_Thief_Skills)
        call SetTextTagText(t, "|cffFF0000" + I2S(R2I(udg_Temp_Real)) + "!|r", 0.023)
        call SetTextTagPosUnit(t, u2, 50)
        call SetTextTagVelocity(t, 0, 64 * 0.071 / 128)
        call SetTextTagPermanent(t, false)
        call SetTextTagLifespan(t, 2)
        call SetTextTagFadepoint(t, 1)
        call SetTextTagVisibility(t, true)
    endif
    set t = null
    call DestroyGroup(ug)
    set ug = null
endfunction

When I test it like this and he lands a Critical Strike, the game crashes.

EDIT: I made it choose a random integer from 1 to 1 for testing purposes.
EDIT 2: Fixed a few things, but still doesn't work.
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Thief Skills
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (Unit-type of GDD_DamageSource) Equal to Thief
      • (Level of 2.2 Thief Skills for GDD_DamageSource) Greater than 0
    • Actions
      • Set Temp_Real = GDD_Damage
      • Custom script: call Thief_Skills(udg_GDD_DamageSource)
^Why the unit type check? If a unit has the ability, shouldn't that be enough? Also, no need for Temp_Real. Just use GDD_Damage instead.

JASS:
function Act_Thief_Skills takes nothing returns boolean
    if GetOwningPlayer(GetFilterUnit()) == Player(11) then // Player(11) is Player 12 in GUI
        call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodRifleman.mdl", GetEnumUnit(), "chest"))
        call DisableTrigger(gg_trg_GUI_Friendly_Damage_Detection)
        call UnitDamageTarget(udg_GDD_DamageSource, GetEnumUnit(), udg_Temp_Real, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
        call EnableTrigger(gg_trg_GUI_Friendly_Damage_Detection)
    endif
    return false
endfunction

function Thief_Skills takes unit u returns nothing
    local integer i = GetRandomInt(1, 1)
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local texttag t = CreateTextTag()
    local unit u2 = udg_GDD_DamageSource
    if (i == 1) then
        set udg_Temp_Real = ((0.25 * (GetUnitAbilityLevel(u2, 'A007')) + 1) * udg_GDD_Damage)
        call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, 200, Condition(function Act_Thief_Skills))
        call SetTextTagText(t, "|cffFF0000" + I2S(R2I(udg_Temp_Real)) + "!|r", 0.023)
        call SetTextTagPosUnit(t, u2, 50)
        call SetTextTagVelocity(t, 0, 64 * 0.071 / 128)
        call SetTextTagPermanent(t, false)
        call SetTextTagLifespan(t, 2)
        call SetTextTagFadepoint(t, 1)
        call SetTextTagVisibility(t, true)
    endif
    set t = null
endfunction

The locals could be set only if the chance is succesful.

If it still bugs, tell how. Also try using BJDebugMsg() for debugging.
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
Okay, cool. Thanks! It is working perfectly now.

Thanks for all your guys' help!

Just a quick question, if I have this:

JASS:
function Test takes nothing returns nothing
    local unit u = GetTriggerUnit()
    call KillUnit(u)
endfunction

Do I need to nullify u?
 
Last edited by a moderator:
Status
Not open for further replies.
Top