//
// _ ___ ___ _ _ _____ __ _ ___ __ _ ___
// | | |_ _|/ __| |_| |_ _| \| |_ _| \| |/ __|
// | |__ | || (_ | _ | | | | \ \ || || \ \ | (_ |
// |____|___|\___|_| |_| |_| |_|\__|___|_|\__|\___|
// By Lyncor. v1.01.
//
// What is Lightning?
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// Lightning is an efficient end-point tracker and fader for lightning
// effects in Warcraft III.
//
// How to implement?
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// Simply create a new trigger object called Lightning, go to 'Edit -> Convert
// to Custom Text', and replace everything that's there with this script.
//
// Lightning Codes (Thanks to Flare):
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// "CLPB" - Chain Lightning Primary
// "CLSB" - Chain Lightning Secondary
// "DRAB" - Drain
// "DRAL" - Drain Life
// "DRAM" - Drain mana
// "AFOD" - Finger of Death
// "FORK" - Forked Lightning
// "HWPB" - Healing Wave Primary
// "HWSB" - Healing Wave Secondary
// "CHIM" - Lightning Attack
// "LEAS" - Magic Leash
// "MBUR" - Mana Burn
// "MFPB" - Mana Flare
// "SPLK" - Spirit Link
//
// Functions:
// ¯¯¯¯¯¯¯¯¯¯¯¯
// For the creation functions:
// - "string code" is the lightning type as a string.
// - "real duration" is how long the lightning should last.
// - "boolean fade" is true if the lightning should fade over its duration.
//
// function Lightning_UnitUnit takes string code, unit from, unit to,
// real duration, boolean fade returns nothing
// - Creates and tracks lightning from one unit to another.
//
// function Lightning_CoordsUnit takes string code, real x, real y, real z,
// unit to, real duration, boolean fade returns nothing
// - Creates and tracks lightning from coordinates to a unit.
//
// function Lightning_UnitCoords takes string code, unit from,
// real x, real y, real z, real duration, boolean fade returns nothing
// - Creates and tracks lightning from a unit to coordinates.
//
// function Lightning_ColorLast takes real r, real g, real b returns nothing
// - Sets the colour of the last created lightning to the red,
// greed and blue values passed into the function (r, g, b).
// - The values are real numbers ranging from 0 to 1.
// - This must only be called immediately after calling a
// creation function.
//
// Thanks:
// ¯¯¯¯¯¯¯¯¯
// - Jesus4Lyf for assistance and writing T32.
//
library Lightning uses T32
globals
// This offset is applied for all unit lightning links.
private constant real HEIGHT_OFFSET = 56.0
endglobals
//===========================================================
// DATA DECLARATION:
//
// The basic data for a link of lightning. This is so there
// is minimal array declaration, and faster recycling of unit
// handle ids.
//
private struct Link //extends array // JassHelper won't allow this with inheritance.
// Allocator that won't lose efficiency with inheritance.
// Faster than vJass allocator.
private static thistype array recycled
private static integer recycledMax = 0
private static integer lastAlloc = 0
static method alloc takes nothing returns thistype
if thistype.recycledMax==0 then
set thistype.lastAlloc = thistype.lastAlloc + 1
return thistype(thistype.lastAlloc)
endif
set thistype.recycledMax = thistype.recycledMax - 1
return thistype.recycled[thistype.recycledMax]
endmethod
method dealloc takes nothing returns nothing
set thistype.recycled[thistype.recycledMax] = this
set thistype.recycledMax = thistype.recycledMax + 1
endmethod
// Data
lightning link
real x // Don't need 2 sets of these,
real y // because if it was linking coords
real z // to coords, it wouldn't move.
unit sU
unit eU
integer ticks
real r
real g
real b
real a
real aSlide
endstruct
//===========================================================
// CALLBACK DECLARATION:
//
// This is all the data and code segments used in the links'
// callback functions. Textmacros are brilliant, because they
// provide functional decomposition without any efficiency
// penalty.
//
// Globals have been used to shorten code (locals also have
// terribly ugly declarations) and provide an efficiency
// boost, as well as eliminate nulling concerns for the unit.
//
// T32 has been used to complete the razor sharp efficiency.
//
globals
private location LOC = Location(0, 0)
endglobals
globals//locals
private real X1
private real Y1
private real Z1
private real X2
private real Y2
// Don't need Z2, can inline into the MoveLightning call.
private unit Unit
endglobals
//===========================================================
// Callback Snippets
//
//! textmacro LGHT_CB__LoadUnit1
set Unit = this.sU
set X1 = GetUnitX(Unit)
set Y1 = GetUnitY(Unit)
call MoveLocation(LOC, X1, Y1)
//! endtextmacro
//! textmacro LGHT_CB__LoadUnit2
set Unit = this.eU
set X2 = GetUnitX(Unit)
set Y2 = GetUnitY(Unit)
call MoveLocation(LOC, X2, Y2)
//! endtextmacro
//! textmacro LGHT_CB__EscapeClause
if this.ticks==0 then
call DestroyLightning(this.link)
call this.dealloc()
return true
endif
set this.ticks = this.ticks - 1 // Is effectively at the end of the periodic function.
//! endtextmacro
//! textmacro LGHT_CB__AlphaUpkeep
call SetLightningColor(this.link, this.r, this.g, this.b, this.a)
set this.a = this.a - this.aSlide
//! endtextmacro
//===========================================================
// T32 Callbacks
//
// One for with alpha fading and one without for each cross
// of unit/coords. For free efficiency if you don't fade.
//
// Semantics:
// "U" means "Unit". "XY" means "Coordinates".
// "a" is for "alpha". Therefore:
// - UU means Unit to Unit, no alpha fade.
// - XYUa means Coordinates to Unit, with alpha fade.
// - etc.
//
private struct LinkUUa extends Link
private method periodic takes nothing returns boolean
//! runtextmacro LGHT_CB__EscapeClause()
//! runtextmacro LGHT_CB__LoadUnit1()
set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
//! runtextmacro LGHT_CB__LoadUnit2()
call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
//! runtextmacro LGHT_CB__AlphaUpkeep()
return false
endmethod
implement T32
endstruct
private struct LinkUU extends Link
private method periodic takes nothing returns boolean
//! runtextmacro LGHT_CB__EscapeClause()
//! runtextmacro LGHT_CB__LoadUnit1()
set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
//! runtextmacro LGHT_CB__LoadUnit2()
call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
return false
endmethod
implement T32
endstruct
private struct LinkXYUa extends Link
private method periodic takes nothing returns boolean
//! runtextmacro LGHT_CB__EscapeClause()
call MoveLocation(LOC, this.x, this.y)
set Z1 = GetLocationZ(LOC) + this.z
//! runtextmacro LGHT_CB__LoadUnit2()
call MoveLightningEx(this.link, true, this.x, this.y, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
//! runtextmacro LGHT_CB__AlphaUpkeep()
return false
endmethod
implement T32
endstruct
private struct LinkXYU extends Link
private method periodic takes nothing returns boolean
//! runtextmacro LGHT_CB__EscapeClause()
call MoveLocation(LOC, this.x, this.y)
set Z1 = GetLocationZ(LOC) + this.z
//! runtextmacro LGHT_CB__LoadUnit2()
call MoveLightningEx(this.link, true, this.x, this.y, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
return false
endmethod
implement T32
endstruct
private struct LinkUXYa extends Link
private method periodic takes nothing returns boolean
//! runtextmacro LGHT_CB__EscapeClause()
//! runtextmacro LGHT_CB__LoadUnit1()
set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
call MoveLocation(LOC, this.x, this.y)
call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, this.x, this.y, GetLocationZ(LOC) + this.z)
//! runtextmacro LGHT_CB__AlphaUpkeep()
return false
endmethod
implement T32
endstruct
private struct LinkUXY extends Link
private method periodic takes nothing returns boolean
//! runtextmacro LGHT_CB__EscapeClause()
//! runtextmacro LGHT_CB__LoadUnit1()
set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
call MoveLocation(LOC, this.x, this.y)
call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, this.x, this.y, GetLocationZ(LOC) + this.z)
return false
endmethod
implement T32
endstruct
//===========================================================
// PUBLIC INTERFACE:
//
// This is the declaration of all functionality exposed to
// end users. Once again, a global struct variable has been
// used to remove the ugly local declaration, and textmacros
// have been used for efficient functional decomposition.
//
globals//locals
private Link data
endglobals
//===========================================================
// Interface Snippets
//
//! textmacro LGHT_I__Unit1
set X1 = GetUnitX(from)
set Y1 = GetUnitY(from)
call MoveLocation(LOC, X1, Y1)
//! endtextmacro
//! textmacro LGHT_I__Unit2
set X2 = GetUnitX(to)
set Y2 = GetUnitY(to)
call MoveLocation(LOC, X2, Y2)
//! endtextmacro
//! textmacro LGHT_I__Start takes WHICH
set data.r = 1.0
set data.g = 1.0
set data.b = 1.0
set data.ticks = R2I(duration / T32_PERIOD)
if fade then
set data.a = 1.0
set data.aSlide = 1 / duration * T32_PERIOD
call Link$WHICH$a(data).startPeriodic()
else
call Link$WHICH$(data).startPeriodic()
endif
//! endtextmacro
//===========================================================
// Interface
//
public function UnitUnit takes string whichCode, unit from, unit to, real duration, boolean fade returns nothing
set data = Link.alloc()
set data.sU = from
set data.eU = to
//! runtextmacro LGHT_I__Unit1()
set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(from)
//! runtextmacro LGHT_I__Unit2()
set data.link = AddLightningEx(whichCode, true, X1, Y1, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(to))
//! runtextmacro LGHT_I__Start("UU")
endfunction
public function CoordsUnit takes string whichCode, real x, real y, real z, unit to, real duration, boolean fade returns nothing
set data = Link.alloc()
set data.x = x
set data.y = y
set data.z = z
set data.eU = to
call MoveLocation(LOC, x, y)
set Z1 = GetLocationZ(LOC) + z
//! runtextmacro LGHT_I__Unit2()
set data.link = AddLightningEx(whichCode, true, x, y, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(to))
//! runtextmacro LGHT_I__Start("XYU")
endfunction
public function UnitCoords takes string whichCode, unit from, real x, real y, real z, real duration, boolean fade returns nothing
set data = Link.alloc()
set data.sU = from
set data.x = x
set data.y = y
set data.z = z
//! runtextmacro LGHT_I__Unit1()
set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(from)
call MoveLocation(LOC, x, y)
set data.link = AddLightningEx(whichCode, true, X1, Y1, Z1, x, y, GetLocationZ(LOC) + z)
//! runtextmacro LGHT_I__Start("UXY")
endfunction
// Let's not clutter our interfaces.
public function ColorLast takes real r, real g, real b returns nothing
set data.r = r
set data.g = g
set data.b = b
call SetLightningColor(data.link, r, g, b, 1.0)
endfunction
//===========================================================
// Note to users:
//
// Keep smiling. God loves you. :D
// Happy mapping.
endlibrary
for i = 1 to 10
loop
or function
etc..//
// _ ___ ___ _ _ _____ __ _ ___ __ _ ___
// | | |_ _|/ __| |_| |_ _| \| |_ _| \| |/ __|
// | |__ | || (_ | _ | | | | \ \ || || \ \ | (_ |
// |____|___|\___|_| |_| |_| |_|\__|___|_|\__|\___|
// By Lyncor. v1.01.
//
// What is Lightning?
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// Lightning is an efficient end-point tracker and fader for lightning
// effects in Warcraft III.
//
// How to implement?
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// Simply create a new trigger object called Lightning, go to 'Edit -> Convert
// to Custom Text', and replace everything that's there with this script.
//
// Lightning Codes (Thanks to Flare):
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// "CLPB" - Chain Lightning Primary
// "CLSB" - Chain Lightning Secondary
// "DRAB" - Drain
// "DRAL" - Drain Life
// "DRAM" - Drain mana
// "AFOD" - Finger of Death
// "FORK" - Forked Lightning
// "HWPB" - Healing Wave Primary
// "HWSB" - Healing Wave Secondary
// "CHIM" - Lightning Attack
// "LEAS" - Magic Leash
// "MBUR" - Mana Burn
// "MFPB" - Mana Flare
// "SPLK" - Spirit Link
//
// Functions:
// ¯¯¯¯¯¯¯¯¯¯¯¯
// For the creation functions:
// - "string code" is the lightning type as a string.
// - "real duration" is how long the lightning should last.
// - "boolean fade" is true if the lightning should fade over its duration.
//
// function Lightning_UnitUnit takes string code, unit from, unit to,
// real duration, boolean fade returns nothing
// - Creates and tracks lightning from one unit to another.
//
// function Lightning_CoordsUnit takes string code, real x, real y, real z,
// unit to, real duration, boolean fade returns nothing
// - Creates and tracks lightning from coordinates to a unit.
//
// function Lightning_UnitCoords takes string code, unit from,
// real x, real y, real z, real duration, boolean fade returns nothing
// - Creates and tracks lightning from a unit to coordinates.
//
// function Lightning_ColorLast takes real r, real g, real b returns nothing
// - Sets the colour of the last created lightning to the red,
// greed and blue values passed into the function (r, g, b).
// - The values are real numbers ranging from 0 to 1.
// - This must only be called immediately after calling a
// creation function.
//
// Thanks:
// ¯¯¯¯¯¯¯¯¯
// - Jesus4Lyf for assistance and writing T32.
//
library Lightning uses T32
globals
// This offset is applied for all unit lightning links.
private constant real HEIGHT_OFFSET = 56.0
endglobals
//===========================================================
// DATA DECLARATION:
//
// The basic data for a link of lightning. This is so there
// is minimal array declaration, and faster recycling of unit
// handle ids.
//
private struct Link //extends array // JassHelper won't allow this with inheritance.
// Allocator that won't lose efficiency with inheritance.
// Faster than vJass allocator.
private static thistype array recycled
private static integer recycledMax = 0
private static integer lastAlloc = 0
static method alloc takes nothing returns thistype
if thistype.recycledMax==0 then
set thistype.lastAlloc = thistype.lastAlloc + 1
return thistype(thistype.lastAlloc)
endif
set thistype.recycledMax = thistype.recycledMax - 1
return thistype.recycled[thistype.recycledMax]
endmethod
method dealloc takes nothing returns nothing
set thistype.recycled[thistype.recycledMax] = this
set thistype.recycledMax = thistype.recycledMax + 1
endmethod
// Data
lightning link
real x // Don't need 2 sets of these,
real y // because if it was linking coords
real z // to coords, it wouldn't move.
unit sU
unit eU
integer ticks
real r
real g
real b
real a
real aSlide
endstruct
//===========================================================
// CALLBACK DECLARATION:
//
// This is all the data and code segments used in the links'
// callback functions. Textmacros are brilliant, because they
// provide functional decomposition without any efficiency
// penalty.
//
// Globals have been used to shorten code (locals also have
// terribly ugly declarations) and provide an efficiency
// boost, as well as eliminate nulling concerns for the unit.
//
// T32 has been used to complete the razor sharp efficiency.
//
globals
private location LOC = Location(0, 0)
endglobals
globals//locals
private real X1
private real Y1
private real Z1
private real X2
private real Y2
// Don't need Z2, can inline into the MoveLightning call.
private unit Unit
endglobals
//===========================================================
// Callback Snippets
//
//! textmacro LGHT_CB__LoadUnit1
set Unit = this.sU
set X1 = GetUnitX(Unit)
set Y1 = GetUnitY(Unit)
call MoveLocation(LOC, X1, Y1)
//! endtextmacro
//! textmacro LGHT_CB__LoadUnit2
set Unit = this.eU
set X2 = GetUnitX(Unit)
set Y2 = GetUnitY(Unit)
call MoveLocation(LOC, X2, Y2)
//! endtextmacro
//! textmacro LGHT_CB__EscapeClause
if this.ticks==0 then
call DestroyLightning(this.link)
call this.dealloc()
return true
endif
set this.ticks = this.ticks - 1 // Is effectively at the end of the periodic function.
//! endtextmacro
//! textmacro LGHT_CB__AlphaUpkeep
call SetLightningColor(this.link, this.r, this.g, this.b, this.a)
set this.a = this.a - this.aSlide
//! endtextmacro
//===========================================================
// T32 Callbacks
//
// One for with alpha fading and one without for each cross
// of unit/coords. For free efficiency if you don't fade.
//
// Semantics:
// "U" means "Unit". "XY" means "Coordinates".
// "a" is for "alpha". Therefore:
// - UU means Unit to Unit, no alpha fade.
// - XYUa means Coordinates to Unit, with alpha fade.
// - etc.
//
private struct LinkUUa extends Link
private method periodic takes nothing returns boolean
//! runtextmacro LGHT_CB__EscapeClause()
//! runtextmacro LGHT_CB__LoadUnit1()
set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
//! runtextmacro LGHT_CB__LoadUnit2()
call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
//! runtextmacro LGHT_CB__AlphaUpkeep()
return false
endmethod
implement T32
endstruct
private struct LinkUU extends Link
private method periodic takes nothing returns boolean
//! runtextmacro LGHT_CB__EscapeClause()
//! runtextmacro LGHT_CB__LoadUnit1()
set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
//! runtextmacro LGHT_CB__LoadUnit2()
call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
return false
endmethod
implement T32
endstruct
private struct LinkXYUa extends Link
private method periodic takes nothing returns boolean
//! runtextmacro LGHT_CB__EscapeClause()
call MoveLocation(LOC, this.x, this.y)
set Z1 = GetLocationZ(LOC) + this.z
//! runtextmacro LGHT_CB__LoadUnit2()
call MoveLightningEx(this.link, true, this.x, this.y, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
//! runtextmacro LGHT_CB__AlphaUpkeep()
return false
endmethod
implement T32
endstruct
private struct LinkXYU extends Link
private method periodic takes nothing returns boolean
//! runtextmacro LGHT_CB__EscapeClause()
call MoveLocation(LOC, this.x, this.y)
set Z1 = GetLocationZ(LOC) + this.z
//! runtextmacro LGHT_CB__LoadUnit2()
call MoveLightningEx(this.link, true, this.x, this.y, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
return false
endmethod
implement T32
endstruct
private struct LinkUXYa extends Link
private method periodic takes nothing returns boolean
//! runtextmacro LGHT_CB__EscapeClause()
//! runtextmacro LGHT_CB__LoadUnit1()
set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
call MoveLocation(LOC, this.x, this.y)
call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, this.x, this.y, GetLocationZ(LOC) + this.z)
//! runtextmacro LGHT_CB__AlphaUpkeep()
return false
endmethod
implement T32
endstruct
private struct LinkUXY extends Link
private method periodic takes nothing returns boolean
//! runtextmacro LGHT_CB__EscapeClause()
//! runtextmacro LGHT_CB__LoadUnit1()
set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
call MoveLocation(LOC, this.x, this.y)
call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, this.x, this.y, GetLocationZ(LOC) + this.z)
return false
endmethod
implement T32
endstruct
//===========================================================
// PUBLIC INTERFACE:
//
// This is the declaration of all functionality exposed to
// end users. Once again, a global struct variable has been
// used to remove the ugly local declaration, and textmacros
// have been used for efficient functional decomposition.
//
globals//locals
private Link data
endglobals
//===========================================================
// Interface Snippets
//
//! textmacro LGHT_I__Unit1
set X1 = GetUnitX(from)
set Y1 = GetUnitY(from)
call MoveLocation(LOC, X1, Y1)
//! endtextmacro
//! textmacro LGHT_I__Unit2
set X2 = GetUnitX(toUnit)
set Y2 = GetUnitY(toUnit)
call MoveLocation(LOC, X2, Y2)
//! endtextmacro
//! textmacro LGHT_I__Start takes WHICH
set data.r = 1.0
set data.g = 1.0
set data.b = 1.0
set data.ticks = R2I(duration / T32_PERIOD)
if fade then
set data.a = 1.0
set data.aSlide = 1 / duration * T32_PERIOD
call Link$WHICH$a(data).startPeriodic()
else
call Link$WHICH$(data).startPeriodic()
endif
//! endtextmacro
//===========================================================
// Interface
//
public function UnitUnit takes string whichCode, unit from, unit toUnit, real duration, boolean fade returns nothing
set data = Link.alloc()
set data.sU = from
set data.eU = toUnit
//! runtextmacro LGHT_I__Unit1()
set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(from)
//! runtextmacro LGHT_I__Unit2()
set data.link = AddLightningEx(whichCode, true, X1, Y1, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(toUnit))
//! runtextmacro LGHT_I__Start("UU")
endfunction
public function CoordsUnit takes string whichCode, real x, real y, real z, unit toUnit, real duration, boolean fade returns nothing
set data = Link.alloc()
set data.x = x
set data.y = y
set data.z = z
set data.eU = toUnit
call MoveLocation(LOC, x, y)
set Z1 = GetLocationZ(LOC) + z
//! runtextmacro LGHT_I__Unit2()
set data.link = AddLightningEx(whichCode, true, x, y, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(toUnit))
//! runtextmacro LGHT_I__Start("XYU")
endfunction
public function UnitCoords takes string whichCode, unit from, real x, real y, real z, real duration, boolean fade returns nothing
set data = Link.alloc()
set data.sU = from
set data.x = x
set data.y = y
set data.z = z
//! runtextmacro LGHT_I__Unit1()
set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(from)
call MoveLocation(LOC, x, y)
set data.link = AddLightningEx(whichCode, true, X1, Y1, Z1, x, y, GetLocationZ(LOC) + z)
//! runtextmacro LGHT_I__Start("UXY")
endfunction
// Let's not clutter our interfaces.
public function ColorLast takes real r, real g, real b returns nothing
set data.r = r
set data.g = g
set data.b = b
call SetLightningColor(data.link, r, g, b, 1.0)
endfunction
//===========================================================
// Note to users:
//
// Keep smiling. God loves you. :D
// Happy mapping.
endlibrary
//! lua
//! endlua
//! lua ObjectMerger
//! endlua
Give me one good example where nested textmacros would be useful.Would be nice to see nested textmacros...
Actually it goes like this:When vJASS runs, first it does proprocessor commands like textmacros and imports. Then it runs Lua. Then it runs the vJASS.
I believe that I'm done with wc3 dev : P
Creating abilities with ObjectMerger modifies the whole map, so all we talked before about doing just .j processing is meaningless.
You will always have to save/disable/save that kind of triggers.
What in the name of smurf are you talking about?- more powerfull loops (like C/Java ones)
Ok, this is the third time someone mentioned this, but I still don't get what is the issue. Please explain this to me in detail.- fix this madness initializer priority : module intitalizer are done before any other ones, which is actually breaking the whole requirements system.
library Poop initializer Init
private function Init takes nothing returns nothing
call BJDebugMsg("Poop Init")
endfunction
endlibrary
library Dog requires Poop
private struct InitStruct extends array
static method onInit takes nothing returns nothing
call BJDebugMsg("Dog Init")
endmethod
endstruct
endlibrary
Bribe's example was going in good direction.For the initializers orders i will make a demo script.
RegisterRectEvent(null, function() { hash.boolean[ITEM_HAMMER] = true; }, function() { hash.boolean[ITEM_HAMMER] = false; });
RegisterRectEvent(null, function() { hash.boolean[ITEM_SCREWDRIVER] = true; }, function() { hash.boolean[ITEM_SCREWDRIVER] = false; });
RegisterRectEvent(null, function() { hash.boolean[ITEM_KEY1] = true; }, function() { hash.boolean[ITEM_KEY1] = false; });
RegisterRectEvent(null, function() { hash.boolean[ITEM_KEY2] = true; }, function() { hash.boolean[ITEM_KEY2] = false; });
RegisterRectEvent(null, function() { hash.boolean[ITEM_KEY3] = true; }, function() { hash.boolean[ITEM_KEY3] = false; });
RegisterRectEvent(null, function() { hash.boolean[ITEM_KNIFE] = true; }, function() { hash.boolean[ITEM_KNIFE] = false; });
RegisterRectEvent(null, function() { hash.boolean[ITEM_LIGHTER] = true; }, function() { hash.boolean[ITEM_LIGHTER] = false; });
RegisterRectEvent(null, function() { hash.boolean[ITEM_INK_LIGHT] = true; }, function() { hash.boolean[ITEM_INK_LIGHT] = false; });
RegisterRectEvent(null, function() { hash.boolean[ITEM_BLOODSTONE] = true; }, function() { hash.boolean[ITEM_BLOODSTONE] = false; });
RegisterRectEvent(null, function() { hash.boolean[ITEM_REMOTE] = true; }, function() { hash.boolean[ITEM_REMOTE] = false; });
RegisterRectEvent(null, function() { hash.boolean[ITEM_PUZZLE_PIECE] = true; }, function() { hash.boolean[ITEM_PUZZLE_PIECE] = false; });
cJass doesn't compile my re-write of the Table library, which was a big WTF moment.
library Table
//***************************************************************
//* Table object 3.0
//* ------------
//*
//* set t=Table.create() - instanceates a new table object
//* call t.destroy() - destroys it
//* t[1234567] - Get value for key 1234567
//* (zero if not assigned previously)
//* set t[12341]=32 - Assigning it.
//* call t.flush(12341) - Flushes the stored value, so it
//* doesn't use any more memory
//* t.exists(32) - Was key 32 assigned? Notice
//* that flush() unassigns values.
//* call t.reset() - Flushes the whole contents of the
//* Table.
//*
//* call t.destroy() - Does reset() and also recycles the id.
//*
//* If you use HandleTable instead of Table, it is the same
//* but it uses handles as keys, the same with StringTable.
//*
//* You can use Table on structs' onInit if the struct is
//* placed in a library that requires Table or outside a library.
//*
//* You can also do 2D array syntax if you want to touch
//* mission keys directly, however, since this is shared space
//* you may want to prefix your mission keys accordingly:
//*
//* set Table["thisstring"][ 7 ] = 2
//* set Table["thisstring"][ 5 ] = Table["thisstring"][7]
//*
//***************************************************************
//=============================================================
globals
private constant integer MAX_INSTANCES=8100 //400000
//Feel free to change max instances if necessary, it will only affect allocation
//speed which shouldn't matter that much.
//=========================================================
private hashtable ht
endglobals
private struct GTable[MAX_INSTANCES]
method reset takes nothing returns nothing
call FlushChildHashtable(ht, integer(this) )
endmethod
private method onDestroy takes nothing returns nothing
call this.reset()
endmethod
//=============================================================
// initialize it all.
//
private static method onInit takes nothing returns nothing
set ht = InitHashtable()
endmethod
endstruct
//Hey: Don't instanciate other people's textmacros that you are not supposed to, thanks.
//! textmacro Table__make takes name, type, key
struct $name$ extends GTable
method operator [] takes $type$ key returns integer
return LoadInteger(ht, integer(this), $key$)
endmethod
method operator []= takes $type$ key, integer value returns nothing
call SaveInteger(ht, integer(this) ,$key$, value)
endmethod
method flush takes $type$ key returns nothing
call RemoveSavedInteger(ht, integer(this), $key$)
endmethod
method exists takes $type$ key returns boolean
return HaveSavedInteger( ht, integer(this) ,$key$)
endmethod
static method flush2D takes string firstkey returns nothing
call $name$(- StringHash(firstkey)).reset()
endmethod
static method operator [] takes string firstkey returns $name$
return $name$(- StringHash(firstkey) )
endmethod
endstruct
//! endtextmacro
//! runtextmacro Table__make("Table","integer","key" )
//! runtextmacro Table__make("StringTable","string", "StringHash(key)" )
//! runtextmacro Table__make("HandleTable","handle","GetHandleId(key)" )
endlibrary
I just want to confirm if this jasshelper ensures compatibility with the features of version 0.2.A.B
IF that's the case, then I'll update my JNGP with this JH version.
local integer lvl = GetUnitAbilityLevel(SpellEvent.CastingUnit, SPELL_ID)
local unit u
call GroupEnumUnitsInArea(ENUM_GROUP, SpellEvent.TargetX, SpellEvent.TargetY, Area(lvl), null)
for u in ENUM_GROUP
if AffectedTargets(u, GetTriggerPlayer()) then
call buffType.apply(u, SpellEvent.CastingUnit, lvl, Duration(lvl))
endif
endfor
local integer lvl= GetUnitAbilityLevel(s__SpellEvent___spellEvent_CastingUnit[SpellEvent], ShadowStride___SPELL_ID)
local unit u
call GroupEnumUnitsInArea(ENUM_GROUP , s__SpellEvent___spellEvent_TargetX[SpellEvent] , s__SpellEvent___spellEvent_TargetY[SpellEvent] , ShadowStride___Area(lvl) , null)
if ShadowStride___AffectedTargets(u , GetTriggerPlayer()) then
call s__ShadowStride_buffType_apply(u , s__SpellEvent___spellEvent_CastingUnit[SpellEvent] , lvl , ShadowStride___Duration(lvl))
endif
endloop // endfor
private function SpellActions takes nothing returns nothing
// This doesn't compile!
while true
endwhile
endfunction
private function Init takes nothing returns nothing
call RegisterSpellEffectResponse(SPELL_ID, SpellActions)
endfunction
It works for me just fine. What version of jasshelper are you using?Shorter example:
JASS:private function SpellActions takes nothing returns nothing // This doesn't compile! while true endwhile endfunction
call RegisterSpellEffectResponse(0, SpellActions)
is commented out, the map compiles successfully.Could you please make it so that "FunctionName.name" only converts the string, instead of also writing up all the duplicated "prototype" functions?
FunctionName.name is a good trick to using ExecuteFunc, because ExecuteFunc avoids handles, allows TriggerSleepAction, and ".name" allows the function to be private or within a struct. Never mind the speed, because I really could care less.
What I want it to do, and what JassHelper manual says it does, is just to compile the string, and not adding the extra proxy function + trigger + condition as well. Because the way JassHelper has it set up now, is that it gains absolutely no advantage to use ".name" instead of ".execute".
scope ScopeName
//========ERROR==============================================================
function InitTrig_ScopeName takes nothing returns nothing
set gg_trg_ScopeName = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_ScopeName, 5 )
call TriggerAddCondition( gg_trg_ScopeName, Condition( function Trig_ScopeName_Conditions ) )
call TriggerAddAction( gg_trg_ScopeName, function Trig_ScopeName_Actions )
endfunction
endscope
scope ScopeName initializer Init
//===========================================================================
function Init takes nothing returns nothing
set gg_trg_ScopeName = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_ScopeName, 5 )
call TriggerAddCondition( gg_trg_ScopeName, Condition( function Trig_ScopeName_Conditions ) )
call TriggerAddAction( gg_trg_ScopeName, function Trig_ScopeName_Actions )
endfunction
endscope