Hi,
here is a lightning spell:
it can target destructable and unit
and get area damage effect when cast on a unit standing on water.
target: tree --> transform tree (4 types) into a dead tree (doesn't affect other type destructable)
target: unit --> deal 40 to 70 dmg ignore armor
if unit is in water it damage every unit within 400 range wich are also in water.
Shock effect: the lightning energize the target giving +10 mana
[Jass=]
function difusion takes nothing returns nothing
local real x1 = GetUnitX(GetEnumUnit())
local real y1 = GetUnitY(GetEnumUnit())
if IsTerrainPathable( x1, y1, PATHING_TYPE_FLOATABILITY) then
call UnitDamageTarget(GetTriggerUnit(), GetEnumUnit(), GetRandomReal(30.00, 40.00), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
call SetUnitState( GetEnumUnit(), UNIT_STATE_MANA, ( GetUnitState( GetEnumUnit(), UNIT_STATE_MANA ) + 10.00 ))
endif
endfunction
function Lightning takes nothing returns boolean
local real x
local real y
local integer treetype
local boolean tree
local unit targetU
local unit caster
local destructable targetD
if GetSpellAbilityId() == 'A102' then
set caster = GetTriggerUnit()
if GetSpellTargetUnit() == null then
set targetD = GetSpellTargetDestructable()
set treetype = GetDestructableTypeId(targetD)
set tree = true
set x = GetDestructableX(targetD)
set y = GetDestructableY(targetD)
else
set targetU = GetSpellTargetUnit()
set tree = false
set x = GetUnitX(targetU)
set y = GetUnitY(targetU)
endif
if tree then
if not GetDestructableLife(targetD) <= 0 and treetype == 'ATtr' or treetype == 'BTtw' or treetype == 'FTtw' or treetype == 'ZTtw' then
call DisableTrigger( gg_trg_DropItemDestructible__JASS )
call RemoveDestructable( targetD )
call EnableTrigger( gg_trg_DropItemDestructible__JASS )
call CreateDestructable( 'NTtw', x, y, 0.00, 0.90, GetRandomInt(0, 9) )
call TriggerRegisterDeathEvent( gg_trg_DropItemDestructible__JASS, bj_lastCreatedDestructable )
endif
else
if IsTerrainPathable( x, y, PATHING_TYPE_FLOATABILITY) then
local group g = CreateGroup()
call GroupEnumUnitsInRange(g, x, y, 400.00, null)
call ForGroup( g, function difusion )
call DestroyGroup(g)
call UnitDamageTarget(caster, targetU, GetRandomReal(0.00, 30.00), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
else
call UnitDamageTarget(caster, targetU, GetRandomReal(30.00, 70.00), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
call SetUnitState( targetU, UNIT_STATE_MANA, ( GetUnitState( targetU, UNIT_STATE_MANA ) + 10.00 ))
endif
endif
endif
return false
endfunction
//===========================================================================
function InitTrig_custom_Lightning_JASS takes nothing returns nothing
set gg_trg_custom_Lightning_JASS = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_custom_Lightning_JASS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_custom_Lightning_JASS, Condition( function Lightning ) )
endfunction
[/code]
is the Jass correct? using group enumeration is a little more difficult that previous spell.
it remove local...
here is a lightning spell:
it can target destructable and unit
and get area damage effect when cast on a unit standing on water.
target: tree --> transform tree (4 types) into a dead tree (doesn't affect other type destructable)
target: unit --> deal 40 to 70 dmg ignore armor
if unit is in water it damage every unit within 400 range wich are also in water.
Shock effect: the lightning energize the target giving +10 mana
[Jass=]
function difusion takes nothing returns nothing
local real x1 = GetUnitX(GetEnumUnit())
local real y1 = GetUnitY(GetEnumUnit())
if IsTerrainPathable( x1, y1, PATHING_TYPE_FLOATABILITY) then
call UnitDamageTarget(GetTriggerUnit(), GetEnumUnit(), GetRandomReal(30.00, 40.00), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
call SetUnitState( GetEnumUnit(), UNIT_STATE_MANA, ( GetUnitState( GetEnumUnit(), UNIT_STATE_MANA ) + 10.00 ))
endif
endfunction
function Lightning takes nothing returns boolean
local real x
local real y
local integer treetype
local boolean tree
local unit targetU
local unit caster
local destructable targetD
if GetSpellAbilityId() == 'A102' then
set caster = GetTriggerUnit()
if GetSpellTargetUnit() == null then
set targetD = GetSpellTargetDestructable()
set treetype = GetDestructableTypeId(targetD)
set tree = true
set x = GetDestructableX(targetD)
set y = GetDestructableY(targetD)
else
set targetU = GetSpellTargetUnit()
set tree = false
set x = GetUnitX(targetU)
set y = GetUnitY(targetU)
endif
if tree then
if not GetDestructableLife(targetD) <= 0 and treetype == 'ATtr' or treetype == 'BTtw' or treetype == 'FTtw' or treetype == 'ZTtw' then
call DisableTrigger( gg_trg_DropItemDestructible__JASS )
call RemoveDestructable( targetD )
call EnableTrigger( gg_trg_DropItemDestructible__JASS )
call CreateDestructable( 'NTtw', x, y, 0.00, 0.90, GetRandomInt(0, 9) )
call TriggerRegisterDeathEvent( gg_trg_DropItemDestructible__JASS, bj_lastCreatedDestructable )
endif
else
if IsTerrainPathable( x, y, PATHING_TYPE_FLOATABILITY) then
local group g = CreateGroup()
call GroupEnumUnitsInRange(g, x, y, 400.00, null)
call ForGroup( g, function difusion )
call DestroyGroup(g)
call UnitDamageTarget(caster, targetU, GetRandomReal(0.00, 30.00), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
else
call UnitDamageTarget(caster, targetU, GetRandomReal(30.00, 70.00), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
call SetUnitState( targetU, UNIT_STATE_MANA, ( GetUnitState( targetU, UNIT_STATE_MANA ) + 10.00 ))
endif
endif
endif
return false
endfunction
//===========================================================================
function InitTrig_custom_Lightning_JASS takes nothing returns nothing
set gg_trg_custom_Lightning_JASS = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_custom_Lightning_JASS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_custom_Lightning_JASS, Condition( function Lightning ) )
endfunction
[/code]
is the Jass correct? using group enumeration is a little more difficult that previous spell.
it remove local...