HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help with iNfraNe's PS based spell.

07-07-2008, 01:53 AM#1
TurtleGlove
Collapse JASS:
function DamageArea takes unit source,real maxdmg,real radius returns nothing
local location locdama = GetUnitLoc(source)
local unit c
local real dxd = GetLocationX(GetUnitLoc(c)) - GetLocationX(locdama)
local real dyd = GetLocationY(GetUnitLoc(c)) - GetLocationY(locdama)
local group g=CreateGroup()
call GroupEnumUnitsInRange(g,GetLocationX(locdama),GetLocationY(locdama),radius,null)
loop
set c=FirstOfGroup(g)
exitwhen c==null
if GetUnitState(c,UNIT_STATE_LIFE)>0 then
call UnitDamageTarget(source,c,(maxdmg-(SquareRoot(dxd * dxd + dyd * dyd))),true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
endif
call GroupRemoveUnit(g,c)
endloop
call DestroyGroup(g)
set g=null
set c=null
call RemoveLocation(locdama)
set dxd =0
set dyd =0
endfunction


function Death_ExplodeNade takes nothing returns nothing
local unit u=GetEnumUnit()
local location locofexp = GetUnitLoc(u)
local unit justforeffc = CreateUnitAtLoc(GetOwningPlayer(u),'e001',locofexp,GetRandomInt(0,359)) //special effect unit
call UnitApplyTimedLife(justforeffc,'BHwe',4.)
call DamageArea(u,300,256.)
call RemoveParticle(u,true)
call RemoveLocation(locofexp)
set justforeffc=null
set u=null
endfunction

function Trig_Grenade_Conditions takes nothing returns boolean
     return GetSpellAbilityId() == 'A001'
endfunction

function Trig_Grenade_Actions takes nothing returns nothing
    local location casterpos = GetUnitLoc(GetSpellAbilityUnit())
    local location topos = GetSpellTargetLoc()
    local unit u = CreateParticle(GetOwningPlayer(GetSpellAbilityUnit()),'h000',GetLocationX(casterpos),GetLocationY(casterpos),GetUnitFacing(GetSpellAbilityUnit()))
    call ParticleSetSpeed(u,GetLocationX(topos)-GetLocationX(casterpos),GetLocationY(topos)-GetLocationY(casterpos),1200)
call ParticleLinkConditionTrigger2Func(u, ParticleGroundHit(), "GroundHit_Bounce")
call ParticleLinkConditionTrigger2Func(u, ParticleDeath(), "Death_ExplodeNade")
call ParticleAddForce(u, G())
call RemoveLocation(casterpos)
call RemoveLocation(topos)
set casterpos = null
set topos = null
set u = null
endfunction

//===========================================================================
function InitTrig_Grenade takes nothing returns nothing
    set gg_trg_Grenade = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Grenade, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Grenade, Condition( function Trig_Grenade_Conditions ) )
    call TriggerAddAction( gg_trg_Grenade, function Trig_Grenade_Actions )
endfunction


problem is the special effect plays like 30 times a second and never stops. Special effect is based off a unit's creation so it's scaleable.
07-07-2008, 01:57 AM#2
grim001
Indent properly if you want anyone to read it...
07-07-2008, 02:41 AM#3
Feroc1ty
why are you using a unit for special effect, also the special effect might have birth animation which keeps repeating itself.
07-07-2008, 03:45 AM#4
TurtleGlove
Quote:
Originally Posted by Feroc1ty
why are you using a unit for special effect, also the special effect might have birth animation which keeps repeating itself.

So I can scale the size of it, I don't know a way of scaling effects; and grim, sorry I didn't know there was an indenting standard, where can I find it?
07-07-2008, 04:54 AM#5
Switch33
Look anywhere at other JASS codes, or download JassCraft and try and follow what it does for "loops" "if"'s etc.
07-08-2008, 06:13 PM#6
iNfraNe
Lol, ppl are still using this over other stuff. I win
07-08-2008, 06:34 PM#7
Captain Griffen
DamageArea leaks two locs, btw.
07-08-2008, 06:46 PM#8
the-thingy
Shouldn't you initialize c before trying to get its location?

And instead of GetLocationX (GetUnitLoc (whichUnit)), why not just use GetUnitX (whichUnit) (same with the Y values)