AlExAlExAlEx
Member
- Reaction score
- 7
Let's take a code from the 4 panda spells it is displayed like this :
Where i have to past this so i can use it ingame ?
Thanks anticipated.
Code:
scope SeismicSlam initializer Init
globals
// Configurables:
// Skills:
private constant integer Abil_id = 'A000'
// Raw code of the main hero ability.
private constant integer Abil2_id = 'A007'
// Raw code of the stomp used at the end.
private constant integer Flytrick = 'Amrf'
// Raw code for "Crow Form". Does not need to be changed in most cases.
// Units:
private constant integer Dummy_id = 'u001'
// Raw code of the dummy "spinning" unit used for the leap.
private constant integer Treedummy_id = 'u000'
// Raw code of the dummy unit used to destroy trees.
// Others:
private constant real Interval = 0.04 // Interval for periodic timer.
private constant real Diff = 0.00 // Distance from cast point that the unit will land.
private constant real Timescale = 3.00 // How fast the unit spins.
private constant string End_anim = "spell slam"
// End animation of the unit.
private constant string Dirt_sfx = "NewDirtEXNofire.mdx"
// Effect made at the end of the spell on land.
private constant string Water_sfx = "Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl"
// Same as above but for landing on water.
private constant boolean Destroytrees = true
// Whether or not to destroy trees.
private constant boolean AllowPreload = true
// Whether or not to allow preloading of the effects.
endglobals
//=======================================================================
private function Area takes integer lvl returns real
return 225.00 // Area of effect for destroying trees.
endfunction
private function Airtime takes integer lvl returns real
return 1.45-(0.15*lvl) // Air time of the leap.
endfunction
//=======================================================================//
// DO NOT TOUCH PAST THIS POINT UNLESS YOU KNOW WHAT YOUR ARE DOING!! //
//=======================================================================//
private keyword Data
globals
private integer Total = 0
private Data array D
private timer Timer = null
private rect Rect1 = null
private boolexpr Treefilt = null
private boolexpr Truefilt = null
private unit Treedummy = null
private real Game_maxX = 0.00
private real Game_minX = 0.00
private real Game_maxY = 0.00
private real Game_minY = 0.00
endglobals
//=======================================================================
private function KillEnumDestructables takes nothing returns nothing
call KillDestructable(GetEnumDestructable())
endfunction
private function TreeCheck takes nothing returns boolean
local destructable dest = GetFilterDestructable()
local boolean result
if GetDestructableLife(dest) > 0.405 then
call ShowUnit(Treedummy,true)
call SetUnitX(Treedummy,GetWidgetX(dest))
call SetUnitY(Treedummy,GetWidgetY(dest))
set result = IssueTargetOrder(Treedummy,"harvest",dest)
call IssueImmediateOrder(Treedummy,"stop")
call ShowUnit(Treedummy,false)
return result
endif
set dest = null
return false
endfunction
//=======================================================================
private function SafeX takes real x returns real
if x<Game_minX then
return Game_minX
elseif x>Game_maxX then
return Game_maxX
endif
return x
endfunction
private function SafeY takes real y returns real
if y<Game_minY then
return Game_minY
elseif y>Game_maxY then
return Game_maxY
endif
return y
endfunction
//=======================================================================
private function MoveDist takes real Maxdist, integer lvl returns real
return Maxdist/(Airtime(lvl)/Interval)
endfunction
private function ConvertCount takes integer i, integer lvl returns real
return (50.00/(Airtime(lvl)/Interval))*i
endfunction
//=======================================================================
private struct Data
unit cast
unit dum
real castx
real casty
real cos
real sin
real maxdist
real movedist
integer i = 1
integer lvl
static method create takes nothing returns Data
local Data d = Data.allocate()
local location loc
local real angle
local real targx
local real targy
set d.cast = GetTriggerUnit()
set d.castx = GetUnitX(d.cast)
set d.casty = GetUnitY(d.cast)
set loc = GetSpellTargetLoc()
set angle = Atan2((GetLocationY(loc)-d.casty),(GetLocationX(loc)-d.castx))
set d.cos = Cos(angle)
set d.sin = Sin(angle)
set targx = GetLocationX(loc)-Diff*d.cos
set targy = GetLocationY(loc)-Diff*d.sin
set d.lvl = GetUnitAbilityLevel(d.cast,Abil_id)
set d.maxdist = SquareRoot((targx-d.castx)*(targx-d.castx)+(targy-d.casty)*(targy-d.casty))
set d.movedist = MoveDist(d.maxdist,d.lvl)
set d.dum = CreateUnit(GetOwningPlayer(d.cast),Dummy_id,d.castx,d.casty,angle*bj_RADTODEG)
call UnitAddAbility(d.dum,Flytrick)
call UnitRemoveAbility(d.dum,Flytrick)
call SetUnitTimeScale(d.dum,Timescale)
call SetUnitPathing(d.dum,false)
call PauseUnit(d.dum,true)
call ShowUnit(d.cast,false)
set Total = Total + 1
if Total == 1 then
call TimerStart(Timer,Interval,true,function Data.Update)
endif
set D[Total] = d
call RemoveLocation(loc)
set loc = null
return d
endmethod
static method Update takes nothing returns nothing
local integer i = 1
local real count
local real height
local real speed
local real newx
local real newy
loop
exitwhen i > Total
if D[i].i < (Airtime(D[i].lvl) / Interval) then
set count = ConvertCount(D[i].i,D[i].lvl)
set height = (count-25.00) * (count-25.00)
set speed = D[i].i * D[i].movedist
set newx = D[i].castx + speed * D[i].cos
set newy = D[i].casty + speed * D[i].sin
call SetUnitPosition(D[i].dum,SafeX(newx),SafeY(newy))
call SetUnitPosition(D[i].cast,SafeX(newx),SafeY(newy))
call SetUnitFlyHeight(D[i].dum,625.00-height,0.00)
call SetUnitFlyHeight(D[i].cast,625.00-height,0.00)
set D[i].i = D[i].i + 1
else
call D[i].destroy()
set D[i] = D[Total]
set Total = Total - 1
set i = i - 1
endif
set i = i + 1
endloop
if Total <= 0 then
call PauseTimer(Timer)
set Total = 0
endif
endmethod
private method onDestroy takes nothing returns nothing
local real newx = GetUnitX(.dum) + Diff * .cos
local real newy = GetUnitY(.dum) + Diff * .sin
local unit u = CreateUnit(GetOwningPlayer(.cast),Treedummy_id,newx,newy,0.00)
call SetUnitFlyHeight(.dum,GetUnitDefaultFlyHeight(.cast),0.00)
call PauseUnit(.dum,false)
call SetUnitPathing(.dum,true)
if Destroytrees then
call SetRect(Rect1,newx-Area(.lvl),newy-Area(.lvl),newx+Area(.lvl),newy+Area(.lvl))
call EnumDestructablesInRect(Rect1,Treefilt,function KillEnumDestructables)
endif
call UnitAddAbility(u,Abil2_id)
call SetUnitAbilityLevel(u,Abil2_id,.lvl)
call IssueImmediateOrder(u,"stomp")
call UnitApplyTimedLife(u,'BTLF',1.00)
if IsTerrainPathable(GetUnitX(u),GetUnitY(u),PATHING_TYPE_FLOATABILITY) then
call DestroyEffect(AddSpecialEffect(Dirt_sfx,newx,newy))
elseif not IsTerrainPathable(GetUnitX(u),GetUnitY(u),PATHING_TYPE_WALKABILITY) then
call DestroyEffect(AddSpecialEffect(Water_sfx,newx,newy))
endif
call RemoveUnit(.dum)
call SetUnitPosition(.cast,newx,newy)
call ShowUnit(.cast,true)
call SetUnitAnimation(.cast,End_anim)
if GetLocalPlayer() == GetOwningPlayer(.cast) then
call ClearSelection()
call SelectUnit(.cast,true)
endif
set .cast = null
set .dum = null
set u = null
endmethod
endstruct
//=======================================================================
private function Actions takes nothing returns nothing
call Data.create()
endfunction
//=======================================================================
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == Abil_id
endfunction
//=======================================================================
private function TrueFilt takes nothing returns boolean
return true
endfunction
//=======================================================================
private function Init takes nothing returns nothing
local trigger trig = CreateTrigger()
local integer i = 0
set Timer = CreateTimer()
set Rect1 = Rect(0.00,0.00,1.00,1.00)
set Treefilt = Filter(function TreeCheck)
set Game_maxX = GetRectMaxX(bj_mapInitialPlayableArea)-64.00
set Game_maxY = GetRectMaxY(bj_mapInitialPlayableArea)-64.00
set Game_minX = GetRectMinX(bj_mapInitialPlayableArea)+64.00
set Game_minY = GetRectMinY(bj_mapInitialPlayableArea)+64.00
set Truefilt = Filter(function TrueFilt)
loop
call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,Truefilt)
set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(trig,Condition(function Conditions))
call TriggerAddAction(trig,function Actions)
set Treedummy = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),Treedummy_id,0.00,0.00,0.00)
call SetUnitPathing(Treedummy,false)
call ShowUnit(Treedummy,false)
if AllowPreload then
call KillUnit(CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),Dummy_id,0.00,0.00,0.00))
call DestroyEffect(AddSpecialEffect(Dirt_sfx,0.00,0.00))
call DestroyEffect(AddSpecialEffect(Water_sfx,0.00,0.00))
endif
endfunction
endscope
Where i have to past this so i can use it ingame ?
Thanks anticipated.