- Joined
- May 4, 2007
- Messages
- 2,260
Hi guys, Well, I was searching for maps in the spells section and I found a Gas Grenada that is just what I need. However, the spell leaks, and I believe I can make it more efficient. So I decided to start doing so, removing all BJ's, and stuff like that.
However I have a problem ... My grenade does not kill the enemy units !!
I will post the code I did here:
[jass=Gas Grenade, my version]
function Trig_Poison_Gas_Grenade_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00Q'
endfunction
//==========================================================
function Trig_Poison_Gas_Grenade_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit() //casting unit
local player owner = GetOwningPlayer(caster) //owner of casting unit
local location l = GetSpellTargetLoc() //target location
local effect e //this will be used to store the cloud effect
local integer duration = 0 //this variable will be used as a counter
local group g = CreateGroup() //it will store units arround the target locations
local unit picked
local real dx = GetLocationX(l) - GetUnitX(caster) //distance between CasterX and targetlocX
local real dy = GetLocationY(l) - GetUnitY(caster) //distance between CasterY and targetlocY
local real dAB = SquareRoot(dx * dx + dy * dy) //transforms the coordinates into a vector AB with lenght
local unit dummy = CreateUnit(owner, 'e003', GetUnitX(caster), GetUnitY(caster), 270.0) //Creates the dummy that will launch the grenade
call IssuePointOrderLoc(dummy, "attackground", l) //Orders dummy to launch grenade to targetloc
call UnitApplyTimedLife(dummy, 'BTLF', 0.90) //kills unit after it launches grenade (takes +/- 0.90 secs to launch it)
call TriggerSleepAction(dAB / 800.0) // this uses a law of physics ( velocity = distance / time). Here I wait until the projectile arrives its destination
set e = AddSpecialEffectLoc("war3mapImported\\Radioactivecloud.mdx", l) //creates the Cloud effect in the target loc
//Unil this comment, everything works in perfection
//after this comment, I need help, I make no idea how to do this
//I want to select all enemy, non-structure units arround the targetloc
//so then I can kill them, or do anything.
//the problem is in creating to group to do this.
call GroupEnumUnitsInRange( g, GetLocationX( l ), GetLocationY( l ), 250, Filter(null) )//Picks all units in a 250 AoE arround targetloc
loop
exitwhen(duration == 10)
set picked = FirstOfGroup(g)
if IsUnitEnemy(picked, owner) and IsUnitType(picked, UNIT_TYPE_MAGIC_IMMUNE) == false and GetUnitState(picked, UNIT_STATE_LIFE) > 0 and IsUnitType(picked, UNIT_TYPE_STRUCTURE) == false then
call KillUnit(picked)
endif
call GroupRemoveUnit(g,picked)
call TriggerSleepAction(1.0)
set duration = duration + 1
endloop
//Now after this comment, stuff is ok too
call DestroyEffect(e)
call DestroyGroup(g)
call RemoveLocation(l)
set e = null
set g = null
set l = null
set caster = null
set dummy = null
set owner = null
set picked = null
endfunction
//=========================================================
function InitTrig_Poison_Gas_Grenade takes nothing returns nothing
set gg_trg_Poison_Gas_Grenade = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Poison_Gas_Grenade, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Poison_Gas_Grenade, Condition( function Trig_Poison_Gas_Grenade_Conditions ) )
call TriggerAddAction( gg_trg_Poison_Gas_Grenade, function Trig_Poison_Gas_Grenade_Actions )
endfunction[/code]
This is what I did. I am also commenting it, so you guys can understand the complexity of the spell.
Now, here is the original spell ... as you can see, it was clearly made of GUI, and then converted.
[jass=GUI converted original version]
function Trig_Poison_Gas_Grenade_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A00Q' ) ) then
return false
endif
return true
endfunction
//Poisen Gas Grenade temporary Unitgroup actions
function PGGgroupActions takes nothing returns nothing
call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), ( 45.00 * I2R(GetUnitAbilityLevelSwapped('A00Q', GetTriggerUnit())) ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
call AddSpecialEffectTargetUnitBJ( "chest", GetEnumUnit(), "Abilities\\Weapons\\IllidanMissile\\IllidanMissile.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call CreateTextTagUnitBJ( ( I2S(( 45 * GetUnitAbilityLevelSwapped('A00Q', GetTriggerUnit()) )) + "!" ), GetEnumUnit(), 0, 10, 0.00, 100, 0.00, 0 )
call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 40.00, 90 )
call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 3.00 )
endfunction
//Poisen Gas Grenade temporary Conditions actions
function PGGgroupW takes nothing returns boolean
return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction
function PGGgroupQ takes nothing returns boolean
return ( GetUnitStateSwap(UNIT_STATE_LIFE, GetFilterUnit()) > 0.00 )
endfunction
function PGGCondition takes nothing returns boolean
return GetBooleanAnd( PGGgroupW(), PGGgroupQ() )
endfunction
//Poisen Gas Grenade Trigger
function Trig_Poison_Gas_Grenade_Actions takes nothing returns nothing
local location PGGlocA = GetUnitLoc(GetTriggerUnit())
local location PGGlocB = GetSpellTargetLoc()
local group PGGgroupA
local integer IntegerPGG
local effect EffPGG
call CreateNUnitsAtLoc( 1, 'e003', GetOwningPlayer(GetTriggerUnit()), PGGlocA, AngleBetweenPoints(PGGlocA, PGGlocB) )
call IssuePointOrderLocBJ( GetLastCreatedUnit(), "attackground", PGGlocB )
call SetUnitPathing( GetLastCreatedUnit(), false )
call UnitApplyTimedLifeBJ( 0.90, 'BTLF', GetLastCreatedUnit() )
call TriggerSleepAction( ( DistanceBetweenPoints(PGGlocA, PGGlocB) / 800.00 ) )
call AddSpecialEffectLocBJ( PGGlocB, "war3mapImported\\Radioactivecloud.mdx" )
set EffPGG = GetLastCreatedEffectBJ()
set IntegerPGG = 1
loop
exitwhen IntegerPGG > 10
set PGGgroupA = GetUnitsInRangeOfLocMatching(220.00, PGGlocB, Condition(function PGGCondition))
call ForGroupBJ( PGGgroupA, function PGGgroupActions )
call TriggerSleepAction(1.00 )
set IntegerPGG = IntegerPGG + 1
endloop
call DestroyEffectBJ( EffPGG )
call RemoveLocation(PGGlocA)
call RemoveLocation(PGGlocB)
call DestroyGroup(PGGgroupA)
set PGGlocA = null
set PGGlocB = null
set PGGgroupA = null
set EffPGG = null
set IntegerPGG = 0
endfunction
//===========================================================================
function InitTrig_Poison_Gas_Grenade takes nothing returns nothing
set gg_trg_Poison_Gas_Grenade = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Poison_Gas_Grenade, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Poison_Gas_Grenade, Condition( function Trig_Poison_Gas_Grenade_Conditions ) )
call TriggerAddAction( gg_trg_Poison_Gas_Grenade, function Trig_Poison_Gas_Grenade_Actions )
endfunction
[/code]
To simplify my code, I replaced the real effect with "call KillUnit(whichUnit)".
But the point will still be the same.
My real problem is in the loop.
Help plz =S
However I have a problem ... My grenade does not kill the enemy units !!
I will post the code I did here:
[jass=Gas Grenade, my version]
function Trig_Poison_Gas_Grenade_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00Q'
endfunction
//==========================================================
function Trig_Poison_Gas_Grenade_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit() //casting unit
local player owner = GetOwningPlayer(caster) //owner of casting unit
local location l = GetSpellTargetLoc() //target location
local effect e //this will be used to store the cloud effect
local integer duration = 0 //this variable will be used as a counter
local group g = CreateGroup() //it will store units arround the target locations
local unit picked
local real dx = GetLocationX(l) - GetUnitX(caster) //distance between CasterX and targetlocX
local real dy = GetLocationY(l) - GetUnitY(caster) //distance between CasterY and targetlocY
local real dAB = SquareRoot(dx * dx + dy * dy) //transforms the coordinates into a vector AB with lenght
local unit dummy = CreateUnit(owner, 'e003', GetUnitX(caster), GetUnitY(caster), 270.0) //Creates the dummy that will launch the grenade
call IssuePointOrderLoc(dummy, "attackground", l) //Orders dummy to launch grenade to targetloc
call UnitApplyTimedLife(dummy, 'BTLF', 0.90) //kills unit after it launches grenade (takes +/- 0.90 secs to launch it)
call TriggerSleepAction(dAB / 800.0) // this uses a law of physics ( velocity = distance / time). Here I wait until the projectile arrives its destination
set e = AddSpecialEffectLoc("war3mapImported\\Radioactivecloud.mdx", l) //creates the Cloud effect in the target loc
//Unil this comment, everything works in perfection
//after this comment, I need help, I make no idea how to do this
//I want to select all enemy, non-structure units arround the targetloc
//so then I can kill them, or do anything.
//the problem is in creating to group to do this.
call GroupEnumUnitsInRange( g, GetLocationX( l ), GetLocationY( l ), 250, Filter(null) )//Picks all units in a 250 AoE arround targetloc
loop
exitwhen(duration == 10)
set picked = FirstOfGroup(g)
if IsUnitEnemy(picked, owner) and IsUnitType(picked, UNIT_TYPE_MAGIC_IMMUNE) == false and GetUnitState(picked, UNIT_STATE_LIFE) > 0 and IsUnitType(picked, UNIT_TYPE_STRUCTURE) == false then
call KillUnit(picked)
endif
call GroupRemoveUnit(g,picked)
call TriggerSleepAction(1.0)
set duration = duration + 1
endloop
//Now after this comment, stuff is ok too
call DestroyEffect(e)
call DestroyGroup(g)
call RemoveLocation(l)
set e = null
set g = null
set l = null
set caster = null
set dummy = null
set owner = null
set picked = null
endfunction
//=========================================================
function InitTrig_Poison_Gas_Grenade takes nothing returns nothing
set gg_trg_Poison_Gas_Grenade = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Poison_Gas_Grenade, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Poison_Gas_Grenade, Condition( function Trig_Poison_Gas_Grenade_Conditions ) )
call TriggerAddAction( gg_trg_Poison_Gas_Grenade, function Trig_Poison_Gas_Grenade_Actions )
endfunction[/code]
This is what I did. I am also commenting it, so you guys can understand the complexity of the spell.
Now, here is the original spell ... as you can see, it was clearly made of GUI, and then converted.
[jass=GUI converted original version]
function Trig_Poison_Gas_Grenade_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A00Q' ) ) then
return false
endif
return true
endfunction
//Poisen Gas Grenade temporary Unitgroup actions
function PGGgroupActions takes nothing returns nothing
call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), ( 45.00 * I2R(GetUnitAbilityLevelSwapped('A00Q', GetTriggerUnit())) ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
call AddSpecialEffectTargetUnitBJ( "chest", GetEnumUnit(), "Abilities\\Weapons\\IllidanMissile\\IllidanMissile.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call CreateTextTagUnitBJ( ( I2S(( 45 * GetUnitAbilityLevelSwapped('A00Q', GetTriggerUnit()) )) + "!" ), GetEnumUnit(), 0, 10, 0.00, 100, 0.00, 0 )
call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 40.00, 90 )
call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 3.00 )
endfunction
//Poisen Gas Grenade temporary Conditions actions
function PGGgroupW takes nothing returns boolean
return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction
function PGGgroupQ takes nothing returns boolean
return ( GetUnitStateSwap(UNIT_STATE_LIFE, GetFilterUnit()) > 0.00 )
endfunction
function PGGCondition takes nothing returns boolean
return GetBooleanAnd( PGGgroupW(), PGGgroupQ() )
endfunction
//Poisen Gas Grenade Trigger
function Trig_Poison_Gas_Grenade_Actions takes nothing returns nothing
local location PGGlocA = GetUnitLoc(GetTriggerUnit())
local location PGGlocB = GetSpellTargetLoc()
local group PGGgroupA
local integer IntegerPGG
local effect EffPGG
call CreateNUnitsAtLoc( 1, 'e003', GetOwningPlayer(GetTriggerUnit()), PGGlocA, AngleBetweenPoints(PGGlocA, PGGlocB) )
call IssuePointOrderLocBJ( GetLastCreatedUnit(), "attackground", PGGlocB )
call SetUnitPathing( GetLastCreatedUnit(), false )
call UnitApplyTimedLifeBJ( 0.90, 'BTLF', GetLastCreatedUnit() )
call TriggerSleepAction( ( DistanceBetweenPoints(PGGlocA, PGGlocB) / 800.00 ) )
call AddSpecialEffectLocBJ( PGGlocB, "war3mapImported\\Radioactivecloud.mdx" )
set EffPGG = GetLastCreatedEffectBJ()
set IntegerPGG = 1
loop
exitwhen IntegerPGG > 10
set PGGgroupA = GetUnitsInRangeOfLocMatching(220.00, PGGlocB, Condition(function PGGCondition))
call ForGroupBJ( PGGgroupA, function PGGgroupActions )
call TriggerSleepAction(1.00 )
set IntegerPGG = IntegerPGG + 1
endloop
call DestroyEffectBJ( EffPGG )
call RemoveLocation(PGGlocA)
call RemoveLocation(PGGlocB)
call DestroyGroup(PGGgroupA)
set PGGlocA = null
set PGGlocB = null
set PGGgroupA = null
set EffPGG = null
set IntegerPGG = 0
endfunction
//===========================================================================
function InitTrig_Poison_Gas_Grenade takes nothing returns nothing
set gg_trg_Poison_Gas_Grenade = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Poison_Gas_Grenade, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Poison_Gas_Grenade, Condition( function Trig_Poison_Gas_Grenade_Conditions ) )
call TriggerAddAction( gg_trg_Poison_Gas_Grenade, function Trig_Poison_Gas_Grenade_Actions )
endfunction
[/code]
To simplify my code, I replaced the real effect with "call KillUnit(whichUnit)".
But the point will still be the same.
My real problem is in the loop.
Help plz =S