Name | Type | is_array | initial_value |
//TESH.scrollpos=230
//TESH.alwaysfold=0
//
//
// PULL&PUSH SYSTEM - HOW TO USE
// BY LENDER
//
//
//--------------------------------------------------------------------------------------
//-- 1. ---------------VARIABLES--------------------------------------------------------
//--------------------------------------------------------------------------------------
//
// A, Global Variables - These are variables that the system use by default if you dont change the exact values by yourself
//
//- PULL_PERIOD (real) Def: 0.03125 time period - dose the units positioning 32 times in a sec
//- PULL_SPEED_DEFAULT (real) Def: 320. pulled units movespeed
//- PULL_HIT_RANGE (real) Def: 100. default range of hitting
//- PULL_SLOWSTART (real) Def: 1. default time needed to pass before it starts changing the units movespeed
//- PULL_SLOWING (real) Def: 0.625 0.625 / 0,03125 = 20 movespeed decrease per second->
// -> for x movespeed increase you need to set this to x*0.03125->
// ->setting this to a negative amount will occure ms increasing
//- PULL_TOSSHEIGHT (real) Def: 400. default value of how high the pulled unit will be tossed
//- PULL_TOSSNUMBER (integer) Def: 1 default value of how many times the pulled unit will be tossed
//- PULL_TOSSSPEED (real) Def: 2000. default starting velocity of the unit ( more higher amount more faster toss effect )
//
//
// B, Changeable Variables - Variables for values that you might want to customize
//- .pullSpeed (real) Def: PULL_SPEED_DEFAULT pulled units movespeed
//- .pausing (boolean) Def: true set this false to pull units without pausing theme
//- .isPulled (boolean) Def: true set it true to pull, false to push the unit
//- .disablePathing (boolean) Def: true set false to NOT disable pathing for unit
//- .isCheckPathing (boolean) Def: true set this false to don't check pathing ( walkability )
//- .hitDests (boolean) Def: true set this false to don't detect hitting destructables
//- .hitUnits (boolean) Def: true set this false to don't detect hitting units
//- .hitRange (real) Def: PULL_HIT_RANGE range between units that counts as a hit
//- .isSlowing (boolean) Def: false set true to turn slowing option on
//- .slowStart (real) Def: PULL_SLOWSTART time required to pass before start the slowing
//- .slowAmount (real) Def: PULL_SLOWING for x movespeed decrease you need to set this to X * 0.03125
//- .tossHeight (real) Def: PULL_TOSSHEIGHT base value of how high the pulled unit will be tossed at the first time when the pull starts
//- .isTossed (boolean) Def: false set this true to enable tossing
//- .tossNumber (integer) Def: PULL_TOSSNUMBER sets the amount how much times the pulled unit will be tossed after eachother
//- .tossSpeed (real) Def: PULL_TOSSSPEED sets the amount of the units rising velocity
//- .isBouncing (boolean) Def: false turn this true if you want your target bouncing off cliffs or map boarder
//
//
// C, Readonly Variables - These Variables are only READABLE
// You can't change it's values but you can use them.
//
// YOU CAN DO - if " readonly variable " > 0 then , ETC... (Almost anything except changing its value)
// YOU CAN'T DO - set " readonly variable " = " value " ...
//
// - .destUnit (unit) if the destination is a unit this variable stores it
// - .victim (unit) target unit , moved unit
// - .tossOrdinalNumber (integer) contains the ordinal number of the actual toss
//
// YOU CAN REFER TO THESE VARIABLES ANY TIME ANY WHERE IN YOUR OWN SPELL
//
//
//--------------------------------------------------------------------------------------
//-- 2. ----------SETUP METHODS---------------------------------------------------------
//--------------------------------------------------------------------------------------
//
/*//---
//sets the unit you want to pull
call .SetPullUnit(a)
// (unit)
//
// a = the target unit
//---------------------------------------------------------
//sets the unit you want as a destination
//if you set a unit as destination
//it will override the destination point coordinates
//with the units coordinates in every 0.03125 seconds
call .SetDestUnit(a)
// (unit)
//
// a = the destination unit
//---------------------------------------------------------
//starts the system
call .start( a , b , c , d )
// (real,real,real,real)
// a = The units X coordinate you want to pull (target)
// b = The units Y coordinate you want to pull (target)
// c = The points X coordinate which will be the destination point
// d = The points Y coordinate which will be the destination point
*/ //---
//
//--------------------------------------------------------------------------------------
//-- 3. ----------EVENTS, EVENT METHODS-------------------------------------------------
//--------------------------------------------------------------------------------------
//
// These are methods automatically called in the system for unique events
// See event descriptions for each method below
//
// You can simply import any of these without the "stub" keyword
// in your spell's Trigger. See under how to
//
// this event will be called only once, when the unit is prepared to be pulled
/* //( SET HERE THE VALUES SEEN UNDER )-----------------------------------------------------
stub method onPullStart takes nothing returns nothing //
endmethod //
//
//this event will be called in every time period (in every 0.03125 second) //
//( YOU ARE FREE TO CHANGE VALUES HERE WHILE THE UNIT MOVES ) //
stub method onAction takes nothing returns nothing //
endmethod //
//
//this event will be called when the moving unit touches a destructable //
// isDestHit must be enabled (set true) to use this //
stub method onDestHit takes destructable d returns nothing //
endmethod //
//
//this event will be called when the moving unit touches a unit //
// isUnitHit must be enabled (set true) to use this //
stub method onUnitHit takes unit u returns nothing //
endmethod //
//
//if your moving unit has a UNIT as Destination //
//this event will be called when the Target unit touches the Unit //
stub method onAtDestUnit takes unit DestUnit ,unit Target returns nothing //
endmethod //
//
//this event will be called when the Targets movespeed becomes <=0 (stops:P) //
stub method onStop takes unit Target returns nothing //
endmethod //
//
//if your moving unit has a POINT(x,y coordinates not location) as Destination //
//this event will be called when the Target unit reaches the point //
stub method onAtDestPoint takes unit Target returns nothing //
endmethod //
//
//this event will be called if the pulled unit was tossed when it reaches the ground //
stub method onLanding takes unit Target returns nothing //
endmethod //
//
//this event will be called when the pulled unit bounces off something //
//.isBouncing have to be ture //
stub method onBounce takes unit Target returns nothing //
endmethod
*/
//
//--------------------------------------------------------------------------------------
//-- 4. -------MAKING A SPELL-----------------------------------------------------------
//--------------------------------------------------------------------------------------
//
// Here's a model to work with
//
/*//////////////////////////////////
struct "Trigger name" extends Pulling
//FILTERING THE CASTED SPELL
//IF THE CASTED SPELLS ID EQUALS WHIT "Ability Id"
//IT WILL RETURN TRUE (THIS IS THE TRIGGERS CONDITION)
private static method filt takes nothing returns boolean
return GetSpellAbilityId() == "Ability Id" //Eg: 'A002'
endmethod
//This creates the struct object for the system
private static method StartCast takes nothing returns nothing
call .setup(thistype.create())
endmethod
private static method setup takes thistype this returns nothing
local unit caster = GetTriggerUnit()
local unit target = GetSpellTargetUnit()
local real cx = GetUnitX(caster)
local real cy = GetUnitY(caster)
local real tx = GetUnitX(target)
local real ty = GetUnitY(target)
//take actions here if u want
//THIS IS THE WAY HOW YOU CAN SET THE TARGET UNIT FOR THE SYSTEM
call .SetPullUnit(target)// <--- target could be any unit
//THIS IS THE WAY HOW YOU CAN SET THE DESTINATION UNIT FOR THE SYSTEM
call .SetDestUnit(caster)// <--- caster could be any unit
//if you dont want a unit as a destination
//the .start(a,b,c,d) methods "c" and "d" values will be the destination POINT
//in this case "c" = cx , "d" = cy
//THIS IS THE WAY HOW YOU START THE SYSTEM
call .start(tx, ty, cx, cy)
set c = null
set t = null
endmethod
//-----------------EVENTS-----------------------------------------------------------------------------
//this is a "must use" event method for costumizing your spell
method onPullStart takes nothing returns nothing
//this is the part where you can mainly set up the system values
//FOR EXAMPLE:
set .pullSpeed = 400.-("abil lvl"*100.)// 300/200/100 Will be the pulled units starting speed
set .isPulled = false // this unit will be pulled (not pushed)
set .isSlowing = true // this units speed will be modified
set .slowStart = 0. // the modification starts when 0 seconds passed by
set .slowAmount = -0.625 // its a negative value so the units speed will be INCREASED by
// 0.625 / 0.03125(period time) = 20 per seconds.
//you can set any variable here. See the list (1.B) on top of this document
endmethod
method onAction takes unit target returns nothing
//take actions here like damaging the target..
endmethod
method onStop takes unit target returns nothing
//take actions here
endmethod
//------this will happens when the pushed unit touches a destructable
method onDestHit takes destructable des returns nothing
//take actions here like
call KillDestructable(des)
endmethod
//------this will happens when the pushed unit touches a unit
method onUnitHit takes unit u returns nothing
//take actions here
endmethod
//-------------------------------------------------------------------------------------------------------
private static method onInit takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger()
call TriggerAddCondition(t, Condition(function thistype.filt))
call TriggerAddAction(t, function thistype.StartCast)
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_CAST, null)
set i = i +1
endloop
endmethod
endstruct
*/ //////////////////////////////////////////////////
// //
// //
// I HOPE THIS HELPED UNDERSTANDING THE SYSTEM //
// //
// //
/////////////////////////////////////////////////////
//TESH.scrollpos=424
//TESH.alwaysfold=0
/////////////////////////////////////////////////////////////////////////////////>
//:~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~/>
//:o Pull (or Push) System
//:~ by Lender
//:o
//:~
//:o This system makes easier the making of spells that requires unit pulling or pushing
//:~ like: -knockbacks
//:o -barriers
//:~ -charges etc...
//:o
//:~ Can be integrated easily in spells.
//:o
//:~ Functionality:
//:o - Get when an unit has been touched
//:~ - Get when a destructable has been touched
//:o - Pretty Costumizable
//:~ - Flexible (Allowes the changing of values at any time)
//:o - Easy understandable (There are Examples to help understand it)
//:~ - Well commented , cathegorized
//:o
//:~
//:o STILL BETA:
//:~ - Help testing the system (give me feedbacks of things that should be fixed) (if u want :P)
//:o - Any ideas with improuving the system will be thanked:)
//:~
//:o Hope you find the system pretty helpfull!(\_(\
//:~ (^ .^)
//:o o((")(")
//:~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~/>
//://////////////////////////////////////////////////////////////////////////////>
library PullPushSystem
//------------------------------------------------------//
// Default values(change if you want) //
//------------------------------------------------------//
globals
constant real PULL_PERIOD = 0.03125 // time period - dose the units positioning 32 times in a sec
constant real PULL_SPEED_DEFAULT = 320. // pulled units movespeed
constant real PULL_HIT_RANGE = 100. // default range of hitting
constant real PULL_SLOWSTART = 1. // default time needs to pass before it starts changing the units movespeed
constant real PULL_SLOWING = 0.625 // 0.625 / 0,03125 = 20 movespeed decrease per second->
// -> for x movespeed increase you need to set this to x*0.03125->
// ->setting this to a negative amount will occure ms increasing
constant real PULL_TOSS_STARTVELOCITY = 2000. // default value of how fast the pulled unit will be tossed up
constant integer PULL_TOSSNUMBER = 1 // default value of how many times the pulled unit will be tossed after eachother
endglobals
//----------------DO NOT CHANGE THESE METHODS RIGHT HERE BUT IN YOUR OWN SCRIPTS------------
//----------------------------LOOK FOR THE DEMO SPELLS HOW TO DO THAT-----------------------
module Events
//this will fire only once when the unit is prepared to be pulled
//( SET HERE THE VALUES SEEN UNDER )-----------------------------------------------------
stub method onPullStart takes nothing returns nothing //
endmethod //
//
//this event will be called in every time period //
//( YOU ARE FREE TO CHANGE VALUES HERE WHILE THE UNIT MOVES ) //
stub method onAction takes unit target returns nothing //
endmethod //
//
//this event will be called when the moving unit touches a destructable //
// isDestHit must be enabled (set true) to use this //
stub method onDestHit takes destructable d returns nothing //
endmethod //
//
//this event will be called when the moving unit touches a unit //
// isUnitHit must be enabled (set true) to use this //
stub method onUnitHit takes unit u returns nothing //
endmethod //
//
//if your moving unit has a UNIT as Destination //
//this event will be called when the Target unit touches the Unit //
stub method onAtDestUnit takes unit DestUnit ,unit Target returns nothing //
endmethod //
//
//this event will be called when the Targets movespeed becomes <=0 (stops:P) //
stub method onStop takes unit Target returns nothing //
endmethod //
//
//if your moving unit has a POINT(x,y coordinates not location) as Destination //
//this event will be called when the Target unit reaches the point //
stub method onAtDestPoint takes unit Target returns nothing //
endmethod //
//
//this event will be called if the pulled unit was tossed when it reaches the ground //
stub method onLanding takes unit Target returns nothing //
endmethod //
//
//this event will be called when the pulled unit bounces off something //
//.isBouncing have to be ture //
stub method onBounce takes unit Target returns nothing //
endmethod //
//
endmodule //------------------------------------------------------//
// values that should be set when "onPullStart" fires //
//------------------------------------------------------//------------------------------------------------------//
// these are just the defaults,set them in your trigger //
// With onPullStart adn/or onAction //
struct Pulling
implement Events
//-----Generic stuff-------------------------------------------------
public real pullSpeed = PULL_SPEED_DEFAULT // pulled units movespeed
public boolean pausing = true // set this false to pull units without pausing theme
public boolean isPulled = true // set it true to pull, false to push the unit
public boolean disablePathing = true // set false to NOT disable pathing for unit
//-----Hitting and pathing-------------------------------------------
public boolean isCheckPathing = true // set this false to don't check pathing ( walkability )
public boolean hitDests = true // set this false to don't hit destructables
public boolean hitUnits = true // set this false to don't hit units
public real hitRange = PULL_HIT_RANGE // range between units counts as a hit
//-----Slowing (Speeding)--------------------------------------------
public boolean isSlowing = false // set true to turn slowing option on
public real slowStart = PULL_SLOWSTART // needed time to pass before start the slowing
public real slowAmount = PULL_SLOWING // for x movespeed decrease you need to set this to x*0.03125
// negative value will couse movespeed increase
//-----Area of Effect------------------------------------------------
public boolean hasAOE = false // set true to get your spell an area of effect
public real aoeRadius = 200. // the radius of the spells AoE
//-----Units---------------------------------------------------------
readonly unit destUnit = null // if the destination is a unit this variable stores it
readonly unit victim = null // target unit , moved unit
//-----Offset--------------------------------------------------------
readonly real tossOrdinalNumber = 0. // contains the ordinal number of the actual toss
public real tossStartVelocity = PULL_TOSS_STARTVELOCITY // base value of how fast the pulled unit will be tossed at the first time when the pull starts
public boolean isTossed = false // set this true to enable tossing
public boolean isJump = false // if isJump is true system calculates variables for a big leap insted of the normal toss effect
public real heightFactor = 1.
public integer tossNumber = PULL_TOSSNUMBER // sets the amount how much times the pulled unit will be tossed after eachother
//-----Bouncing------------------------------------------------------
public boolean isBouncing = false // turn this true if you want your target bouncing off cliffs or map boarder
//-----------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------
//------------------------------------------------------//
// Values used by the system . SHOULDN'T BE CHANGED //
//------------------------------------------------------//
private static boolean refreshedPathings = false //prevents enabling pathing for pulled units that have pathing disabled if more then one pullorpush-spells were casted at the same time
private boolean isPaused = false //turns to true when the unit is paused
private boolean noDest = false //turns to true if speed is null at the beginning (no vertical moving)
private real pulledX = 0. //pulled units x coord
private real pulledY = 0. //pulled units y coord
private real pulledZ = 0. //pulled units z coord
private real pulltoX = 0. //destinations x coord
private real pulltoY = 0. //destinations y coord
private real calcX = 0. //periodic pulling vectors x coord
private real calcY = 0. //prriodic pulling vectors y coord
private real calcZ = 0. //prriodic pulling vectors z coord
private integer slowTick = 0 //period counter for slowstart
private boolean hasUnitDest = false //turns true if the targeted destination is a unit
private static timer t = null //period timer
private static integer count = 0 //instance counter
private integer tossCount = 0 //Tosses made already
private real tossVelocity = 0 //Tosses made already
private real gravity = 150
private boolean active = false //turns true when the pulling begins
private static thistype curPull = 0 //equals to the current running instance
private boolean isPulReg = false //turns true when instance registered to the struct array
private static rect rec = null //hitting detection rect
private boolean notPathed = false //turns true when units pathing turned off
private real pullAngle = 0. //stores the pulling Angle in radians
private integer dummySpellLvl = 0
private thistype next
private thistype prev
private static thistype first
private static thistype last
private static thistype thiss
private static unit dummy
//-------------------------------------------------------------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////////////
// //
// SYSTEM METHODS. DON'T EDIT ANYTHING UNDER WITHOUT PERMISSION //
// //
///////////////////////////////////////////////////////////////////////////////////////
//--------------------------------------------------------------------
//---------PULLED AND (IF NEEDED)DESTINATION UNIT SAVING--------------
//-------------------CAN AND *SHOULD* BE USED FREELY------------------
public method SetDestUnit takes unit u returns nothing
set .destUnit = u
set .hasUnitDest = true
endmethod
public method SetPullUnit takes unit u returns nothing
if .pausing and IsUnitPaused(.victim) then
call PauseUnit(.victim,false)
call PauseUnit(u,true)
endif
if .disablePathing then
call SetUnitPathing(.victim,true)
call SetUnitPathing(u,false)
endif
set .victim = u
set .pulledX = GetUnitX(u)
set .pulledY = GetUnitY(u)
//! runtextmacro SetCollisionMacro()
endmethod
//---- STOP METHOD ----------------------------------------
public method SuddenStop takes nothing returns nothing
set .active = false
if .isTossed then
set .isTossed = false
call SetUnitFlyHeight(.victim,0.,0)
endif
if .notPathed then
call SetUnitPathing(.victim,true)
set thistype.refreshedPathings = false
endif
if .isPaused then
call PauseUnit(.victim,false)
endif
if GetWidgetLife(.victim) > 0.405 then
call .onStop(.victim)
endif
endmethod
//--------------------------------------------------------------------
//---------calculating periodic x and y movement----------------------
//--------------------------------------------------------------------
private method calcXY takes nothing returns nothing
local real velocity = .pullSpeed * PULL_PERIOD
set .calcX = velocity * Cos(.pullAngle)
set .calcY = velocity * Sin(.pullAngle)
endmethod
//--------------------------------------------------------------------
//---------TOSS CALCULATIONS------------------------------------------
//--------------------------------------------------------------------
private method calculateZ takes nothing returns nothing
if .tossCount < .tossNumber then
set .tossVelocity = .tossVelocity - .gravity
if GetWidgetLife(.victim) > 0.405 then
set .calcZ = .calcZ + (.tossVelocity * PULL_PERIOD)
else
set .calcZ = 0.
call SetUnitFlyHeight(.victim,0.,0)
endif
else
set .calcZ = 0.
set .isTossed = false
endif
if .calcZ < 0 then
set .calcZ = 0.
endif
endmethod
private method setUpJumpProperties takes nothing returns nothing
local real s = SquareRoot((.pulltoX-.pulledX)*(.pulltoX-.pulledX)+(.pulltoY-.pulledY)*(.pulltoY-.pulledY))
local real t
if s <= 800 then
set t = 1. + ((s - 800.)/(1000*.heightFactor))
else
set t = 1. + ((s - 800.)/(500*.heightFactor))
endif
set .isPulled = true
set .hitRange = 0.01
set .isSlowing = false
set .isTossed = true
set .tossNumber = 1
set .isBouncing = false
set .isCheckPathing = false
set .pullSpeed = s/t
set .tossStartVelocity = ((t/PULL_PERIOD)*.gravity)/2
endmethod
//--------------------------------------------------------------------
//---------HIT DETECTIONING , EVENT RELEASING-------------------------
//--------------------------------------------------------------------
//-----dest hit-----
private static method HitDests takes nothing returns boolean
local thistype this = thistype.curPull
if not .isPaused then
call PauseUnit(.victim,true)
endif
call .onDestHit(GetFilterDestructable())
if .pausing then
call PauseUnit(.victim,false)
endif
return false
endmethod
//-----unit hit-----
//! textmacro UnitHitMacro takes UNIT, X, Y, RADIUS
call GroupEnumUnitsInRange(bj_lastCreatedGroup, .$X$, .$Y$, .$RADIUS$ + 172, null)
loop
set $UNIT$ = FirstOfGroup(bj_lastCreatedGroup)
exitwhen $UNIT$ == null
call GroupRemoveUnit(bj_lastCreatedGroup, $UNIT$)
if $UNIT$ != .victim then
if IsUnitInRangeXY($UNIT$, .$X$, .$Y$, .$RADIUS$) then
//! endtextmacro
//! textmacro UnitHitMacroEnd
endif
endif
endloop
//! endtextmacro
//-------------------------------------------------------------------
//---------Pathing Location Calculation (is it pathable ahead?)------
//-------------------------------------------------------------------
private method calcModAngleXY takes nothing returns boolean
local real modX = .pulledX + (.dummySpellLvl*16+1) * Cos(.pullAngle)
local real modY = .pulledY + (.dummySpellLvl*16+1) * Sin(.pullAngle)
return not IssuePointOrderById(.dummy,0xD0100,modX,modY)
endmethod
//--------------------------------------------------------------------
//---------UNIT MOVEMENT , POSITIONING--------------------------------
//--------------------------------------------------------------------
private method positioning takes nothing returns nothing
local unit u = null
local real lx
local real ly
local real atan
//ooooooooooooooooooooooooooooooooooooooooooooooo//
//----The units death will break the instance----//
if GetUnitState(.victim,UNIT_STATE_LIFE) > 0.405 then
//ooooooooooooooooooooooooooooooooooooooooooooooo//
//----Setting the units pathing-----------------//
if .disablePathing then
if not thistype.refreshedPathings then
set .notPathed = thistype.refreshedPathings
set thistype.refreshedPathings = true
endif
if not .notPathed then
set .notPathed = true
call SetUnitPathing(.victim,false)
endif
endif
//ooooooooooooooooooooooooooooooooooooooooooooooo//
//----Pausing the unit for the pulls duration----//
if .pausing then
set .isPaused = IsUnitPaused(.victim)
if not (.isPaused) then
call PauseUnit(.victim,true)
set .isPaused = true
endif
endif
//ooooooooooooooooooooooooooooooooooooooooooooooo//
//----Refreshing pull Angle----------------------//
//--refreshing the units location--
set .pulledX = GetUnitX(.victim)
set .pulledY = GetUnitY(.victim)
if .hasUnitDest then
if .destUnit != null then
set .pulltoX = GetUnitX(.destUnit)
set .pulltoY = GetUnitY(.destUnit)
if .isPulled then
set .pullAngle = Atan2(.pulltoY-.pulledY,.pulltoX-.pulledX)
else
set .pullAngle = Atan2(.pulledY-.pulltoY,.pulledX-.pulltoX)
endif
endif
endif
//ooooooooooooooooooooooooooooooooooooooooooooooo//
//----Periodic Rising (Z value)------------------//
if .isTossed then
call .calculateZ()
call SetUnitFlyHeight(.victim,.calcZ,0)
if .calcZ == 0 then
call .onLanding(.victim)
if .isJump then
call .SuddenStop()
endif
set .tossCount = .tossCount+1
set .tossOrdinalNumber = .tossCount
set .tossStartVelocity = .tossStartVelocity*2/3
set .tossVelocity = .tossStartVelocity
endif
endif
//ooooooooooooooooooooooooooooooooooooooooooooooo//
//----Pathing check------------------------------//
if .isCheckPathing then
//----Save Collision modifiers for victim----
//! textmacro SetCollisionMacro
if not IsUnitInRangeXY(.victim, .pulledX + 17, .pulledY, 0.) then
set .dummySpellLvl = 1
elseif not IsUnitInRangeXY(.victim, .pulledX + 33, .pulledY, 0.) then
set .dummySpellLvl = 2
elseif not IsUnitInRangeXY(.victim, .pulledX + 49, .pulledY, 0.) then
set .dummySpellLvl = 3
else
set .dummySpellLvl = 4
endif
//! endtextmacro
call PauseUnit(.dummy,false)
call SetUnitAbilityLevel(.dummy,'ppds',.dummySpellLvl)
if .calcModAngleXY() then
if not .isPulled and not .hasUnitDest then
set .pullAngle = (360.-(.pullAngle*bj_RADTODEG)) * bj_DEGTORAD
if .calcModAngleXY() then
set .pullAngle = (ModuloReal(180.+(.pullAngle*bj_RADTODEG),360.)) * bj_DEGTORAD
if .calcModAngleXY() then
set .pullAngle = (360.-(.pullAngle*bj_RADTODEG)) * bj_DEGTORAD
if .isBouncing then
call .onBounce(.victim)
else
call .SuddenStop()
endif
else
if .isBouncing then
call .onBounce(.victim)
else
call .SuddenStop()
endif
endif
else
if .isBouncing then
call .onBounce(.victim)
else
call .SuddenStop()
endif
endif
else
call .SuddenStop()
endif
endif
call PauseUnit(.dummy,true)
endif
//ooooooooooooooooooooooooooooooooooooooooooooooo//
//----X and Y vector calc for a period-----------//
call .calcXY()
//ooooooooooooooooooooooooooooooooooooooooooooooo//
//----Placing the unit to the next point---------//
if .active then
set .pulledX = .pulledX+.calcX
set .pulledY = .pulledY+.calcY
call SetUnitX(.victim,.pulledX)
call SetUnitY(.victim,.pulledY)
endif
//ooooooooooooooooooooooooooooooooooooooooooooooo//
//----Hit detection for units and destructables--//
if .hitDests then
call SetRect(thistype.rec, .pulledX-.hitRange , .pulledY-.hitRange , .pulledX+.hitRange , .pulledY+.hitRange)
call EnumDestructablesInRect(thistype.rec, Condition(function thistype.HitDests), null)
endif
if .hitUnits then
//! runtextmacro UnitHitMacro("u","pulledX","pulledY","hitRange")
call .onUnitHit(u)
//! runtextmacro UnitHitMacroEnd()
endif
//ooooooooooooooooooooooooooooooooooooooooooooooo//
//----Speed reduction/increase-------------------//
if .isSlowing then
if .slowStart <= .slowTick*PULL_PERIOD then
set .pullSpeed = .pullSpeed - .slowAmount
endif
endif
//ooooooooooooooooooooooooooooooooooooooooooooooo//
//----Checks if the unit reached its destination-//
if .isPulled and not .noDest then
if .active then
if (.pulltoX-.pulledX)*(.pulltoX-.pulledX)+(.pulltoY-.pulledY)*(.pulltoY-.pulledY) <= .hitRange*.hitRange then
set .active = false
if .notPathed then
call SetUnitPathing(.victim,true)
set thistype.refreshedPathings = false
endif
if .isPaused then
call PauseUnit(.victim,false)
endif
if .hasUnitDest then
call .onAtDestUnit(.destUnit,.victim)
else
call .onAtDestPoint(.victim)
endif
endif
endif
endif
//ooooooooooooooooooooooooooooooooooooooooooooooo//
//----Checks if a unit has 0 moving speed--------//
if .active and .pullSpeed<=0 and .isSlowing then
call .SuddenStop()
endif
//--------------counting--------------------------
set .slowTick = .slowTick + 1
else
//--------------dead unit brakes the instance-----
call .SuddenStop()
endif
endmethod
//--------------------------------------------------------------------
//STRUCT CREATION , REGISTRATION , INSTANCE HANDLING FOR MULTI STRUCTS
//--------------------------------------------------------------------
//-------------EVENT RELEASING IN EVERY TIME PERIOD---------------
private method action takes nothing returns nothing
call .onAction(.victim)
call .positioning()
endmethod
//----------------STRUCT LIST HANDLING---------------------------
static method pull takes nothing returns nothing
local thistype trash
set thistype.thiss = thistype.first.next
loop
exitwhen thistype.thiss == thistype.last
if thistype.thiss.active and thistype.thiss != 0 then
set thistype.curPull = thistype.thiss
call thistype.thiss.action()
else
if thistype.thiss != 0 then
set thistype.thiss.next.prev = thistype.thiss.prev
set thistype.thiss.prev.next = thistype.thiss.next
set trash = thistype.thiss
set thistype.thiss = thistype.thiss.prev
call trash.destroy()
endif
set thistype.count = thistype.count -1
endif
set thistype.thiss = thistype.thiss.next
endloop
if thistype.count <= 0 then
set thistype.count = 0
call PauseTimer(thistype.t)
endif
endmethod
//-------------------REGISTERING-----LINKING IN THE LIST--------------------
public method start takes real x, real y, real x2, real y2 returns nothing
local thistype lth = thistype.last
set .pulledX = x
set .pulledY = y
set .pulltoX = x2
set .pulltoY = y2
set thistype.refreshedPathings = false
call .onPullStart()
if .isPulled then
set .pullAngle = Atan2(y2-y,x2-x)
else
set .pullAngle = Atan2(y-y2,x-x2)
endif
if .isJump then
call .setUpJumpProperties()
endif
if .pullSpeed == 0 then
set .noDest = true
endif
if .isTossed then
call UnitAddAbility(.victim,'Amrf')
call UnitRemoveAbility(.victim,'Amrf')
set .tossVelocity = .tossStartVelocity
endif
if not .isPulReg then
set .active = true
set .isPulReg = true
//this goes here and there and that goes there and here...
set .prev = lth.prev
set .next = lth
set .prev.next = this
set lth.prev = this
set thistype.count = thistype.count + 1
if thistype.count == 1 then
call TimerStart(thistype.t, PULL_PERIOD, true, function thistype.pull)
endif
endif
endmethod
//----------------------------------------------------------------------------------------------------------
//-------------INITIALIZATIONS------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------
private static method onInit takes nothing returns nothing
set thistype.t = CreateTimer()
set thistype.rec = Rect(0.,0.,0.,0.)
set thistype.dummy = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'psdu',0.,0.,0.)
call PauseUnit(thistype.dummy,true)
set thistype.first = .create()
set thistype.last = .create()
set thistype.first.next = thistype.last
set thistype.last.prev = thistype.first
endmethod
endstruct
endlibrary
//TESH.scrollpos=27
//TESH.alwaysfold=0
struct DemoSpell_1 extends Pulling
private static integer lvl = 0 //For saving the ability level
private static unit caster = null //For saving the caster unit
private static unit target = null //and the target unit
//-------------------Conditions-------------------------------------------------------
private static method filt takes nothing returns boolean
return GetSpellAbilityId() == 'A000' and GetSpellTargetUnit() != GetSpellAbilityUnit()
endmethod
//---------------------Creating the struct--------------------------------------------
private static method StartCast takes nothing returns nothing
call .setup(thistype.create())
endmethod
//---------------Newly created structs setup part-(-NOT FOR THE STRUCT VALUES BUT FOR YOUR SPELL)
private static method setup takes thistype this returns nothing
//saving locally
local unit c = GetTriggerUnit() //the caster
local unit t = GetSpellTargetUnit() //the spelltarget
local real cx = GetUnitX(c) //caster x coord
local real cy = GetUnitY(c) //caster y coord
local real tx = GetUnitX(t) //target x coord
local real ty = GetUnitY(t) //target y coord
local integer lvl = GetUnitAbilityLevel(c, GetSpellAbilityId()) //ability level
//FEEL FREE TO TAKE ANY ACTIONS HERE TO MAKE YOUR SPELL AWESOME
set .lvl = lvl //passing the values for the struct
set .caster = c
set .target = t
//----------------------------------------------------------------
call .SetPullUnit(.target) //calling a method that passes the target unit to the struct (THIS WILL BE THE PULLED UNIT)
call .SetDestUnit(.caster) //calling a method that passes the destination unit to the struct (ALWAYS USE THIS IF U HAVE A UNIT AS DESTINATION)
call .start(tx, ty, cx, cy) //calling the main method and passing the tx,ty (the targets coordinations) and cx,cy (the casters coordinations)
//tx,ty should be the units coords wich u want to pull -||- cx,cy should be the point where you pulling to, or where you pushing from the target unit
set c = null
set t = null
endmethod
//-----------------------------------------
//----------EVENTS FROM THE SYSTEM---------
//-----------------------------------------
//---------------EVENT (this is the time to customize your spell)-SETUP-(Happens when the pulling starts(only once)---
method onPullStart takes nothing returns nothing
set .pullSpeed = 400.-(.lvl*100.) // 300/200/100 Will be the pulled units starting speed
set .isPulled = true // this unit will be pulled (not pushed)
set .isSlowing = true // this units speed will be modified
set .slowStart = 0. // the modification starts when 0 seconds passed by
set .slowAmount = -0.625 // its a negative value so the units speed will be INCREASED by
endmethod // 0.625 / 0.03125(period time) = 20 per seconds.
//---------------EVENT (this will happens every time the pulled unit moves (every period))
method onAction takes nothing returns nothing
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Orc\\Orcblood\\HeroShadowHunterBlood.mdl",.victim,"chest"))
call UnitDamageTarget(thistype.caster,.victim,thistype.lvl*.78125*0.1,false,false,null,null,null)
endmethod
//---------------EVENT (this will happen when the pulled unit reaches his (DESTINATION))<----(in this case it is a unit)
//------------HERE U CAN DO ACTIONS---------------------------------------------------------
method onAtDestUnit takes unit DestUnit ,unit Target returns nothing
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl",Target,"chest"))
call UnitDamageTarget(DestUnit,Target,thistype.lvl*10,false,false,null,null,null)
endmethod
//-----------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------
//setting the event ,calling the condition and the StartCast(the Action) method which starts the system
private static method onInit takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger()
call TriggerAddCondition(t, Condition(function thistype.filt))
call TriggerAddAction(t, function thistype.StartCast)
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_CAST, null)
set i = i +1
endloop
endmethod
endstruct
//TESH.scrollpos=0
//TESH.alwaysfold=0
struct DemoSpell_2 extends Pulling
private static integer lvl = 0
private static unit caster = null
private static method filt takes nothing returns boolean
return GetSpellAbilityId() == 'A001'
endmethod
private static method StartCast takes nothing returns nothing
call .setup(thistype.create())
endmethod
private static method setup takes thistype this returns nothing
local unit c = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local real cx = GetUnitX(c)
local real cy = GetUnitY(c)
local real tx = GetUnitX(t)
local real ty = GetUnitY(t)
local integer lvl = GetUnitAbilityLevel(c, GetSpellAbilityId())
set .lvl = lvl
set .caster = c
call .SetPullUnit(t)
call .start(tx, ty, cx, cy)
set c = null
set t = null
endmethod
//-----------------EVENTS-----------------------------------------------------------------------------
method onPullStart takes nothing returns nothing
set .pullSpeed = .lvl*200
set .isPulled = false //the unit will be Pushed (not pulled)
set .isSlowing = true
set .slowStart = .5 //starts to modify the speed after 5 seconds
set .slowAmount = .pullSpeed*0.03125 //this is a positive value the speed will be DECREASING
set .isBouncing = true // enables bouncing from walls
endmethod
//------this will happens every time when the pushed unit moves (every period)
method onAction takes nothing returns nothing
call UnitDamageTarget(thistype.caster,.victim,thistype.lvl*0.625*0.1,false,false,null,null,null)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl",.victim,"chest"))
endmethod
//------this will happens when the pushed units speed decreased to 0 or under
method onStop takes unit target returns nothing
call UnitDamageTarget(thistype.caster,target,thistype.lvl*10,false,false,null,null,null)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl",.victim,"chest"))
endmethod
//------this will happens when the pushed unit touches a destructable
method onDestHit takes destructable d returns nothing
call KillDestructable(d)
endmethod
//------this will happens when the pushed unit touches a unit
method onUnitHit takes unit u returns nothing
if u != .caster then
call UnitDamageTarget(thistype.caster,u,thistype.lvl*2,false,false,null,null,null)
endif
endmethod
method onBounce takes unit target returns nothing
call UnitDamageTarget(thistype.caster,target,thistype.lvl*10,false,false,null,null,null)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Volcano\\VolcanoDeath.mdl",target,"chest"))
endmethod
//-------------------------------------------------------------------------------------------------------
private static method onInit takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger()
call TriggerAddCondition(t, Condition(function thistype.filt))
call TriggerAddAction(t, function thistype.StartCast)
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_CAST, null)
set i = i +1
endloop
endmethod
endstruct
//TESH.scrollpos=0
//TESH.alwaysfold=0
struct DemoSpell_76 extends Pulling
private static integer lvl = 0
private static unit caster = null
private static real hookx
private static real hooky
private static timer ti
private static effect array efar
private static integer idx = 0
private static group g
private static real perDistX
private static real perDistY
private static real cx
private static real cy
private static method filt takes nothing returns boolean
return GetSpellAbilityId() == 'A002'
endmethod
private static method endhook takes nothing returns nothing
call DestroyEffect(.efar[.idx])
set .idx = .idx - 1
if .idx < 0 then
call PauseTimer(.ti)
call DestroyTimer(.ti)
endif
endmethod
private static method setup takes thistype this returns nothing
local unit t = FirstOfGroup(.g)
local real cx = GetUnitX(.caster)
local real cy = GetUnitY(.caster)
local real tx = GetUnitX(t)
local real ty = GetUnitY(t)
local integer lvl = .lvl
set .lvl = lvl
call .SetPullUnit(t)
call .start(tx, ty, cx, cy)
set t = null
call DestroyGroup(.g)
endmethod
private static method filter takes nothing returns nothing
local group ug = CreateGroup()
local unit fog
loop
set fog = FirstOfGroup(.g)
exitwhen fog == null
if fog != .caster and GetWidgetLife(fog) > 0.405 and not (IsUnitType(fog, UNIT_TYPE_STRUCTURE)) then
call GroupAddUnit(ug,fog)
call GroupRemoveUnit(.g,fog)
else
call GroupRemoveUnit(.g,fog)
endif
endloop
loop
set fog = FirstOfGroup(ug)
exitwhen fog == null
call GroupAddUnit(.g,fog)
call GroupRemoveUnit(ug,fog)
endloop
endmethod
private static method retrue takes nothing returns boolean
return true
endmethod
private static method hook takes nothing returns nothing
local real xdif
local real ydif
local real dist = 1000. + .lvl * 100
local boolexpr b=Condition(function thistype.retrue)
set .hookx = .hookx + .perDistX
set .hooky = .hooky + .perDistY
set .idx = .idx + 1
set xdif = .hookx - .cx
set ydif = .hooky - .cy
call GroupEnumUnitsInRange(.g,.hookx,.hooky,75.,b)
call .filter()
if dist * dist <= (xdif * xdif + ydif * ydif) or (FirstOfGroup(.g) != null) then
if FirstOfGroup(.g) != null then
call .setup(thistype.create())
endif
call DestroyTimer(.ti)
set .ti = CreateTimer()
call TimerStart(.ti,0.03125,true,function thistype.endhook)
else
call DestroyGroup(.g)
set .g = CreateGroup()
set .efar[.idx] = AddSpecialEffect("Abilities\\Weapons\\SentinelMissile\\SentinelMissile.mdl",.hookx,.hooky)
endif
endmethod
//-----------------EVENTS-----------------------------------------------------------------------------
method onPullStart takes nothing returns nothing
set .pullSpeed = 1500
set .isPulled = true //the unit will be Pushed (not pulled)
set .isSlowing = false
call UnitDamageTarget(thistype.caster,.victim,50.,false,false,null,null,null)
endmethod
//------this will happens every time when the pushed unit moves (every period)
method onAction takes nothing returns nothing
call UnitDamageTarget(thistype.caster,.victim,thistype.lvl*0.78125,false,false,null,null,null)
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Critters\\Albatross\\CritterBloodAlbatross.mdl",.victim,"origin"))
endmethod
//----------------------------------------------------------------------------------------------------
private static method Aim takes nothing returns nothing
local real x = GetLocationX(GetSpellTargetLoc())
local real y = GetLocationY(GetSpellTargetLoc())
local real c1 = GetUnitX(GetTriggerUnit())
local real c2 = GetUnitY(GetTriggerUnit())
local real vax = x-c1
local real vay = y-c2
local real da = SquareRoot((vax*vax) + (vay*vay))
local real ar = 46.875/da
local real x0 = vax*ar
local real y0 = vay*ar
set .lvl = GetUnitAbilityLevel(.caster, GetSpellAbilityId())
set .caster = GetTriggerUnit()
set .cx = GetUnitX(GetTriggerUnit())
set .cy = GetUnitY(GetTriggerUnit())
set .perDistX = x0
set .perDistY = y0
set .hookx = .cx
set .hooky = .cy
set .ti = CreateTimer()
set .g = CreateGroup()
call TimerStart(thistype.ti,0.03125,true,function thistype.hook)
endmethod
//-------------------------------------------------------------------------------------------------------
private static method onInit takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger()
call TriggerAddCondition(t, Condition(function thistype.filt))
call TriggerAddAction(t, function thistype.Aim)
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_CAST, null)
set i = i +1
endloop
endmethod
endstruct
//TESH.scrollpos=0
//TESH.alwaysfold=0
struct DemoSpell_4 extends Pulling
private static integer lvl = 0
private static unit caster = null
private static method filt takes nothing returns boolean
return GetSpellAbilityId() == 'A003'
endmethod
private static method ret takes nothing returns boolean
return true
endmethod
private static method StartCast takes nothing returns nothing
local group targetGroup = CreateGroup()
local unit fog
local boolexpr rt = Condition(function thistype.ret)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl",GetTriggerUnit(),"chest"))
call GroupEnumUnitsInRange(targetGroup,GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit()),300.,rt)
loop
exitwhen FirstOfGroup(targetGroup) == null
set fog = FirstOfGroup(targetGroup)
if not (IsUnitType(fog,UNIT_TYPE_STRUCTURE)) and GetWidgetLife(fog) > 0.405 and GetTriggerUnit()!= fog then
call .setup(thistype.create(),fog)
endif
call GroupRemoveUnit(targetGroup,fog)
endloop
call DestroyGroup(targetGroup)
endmethod
private static method setup takes thistype this, unit un returns nothing
local unit c = GetTriggerUnit()
local unit t = un
local real cx = GetUnitX(c)
local real cy = GetUnitY(c)
local real tx = GetUnitX(t)
local real ty = GetUnitY(t)
local integer lvl = GetUnitAbilityLevel(c, GetSpellAbilityId())
set .lvl = lvl
set .caster = c
call .SetPullUnit(t)
call .start(tx, ty, cx, cy)
set c = null
set t = null
endmethod
//-----------------EVENTS-----------------------------------------------------------------------------
method onPullStart takes nothing returns nothing
set .pullSpeed = .lvl*50
set .isPulled = false //the unit will be Pushed (not pulled)
set .isTossed = true
set .tossStartVelocity = 2000. //tossed unit fly up to 500.
set .tossNumber = 3 // will be tossed 6 times
set .isBouncing = true // enables bouncing from walls
endmethod
//------this will happens every time when the pushed unit moves (every period)
method onAction takes nothing returns nothing
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl",.victim,"chest"))
endmethod
//------this will happens when the pushed unit touches a destructable
method onDestHit takes destructable d returns nothing
call KillDestructable(d)
endmethod
//------this will happens when the pushed unit touches a unit
method onLanding takes unit target returns nothing
call UnitDamageTarget(thistype.caster,target,thistype.lvl*5,false,false,null,null,null)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl",.victim,"chest"))
if .tossOrdinalNumber == .tossNumber then
set .pullSpeed = 0
endif
endmethod
//-------------------------------------------------------------------------------------------------------
private static method onInit takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger()
call TriggerAddCondition(t, Condition(function thistype.filt))
call TriggerAddAction(t, function thistype.StartCast)
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_CAST, null)
set i = i +1
endloop
endmethod
endstruct
//TESH.scrollpos=21
//TESH.alwaysfold=0
struct DemoSpell_5 extends Pulling
private static integer lvl = 0 //For saving the ability level
private static unit caster = null //For saving the caster unit
private static unit target = null //and the target unit
//-------------------Conditions-------------------------------------------------------
private static method filt takes nothing returns boolean
return GetSpellAbilityId() == 'A004'
endmethod
//---------------------Creating the struct--------------------------------------------
private static method StartCast takes nothing returns nothing
call .setup(thistype.create())
endmethod
private static method ret takes nothing returns boolean
return true
endmethod
//---------------Newly created structs setup part-(-NOT FOR THE SYSTEM VALUES BUT FOR YOUR SPELL)
private static method setup takes thistype this returns nothing
//saving locally
local unit c = GetTriggerUnit() //the caster
local location t = GetSpellTargetLoc()
local real cx = GetUnitX(c) //caster x coord
local real cy = GetUnitY(c) //caster y coord
local real tx = GetLocationX(t) //target x coord
local real ty = GetLocationY(t) //target y coord
local integer lvl = GetUnitAbilityLevel(c, 'A004') //ability level
//FEEL FREE TO TAKE ANY ACTIONS HERE TO MAKE YOUR SPELL AWESOME
set .lvl = lvl //passing the values for the demospell struct
set .caster = c
//----------------------------------------------------------------
call .SetPullUnit(.caster) //calling a method that passes the target unit to the struct (THIS WILL BE THE PULLED UNIT)
call .start(cx, cy, tx, ty) //calling the main method and passing the tx,ty (the targets coordinations) and cx,cy (the casters coordinations)
//tx,ty should be the units coords wich u want to pull -||- cx,cy should be the point where you pulling to, or where you pushing from the target unit
set c = null
set t = null
endmethod
//-----------------------------------------
//----------EVENTS FROM THE SYSTEM---------
//-----------------------------------------
//---------------EVENT (this is the time to customize your spell)-SETUP-(Happens when the pulling starts(only ONCE)---
method onPullStart takes nothing returns nothing
set .isJump = true // this is a jump spell
// JUMP SPELLS ARE AUTOMATIC . THE HAVE TO DO ALMOST NOTHING HERE
//THESE VARIABLES WILL BE CALCULATED BY THE SYSTEM (event if you set theme...) :
// - .isPulled will equal true
// - .isSlowing will equal false
// - .isTossed will equal true
// - .tossNumber will be only 1 (as it is one jump:D)
// - .isBouncing will equal false
// - .isCheckPathing will equal false
// - .pullSpeed (calculated)
// - .tossStartVelocity (calculated)
endmethod
//---------------EVENT (this fires every time the pulled unit is moved (every period))
method onAction takes nothing returns nothing
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl",.victim,"chest"))
endmethod
method onLanding takes unit Target returns nothing
local group targetGroup = CreateGroup()
local unit fog
local boolexpr rt = Condition(function thistype.ret)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl",Target,"chest"))
call GroupEnumUnitsInRange(targetGroup,GetUnitX(Target),GetUnitY(Target),500.,rt)
loop
exitwhen FirstOfGroup(targetGroup) == null
set fog = FirstOfGroup(targetGroup)
if not (IsUnitType(fog,UNIT_TYPE_STRUCTURE)) and GetWidgetLife(fog) > 0.405 and Target != fog then
call UnitDamageTarget(Target,fog,.lvl * 75,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIfb\\AIfbSpecialArt.mdl",fog,"chest"))
endif
call GroupRemoveUnit(targetGroup,fog)
endloop
call DestroyGroup(targetGroup)
endmethod
//-----------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------
//setting the event ,calling the condition and the StartCast(the Action) method which starts the system
private static method onInit takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger()
call TriggerAddCondition(t, Condition(function thistype.filt))
call TriggerAddAction(t, function thistype.StartCast)
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_CAST, null)
set i = i +1
endloop
endmethod
endstruct
//TESH.scrollpos=6
//TESH.alwaysfold=0
struct JumpAttack extends Pulling
private static unit caster = null
private static unit target = null
private static boolean b = false
//-------------------Conditions-------------------------------------------------------
private static method filt takes nothing returns boolean
if IsUnitType(GetAttacker(),UNIT_TYPE_MELEE_ATTACKER) and IsUnitType(GetTriggerUnit(),UNIT_TYPE_FLYING) then
call .setup(thistype.create())
return false
endif
return false
endmethod
//---------------Newly created structs setup part-(-NOT FOR THE SYSTEM VALUES BUT FOR YOUR SPELL)
private static method setup takes thistype this returns nothing
set .caster = GetAttacker()
set .target = GetTriggerUnit()
//------------------------system start--------------------------------
call .SetPullUnit(.caster)
call .start(GetUnitX(.caster), GetUnitY(.caster), GetUnitX(.target), GetUnitY(.target))
endmethod
method onPullStart takes nothing returns nothing
set .isJump = true
set .pausing = false
set .disablePathing = false
set .hitUnits = false
set .hitDests = false
set .heightFactor = 3 //higher value, higher jump
endmethod
private method onAction takes unit target returns nothing
if IsUnitPaused(target) then
call BJDebugMsg("true")
else
call BJDebugMsg("false")
endif
endmethod
private static method onInit takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger()
call TriggerAddCondition(t, Condition(function thistype.filt))
loop
exitwhen i >= bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_ATTACKED, null)
set i = i +1
endloop
endmethod
endstruct