Rllulium
New Member
- Reaction score
- 10
Hello Again.
I picked up JASS (very) recently, deciding that it wasn't nearly as complicated as I first had anticipated. While knowledge of GUI and some general programming gave me a head start, problems are gathering up as soon as I attempt anything more complicated. I'd appreciate it if someone could take a look at this projectile spell and tell me what is wrong:
Thanks in advance!
I picked up JASS (very) recently, deciding that it wasn't nearly as complicated as I first had anticipated. While knowledge of GUI and some general programming gave me a head start, problems are gathering up as soon as I attempt anything more complicated. I'd appreciate it if someone could take a look at this projectile spell and tell me what is wrong:
JASS:
globals
trigger PjMoveTrigger
integer PjIndex = 0
integer PjUserData
integer array PjSpellLevel
real array PjRange
real array PjDistance
real array PjAngle
unit array PjCaster
location PjStart
location PjClick
location PjLocation
location PjMovement
group PjGroup = CreateGroup()
group PjTarget = CreateGroup()
group PjRandom = CreateGroup()
endglobals
function PjConditions takes nothing returns boolean
return GetSpellAbilityId() == 039;A004039;
endfunction
function PjActions takes nothing returns nothing
set PjIndex = (PjIndex + 1)
set PjCaster[PjIndex] = GetSpellAbilityUnit()
set PjSpellLevel[PjIndex] = GetUnitAbilityLevelSwapped(039;A004039;, PjCaster[PjIndex])
set PjStart = GetUnitLoc(PjCaster[PjIndex])
set PjClick = GetSpellTargetLoc()
set PjAngle[PjIndex] = AngleBetweenPoints(PjStart, PjClick)
call CreateUnitAtLocSaveLast(GetOwningPlayer(PjCaster[PjIndex]),039;e000039;,PolarProjectionBJ(PjStart, 20., PjAngle[PjIndex]) , PjAngle[PjIndex])
call SetUnitPathing( GetLastCreatedUnit(), false )
call SetUnitUserData( GetLastCreatedUnit(), PjIndex)
call GroupAddUnit(PjGroup, GetLastCreatedUnit())
set PjRange[PjIndex] = 1000.
set PjDistance[PjIndex] = 0.
call RemoveLocation(PjStart)
call RemoveLocation(PjClick)
if(not( IsTriggerEnabled(PjMoveTrigger)))then
call EnableTrigger(PjMoveTrigger)
endif
endfunction
//===========================================================================
function InitTrig_Projectile_Setup takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( t, Condition( function PjConditions ) )
call TriggerAddAction( t, function PjActions )
endfunction
JASS:
function PjTargetCheck takes nothing returns boolean
local boolean b = false
if (IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetEnumUnit())) == true and IsUnitAliveBJ(GetFilterUnit()) == true) then
set b = true
endif
return b
endfunction
function PjDamage takes nothing returns nothing
call Damage_Spell(PjCaster[PjIndex],GetEnumUnit(),100)
endfunction
function PjMove takes nothing returns nothing
set PjUserData = GetUnitUserData(GetEnumUnit())
set PjLocation = GetUnitLoc(GetEnumUnit())
set PjMovement = Location(GetLocationX(PjLocation) + Cos(PjAngle[PjUserData])*20, GetLocationY(PjLocation) + Sin(PjAngle[PjUserData])*20)
call SetUnitPositionLoc( GetEnumUnit(), PjMovement )
set PjDistance[PjUserData] = ( PjDistance[PjUserData] + 20.00 )
set PjTarget = GetUnitsInRangeOfLocMatching(100.00, PjMovement, Condition(function PjTargetCheck))
set PjRandom = GetRandomSubGroup(1, PjTarget)
call ForGroup( PjRandom, function PjDamage )
if ( CountUnitsInGroup(PjTarget) > 0 ) then
call KillUnit( GetEnumUnit() )
call GroupRemoveUnit(PjGroup, GetEnumUnit())
endif
if( PjDistance[PjUserData]>= PjRange[PjUserData])then
call KillUnit( GetEnumUnit() )
call GroupRemoveUnit(PjGroup, GetEnumUnit())
endif
call RemoveLocation(PjLocation)
call RemoveLocation(PjMovement)
call DestroyGroup(PjTarget)
call DestroyGroup(PjRandom)
endfunction
function PjMoveActions takes nothing returns nothing
call ForGroup(PjGroup, function PjMove)
if ( CountUnitsInGroup(PjGroup) == 0 ) then
call DisableTrigger( GetTriggeringTrigger() )
endif
endfunction
//===========================================================================
function InitTrig_Projectile_Movement takes nothing returns nothing
set PjMoveTrigger = CreateTrigger( )
call DisableTrigger( PjMoveTrigger )
call TriggerRegisterTimerEventPeriodic( PjMoveTrigger, 0.02 )
call TriggerAddAction( PjMoveTrigger, function PjMove )
endfunction
Thanks in advance!