• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[vJASS] Glaive of Destruction v1.0.0.4 [vJASS]

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.

[r] Glaive of Destruction v1.0.0.4 [r]
[r] Description [r]
Releases a gigantic glaive that damages nearby enemies and stuns the for 3 seconds.
Level 1 - 75 damage
Level 2 - 150 damage
Level 3 - 225 damage
Level 4 - 300 damage

[r] Changelogs [r]
v1.0.0.0 - Initial Release
v1.0.0.1 - Added Configurables
v1.0.0.2 - Updated, MUI, no Further Leaks
v1.0.0.3 - Converted from GUI to vJASS (vJASS)
v1.0.0.4 - Added: TerrainPathability, and Effects

[r] Credits [r]
UsersThings
David v1.0.0.1
Hanky v1.0.0.2
Bribe v1.0.0.3 to v1.0.0.4
Nestharus v1.0.0.3 to v1.0.0.4
Magtheridon96 v1.0.0.3 to v1.0.0.4
iAyanami v1.0.0.3 to v1.0.0.4
Rising_Dusk v1.0.0.3 to v1.0.0.4
Configurables
Indexing Template
SpellEffectEvent
TimerTools - UnitIndexer - WorldBounds
RegisterPlayerUnitEvent
StunSystem
TerrainPathability

How to Use

  • Copy the Glaive of Destruction Folder
    -paste it into your map
  • Copy the Systems Folder
    -paste it into your map
  • Copy the Stun System from the Abilities
    -paste it into your map
  • Copy the Glaive of Destruction Ability from the Abilities
    -paste it into your map
  • Copy the Stun Dummy from the Units
    -paste it into your map
  • Copy the Dummy from the Units
    -paste it into your map
Requirements

  • JNGP
  • SpellEffectEvent
  • StunSystem
  • TimerTools
  • UnitIndexer
  • RegisterPlayerUnitEvent
JASS:
library GlaiveOfDestruction uses RegisterPlayerUnitEvent ,SpellEffectEvent, Tt, UnitIndexer, StunSystem, TerrainPathability
//************************************************************************
//Credits To:
//Magtheridon96, Bribe, iAyanami, Nestharus, Rising_Dusk
//************************************************************************
globals
 //==================
 private constant integer DUM_CODE = 'h000'  //raw code of the dummy
 private constant integer ABIL_CODE = 'A000'  //raw code of the Spell
 //===================
 private constant real DUM_SCALE = 3.3 //Size of the Glaive
 private constant real SPEED = 800. //Speed of the Glaive
 private constant real HEIGHT = 150. //height of the Glaive
 private constant real COL_SIZE = 250. // collision size of the Glaive
 private constant real STUN_DUR = 3. // stun duration
 private constant string SFX = "Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl"
private constant string ATTACH = "origin"
 //===================
 private constant attacktype ATK = ATTACK_TYPE_NORMAL // attack type
 private constant damagetype DMG = DAMAGE_TYPE_MAGIC // damage type
 //===================
 private constant player NEUTRAL_PASSIVE = Player(PLAYER_NEUTRAL_PASSIVE)
 private group G = CreateGroup()
endglobals
 //*******************************************************
//CONFIGURABLES
//********************************************************
//distance
private constant function GetDistance takes integer level returns real
    return 1400.
endfunction
//Glaives AoE
private constant function GetAoE takes integer level returns real
    return 250.
endfunction
//damage
private constant function GetDamage takes integer level returns real
    return 75. * level
endfunction
//Prevents the Glaive from damaging dead units/mechanical units/structures/destructibles/allies/etc.
private constant function GetFilter takes unit caster, unit target returns boolean
    return /*
    */ not IsUnitType(target, UNIT_TYPE_DEAD) and /* // target is alive
    */ IsUnitEnemy(target, GetOwningPlayer(caster)) and /* // target is an enemy of caster
    */ not IsUnitType(target, UNIT_TYPE_STRUCTURE) and /* // target is not a structure
    */ not IsUnitType(target, UNIT_TYPE_MECHANICAL) // target is not mechanic
endfunction
//***************************************************
//STRUCT
//****************************************************
private struct Main extends array
    private group g
    private unit u
    private player owner
    private unit dummy
    private real aoe
    private real damage
    private real distance
    private real sin
    private real cos
    private static integer array store
    private static constant real TIMEOUT = 0.031260000
    private static constant real MAX_SPEED = SPEED * TIMEOUT
    
    implement CTTC
        local unit u
        local real x
        local real y
    
    implement CTTCExpire
        set x = GetUnitX(this.dummy) + this.cos
        set y = GetUnitY(this.dummy) + this.sin
      
   //Pathability
           if IsTerrainWalkable(x, y) then
            call SetUnitX(this.dummy, x)
            call SetUnitY(this.dummy, y)
        else
            set this.distance = 0
        endif
        set this.distance = this.distance - MAX_SPEED
        call GroupEnumUnitsInRange(G, x, y, this.aoe + COL_SIZE, null)
        loop
            set u = FirstOfGroup(G)
            exitwhen u == null
            call GroupRemoveUnit(G, u)
                                 
            if not IsUnitInGroup(u, this.g) and GetFilter(this.u, u) and IsUnitInRangeXY(u, x, y, this.aoe+COL_SIZE) then
                call GroupAddUnit(this.g, u)
                call UnitDamageTarget(this.u, u, this.damage, true, false, ATK, DMG, null)
                call Stun.apply(u, STUN_DUR, false)
                call DestroyEffect(AddSpecialEffectTarget(SFX,u,ATTACH))
            endif
        endloop
               
         if this.distance <= 0 then
            if thistype.store[GetUnitId(this.u)] == this then
                set thistype.store[GetUnitId(this.u)] = 0
            endif
        
            call GroupClear(this.g)
            call DestroyGroup(this.g)
            call KillUnit(this.dummy)
            
            set this.g = null
            
            call this.destroy()
        endif
        implement CTTCEnd
        
        private static method onCast takes nothing returns boolean
        local thistype this = thistype.create()
        local integer level
        local real a
        
        set this.g = CreateGroup()
        set this.u = GetTriggerUnit()
        set this.owner = GetTriggerPlayer()
        set a = Atan2(GetSpellTargetY() - GetUnitY(this.u), GetSpellTargetX() - GetUnitX(this.u))
        set this.dummy = CreateUnit(this.owner, DUM_CODE, GetUnitX(this.u), GetUnitY(this.u), a * bj_RADTODEG)
        set level = GetUnitAbilityLevel(this.u, ABIL_CODE)
        set this.aoe = GetAoE
        set this.damage = GetDamage(level)
        set this.distance = GetDistance(level)
        set this.sin = MAX_SPEED * Sin(a)
        set this.cos = MAX_SPEED * Cos(a)
        set thistype.store[GetUnitId(this.u)] = this
        
        call SetUnitScale(this.dummy, DUM_SCALE, 0, 0)
        call SetUnitFlyHeight(this.dummy, HEIGHT, 0)
        
        return false
    endmethod
    //**********************************
    //SPELL EVENT
    //**********************************
    private static method onInit takes nothing returns nothing
        call RegisterSpellEffectEvent(ABIL_CODE, function thistype.onCast)
    endmethod
endstruct
endlibrary

Keywords:
Glaive Thrower, Throw, Spell, Reputation, Glaive, vJASS, Magtheridon96, Libraries
Contents

Just another Warcraft III map (Map)

Reviews
12th Dec 2015 IcemanBo: Too long as NeedsFix. Rejected. 21:06, 22nd Sep 2012 Magtheridon96: When you update a resource from GUI to vJASS, the standards crank up just a teenie tiny bit. - Use 0.03125 as a timeout instead of 0.031260000. The...

Moderator

M

Moderator

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

21:06, 22nd Sep 2012
Magtheridon96: When you update a resource from GUI to vJASS, the standards crank up just a teenie tiny bit.

- Use 0.03125 as a timeout instead of 0.031260000. The inaccuracy between 0.03125 and 0.031250000 will make no difference in this case.

- Don't repeat GetUnitX(this.u)/GetUnitY(this.u) more than once inside the cast function.

- Instead of having one group per struct instance, you can use a Table (by Bribe) to attach booleans to handle IDs.

- Your indentation is messed up after that IsTerrainWalkable line.
 
Level 17
Joined
Jul 17, 2011
Messages
1,863
well you can start by reading this
Not Rated
21:06, 22nd Sep 2012
Magtheridon96:
It seems to me that someone has misinformed you about making a spell MUI.
First of all, you don't need to use arrays if you're giving them constant values, use variables.
Also, instead of having 4 lines that go "If Level == 1, blablabla", use constant arrays.
For damage, create a real array called Damage.
On map initialization, in a trigger:
Trigger
Set Damage[1] = 100.00
Set Damage[2] = 150.00
Set Damage[3] = 200.00
Set Damage[4] = 250.00

Then, when you want to deal damage to a unit, deal while using Damage[(Level of (Ability being cast) for (Triggering unit))] as the amount of damage.
I told you this like 3, 4 times D:

You should also store everything that you're repeating more than once into variables and use those variables instead of the values.
It makes things more efficient.
You should also make the special effects configurable, along with all the other constant values in your spell.
Also, your spell can destroy bridges. To fix this, create a dummy unit on map initialization, and give it the harvest ability, then hide it. When you pick all destructables, order the dummy unit to harvest the destructable. After that, check if the current order of the dummy is "harvest". If so, then the destructable is indeed a tree, and you can kill it.
By the way, you're leaking 2 points in the cast trigger. Finally, (Casting unit) -> (Triggering unit).
It's slightly faster.
 
Top