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

Sand King by JushirO v 0.1

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
SejinOo , Clinks , Kabuki , Kaito Kiddo thanks guys :)

Keywords:
Sand King , Spell , Epicenter , Burrow Strike , Hero
Contents

Sand King (Map)

Reviews
12th Dec 2015 IcemanBo: Too long as NeedsFix. Rejected. Required changes: Get rid of BJ functions in Burrow Strike TriggerSleepAction is not very accurate Epicenter is not MUI

Moderator

M

Moderator

12th Dec 2015
IcemanBo: Too long as NeedsFix. Rejected.

Reviewed by Maker, Sand King by JushirO, 11th Jan 2012

Required changes:
  • Get rid of BJ functions in Burrow Strike
  • TriggerSleepAction is not very accurate
  • Epicenter is not MUI
 
Stolen or not, you should post the code and improve these, else they will be rejected.

JASS:
function Trig_Burrowstrike_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A008'         
endfunction

function Trig_Burrowstrike_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()    
    local integer i = GetUnitAbilityLevelSwapped('A008', u)
    local location l = GetUnitLoc(u)
    local location m = GetSpellTargetLoc()
    call CreateNUnitsAtLoc( 1, 'n000', GetOwningPlayer(u), PolarProjectionBJ(l, -100.00, AngleBetweenPoints(l, m)), GetUnitFacing(u) )
    if i==1 then
        call UnitAddAbility( GetLastCreatedUnit(), 'A005' )
        call SetUnitAbilityLevelSwapped( 'A005', GetLastCreatedUnit(), ( R2I(DistanceBetweenPoints(l, m)) / 100 ) )
    else
        if i==2 then
            call UnitAddAbility( GetLastCreatedUnit(), 'A006' )
            call SetUnitAbilityLevelSwapped( 'A006', GetLastCreatedUnit(), ( R2I(DistanceBetweenPoints(l, m)) / 100 ) )
        else
            if i==3 then
                call UnitAddAbility( GetLastCreatedUnit(), 'A007' )
                call SetUnitAbilityLevelSwapped( 'A007', GetLastCreatedUnit(), ( R2I(DistanceBetweenPoints(l, m)) / 100 ) )
            else
                call UnitAddAbility( GetLastCreatedUnit(), 'A004' )
                call SetUnitAbilityLevelSwapped( 'A004', GetLastCreatedUnit(), ( R2I(DistanceBetweenPoints(l, m)) / 100 ) )
            endif
        endif
    endif    
    call IssuePointOrder( GetLastCreatedUnit(), "impale", GetLocationX(m),GetLocationY(m) )
    call TriggerSleepAction( ( DistanceBetweenPoints(l, m) / 4000.00 ) )
    call SetUnitPositionLoc( u, m )
    call SetUnitAnimation( u, "morph ALTERNATE" )
    set u = null
    call RemoveLocation(l)
    call RemoveLocation(m)
    set l = null
    set m = null
endfunction

//===========================================================================
function InitTrig_Burrowstrike takes nothing returns nothing
    set gg_trg_Burrowstrike = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Burrowstrike, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Burrowstrike, Condition( function Trig_Burrowstrike_Conditions ) )
    call TriggerAddAction( gg_trg_Burrowstrike, function Trig_Burrowstrike_Actions )
endfunction

  • Epicenter
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Epicenter
    • Actions
      • Set Epicenter_Caster = (Triggering unit)
      • Set Epicenter_Pulses = (4 + (2 x (Level of Epicenter Slow for Epicenter_Caster)))
      • Set Epicenter_Damage = 110
      • Trigger - Turn on Epicenter Action <gen>
      • Wait until (Epicenter_Pulses Equal to 0), checking every 0.10 seconds
      • Trigger - Turn off Epicenter Action <gen>
  • Epicenter Action
    • Events
      • Time - Every 0.30 seconds of game time
    • Conditions
    • Actions
      • Set Epicenter_Pulses = (Epicenter_Pulses - 1)
      • Set Epicenter_Caster_Loc = (Position of Epicenter_Caster)
      • Set Epicenter_Group = (Units within 600.00 of Epicenter_Caster_Loc matching ((((Matching unit) belongs to an enemy of (Owner of Epicenter_Caster)) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) is A structure) Equal to False))))
      • Environment - Create a 0.50 second Temporary crater deformation at Epicenter_Caster_Loc with radius 560.00 and depth 28.00
      • Unit - Create 1 Dummy Unit for (Owner of Epicenter_Caster) at Epicenter_Caster_Loc facing Default building facing degrees
      • Unit - Add Epicenter Slow to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Unit - Add a 0.30 second Generic expiration timer to (Last created unit)
      • Unit Group - Pick every unit in Epicenter_Group and do (Actions)
        • Loop - Actions
          • Set Epicenter_Picked_Loc = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Epicenter_Caster_Loc and Epicenter_Picked_Loc) Less than or equal to 200.00
            • Then - Actions
              • Unit - Cause Epicenter_Caster to damage (Picked unit), dealing ((Real(Epicenter_Damage)) + 20.00) damage of attack type Spells and damage type Universal
            • Else - Actions
              • Custom script: call RemoveLocation (udg_Epicenter_Picked_Loc)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between Epicenter_Caster_Loc and Epicenter_Picked_Loc) Less than or equal to 400.00
                • Then - Actions
                  • Unit - Cause Epicenter_Caster to damage (Picked unit), dealing ((Real(Epicenter_Damage)) - 20.00) damage of attack type Spells and damage type Universal
                • Else - Actions
                  • Custom script: call RemoveLocation (udg_Epicenter_Picked_Loc)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between Epicenter_Caster_Loc and Epicenter_Picked_Loc) Less than or equal to 600.00
                    • Then - Actions
                      • Unit - Cause Epicenter_Caster to damage (Picked unit), dealing ((Real(Epicenter_Damage)) - 30.00) damage of attack type Spells and damage type Universal
                    • Else - Actions
          • Custom script: call RemoveLocation (udg_Epicenter_Caster_Loc)
      • Custom script: call RemoveLocation (udg_Epicenter_Picked_Loc)
      • Custom script: call DestroyGroup (udg_Epicenter_Group)
First of all, you should get rid of all the BJs.
The BJs are those funtions highlighted in red.
ALL BJs are bad except for TriggerRegisterAnyUnitEventBJ, ModuloInteger, ModuloReal, IAbsBJ, RAbsBJ,
IMinBJ, IMaxBJ, RMinBJ, RMaxBJ and IntegerTertiary. Instead of GetLastCreatedUnit() and CreateNUnitsAtLoc(),
you should use a local unit variable and set it to CreateUnit(....) then use that unit variable instead of using
GetLastCreatedUnit().

You have leaks in there too. PolarProjectionBJ(l, -100.00, AngleBetweenPoints(l, m)) Leaks.
Instead of SetUnitAbilityLevelSwapped, just use SetUnitAbilityLevel. It's more
efficient and it's name is shorter -> thus it's faster.

DistanceBetweenPoints -> SquareRoot((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
And you should cache the distance to increase efficiency since you're calling the function multiple times.
Instead of locations, you should be using coordinates. No one uses locations in Jass .. unless you want to
find the Z of a certain point on the map via GetLocationZ

AngleBetweenPoints -> bj_RADTODEG * Atan2(y2 - y1, x2 - x1)

And you shouldn't be setting the animation of the unit to something like that, it might not have it.
All models are expected to have the "walk", "stand" and "attack" animations at least. Use those.
You could make it configurable using functions like this though:

JASS:
function BurrowStrike_Animation takes nothing returns string
    return "stand"
endfunction

Instead of SetUnitPositionLoc, use SetUnitX and SetUnitY.
And you shouldn't be using waits, use timers instead. (Don't use TriggerSleepAction)

And all this was directed only at your BurrowStrike spell.
There are a lot of things that could and should be improved.

These spells aren't MUI. MUI means Multi-Unit-Instanceable.
To make a spell MUI, you can either use Hashtables, or arrays.

If you want to use arrays, you can either go with Dynamic Indexing or you can use a simple stack structure.
I'd go with Dynamic Indexing if I were you. It has O(1) complexity. (Meaning it's faster)

If you want to use hashtables, there are plenty of tutorials in the Tutorials section.
Here's one I like: http://www.hiveworkshop.com/forums/...9/complete-beginners-guide-hashtables-197381/
 
Last edited:
Level 5
Joined
Jan 5, 2012
Messages
134
I feel this is stolen, if not then 4/5
Epicenter, like they said, is not MUI. Fix it.

EDIT:
The Epicenter doesn't have the effect.
Too Empty and Boring. 2/5
 
Top