skyblader
You're living only because it's illegal killing.
- Reaction score
- 159
Er, then yeah just switch roles.
Er, then yeah just switch roles.
library Fire
globals
private constant integer FIRE = 039;h000039; // raw code of unit "Fire"
private constant integer ABILID = 039;A000039; // raw code of ability
private hashtable Hash = InitHashtable()
private trigger array Trig
private integer TrigCount = -1
endglobals
private function InRangeOfFire takes nothing returns nothing
local unit cre = LoadUnitHandle(Hash, GetHandleId(GetTriggeringTrigger()), 0)// load the value of cre
local unit u = LoadUnitHandle(Hash, GetHandleId(GetTriggeringTrigger()), 1) // load the value of u
local unit trigu = GetTriggerUnit() // setting the entering unit as trigu
local effect e = AddSpecialEffect("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl", GetUnitX(trigu), GetUnitY(trigu)) // creating effect of position of trigu
local integer i = GetUnitUserData(u) // loading triggering trigger array value from cre's custom value
local integer loopindex = i
call UnitDamageTarget(u, trigu, GetUnitAbilityLevel(u, ABILID) * 50.0, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS) // dealing damage equal to level of ABILID * 50.0
call GroupRemoveUnit(udg_FireGroupSF, cre) // removing cre from FireGroupSF
call RemoveUnit(cre) // removing cre from game
call FlushChildHashtable(Hash, GetHandleId(GetTriggeringTrigger())) // flush Hash with parent handle id of triggering trigger
call DestroyEffect(e) // destroying created effect
set Trig<i> = null // nulling the current trigger
if i < TrigCount then // checking if the current trigger is less than the highest array value
loop // if it is, set all higher array values to one lower
exitwhen loopindex > TrigCount
set Trig[loopindex] = Trig[loopindex + 1]
set loopindex = loopindex + 1
endloop
set Trig[TrigCount] = null
endif
set TrigCount = TrigCount - 1 // decreasing the array value count
set u = null // nulling
set cre = null // local
set trigu = null // vars
set e = null //
call DestroyTrigger(GetTriggeringTrigger()) // destroying the current trigger
endfunction
private function GroupFunc takes nothing returns nothing
local unit u = GetEnumUnit() // setting the picked unit to "u"
local unit cre
local integer id
local real dur = LoadReal(udg_SpitfireHash, GetHandleId(u), 0)
if dur <= 0 then // checking if dur is less than or equal to 0
call FlushChildHashtable(udg_SpitfireHash, GetHandleId(u)) // flush SpitfireHash with parent handle id of u
call GroupRemoveUnit(udg_SpitfireGroupSF, u) // removing u from SpitfireGroupSF
call SetUnitMoveSpeed(u, GetUnitDefaultMoveSpeed(u)) // setting movement speed of u to default movespeed
else
set cre = CreateUnit(GetOwningPlayer(u), FIRE, GetUnitX(u), GetUnitY(u), 0) // creating the unit "Fire" and setting it to "cre"
set id = GetHandleId(cre) // saving the handle id of cre to "id"
call SaveReal(udg_FireHash, id, 0, GetUnitFacing(u)) // saving facing of cre as 0 of id in FireHash
call SaveReal(udg_FireHash, id, 1, 800.0 / 24.0) // saving value 800.0 / 24.0 as 1 of id in FireHash
call SaveReal(udg_FireHash, id, 2, 24.0) // saving value 24.0 as 2 of id in FireHash
call GroupAddUnit(udg_FireGroupSF, cre) // adding cre to FireGroupSF
call SaveReal(udg_SpitfireHash, GetHandleId(u), 0, dur - udg_IntervalSF) // updating dur and saving it in SpitfireHash
call SetUnitAnimation(u, "attack") // playing u's attack animation
set TrigCount = TrigCount + 1 // increasing the array value of Trig
set Trig[TrigCount] = CreateTrigger() // creating a new trigger
call TriggerRegisterUnitInRange(Trig[TrigCount], cre, udg_RangeOfFire, null) // adding the event "A unit comes within RangeOfFire of cre" to the created trigger
call TriggerAddAction(Trig[TrigCount], function InRangeOfFire) // adding the action to created trigger, which is the function "InRangeOfFire" (above function)
call SetUnitUserData(cre, TrigCount) // saving created trigger array value as cre's custom value
call SaveUnitHandle(Hash, GetHandleId(Trig[TrigCount]), 0, cre) // saving cre as 0 of handle id of the triggering trigger in Hash
call SaveUnitHandle(Hash, GetHandleId(Trig[TrigCount]), 1, u) // saving u as 1 of handle id of the triggering trigger in Hash
endif
set u = null // nulling
set cre = null// local vars
endfunction
public function CreatingFire takes nothing returns nothing
call ForGroup(udg_SpitfireGroupSF, function GroupFunc)
endfunction
endlibrary
</i>
Hmm.... Thanks for taking the time to write all the comments down :thup: But if I insert that, what would it do? Like what the codes actually do in simple terms. E.g. Destroys fire upon contact and deal damage.
Nono I meant insert your codes into my map, what does it do?
Remind me which trigger that replaces? o.o
Okay, it should be working now... Only problem is, how do I insert a condition for the unit that comes in range of the fire? I believe the fire is coming in range of the caster and being destroyed upon creation constantly... So I need to insert a condition checking whether the unit is an enemy of player 1.
private function InRangeOfFire takes nothing returns nothing
local unit cre = LoadUnitHandle(Hash, GetHandleId(GetTriggeringTrigger()), 0)// load the value of cre
local unit u = LoadUnitHandle(Hash, GetHandleId(GetTriggeringTrigger()), 1) // load the value of u
local unit trigu = GetTriggerUnit() // setting the entering unit as trigu
local effect
local integer i = GetUnitUserData(u) // loading triggering trigger array value from cre's custom value
local integer loopindex = i
if IsUnitEnemy(trigu, GetOwningPlayer(u)) then
set e = AddSpecialEffect("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl", GetUnitX(trigu), GetUnitY(trigu)) // creating effect of position of trigu
call UnitDamageTarget(u, trigu, GetUnitAbilityLevel(u, ABILID) * 50.0, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS) // dealing damage equal to level of ABILID * 50.0
call GroupRemoveUnit(udg_FireGroupSF, cre) // removing cre from FireGroupSF
call RemoveUnit(cre) // removing cre from game
call FlushChildHashtable(Hash, GetHandleId(GetTriggeringTrigger())) // flush Hash with parent handle id of triggering trigger
call DestroyEffect(e) // destroying created effect
set Trig<i> = null // nulling the current trigger
if i < TrigCount then // checking if the current trigger is less than the highest array value
loop // if it is, set all higher array values to one lower
exitwhen loopindex > TrigCount
set Trig[loopindex] = Trig[loopindex + 1]
set loopindex = loopindex + 1
endloop
set Trig[TrigCount] = null
endif
set TrigCount = TrigCount - 1 // decreasing the array value count
call DestroyTrigger(GetTriggeringTrigger()) // destroying the current trigger
endif
set u = null // nulling
set cre = null // local
set trigu = null // vars
set e = null //
endfunction
</i>
library Fire
globals
private constant integer FIRE = 039;h003039; // raw code of unit "Fire"
private constant integer ABILID = 039;A001039; // raw code of ability
private hashtable Hash = InitHashtable()
private trigger array Trig
private integer TrigCount = -1
endglobals
private function InRangeOfFire takes nothing returns nothing
local unit cre = LoadUnitHandle(Hash, GetHandleId(GetTriggeringTrigger()), 0)// load the value of cre
local unit u = LoadUnitHandle(Hash, GetHandleId(GetTriggeringTrigger()), 1) // load the value of u
local unit trigu = GetTriggerUnit() // setting the entering unit as trigu
local effect e = AddSpecialEffect("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl", GetUnitX(trigu), GetUnitY(trigu)) // creating effect of position of trigu
local integer i = GetUnitUserData(u) // loading triggering trigger array value from cre's custom value
local integer loopindex = i
if IsUnitEnemy(trigu, GetOwningPlayer(u)) then
set e = AddSpecialEffect("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl", GetUnitX(trigu), GetUnitY(trigu)) // creating effect of position of trigu
call UnitDamageTarget(u, trigu, GetUnitAbilityLevel(u, ABILID) * 50.0, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS) // dealing damage equal to level of ABILID * 50.0
call GroupRemoveUnit(udg_FireGroupSF, cre) // removing cre from FireGroupSF
call RemoveUnit(cre) // removing cre from game
call FlushChildHashtable(Hash, GetHandleId(GetTriggeringTrigger())) // flush Hash with parent handle id of triggering trigger
call DestroyEffect(e) // destroying created effect
set Trig<i> = null // nulling the current trigger
if i < TrigCount then // checking if the current trigger is less than the highest array value
loop // if it is, set all higher array values to one lower
exitwhen loopindex > TrigCount
set Trig[loopindex] = Trig[loopindex + 1]
set loopindex = loopindex + 1
endloop
set Trig[TrigCount] = null
endif
set TrigCount = TrigCount - 1 // decreasing the array value count
call DestroyTrigger(GetTriggeringTrigger()) // destroying the current trigger
endif
set u = null // nulling
set cre = null // local
set trigu = null // vars
set e = null //
endfunction
private function GroupFunc takes nothing returns nothing
local unit u = GetEnumUnit() // setting the picked unit to "u"
local unit cre
local integer id
local real dur = LoadReal(udg_SpitfireHash, GetHandleId(u), 0)
if dur <= 0 then // checking if dur is less than or equal to 0
call FlushChildHashtable(udg_SpitfireHash, GetHandleId(u)) // flush SpitfireHash with parent handle id of u
call GroupRemoveUnit(udg_SpitfireGroupSF, u) // removing u from SpitfireGroupSF
call SetUnitMoveSpeed(u, GetUnitDefaultMoveSpeed(u)) // setting movement speed of u to default movespeed
else
set cre = CreateUnit(GetOwningPlayer(u), FIRE, GetUnitX(u), GetUnitY(u), 0) // creating the unit "Fire" and setting it to "cre"
set id = GetHandleId(cre) // saving the handle id of cre to "id"
call SaveReal(udg_FireHash, id, 0, GetUnitFacing(u)) // saving facing of cre as 0 of id in FireHash
call SaveReal(udg_FireHash, id, 1, 800.0 / 24.0) // saving value 800.0 / 24.0 as 1 of id in FireHash
call SaveReal(udg_FireHash, id, 2, 24.0) // saving value 24.0 as 2 of id in FireHash
call GroupAddUnit(udg_FireGroupSF, cre) // adding cre to FireGroupSF
call SaveReal(udg_SpitfireHash, GetHandleId(u), 0, dur - udg_IntervalSF) // updating dur and saving it in SpitfireHash
call SetUnitAnimation(u, "attack") // playing u's attack animation
set TrigCount = TrigCount + 1 // increasing the array value of Trig
set Trig[TrigCount] = CreateTrigger() // creating a new trigger
call TriggerRegisterUnitInRange(Trig[TrigCount], cre, udg_RangeOfFire, null) // adding the event "A unit comes within RangeOfFire of cre" to the created trigger
call TriggerAddAction(Trig[TrigCount], function InRangeOfFire) // adding the action to created trigger, which is the function "InRangeOfFire" (above function)
call SetUnitUserData(cre, TrigCount) // saving created trigger array value as cre's custom value
call SaveUnitHandle(Hash, GetHandleId(Trig[TrigCount]), 0, cre) // saving cre as 0 of handle id of the triggering trigger in Hash
call SaveUnitHandle(Hash, GetHandleId(Trig[TrigCount]), 1, u) // saving u as 1 of handle id of the triggering trigger in Hash
endif
set u = null // nulling
set cre = null// local vars
endfunction
public function CreatingFire takes nothing returns nothing
call ForGroup(udg_SpitfireGroupSF, function GroupFunc)
endfunction
endlibrary</i>
I got a Lua error when Itried to test it. o.o