- Joined
- Apr 6, 2008
- Messages
- 760
i'v been experimenting abit just wondeing if there is really any diffrent between scopes and librarys...
is it really good 2 do this?
look at this code it uses CSSafety and CSData and i did library it to need CSSAfety(only reason) and the spell works just fine
is it really good 2 do this?
look at this code it uses CSSafety and CSData and i did library it to need CSSAfety(only reason) and the spell works just fine
JASS:
library SonicBlast initializer Init needs CSSafety
//!=============================================================================!\\
//! Sonic Blast by Ciebron. !\\
//! Give Credits is you use this in your map !\\
//! --------------------------------------------------------------------------- !\\
//! Requires: !\\
//! ¯¯¯¯¯¯¯¯¯ !\\
//! - Object Editor - A hero !\\
//! - Object Editor - The Orb of Zeuz ability !\\
//! - Object Editor aadada - The Orb Dummy Unit !\\
//! - Trigger Editor - This Trigger !\\
//! - Trigger Editor - CSData - by Vexorian !\\
//! - Trigger Editor - CSSaftey - by Vexorian !\\
//! ([url]http://www.wc3campaigns.net/showthread.php?t=80534][/url]) !\\
//! !\\
//!=============================================================================!\\
//!=================================Setup Starts================================!\\
//!=============================================================================!\\
globals
private constant integer Abil_id = 'A002' //! Ability RawCode
private constant integer Dummy_id = 'h001' //! Dummy Unit RawCode
private constant real Time = 1. //! Time to move Dist
private constant real Dist = 1000. //! Distance to move
private constant real Aoe = 200. //! Aoe to pick units Around the dummy
endglobals
//!=============================================================================!\\
//!=================================Setup Ends==================================!\\
//!=============================================================================!\\
private struct Data
unit c
unit dum
real cos
real sin
real dist
real movedist
integer lvl
group g
timer t
player play
method onDestroy takes nothing returns nothing
call KillUnit(.dum)
call ReleaseTimer(.t)
call ReleaseGroup(.g)
endmethod
endstruct
private function preload takes nothing returns nothing
call RemoveUnit(CreateUnit(Player(15),Dummy_id,0.,0.,0.))
endfunction
private function UnitFilter takes nothing returns boolean
local Data d = GetCSData(GetExpiredTimer())
local unit f = GetFilterUnit()
local boolean ok = GetWidgetLife(f) > 0. and not IsUnitType(f,UNIT_TYPE_MAGIC_IMMUNE) and not IsUnitType(f,UNIT_TYPE_STRUCTURE) and not IsUnitInGroup(f,d.g) and IsUnitEnemy(f,d.play)
set f = null
return ok
endfunction
private function Move takes nothing returns nothing
local Data d = GetCSData(GetExpiredTimer())
local real x = GetUnitX(d.dum)+d.movedist*d.cos
local real y = GetUnitY(d.dum)+d.movedist*d.sin
local group g = NewGroup()
local unit a
set d.dist = d.dist + d.movedist
if MinX < x and MaxX > x then
call SetUnitX(d.dum,x)
endif
if MinY < y and MaxY > y then
call SetUnitY(d.dum,y)
endif
call GroupEnumUnitsInRange(g,x,y,Aoe,Filter(function UnitFilter))
loop
set a = FirstOfGroup(g)
exitwhen a == null
call GroupRemoveUnit(g,a)
call UnitDamageTarget(d.c,a,75*d.lvl,false,false,ATTACK_TYPE_MAGIC,null,null)
call Knockback(a,200.,Atan2(GetUnitY(a)-y,GetUnitX(a)-x),I2R(d.lvl)/2)
call GroupAddUnit(d.g,a)
endloop
if d.dist >= Dist then
call d.destroy()
endif
call ReleaseGroup(g)
set g = null
endfunction
private function Actions takes nothing returns nothing
local Data d = Data.create()
local location loc = GetSpellTargetLoc()
local real tx = GetLocationX(loc)
local real ty = GetLocationY(loc)
local real x
local real y
local real angle
set d.c = GetTriggerUnit()
set d.play = GetOwningPlayer(d.c)
set x = GetUnitX(d.c)
set y = GetUnitY(d.c)
set d.lvl = GetUnitAbilityLevel(d.c,Abil_id)
set d.dist = 0
set angle = Atan2(ty-y,tx-x)*57.27589
set d.cos = Cos(angle*3.14159/180.)
set d.sin = Sin(angle*3.14159/180.)
set d.movedist = (Dist/Time)/(1./.035)
set d.dum = CreateUnit(d.play,Dummy_id,x+50*d.cos,y+50*d.sin,angle)
set d.g = NewGroup()
set d.t = NewTimer()
call SetCSData(d.t,d)
call TimerStart(d.t,.035,true,function Move)
call RemoveLocation(loc)
set loc = null
endfunction
private function FilterFunc takes nothing returns boolean
return GetSpellAbilityId()==Abil_id
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer index = 0
loop
call TriggerRegisterPlayerUnitEvent(t,Player(index),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddAction(t,function Actions)
call TriggerAddCondition(t,Filter(function FilterFunc))
call preload()
set t = null
endfunction
endlibrary