- Joined
- Apr 24, 2012
- Messages
- 5,113
[jass=]//********************************************************************************************
//*
//*
//* SUPERNOVA version 1.0
//*
//* made by RADAMANTUS a.k.a ALMIA
//*
//*
//********************************************************************************************
//*
//* TOOLTIP:
//*
//* Summons a red star on the targeted point,the red star then explodes after 2 seconds
//* releasing 12 meteorites per layer outward the star's point.Each meteorite deals 15/30/45
//* damage and the explosion has 5 layers.Each layer has a distance of 100 x the layer number
//* from the star.
//*
//********************************************************************************************
//*
//* HOW TO IMPORT?
//*
//* 1)Import the dummy and its model
//* 2)Import the ability
//* 3)If you want,import the sun model
//* 4)Copy the code
//* 5)Create this variables:
//* - udg_SN_Hash
//* - udg_SN_Group
//* - udg_SN_Loop
//* 6)Enjoy!
//*
//********************************************************************************************
//*
//* CREDITS
//*
//* - Vexorian for the dummy.mdx(also for Anitarf and Infrane)
//* - WILL THE ALMIGHTY for the sun model
//*
//********************************************************************************************
//* CONSTANT FUNCTIONS
//*
//* Configuration of the spell
//*
//********************************************************************************************
//Loop Value
constant function SN_Interval takes nothing returns real
return 0.03125
endfunction
// Rawcode of the ability
constant function SN_Abil takes nothing returns integer
return 'A000'
endfunction
//Rawcode of the dummy
constant function SN_Dummy takes nothing returns integer
return 'h000'
endfunction
//Model of the star
//Credits to WILL THE ALMIGHTY for the model
constant function SN_Starmdl takes nothing returns string
return "war3mapImported\\Sun.mdx"
endfunction
//Model of the meteorites
constant function SN_Meteormdl takes nothing returns string
return "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl"
endfunction
//Model of the ministars
constant function SN_Minimdl takes nothing returns string
return "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl"
endfunction
//Scale of the star
constant function SN_Starscale takes nothing returns real
return 100.
endfunction
//Scale of the meteorites a.k.a segments
constant function SN_Meteorscale takes nothing returns real
return 10.
endfunction
//Scale of the mini-stars
constant function SN_Miniscale takes nothing returns real
return 10.
endfunction
//Life Time of the Star
constant function SN_Duration takes nothing returns real
return 2.
endfunction
//Flyheight of the Star
constant function SN_StarZ takes nothing returns real
return 100.
endfunction
//FlyHeight of the mini-stars
constant function SN_MinistarZ takes nothing returns real
return 100.
endfunction
//Damage done by the explosion
constant function SN_ExpDam takes nothing returns real
return 15.
endfunction
//AoE of Damage
constant function SN_Radius takes nothing returns real
return 150.
endfunction
//Number of segments per layer
constant function SN_SegPerLayer takes nothing returns integer
return 12
endfunction
//Number of layers
constant function SN_Layer takes nothing returns integer
return 5
endfunction
//Distance per layer
constant function SN_LayerThick takes nothing returns real
return 100.
endfunction
//Height of the segment
constant function SN_ArcHeight takes nothing returns real
return 1.
endfunction
//Speed of the segment to reach their locations
constant function SN_Speed takes nothing returns real
return 250.
endfunction
//Number of mini-stars spinning the star
constant function SN_StarNo takes nothing returns integer
return 12
endfunction
//Speed of the mini-stars spinning
constant function SN_SpinSpeed takes nothing returns real
return 90.
endfunction
//Starting distance of the mini-stars
constant function SN_StartDist takes nothing returns real
return 500.
endfunction
//Time for the mini-stars to spin
constant function SN_SpinTime takes nothing returns real
return SN_Duration()
endfunction
//Explosion SFX of the Star
constant function SN_ExpSFX takes nothing returns string
return "Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl"
endfunction
//Explosion SFX of the segments
constant function SN_SegSFX takes nothing returns string
return "Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl"
endfunction
//Creation SFX of the mini-stars
constant function SN_SpawnSFX takes nothing returns string
return "Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl"
endfunction
//********************************************************************************************
//*
//* END OF CONFIGURATION
//*
//********************************************************************************************
//*
//* FORMULAS AND OTHER FUNCTIONS
//*
//********************************************************************************************
//Get Speed of the Segments
function SN_GetSegmentSpeed takes integer lvl returns real
return SN_Speed() * SN_Interval()
endfunction
//Get Spin Speed of the mini-stars
function SN_GetSpinSpeed takes integer lvl returns real
return SN_SpinSpeed() * SN_Interval()
endfunction
//Get Speed of the mini-stars
function SN_GetStarSpeed takes integer lvl returns real
return (SN_StartDist() / SN_SpinTime()) * SN_Interval()
endfunction
//Get Damage
function SN_GetDamage takes integer lvl returns real
return SN_ExpDam() * I2R(lvl)
endfunction
//Get Parabola
function SN_GetParabola takes real d , real t returns real
return ((( 4 * (SN_ArcHeight() * d) ) / d ) * (( d - t ) * ( t / d )))
endfunction
//Get Ability Level
function SN_GetLevel takes unit u returns integer
return GetUnitAbilityLevel(u,SN_Abil())
endfunction
//Get Angle
function SN_GetAngle takes integer i returns real
return (360 / I2R(SN_SegPerLayer())) * I2R(i)
endfunction
//Get Distance of Segment
function SN_GetDist takes integer i returns real
return SN_LayerThick() * I2R(i)
endfunction
//AttackType and DamageType
function SN_AtkTyp takes nothing returns attacktype
return ATTACK_TYPE_CHAOS
endfunction
function SN_DmgTyp takes nothing returns damagetype
return DAMAGE_TYPE_DIVINE
endfunction
//********************************************************************************************
//*
//* UTILITIES FUNCTIONS
//*
//********************************************************************************************
//Move Dummies
function SN_Move takes unit u , real x , real y returns nothing
call SetUnitX(u,x)
call SetUnitY(u,y)
endfunction
//Move Segment
function SN_MoveSegment takes unit u , real dist , real angle returns nothing
local real x = GetUnitX(u) + dist * Cos(angle * bj_DEGTORAD)
local real y = GetUnitY(u) + dist * Sin(angle * bj_DEGTORAD)
call SN_Move(u,x,y)
endfunction
//Move Stars
function SN_MoveStars takes unit u , unit c , real dist , real angle returns nothing
local real x = GetUnitX(c) + dist * Cos(angle * bj_DEGTORAD)
local real y = GetUnitY(c) + dist * Sin(angle * bj_DEGTORAD)
call SN_Move(u,x,y)
endfunction
//Create Star
function SN_CreateStar takes player p,real x,real y returns unit
set bj_lastCreatedUnit = CreateUnit(p,SN_Dummy(),x,y,0)
call SetUnitFlyHeight(bj_lastCreatedUnit,SN_StarZ(),0)
call SetUnitScale(bj_lastCreatedUnit,SN_Starscale(),0,0)
return bj_lastCreatedUnit
endfunction
//Create Segments
function SN_CreateSegment takes player p,real x,real y,real angle returns unit
set bj_lastCreatedUnit = CreateUnit(p,SN_Dummy(),x,y,angle)
call SetUnitScale(bj_lastCreatedUnit,SN_Meteorscale(),0,0)
return bj_lastCreatedUnit
endfunction
//Create mini-stars
function SN_CreateMinistar takes player p ,real x,real y,real angle returns unit
set bj_lastCreatedUnit = CreateUnit(p,SN_Dummy(),x,y,angle)
call SetUnitFlyHeight(bj_lastCreatedUnit,SN_MinistarZ(),0)
call SetUnitScale(bj_lastCreatedUnit,SN_Miniscale(),0,0)
return bj_lastCreatedUnit
endfunction
//Creation of Segments for Loop
function SN_CreateSegments takes player p ,real x,real y,integer lvl returns nothing
local integer i
local integer i2
local real angle
local real distance
local unit u
local integer ukey
loop
set i = i + 1
set angle = SN_GetAngle(i)
loop
set i2 = i2 + 1
set distance = SN_GetDist(i)
set u = SN_CreateSegment(p,x,y,angle)
set ukey = GetHandleId(u)
call UnitAddAbility(u,SN_Abil())
call SetUnitAbilityLevel(u,SN_Abil(),lvl)
call SaveReal(udg_SN_Hash,ukey,StringHash("angle"),angle)
call SaveReal(udg_SN_Hash,ukey,StringHash("dist"),distance)
call SaveInteger(udg_SN_Hash,ukey,StringHash("id"),3)
call SaveEffectHandle(udg_SN_Hash,ukey,StringHash("mdl"),AddSpecialEffectTarget(SN_Meteormdl(),u,"chest"))
call GroupAddUnit(udg_SN_Group,u)
exitwhen i2 == SN_Layer()
endloop
exitwhen i == SN_SegPerLayer()
endloop
set u = null
endfunction
//Creation of Ministars in Loop
function SN_CreateMinistars takes unit o,player p,real x,real y returns nothing
local integer i
local unit u
local real x2
local real y2
local integer ukey
local real angle
loop
set i = i + 1
set angle = SN_GetAngle(i)
set x2 = x + SN_StartDist() * Cos(angle * bj_DEGTORAD)
set y2 = y + SN_StartDist() * Sin(angle * bj_DEGTORAD)
set u = SN_CreateMinistar(p,x2,y2,angle)
set ukey = GetHandleId(u)
call SaveReal(udg_SN_Hash,ukey,StringHash("angle"),angle)
call SaveUnitHandle(udg_SN_Hash,ukey,StringHash("origin"),o)
call SaveInteger(udg_SN_Hash,ukey,StringHash("id"),3)
call SaveEffectHandle(udg_SN_Hash,ukey,StringHash("mdl"),AddSpecialEffectTarget(SN_Minimdl(),u,"chest"))
call GroupAddUnit(udg_SN_Group,u)
call DestroyEffect(AddSpecialEffect(SN_SpawnSFX(),x,y))
exitwhen i == SN_StarNo()
endloop
set u = null
endfunction
//Filters
//Filter Enemy
function SN_FilterUnit takes unit u ,player p returns boolean
return IsUnitEnemy(u,p) and not IsUnitType(u,UNIT_TYPE_DEAD) and IsUnitType(u,UNIT_TYPE_STRUCTURE) and not IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE)
endfunction
//********************************************************************************************
//*
//* SPELL FUNCTIONS
//*
//********************************************************************************************
//For Group function
function SN_ForGroup takes nothing returns nothing
local unit u = GetEnumUnit()
local integer ukey = GetHandleId(u)
local player p
local real angle
local real duration
local real travelled
local real dist
local unit o
local integer groupid
local integer lvl
local real damage
local effect model
local real x
local real y
local real x2
local real y2
local group g = CreateGroup()
local unit e
local real speed
//Set variables
set groupid = LoadInteger(udg_SN_Hash,ukey,StringHash("id"))
set dist = LoadReal(udg_SN_Hash,ukey,StringHash("dist"))
set angle = LoadReal(udg_SN_Hash,ukey,StringHash("angle"))
set duration = LoadReal(udg_SN_Hash,ukey,StringHash("duration"))
set travelled = LoadReal(udg_SN_Hash,ukey,StringHash("travelled"))
set model = LoadEffectHandle(udg_SN_Hash,ukey,StringHash("mdl"))
set p = GetOwningPlayer(u)
set x = GetUnitX(u)
set y = GetUnitY(u)
set lvl = SN_GetLevel(u)
//Filter group id
//For Star
if groupid == 1 then
if duration < SN_Duration() then
call SaveReal(udg_SN_Hash,ukey,StringHash("duration"),duration + SN_Interval())
else
call SN_CreateSegments(p,x,y,lvl)
call DestroyEffect(AddSpecialEffect(SN_ExpSFX(),x,y))
call FlushChildHashtable(udg_SN_Hash,ukey)
call GroupRemoveUnit(udg_SN_Group,u)
call DestroyEffect(model)
call RemoveUnit(u)
endif
//For Segment
elseif groupid == 2 then
set speed = SN_GetSegmentSpeed(lvl)
if travelled < dist then
call SN_MoveSegment(u,speed,angle)
call SetUnitFlyHeight(u,SN_GetParabola(dist,travelled),0)
call SaveReal(udg_SN_Hash,ukey,StringHash("travelled"),travelled + speed)
else
set damage = SN_GetDamage(lvl)
call GroupEnumUnitsInRange(g,x,y,SN_Radius(),null)
loop
set e =FirstOfGroup(g)
exitwhen e == null
if SN_FilterUnit(u,p) then
call UnitDamageTarget(u,e,damage,false,false,SN_AtkTyp(),SN_DmgTyp(),null)
endif
call GroupRemoveUnit(g,e)
endloop
call DestroyEffect(AddSpecialEffect(SN_SegSFX(),x,y))
call DestroyEffect(model)
call FlushChildHashtable(udg_SN_Hash,ukey)
call GroupRemoveUnit(udg_SN_Group,u)
call RemoveUnit(u)
endif
//For Ministar
elseif groupid == 3 then
set o = LoadUnitHandle(udg_SN_Hash,ukey,StringHash("origin"))
set x2 = GetUnitX(o)
set y2 = GetUnitY(o)
set dist = (x2 - x) * (x2 - x) + (y2 - y) * (y2 - y)
if dist > 625 then
set angle = angle + SN_GetSpinSpeed(lvl)
call SN_MoveStars(u,o,dist - (SN_GetStarSpeed(lvl) * SN_GetStarSpeed(lvl)),angle)
call SaveReal(udg_SN_Hash,ukey,StringHash("angle"),angle)
else
call DestroyEffect(model)
call FlushChildHashtable(udg_SN_Hash,ukey)
call GroupRemoveUnit(udg_SN_Group,u)
call RemoveUnit(u)
endif
endif
//Clean
set u = null
set g = null
set model = null
set p = null
set o = null
endfunction
//Periodic
function SN_Periodic takes nothing returns nothing
call ForGroup(udg_SN_Group,function SN_ForGroup)
endfunction
//Cast
function SN_Cast takes nothing returns boolean
local real x
local real y
local player p
local unit u
local integer ukey
local integer lvl
local unit c
if GetSpellAbilityId() == SN_Abil() then
set c = GetTriggerUnit()
set p = GetTriggerPlayer()
set lvl = SN_GetLevel(c)
set x = GetSpellTargetX()
set y = GetSpellTargetY()
set u = SN_CreateStar(p,x,y)
set ukey = GetHandleId(u)
call SaveInteger(udg_SN_Hash,ukey,StringHash("id"),1)
call SaveEffectHandle(udg_SN_Hash,ukey,StringHash("mdl"),AddSpecialEffectTarget(SN_Starmdl(),u,"chest"))
call UnitAddAbility(u,SN_Abil())
call SetUnitAbilityLevel(u,SN_Abil(),lvl)
call GroupAddUnit(udg_SN_Group,u)
call SN_CreateMinistars(u,p,x,y)
call BJDebugMsg("Cast")
endif
return false
endfunction
//Initialization
function InitTrig_SuperNova takes nothing returns nothing
call BJDebugMsg("Init")
set gg_trg_SuperNova = CreateTrigger()
set udg_SN_Loop = CreateTrigger()
set udg_SN_Hash = InitHashtable()
set udg_SN_Group = CreateGroup()
call TriggerAddCondition(gg_trg_SuperNova,Filter(function SN_Cast))
call TriggerRegisterAnyUnitEventBJ(gg_trg_SuperNova,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerRegisterTimerEventPeriodic(udg_SN_Loop,SN_Interval())
call TriggerAddAction(udg_SN_Loop,function SN_Periodic)
endfunction[/code]
This is my first time coding pure JASS.So im asking for help.
First,im using dummy.mdx but when i attach the sun model,it doesnt show.
Second, the mini-stars are not spawning
3rd,the loop is not working correctly
//*
//*
//* SUPERNOVA version 1.0
//*
//* made by RADAMANTUS a.k.a ALMIA
//*
//*
//********************************************************************************************
//*
//* TOOLTIP:
//*
//* Summons a red star on the targeted point,the red star then explodes after 2 seconds
//* releasing 12 meteorites per layer outward the star's point.Each meteorite deals 15/30/45
//* damage and the explosion has 5 layers.Each layer has a distance of 100 x the layer number
//* from the star.
//*
//********************************************************************************************
//*
//* HOW TO IMPORT?
//*
//* 1)Import the dummy and its model
//* 2)Import the ability
//* 3)If you want,import the sun model
//* 4)Copy the code
//* 5)Create this variables:
//* - udg_SN_Hash
//* - udg_SN_Group
//* - udg_SN_Loop
//* 6)Enjoy!
//*
//********************************************************************************************
//*
//* CREDITS
//*
//* - Vexorian for the dummy.mdx(also for Anitarf and Infrane)
//* - WILL THE ALMIGHTY for the sun model
//*
//********************************************************************************************
//* CONSTANT FUNCTIONS
//*
//* Configuration of the spell
//*
//********************************************************************************************
//Loop Value
constant function SN_Interval takes nothing returns real
return 0.03125
endfunction
// Rawcode of the ability
constant function SN_Abil takes nothing returns integer
return 'A000'
endfunction
//Rawcode of the dummy
constant function SN_Dummy takes nothing returns integer
return 'h000'
endfunction
//Model of the star
//Credits to WILL THE ALMIGHTY for the model
constant function SN_Starmdl takes nothing returns string
return "war3mapImported\\Sun.mdx"
endfunction
//Model of the meteorites
constant function SN_Meteormdl takes nothing returns string
return "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl"
endfunction
//Model of the ministars
constant function SN_Minimdl takes nothing returns string
return "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl"
endfunction
//Scale of the star
constant function SN_Starscale takes nothing returns real
return 100.
endfunction
//Scale of the meteorites a.k.a segments
constant function SN_Meteorscale takes nothing returns real
return 10.
endfunction
//Scale of the mini-stars
constant function SN_Miniscale takes nothing returns real
return 10.
endfunction
//Life Time of the Star
constant function SN_Duration takes nothing returns real
return 2.
endfunction
//Flyheight of the Star
constant function SN_StarZ takes nothing returns real
return 100.
endfunction
//FlyHeight of the mini-stars
constant function SN_MinistarZ takes nothing returns real
return 100.
endfunction
//Damage done by the explosion
constant function SN_ExpDam takes nothing returns real
return 15.
endfunction
//AoE of Damage
constant function SN_Radius takes nothing returns real
return 150.
endfunction
//Number of segments per layer
constant function SN_SegPerLayer takes nothing returns integer
return 12
endfunction
//Number of layers
constant function SN_Layer takes nothing returns integer
return 5
endfunction
//Distance per layer
constant function SN_LayerThick takes nothing returns real
return 100.
endfunction
//Height of the segment
constant function SN_ArcHeight takes nothing returns real
return 1.
endfunction
//Speed of the segment to reach their locations
constant function SN_Speed takes nothing returns real
return 250.
endfunction
//Number of mini-stars spinning the star
constant function SN_StarNo takes nothing returns integer
return 12
endfunction
//Speed of the mini-stars spinning
constant function SN_SpinSpeed takes nothing returns real
return 90.
endfunction
//Starting distance of the mini-stars
constant function SN_StartDist takes nothing returns real
return 500.
endfunction
//Time for the mini-stars to spin
constant function SN_SpinTime takes nothing returns real
return SN_Duration()
endfunction
//Explosion SFX of the Star
constant function SN_ExpSFX takes nothing returns string
return "Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl"
endfunction
//Explosion SFX of the segments
constant function SN_SegSFX takes nothing returns string
return "Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl"
endfunction
//Creation SFX of the mini-stars
constant function SN_SpawnSFX takes nothing returns string
return "Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl"
endfunction
//********************************************************************************************
//*
//* END OF CONFIGURATION
//*
//********************************************************************************************
//*
//* FORMULAS AND OTHER FUNCTIONS
//*
//********************************************************************************************
//Get Speed of the Segments
function SN_GetSegmentSpeed takes integer lvl returns real
return SN_Speed() * SN_Interval()
endfunction
//Get Spin Speed of the mini-stars
function SN_GetSpinSpeed takes integer lvl returns real
return SN_SpinSpeed() * SN_Interval()
endfunction
//Get Speed of the mini-stars
function SN_GetStarSpeed takes integer lvl returns real
return (SN_StartDist() / SN_SpinTime()) * SN_Interval()
endfunction
//Get Damage
function SN_GetDamage takes integer lvl returns real
return SN_ExpDam() * I2R(lvl)
endfunction
//Get Parabola
function SN_GetParabola takes real d , real t returns real
return ((( 4 * (SN_ArcHeight() * d) ) / d ) * (( d - t ) * ( t / d )))
endfunction
//Get Ability Level
function SN_GetLevel takes unit u returns integer
return GetUnitAbilityLevel(u,SN_Abil())
endfunction
//Get Angle
function SN_GetAngle takes integer i returns real
return (360 / I2R(SN_SegPerLayer())) * I2R(i)
endfunction
//Get Distance of Segment
function SN_GetDist takes integer i returns real
return SN_LayerThick() * I2R(i)
endfunction
//AttackType and DamageType
function SN_AtkTyp takes nothing returns attacktype
return ATTACK_TYPE_CHAOS
endfunction
function SN_DmgTyp takes nothing returns damagetype
return DAMAGE_TYPE_DIVINE
endfunction
//********************************************************************************************
//*
//* UTILITIES FUNCTIONS
//*
//********************************************************************************************
//Move Dummies
function SN_Move takes unit u , real x , real y returns nothing
call SetUnitX(u,x)
call SetUnitY(u,y)
endfunction
//Move Segment
function SN_MoveSegment takes unit u , real dist , real angle returns nothing
local real x = GetUnitX(u) + dist * Cos(angle * bj_DEGTORAD)
local real y = GetUnitY(u) + dist * Sin(angle * bj_DEGTORAD)
call SN_Move(u,x,y)
endfunction
//Move Stars
function SN_MoveStars takes unit u , unit c , real dist , real angle returns nothing
local real x = GetUnitX(c) + dist * Cos(angle * bj_DEGTORAD)
local real y = GetUnitY(c) + dist * Sin(angle * bj_DEGTORAD)
call SN_Move(u,x,y)
endfunction
//Create Star
function SN_CreateStar takes player p,real x,real y returns unit
set bj_lastCreatedUnit = CreateUnit(p,SN_Dummy(),x,y,0)
call SetUnitFlyHeight(bj_lastCreatedUnit,SN_StarZ(),0)
call SetUnitScale(bj_lastCreatedUnit,SN_Starscale(),0,0)
return bj_lastCreatedUnit
endfunction
//Create Segments
function SN_CreateSegment takes player p,real x,real y,real angle returns unit
set bj_lastCreatedUnit = CreateUnit(p,SN_Dummy(),x,y,angle)
call SetUnitScale(bj_lastCreatedUnit,SN_Meteorscale(),0,0)
return bj_lastCreatedUnit
endfunction
//Create mini-stars
function SN_CreateMinistar takes player p ,real x,real y,real angle returns unit
set bj_lastCreatedUnit = CreateUnit(p,SN_Dummy(),x,y,angle)
call SetUnitFlyHeight(bj_lastCreatedUnit,SN_MinistarZ(),0)
call SetUnitScale(bj_lastCreatedUnit,SN_Miniscale(),0,0)
return bj_lastCreatedUnit
endfunction
//Creation of Segments for Loop
function SN_CreateSegments takes player p ,real x,real y,integer lvl returns nothing
local integer i
local integer i2
local real angle
local real distance
local unit u
local integer ukey
loop
set i = i + 1
set angle = SN_GetAngle(i)
loop
set i2 = i2 + 1
set distance = SN_GetDist(i)
set u = SN_CreateSegment(p,x,y,angle)
set ukey = GetHandleId(u)
call UnitAddAbility(u,SN_Abil())
call SetUnitAbilityLevel(u,SN_Abil(),lvl)
call SaveReal(udg_SN_Hash,ukey,StringHash("angle"),angle)
call SaveReal(udg_SN_Hash,ukey,StringHash("dist"),distance)
call SaveInteger(udg_SN_Hash,ukey,StringHash("id"),3)
call SaveEffectHandle(udg_SN_Hash,ukey,StringHash("mdl"),AddSpecialEffectTarget(SN_Meteormdl(),u,"chest"))
call GroupAddUnit(udg_SN_Group,u)
exitwhen i2 == SN_Layer()
endloop
exitwhen i == SN_SegPerLayer()
endloop
set u = null
endfunction
//Creation of Ministars in Loop
function SN_CreateMinistars takes unit o,player p,real x,real y returns nothing
local integer i
local unit u
local real x2
local real y2
local integer ukey
local real angle
loop
set i = i + 1
set angle = SN_GetAngle(i)
set x2 = x + SN_StartDist() * Cos(angle * bj_DEGTORAD)
set y2 = y + SN_StartDist() * Sin(angle * bj_DEGTORAD)
set u = SN_CreateMinistar(p,x2,y2,angle)
set ukey = GetHandleId(u)
call SaveReal(udg_SN_Hash,ukey,StringHash("angle"),angle)
call SaveUnitHandle(udg_SN_Hash,ukey,StringHash("origin"),o)
call SaveInteger(udg_SN_Hash,ukey,StringHash("id"),3)
call SaveEffectHandle(udg_SN_Hash,ukey,StringHash("mdl"),AddSpecialEffectTarget(SN_Minimdl(),u,"chest"))
call GroupAddUnit(udg_SN_Group,u)
call DestroyEffect(AddSpecialEffect(SN_SpawnSFX(),x,y))
exitwhen i == SN_StarNo()
endloop
set u = null
endfunction
//Filters
//Filter Enemy
function SN_FilterUnit takes unit u ,player p returns boolean
return IsUnitEnemy(u,p) and not IsUnitType(u,UNIT_TYPE_DEAD) and IsUnitType(u,UNIT_TYPE_STRUCTURE) and not IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE)
endfunction
//********************************************************************************************
//*
//* SPELL FUNCTIONS
//*
//********************************************************************************************
//For Group function
function SN_ForGroup takes nothing returns nothing
local unit u = GetEnumUnit()
local integer ukey = GetHandleId(u)
local player p
local real angle
local real duration
local real travelled
local real dist
local unit o
local integer groupid
local integer lvl
local real damage
local effect model
local real x
local real y
local real x2
local real y2
local group g = CreateGroup()
local unit e
local real speed
//Set variables
set groupid = LoadInteger(udg_SN_Hash,ukey,StringHash("id"))
set dist = LoadReal(udg_SN_Hash,ukey,StringHash("dist"))
set angle = LoadReal(udg_SN_Hash,ukey,StringHash("angle"))
set duration = LoadReal(udg_SN_Hash,ukey,StringHash("duration"))
set travelled = LoadReal(udg_SN_Hash,ukey,StringHash("travelled"))
set model = LoadEffectHandle(udg_SN_Hash,ukey,StringHash("mdl"))
set p = GetOwningPlayer(u)
set x = GetUnitX(u)
set y = GetUnitY(u)
set lvl = SN_GetLevel(u)
//Filter group id
//For Star
if groupid == 1 then
if duration < SN_Duration() then
call SaveReal(udg_SN_Hash,ukey,StringHash("duration"),duration + SN_Interval())
else
call SN_CreateSegments(p,x,y,lvl)
call DestroyEffect(AddSpecialEffect(SN_ExpSFX(),x,y))
call FlushChildHashtable(udg_SN_Hash,ukey)
call GroupRemoveUnit(udg_SN_Group,u)
call DestroyEffect(model)
call RemoveUnit(u)
endif
//For Segment
elseif groupid == 2 then
set speed = SN_GetSegmentSpeed(lvl)
if travelled < dist then
call SN_MoveSegment(u,speed,angle)
call SetUnitFlyHeight(u,SN_GetParabola(dist,travelled),0)
call SaveReal(udg_SN_Hash,ukey,StringHash("travelled"),travelled + speed)
else
set damage = SN_GetDamage(lvl)
call GroupEnumUnitsInRange(g,x,y,SN_Radius(),null)
loop
set e =FirstOfGroup(g)
exitwhen e == null
if SN_FilterUnit(u,p) then
call UnitDamageTarget(u,e,damage,false,false,SN_AtkTyp(),SN_DmgTyp(),null)
endif
call GroupRemoveUnit(g,e)
endloop
call DestroyEffect(AddSpecialEffect(SN_SegSFX(),x,y))
call DestroyEffect(model)
call FlushChildHashtable(udg_SN_Hash,ukey)
call GroupRemoveUnit(udg_SN_Group,u)
call RemoveUnit(u)
endif
//For Ministar
elseif groupid == 3 then
set o = LoadUnitHandle(udg_SN_Hash,ukey,StringHash("origin"))
set x2 = GetUnitX(o)
set y2 = GetUnitY(o)
set dist = (x2 - x) * (x2 - x) + (y2 - y) * (y2 - y)
if dist > 625 then
set angle = angle + SN_GetSpinSpeed(lvl)
call SN_MoveStars(u,o,dist - (SN_GetStarSpeed(lvl) * SN_GetStarSpeed(lvl)),angle)
call SaveReal(udg_SN_Hash,ukey,StringHash("angle"),angle)
else
call DestroyEffect(model)
call FlushChildHashtable(udg_SN_Hash,ukey)
call GroupRemoveUnit(udg_SN_Group,u)
call RemoveUnit(u)
endif
endif
//Clean
set u = null
set g = null
set model = null
set p = null
set o = null
endfunction
//Periodic
function SN_Periodic takes nothing returns nothing
call ForGroup(udg_SN_Group,function SN_ForGroup)
endfunction
//Cast
function SN_Cast takes nothing returns boolean
local real x
local real y
local player p
local unit u
local integer ukey
local integer lvl
local unit c
if GetSpellAbilityId() == SN_Abil() then
set c = GetTriggerUnit()
set p = GetTriggerPlayer()
set lvl = SN_GetLevel(c)
set x = GetSpellTargetX()
set y = GetSpellTargetY()
set u = SN_CreateStar(p,x,y)
set ukey = GetHandleId(u)
call SaveInteger(udg_SN_Hash,ukey,StringHash("id"),1)
call SaveEffectHandle(udg_SN_Hash,ukey,StringHash("mdl"),AddSpecialEffectTarget(SN_Starmdl(),u,"chest"))
call UnitAddAbility(u,SN_Abil())
call SetUnitAbilityLevel(u,SN_Abil(),lvl)
call GroupAddUnit(udg_SN_Group,u)
call SN_CreateMinistars(u,p,x,y)
call BJDebugMsg("Cast")
endif
return false
endfunction
//Initialization
function InitTrig_SuperNova takes nothing returns nothing
call BJDebugMsg("Init")
set gg_trg_SuperNova = CreateTrigger()
set udg_SN_Loop = CreateTrigger()
set udg_SN_Hash = InitHashtable()
set udg_SN_Group = CreateGroup()
call TriggerAddCondition(gg_trg_SuperNova,Filter(function SN_Cast))
call TriggerRegisterAnyUnitEventBJ(gg_trg_SuperNova,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerRegisterTimerEventPeriodic(udg_SN_Loop,SN_Interval())
call TriggerAddAction(udg_SN_Loop,function SN_Periodic)
endfunction[/code]
This is my first time coding pure JASS.So im asking for help.
First,im using dummy.mdx but when i attach the sun model,it doesnt show.
Second, the mini-stars are not spawning
3rd,the loop is not working correctly