- Joined
- Oct 18, 2007
- Messages
- 930
Ok I'm stuck on this spell of mine.
For some reason it wont work. I have tried everything.
Well it bugs up in the missile loops as far as I know. Well, here is code
And map
For some reason it wont work. I have tried everything.
Well it bugs up in the missile loops as far as I know. Well, here is code
JASS:
scope Flare initializer Init
globals
// Constants For Spell
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//* IDENTIFYER TYPE NAME VALUE
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// Rawcodes
private constant integer AbilityId = 'A000'
private constant integer DummyId = 'n000'
private constant integer FlyId = 'Amrf'
private constant string Order = "channel" // Orderstring for the ability Channel
// String Globals
// General Strings
private constant string CastEffect = "Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl"
private constant string CastEffectAttach = "origin"
private constant string StopOrder = "stop"
// Dummy Strings
private constant string DummyModelPath = "war3mapImported\\Dummy.mdx"
private constant string DummyAttachPoint = "origin"
// Missile Strings
private constant string MissileModelPath = "Abilities\\Weapons\\FireBallMissile\\FireBallMissile.mdl"
// Wave Strings
private constant string WaveOverTimeArt = "Abilities\\Spells\\Other\\Doom\\DoomTarget.mdl"
private constant string WaveOverTimeArtAttach = "origin"
// Real Globals
// Missile Reals
private constant real MissileScale = 0.8
private constant real MissileScaleInc = 0.1
private constant real MissileArc = 0.6
private constant real MissileSpeed = 20.
private constant real MissileMoveInterval = 0.03
private constant real MissileDist = 35.
// Damage Reals
private constant real DamageAmount = 25.
private constant real DamageAmountInc = 10.
private constant real DamageAoe = 45.
private constant real DamageAoeInc = 15.
// Wave Reals
private constant real WaveInterval = 0.1
private constant real WaveAngleSpread = 45.
private constant real WaveMissileDistIncPerWave = 25.
// Integer Globals
// Missile Integers
private constant integer MissileAngleOfAttack = 90
private constant integer WaveAmountOfMissiles = 10
private constant integer WaveAmountOfMissilesInc = 5
// Misc Globals
// Damage Miscs
private constant attacktype DamageAttacktype = ATTACK_TYPE_NORMAL
private constant damagetype DamageDamagetype = DAMAGE_TYPE_NORMAL
private constant weapontype DamageWeapontype = null
private constant boolean DamageIsAttack = false
private constant boolean DamageIsRanged = true
//------------------------------------------------------------------------------------------
endglobals
// End Of Constants!
//=====================
globals
private group TempGroup = CreateGroup()
private unit TempUnit = null
private player TempPlayer = null
private boolexpr EnemyFilter = null
private integer IdOrder = 0
private boolean array EffectBool
endglobals
private function EffectBoolSetup takes nothing returns nothing
set EffectBool[0] = CastEffect != "" and CastEffectAttach != "" and CastEffect != null and CastEffectAttach != null
set EffectBool[1] = MissileModelPath != "" and DummyModelPath != "" and DummyAttachPoint != "" and MissileModelPath != null and DummyModelPath != null and DummyAttachPoint != null
set EffectBool[2] = WaveOverTimeArt != "" and WaveOverTimeArtAttach != "" and WaveOverTimeArt != null and WaveOverTimeArtAttach != null
endfunction
private function GroupFilter takes nothing returns boolean
return GetWidgetLife(GetFilterUnit()) > .405 and IsUnitEnemy(GetFilterUnit(), TempPlayer) and IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) == true
endfunction
private struct Missile
unit u
player p
real cos
real sin
real dist = 0
real maxdist
real dam
real aoe
real h = 0
unit m
effect art
static real nX1 = 0
static real nY1 = 0
static real nX2 = 0
static real nY2 = 0
static real nH = 0
static integer array Index
static integer Total = 0
static timer Tim = CreateTimer()
static location Loc1 = Location(0, 0)
static location Loc2 = Location(0, 0)
static method Loop takes nothing returns nothing
local Missile dat
local integer i = 0
loop
exitwhen i >= dat.Total
set dat = dat.Index[i]
if dat.dist < dat.maxdist then
set dat.dist = dat.dist + MissileSpeed
set dat.nX1 = GetUnitX(dat.m)
set dat.nY1 = GetUnitY(dat.m)
call MoveLocation(dat.Loc1, dat.nX1, dat.nY1)
set dat.nX2 = dat.nX1 + dat.dist * dat.cos
set dat.nY2 = dat.nY1 + dat.dist * dat.sin
call MoveLocation(dat.Loc2, dat.nX2, dat.nY2)
set dat.nH = ((4 * MissileArc)*(dat.maxdist * dat.dist)*(dat.dist / dat.maxdist))
call SetUnitX(dat.m, dat.nX2)
call SetUnitY(dat.m, dat.nY2)
call SetUnitFlyHeight(dat.m, dat.nH - GetLocationZ(dat.Loc1), 0)
call SetUnitAnimationByIndex(dat.m, R2I(Atan2((dat.nH + GetLocationZ(dat.Loc2)) - (dat.h + GetLocationZ(dat.Loc1)), dat.dist)) + MissileAngleOfAttack)
set dat.h = dat.nH
call BJDebugMsg("'if dat.dist < dat.maxdist then' passed trough!")
else
set dat.nX1 = GetUnitX(dat.m)
set dat.nY1 = GetUnitY(dat.m)
set TempPlayer = dat.p
call GroupEnumUnitsInRange(TempGroup, dat.nX1, dat.nY1, dat.aoe, EnemyFilter)
loop
set TempUnit = FirstOfGroup(TempGroup)
exitwhen TempUnit == null
call UnitDamageTarget(dat.u, TempUnit, dat.dam, DamageIsAttack, DamageIsRanged, DamageAttacktype, DamageDamagetype, DamageWeapontype)
call GroupRemoveUnit(TempGroup, TempUnit)
endloop
call KillUnit(dat.m)
call DestroyEffect(dat.art)
set dat.m = null
set dat.art = null
set dat.u = null
set dat.p = null
call dat.destroy()
set dat.Total = dat.Total - 1
set dat.Index[i] = dat.Index[dat.Total]
set i = i - 1
call BJDebugMsg("'if dat.dist < dat.maxdist then' not passed trough!")
endif
set i = i + 1
endloop
if dat.Total == 0 then
call PauseTimer(dat.Tim)
endif
endmethod
static method New takes real x0, real y0, real a, real d, real s, unit u, player p, real dam, real aoe returns nothing
local Missile dat = Missile.allocate()
set dat.u = u
set dat.p = p
set dat.maxdist = d
set dat.dam = dam
set dat.aoe = aoe
set dat.cos = Cos(a)
set dat.sin = Sin(a)
set dat.m = CreateUnit(p, DummyId, x0, y0, a * bj_RADTODEG)
call SetUnitScale(dat.m, s, s, s)
call UnitAddAbility(dat.m, FlyId)
call UnitRemoveAbility(dat.m, FlyId)
if EffectBool[1] then
set dat.art = AddSpecialEffectTarget(MissileModelPath, dat.m, DummyAttachPoint)
endif
if dat.Total == 0 then
call TimerStart(dat.Tim, MissileMoveInterval, true, function Missile.Loop)
endif
set dat.Index[dat.Total] = dat
set dat.Total = dat.Total + 1
endmethod
endstruct
private struct Wave
unit u
player p
real dist = MissileDist
real a
real x
real y
integer c = 0
integer mc
real Mdam
real Maoe
real Mscale
effect art
static integer array Index
static integer Total = 0
static timer Tim = CreateTimer()
static method Loop takes nothing returns nothing
local Wave dat
local integer i = 0
loop
exitwhen i >= dat.Total
set dat = dat.Index[i]
if GetUnitCurrentOrder(dat.u) == IdOrder and GetWidgetLife(dat.u) > .405 and dat.c < dat.mc then
call Missile.New(dat.x, dat.y, (GetRandomReal(-WaveAngleSpread, WaveAngleSpread) * bj_DEGTORAD) + dat.a, dat.dist, dat.Mscale, dat.u, dat.p, dat.Mdam, dat.Maoe)
set dat.dist = dat.dist + WaveMissileDistIncPerWave
set dat.c = dat.c + 1
else
call IssueImmediateOrder(dat.u, StopOrder)
call DestroyEffect(dat.art)
set dat.u = null
set dat.p = null
set dat.art = null
call dat.destroy()
set dat.Total = dat.Total - 1
set dat.Index[i] = dat.Index[dat.Total]
set i = i - 1
endif
set i = i + 1
endloop
if dat.Total == 0 then
call PauseTimer(dat.Tim)
endif
endmethod
static method Start takes unit u, real a, real x, real y, integer lvl returns nothing
local Wave dat = Wave.allocate()
set dat.u = u
set dat.p = GetOwningPlayer(u)
set dat.x = x
set dat.y = y
set dat.a = a
if EffectBool[2] then
set dat.art = AddSpecialEffectTarget(WaveOverTimeArt, u, WaveOverTimeArtAttach)
endif
set dat.mc = WaveAmountOfMissiles + ( WaveAmountOfMissilesInc * ( lvl - 1 ) )
set dat.Mdam = DamageAmount + ( DamageAmountInc * ( lvl - 1 ) )
set dat.Maoe = DamageAoe + ( DamageAoeInc * ( lvl - 1 ) )
set dat.Mscale = MissileScale + ( MissileScaleInc * ( lvl - 1 ) )
if dat.Total == 0 then
call TimerStart(dat.Tim, WaveInterval, true, function Wave.Loop)
endif
set dat.Index[dat.Total] = dat
set dat.Total = dat.Total + 1
endmethod
endstruct
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == AbilityId
endfunction
private function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local location loc = GetSpellTargetLoc()
local real x2 = GetLocationX(loc)
local real y2 = GetLocationY(loc)
call Wave.Start(u, Atan2(y2 - y, x2 - x), x, y, GetUnitAbilityLevel(u, AbilityId))
if EffectBool[0] then
call DestroyEffect(AddSpecialEffectTarget(CastEffect, u, CastEffectAttach))
endif
call RemoveLocation(loc)
set u = null
set loc = null
endfunction
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(trg, function Actions)
call TriggerAddCondition(trg, Condition(function Conditions))
set trg = null
set IdOrder = OrderId(Order)
set EnemyFilter = Condition(function GroupFilter)
call EffectBoolSetup()
if EffectBool[0] then
call Preload(CastEffect)
endif
if EffectBool[1] then
call Preload(MissileModelPath)
call Preload(DummyModelPath)
endif
if EffectBool[2] then
call Preload(WaveOverTimeArt)
endif
call PreloadStart()
call RemoveUnit(CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), DummyId, 0, 0, 0))
endfunction
endscope
And map
Attachments
Last edited: