- Joined
- Mar 5, 2008
- Messages
- 3,887
Yes i use JassCraft.
And thanks guys, again
And thanks guys, again
//==================================================================================
//==================================================================================
//===============================ROOTING==v,1,2=====================================
//==================================================================================
//===============================BY==xD,Schurke=====================================
//==================================================================================
scope rooting initializer rootInt
//=========CONSTANTS===============
globals
//Dummy Rawcode
private constant integer dummyid = 'h000'
//Ability/Buff Rawcodes
private constant integer spellid = 'A000'
private constant integer dummyspellone = 'A002'
private constant integer dummyspelltwo = 'A003'
private constant integer dummyspellthree = 'A004'
private constant integer dummyspellfour = 'A005'
private constant integer buffraw = 'B000'
private constant integer buffoneraw = 'B002'
private constant integer bufftworaw = 'B003'
private constant integer timedlife = 'BTLF'
//Modelpaths
private constant string sfxstring = "Abilities\\Spells\\NightElf\\EntanglingRoots\\EntanglingRootsTarget.mdl"
private constant string sfxstringtwo = "Objects\\Spawnmodels\\Critters\\Albatross\\CritterBloodAlbatross.mdl"
private constant string sfxstringthree = "Objects\\Spawnmodels\\Undead\\UndeadLargeDeathExplode\\UndeadLargeDeathExplode.mdl"
//attachment strings
private constant string handright = "hand right"
private constant string handleft = "hand left"
private constant string chest = "chest"
private constant string head = "head"
private constant string origin = "origin"
//IssueOrder strings
private constant string ent ="entanglingroots"
private constant string roar ="roar"
private constant string soul = "soulburn"
private constant string ens = "ensnare"
//Timer Interval
private constant real Interval = 0.01
endglobals
//========END=CONSTANTS============
private struct rootstruct
unit caster //stores the caster
unit target //stores the target
real i = 0 //counter
effect array sfx [5] //stores the effects
timer t = CreateTimer()
static method rootTimer takes nothing returns nothing
local timer t = GetExpiredTimer() //timer
local rootstruct Dat = GetHandleInt(t,"dat") //gets the struct
local unit dummy //dummy var
local effect sfx //non permanent special effect
local unit u //for group reason
local group g = CreateGroup() //for group reason
set Dat.i = Dat.i + Interval //increases counter
if GetUnitState(Dat.target,UNIT_STATE_LIFE) <= 0 then //part to check if the target is dead and if it's true, it will damage all nearby enemy units and roots them (loop is for goup selection etc.) also resets all things (struct,timer etc.)
call PauseTimer(t)
set sfx = AddSpecialEffect(sfxstringthree,GetUnitX(Dat.target),GetUnitY(Dat.target))
call DestroyEffect(sfx)
call GroupEnumUnitsInRange(g,GetUnitX(Dat.target),GetUnitY(Dat.target),200,null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if IsUnitEnemy(u,GetOwningPlayer(Dat.caster)) and GetUnitState(u,UNIT_STATE_LIFE) > 0 and IsUnitType(u,UNIT_TYPE_STRUCTURE) != true then
call UnitDamageTarget(Dat.caster,u,I2R(GetRandomInt(50,150)),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
set dummy = CreateUnit(GetOwningPlayer(Dat.caster),dummyid,GetUnitX(Dat.target),GetUnitY(Dat.target),0)
call UnitApplyTimedLife(dummy,timedlife,1)
call UnitAddAbility(dummy,dummyspellfour)
call SetUnitAbilityLevel(dummy,dummyspellfour,GetUnitAbilityLevel(Dat.caster,spellid))
call IssueTargetOrder(dummy,ent,u)
set sfx = AddSpecialEffectTarget(sfxstringtwo,u,chest)
call DestroyEffect(sfx)
call GroupRemoveUnit(g,u)
else
call GroupRemoveUnit(g,u)
endif
endloop
call DestroyGroup(g)
call FlushHandleLocals(t)
call rootstruct.destroy(Dat)
call DestroyTimer(t)
elseif GetUnitAbilityLevel(Dat.target,buffraw) <= 0 then //only important if rooting was dispelled etc.
call FlushHandleLocals(t)
call rootstruct.destroy(Dat)
call DestroyTimer(t)
elseif Dat.i == 1 then //effect for after 1 second (roots the hand and checks for a 33% chance if the target won't deal damage anymore)
set Dat.sfx[1] = AddSpecialEffectTarget(sfxstring,Dat.target,handright)
set sfx = AddSpecialEffectTarget(sfxstringtwo,Dat.target,handleft)
call DestroyEffect(sfx)
call UnitDamageTarget(Dat.caster,Dat.target,20*GetUnitAbilityLevel(Dat.caster,spellid),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
if GetRandomInt(1,3) == 1 then
set dummy = CreateUnit(GetOwningPlayer(Dat.caster),dummyid,GetUnitX(Dat.target),GetUnitY(Dat.target),0)
call UnitAddAbility(dummy,dummyspellone)
call IssueImmediateOrder(dummy,roar)
call UnitApplyTimedLife(dummy,timedlife,1)
endif
elseif Dat.i == 2 then //not realy important part only damages and creates effect
set Dat.sfx[2] = AddSpecialEffectTarget(sfxstring,Dat.target,handleft)
set sfx = AddSpecialEffectTarget(sfxstringtwo,Dat.target,handleft)
call DestroyEffect(sfx)
call UnitDamageTarget(Dat.caster,Dat.target,20*GetUnitAbilityLevel(Dat.caster,spellid),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
elseif Dat.i == 3 then //effect for after 3 seconds (roots the head and checks for a 33% chance if the target won't cast spells anymore)
set Dat.sfx[3] = AddSpecialEffectTarget(sfxstring,Dat.target,head)
set sfx = AddSpecialEffectTarget(sfxstringtwo,Dat.target,head)
call DestroyEffect(sfx)
call UnitDamageTarget(Dat.caster,Dat.target,20*GetUnitAbilityLevel(Dat.caster,spellid),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
if GetRandomInt(1,3) == 1 then
set dummy = CreateUnit(GetOwningPlayer(Dat.caster),dummyid,GetUnitX(Dat.target),GetUnitY(Dat.target),0)
call UnitAddAbility(dummy,dummyspelltwo)
call IssueTargetOrder(dummy,soul,Dat.target)
call UnitApplyTimedLife(dummy,timedlife,1)
endif
elseif Dat.i == 4 then //effect+damage and roots target to the ground
set Dat.sfx[4] = AddSpecialEffectTarget(sfxstring,Dat.target,origin)
set sfx = AddSpecialEffectTarget(sfxstringtwo,Dat.target,origin)
call DestroyEffect(sfx)
call UnitDamageTarget(Dat.caster,Dat.target,20*GetUnitAbilityLevel(Dat.caster,spellid),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
set dummy = CreateUnit(GetOwningPlayer(Dat.caster),dummyid,GetUnitX(Dat.target),GetUnitY(Dat.target),0)
call UnitAddAbility(dummy,dummyspellthree)
call IssueTargetOrder(dummy,ens,Dat.target)
call UnitApplyTimedLife(dummy,timedlife,1)
elseif Dat.i == 5 then //only damage
call UnitDamageTarget(Dat.caster,Dat.target,20*GetUnitAbilityLevel(Dat.caster,spellid),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
elseif Dat.i == 6 then //only damage
call UnitDamageTarget(Dat.caster,Dat.target,20*GetUnitAbilityLevel(Dat.caster,spellid),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
elseif Dat.i == 7 then //if target didn't die this resets everything for no leaks etc.
call FlushHandleLocals(t)
call rootstruct.destroy(Dat)
endif
//setting all vars to null
set dummy = null
set t = null
set sfx = null
set u = null
endmethod
static method create takes unit u,unit t returns rootstruct //sets the caster and target
local rootstruct Dat = rootstruct.allocate()
set Dat.caster = u
set Dat.target = t
set Dat.sfx[0] = AddSpecialEffectTarget(sfxstring,Dat.target,"chest")
call DestroyEffect(AddSpecialEffectTarget(sfxstringtwo,Dat.target,"chest"))
call TimerStart(Dat.t,Interval,true,function rootstruct.rootTimer)
call SetHandleInt(Dat.t,"dat",Dat)
return Dat
endmethod
method onDestroy takes nothing returns nothing //remove leaks :D
local integer i = 0
call UnitRemoveAbility(.target,buffoneraw)
call UnitRemoveAbility(.target,bufftworaw)
set .caster = null
set .target = null
call DestroyTimer(.t)
set .t = null
loop
exitwhen i >= 5
call DestroyEffect(.sfx[i])
set .sfx[i] = null
set i = i + 1
endloop
endmethod
endstruct
//===============CONDITION/START=====================
private function rootCond takes nothing returns boolean
local unit u = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local rootstruct Dat
if GetSpellAbilityId() == spellid then
set Dat = rootstruct.create(u,t)
endif
set u = null
set t = null
return false
endfunction
//event part with preloading ;)
private function rootInt takes nothing returns nothing
local trigger int = CreateTrigger()
local integer index = 0
local unit u
loop
call TriggerRegisterPlayerUnitEvent(int, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(int,Condition(function rootCond))
set int = null
//preload dummy etc
set u = CreateUnit(Player(14),dummyid,9999999,9999999,0)
call UnitAddAbility(u,dummyspellone)
call UnitAddAbility(u,dummyspelltwo)
call UnitAddAbility(u,dummyspellthree)
call UnitAddAbility(u,dummyspellfour)
call RemoveUnit(u)
set u = null
call Preload(sfxstring)
call Preload(sfxstringtwo)
endfunction
endscope
got a question...where can i go to check out the various winners' spells in previous contests?
Could someone point me to a struct tutorial. What are the benefits of using them? The type of coding xD.Schurke is using. I'd like to learn this if there is a good reason for it. Seems kinda complicated though. Sorry for off topic post.
It is settled - tomorrow after my first examination in the university(starting at 9:00 probably ending at 9:30 because it is on basic programming), I will go straight home and I will code something big
Maybe I will have to spend a couple of hours in the toilet for inspiration. When I am in there, ideas seem to come faster
And then I am off to climbing![]()
Could someone point me to a struct tutorial. What are the benefits of using them? The type of coding xD.Schurke is using. I'd like to learn this if there is a good reason for it. Seems kinda complicated though. Sorry for off topic post.
//==================================================================================
//==================================================================================
//===============================ROOTING==v,1,4=====================================
//==================================================================================
//===============================BY==xD,Schurke=====================================
//==================================================================================
scope rooting initializer rootInt
//=========CONSTANTS===============
globals
//Dummy Rawcode
private constant integer dummyid = 'h000'
//Ability/Buff Rawcodes
private constant integer spellid = 'A000' //The hero spell
private constant integer dummyspellone = 'A002' //damage reduce
private constant integer dummyspelltwo = 'A003' //silence spell
private constant integer dummyspellthree = 'A004' //roots the target
private constant integer dummyspellfour = 'A005' //roots for all nearby enemy units
private constant integer buffraw = 'B000' //normal herospell debuff
private constant integer buffoneraw = 'B002' //damage reduce debuff
private constant integer bufftworaw = 'B003' //silence debuff
private constant integer timedlife = 'BTLF' //timed life debuff
//Modelpaths
private constant string sfxstring = "Abilities\\Spells\\NightElf\\EntanglingRoots\\EntanglingRootsTarget.mdl" //root model
private constant string sfxstringtwo = "Objects\\Spawnmodels\\Critters\\Albatross\\CritterBloodAlbatross.mdl" //bloodeffect
private constant string sfxstringthree = "Objects\\Spawnmodels\\Undead\\UndeadLargeDeathExplode\\UndeadLargeDeathExplode.mdl" //explode effect
//attachment strings
private constant string handright = "hand right"
private constant string handleft = "hand left"
private constant string chest = "chest"
private constant string head = "head"
private constant string origin = "origin"
//IssueOrder strings
private constant string ent ="entanglingroots"
private constant string roar ="roar"
private constant string soul = "soulburn"
private constant string ens = "ensnare"
//Timer Interval
private constant real Interval = 0.01
endglobals
//function for damage
private function damage takes integer level returns real
return I2R(20 * level)
endfunction
//========END=CONSTANTS============
private struct rootstruct
unit caster //stores the caster
unit target //stores the target
real i = 0 //counter
effect array sfx [5] //stores the effects
timer t = CreateTimer()
static method rootTimer takes nothing returns nothing
local rootstruct Dat = GetTimerData(GetExpiredTimer()) //gets the struct
local unit dummy //dummy var
local effect sfx //non permanent special effect
local unit u //for group reason
local group g = CreateGroup() //for group reason
set Dat.i = Dat.i + Interval //increases counter
if GetUnitState(Dat.target,UNIT_STATE_LIFE) <= 0 then //part to check if the target is dead and if it's true, it will damage all nearby enemy units and roots them (loop is for goup selection etc.) also resets all things (struct,timer etc.)
set sfx = AddSpecialEffect(sfxstringthree,GetUnitX(Dat.target),GetUnitY(Dat.target))
call DestroyEffect(sfx)
call GroupEnumUnitsInRange(g,GetUnitX(Dat.target),GetUnitY(Dat.target),200,null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if IsUnitEnemy(u,GetOwningPlayer(Dat.caster)) and GetUnitState(u,UNIT_STATE_LIFE) > 0 and IsUnitType(u,UNIT_TYPE_STRUCTURE) != true then
call UnitDamageTarget(Dat.caster,u,I2R(GetRandomInt(50,150)),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
set dummy = CreateUnit(GetOwningPlayer(Dat.caster),dummyid,GetUnitX(Dat.target),GetUnitY(Dat.target),0)
call UnitApplyTimedLife(dummy,timedlife,1)
call UnitAddAbility(dummy,dummyspellfour)
call SetUnitAbilityLevel(dummy,dummyspellfour,GetUnitAbilityLevel(Dat.caster,spellid))
call IssueTargetOrder(dummy,ent,u)
set sfx = AddSpecialEffectTarget(sfxstringtwo,u,chest)
call DestroyEffect(sfx)
call GroupRemoveUnit(g,u)
else
call GroupRemoveUnit(g,u)
endif
endloop
call DestroyGroup(g)
call rootstruct.destroy(Dat)
elseif GetUnitAbilityLevel(Dat.target,buffraw) <= 0 then //only important if rooting was dispelled etc.
call rootstruct.destroy(Dat)
elseif Dat.i == 1 then //effect for after 1 second (roots the hand and checks for a 33% chance if the target won't deal damage anymore)
set Dat.sfx[1] = AddSpecialEffectTarget(sfxstring,Dat.target,handright)
set sfx = AddSpecialEffectTarget(sfxstringtwo,Dat.target,handleft)
call DestroyEffect(sfx)
call UnitDamageTarget(Dat.caster,Dat.target,damage(GetUnitAbilityLevel(Dat.caster,spellid)),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
if GetRandomInt(1,3) == 1 then
set dummy = CreateUnit(GetOwningPlayer(Dat.caster),dummyid,GetUnitX(Dat.target),GetUnitY(Dat.target),0)
call UnitAddAbility(dummy,dummyspellone)
call IssueImmediateOrder(dummy,roar)
call UnitApplyTimedLife(dummy,timedlife,1)
endif
elseif Dat.i == 2 then //not realy important part only damages and creates effect
set Dat.sfx[2] = AddSpecialEffectTarget(sfxstring,Dat.target,handleft)
set sfx = AddSpecialEffectTarget(sfxstringtwo,Dat.target,handleft)
call DestroyEffect(sfx)
call UnitDamageTarget(Dat.caster,Dat.target,damage(GetUnitAbilityLevel(Dat.caster,spellid)),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
elseif Dat.i == 3 then //effect for after 3 seconds (roots the head and checks for a 33% chance if the target won't cast spells anymore)
set Dat.sfx[3] = AddSpecialEffectTarget(sfxstring,Dat.target,head)
set sfx = AddSpecialEffectTarget(sfxstringtwo,Dat.target,head)
call DestroyEffect(sfx)
call UnitDamageTarget(Dat.caster,Dat.target,damage(GetUnitAbilityLevel(Dat.caster,spellid)),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
if GetRandomInt(1,3) == 1 then
set dummy = CreateUnit(GetOwningPlayer(Dat.caster),dummyid,GetUnitX(Dat.target),GetUnitY(Dat.target),0)
call UnitAddAbility(dummy,dummyspelltwo)
call IssueTargetOrder(dummy,soul,Dat.target)
call UnitApplyTimedLife(dummy,timedlife,1)
endif
elseif Dat.i == 4 then //effect+damage and roots target to the ground
set Dat.sfx[4] = AddSpecialEffectTarget(sfxstring,Dat.target,origin)
set sfx = AddSpecialEffectTarget(sfxstringtwo,Dat.target,origin)
call DestroyEffect(sfx)
call UnitDamageTarget(Dat.caster,Dat.target,damage(GetUnitAbilityLevel(Dat.caster,spellid)),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
set dummy = CreateUnit(GetOwningPlayer(Dat.caster),dummyid,GetUnitX(Dat.target),GetUnitY(Dat.target),0)
call UnitAddAbility(dummy,dummyspellthree)
call IssueTargetOrder(dummy,ens,Dat.target)
call UnitApplyTimedLife(dummy,timedlife,1)
elseif Dat.i == 5 then //only damage
call UnitDamageTarget(Dat.caster,Dat.target,damage(GetUnitAbilityLevel(Dat.caster,spellid)),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
elseif Dat.i == 6 then //only damage
call UnitDamageTarget(Dat.caster,Dat.target,damage(GetUnitAbilityLevel(Dat.caster,spellid)),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
elseif Dat.i == 7 then //if target didn't die this resets everything for no leaks etc.
call rootstruct.destroy(Dat)
endif
//setting all vars to null
set dummy = null
set sfx = null
set u = null
endmethod
static method create takes unit u,unit t returns rootstruct //sets the caster and target
local rootstruct Dat = rootstruct.allocate()
set Dat.caster = u
set Dat.target = t
set Dat.sfx[0] = AddSpecialEffectTarget(sfxstring,Dat.target,"chest")
call DestroyEffect(AddSpecialEffectTarget(sfxstringtwo,Dat.target,"chest"))
call SetTimerData(Dat.t,integer(Dat))
call TimerStart(Dat.t,Interval,true,function rootstruct.rootTimer)
return Dat
endmethod
method onDestroy takes nothing returns nothing //remove leaks :D
local integer i = 0
call UnitRemoveAbility(.target,buffoneraw)
call UnitRemoveAbility(.target,bufftworaw)
set .caster = null
set .target = null
call DestroyTimer(.t)
set .t = null
loop
exitwhen i >= 5
call DestroyEffect(.sfx[i])
set .sfx[i] = null
set i = i + 1
endloop
endmethod
endstruct
//===============CONDITION/START=====================
private function rootCond takes nothing returns boolean
local unit u = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local rootstruct Dat
if GetSpellAbilityId() == spellid then
set Dat = rootstruct.create(u,t)
endif
set u = null
set t = null
return false
endfunction
//event part with preloading ;)
private function rootInt takes nothing returns nothing
local trigger int = CreateTrigger()
local integer index = 0
local unit u
loop
call TriggerRegisterPlayerUnitEvent(int, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(int,Condition(function rootCond))
set int = null
//preload dummy etc
set u = CreateUnit(Player(14),dummyid,9999999,9999999,0)
call UnitAddAbility(u,dummyspellone)
call UnitAddAbility(u,dummyspelltwo)
call UnitAddAbility(u,dummyspellthree)
call UnitAddAbility(u,dummyspellfour)
call RemoveUnit(u)
set u = null
call Preload(sfxstring)
call Preload(sfxstringtwo)
endfunction
endscope
//==================================================================================
//==================================================================================
//===============================ROOTING==v.1.5=====================================
//==================================================================================
//===============================BY==xD.Schurke=====================================
//==================================================================================
scope rooting initializer rootInt
//=========CONSTANTS===============
globals
//Dummy Rawcode
private constant integer dummyid = 'h000' //change to you map specific dummy rawcode
//Ability/Buff Rawcodes
private constant integer spellid = 'A000' //The hero spell
private constant integer dummyspellone = 'A002' //damage reduce must be roar with negative value
private constant integer dummyspelltwo = 'A003' //silence spell must be soulburn with 0 damage
private constant integer dummyspellthree = 'A004' //roots the target ensnare
private constant integer dummyspellfour = 'A005' //roots for all nearby enemy units
private constant integer buffraw = 'B000' //normal herospell debuff (debuff of 'A000')
private constant integer buffoneraw = 'B002' //damage reduce debuff (debuff of 'A002)
private constant integer bufftworaw = 'B003' //silence debuff (debuff of 'A003')
private constant integer timedlife = 'BTLF' //timed life debuff Don't change
//Modelpaths
private constant string sfxstring = "Abilities\\Spells\\NightElf\\EntanglingRoots\\EntanglingRootsTarget.mdl" //root model change for a new model
private constant string sfxstringtwo = "Objects\\Spawnmodels\\Critters\\Albatross\\CritterBloodAlbatross.mdl" //bloodeffect
private constant string sfxstringthree = "Objects\\Spawnmodels\\Undead\\UndeadLargeDeathExplode\\UndeadLargeDeathExplode.mdl" //explode effect
//attachment strings shouldn't be changed
private constant string handright = "hand right"
private constant string handleft = "hand left"
private constant string chest = "chest"
private constant string head = "head"
private constant string origin = "origin"
//IssueOrder strings shouldn't be changed
private constant string ent ="entanglingroots"
private constant string roar ="roar"
private constant string soul = "soulburn"
private constant string ens = "ensnare"
//Timer Interval
private constant real Interval = 0.01
endglobals
//function for damage change the number to have more/less damage
private function damage takes integer level returns real
return I2R(20 * level)
endfunction
//========END=CONSTANTS============
private struct rootstruct
unit caster //stores the caster
unit target //stores the target
real i = 0 //counter
effect array sfx [5] //stores the effects
timer t
static method rootTimer takes nothing returns nothing
local rootstruct Dat = GetTimerData(GetExpiredTimer()) //gets the struct
local unit dummy //dummy var
local effect sfx //non permanent special effect
local unit u //for group reason
local group g = CreateGroup() //for group reason
set Dat.i = Dat.i + Interval //increases counter
if GetUnitState(Dat.target,UNIT_STATE_LIFE) <= 0 then //part to check if the target is dead and if it's true, it will damage all nearby enemy units and roots them (loop is for goup selection etc.) also resets all things (struct,timer etc.)
set sfx = AddSpecialEffect(sfxstringthree,GetUnitX(Dat.target),GetUnitY(Dat.target))
call DestroyEffect(sfx)
call GroupEnumUnitsInRange(g,GetUnitX(Dat.target),GetUnitY(Dat.target),200,null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if IsUnitEnemy(u,GetOwningPlayer(Dat.caster)) and GetUnitState(u,UNIT_STATE_LIFE) > 0 and IsUnitType(u,UNIT_TYPE_STRUCTURE) != true then
call UnitDamageTarget(Dat.caster,u,I2R(GetRandomInt(50,150)),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
set dummy = CreateUnit(GetOwningPlayer(Dat.caster),dummyid,GetUnitX(Dat.target),GetUnitY(Dat.target),0)
call UnitApplyTimedLife(dummy,timedlife,1)
call UnitAddAbility(dummy,dummyspellfour)
call SetUnitAbilityLevel(dummy,dummyspellfour,GetUnitAbilityLevel(Dat.caster,spellid))
call IssueTargetOrder(dummy,ent,u)
set sfx = AddSpecialEffectTarget(sfxstringtwo,u,chest)
call DestroyEffect(sfx)
call GroupRemoveUnit(g,u)
else
call GroupRemoveUnit(g,u)
endif
endloop
call DestroyGroup(g)
call rootstruct.destroy(Dat)
elseif GetUnitAbilityLevel(Dat.target,buffraw) <= 0 then //only important if rooting was dispelled etc.
call rootstruct.destroy(Dat)
elseif Dat.i == 1 then //effect for after 1 second (roots the hand and checks for a 33% chance if the target won't deal damage anymore)
set Dat.sfx[1] = AddSpecialEffectTarget(sfxstring,Dat.target,handright)
set sfx = AddSpecialEffectTarget(sfxstringtwo,Dat.target,handleft)
call DestroyEffect(sfx)
call UnitDamageTarget(Dat.caster,Dat.target,damage(GetUnitAbilityLevel(Dat.caster,spellid)),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
if GetRandomInt(1,3) == 1 then
set dummy = CreateUnit(GetOwningPlayer(Dat.caster),dummyid,GetUnitX(Dat.target),GetUnitY(Dat.target),0)
call UnitAddAbility(dummy,dummyspellone)
call IssueImmediateOrder(dummy,roar)
call UnitApplyTimedLife(dummy,timedlife,1)
endif
elseif Dat.i == 2 then //not realy important part only damages and creates effect
set Dat.sfx[2] = AddSpecialEffectTarget(sfxstring,Dat.target,handleft)
set sfx = AddSpecialEffectTarget(sfxstringtwo,Dat.target,handleft)
call DestroyEffect(sfx)
call UnitDamageTarget(Dat.caster,Dat.target,damage(GetUnitAbilityLevel(Dat.caster,spellid)),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
elseif Dat.i == 3 then //effect for after 3 seconds (roots the head and checks for a 33% chance if the target won't cast spells anymore)
set Dat.sfx[3] = AddSpecialEffectTarget(sfxstring,Dat.target,head)
set sfx = AddSpecialEffectTarget(sfxstringtwo,Dat.target,head)
call DestroyEffect(sfx)
call UnitDamageTarget(Dat.caster,Dat.target,damage(GetUnitAbilityLevel(Dat.caster,spellid)),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
if GetRandomInt(1,3) == 1 then
set dummy = CreateUnit(GetOwningPlayer(Dat.caster),dummyid,GetUnitX(Dat.target),GetUnitY(Dat.target),0)
call UnitAddAbility(dummy,dummyspelltwo)
call IssueTargetOrder(dummy,soul,Dat.target)
call UnitApplyTimedLife(dummy,timedlife,1)
endif
elseif Dat.i == 4 then //effect+damage and roots target to the ground
set Dat.sfx[4] = AddSpecialEffectTarget(sfxstring,Dat.target,origin)
set sfx = AddSpecialEffectTarget(sfxstringtwo,Dat.target,origin)
call DestroyEffect(sfx)
call UnitDamageTarget(Dat.caster,Dat.target,damage(GetUnitAbilityLevel(Dat.caster,spellid)),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
set dummy = CreateUnit(GetOwningPlayer(Dat.caster),dummyid,GetUnitX(Dat.target),GetUnitY(Dat.target),0)
call UnitAddAbility(dummy,dummyspellthree)
call IssueTargetOrder(dummy,ens,Dat.target)
call UnitApplyTimedLife(dummy,timedlife,1)
elseif Dat.i == 5 then //only damage
call UnitDamageTarget(Dat.caster,Dat.target,damage(GetUnitAbilityLevel(Dat.caster,spellid)),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
elseif Dat.i == 6 then //only damage
call UnitDamageTarget(Dat.caster,Dat.target,damage(GetUnitAbilityLevel(Dat.caster,spellid)),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
elseif Dat.i == 7 then //if target didn't die this resets everything for no leaks etc.
call rootstruct.destroy(Dat)
endif
//setting all vars to null
set dummy = null
set sfx = null
set u = null
endmethod
static method create takes unit u,unit t returns rootstruct //sets the caster and target
local rootstruct Dat = rootstruct.allocate()
set Dat.caster = u
set Dat.target = t
set Dat.t = NewTimer()
set Dat.sfx[0] = AddSpecialEffectTarget(sfxstring,Dat.target,"chest")
call DestroyEffect(AddSpecialEffectTarget(sfxstringtwo,Dat.target,"chest"))
call SetTimerData(Dat.t,integer(Dat))
call TimerStart(Dat.t,Interval,true,function rootstruct.rootTimer)
return Dat
endmethod
method onDestroy takes nothing returns nothing //remove leaks :D
local integer i = 0
call UnitRemoveAbility(.target,buffoneraw)
call UnitRemoveAbility(.target,bufftworaw)
set .caster = null
set .target = null
call ReleaseTimer(.t)
set .t = null
loop
exitwhen i >= 5
call DestroyEffect(.sfx[i])
set .sfx[i] = null
set i = i + 1
endloop
endmethod
endstruct
//===============CONDITION/START=====================
private function rootCond takes nothing returns boolean
local unit u = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local rootstruct Dat
if GetSpellAbilityId() == spellid then
set Dat = rootstruct.create(u,t)
endif
set u = null
set t = null
return false
endfunction
//event part with preloading ;)
private function rootInt takes nothing returns nothing
local trigger int = CreateTrigger()
local integer index = 0
local unit u
loop
call TriggerRegisterPlayerUnitEvent(int, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(int,Condition(function rootCond))
set int = null
//preload dummy etc
set u = CreateUnit(Player(14),dummyid,9999999,9999999,0)
call UnitAddAbility(u,dummyspellone)
call UnitAddAbility(u,dummyspelltwo)
call UnitAddAbility(u,dummyspellthree)
call UnitAddAbility(u,dummyspellfour)
call RemoveUnit(u)
set u = null
call Preload(sfxstring)
call Preload(sfxstringtwo)
endfunction
endscope
Here's my final version. Crosses fingers =P.
all in all you should rework your code![]()
lol^^
scope BeeSwarm initializer Init
//=========================Bee Swarm by BlackShogun==========================//
//=================================Setup=====================================//
//spell rawcode
private constant function BeeSwarmRawCode takes nothing returns integer
return 'A000'
endfunction
//dummy unit rawcode
private constant function BeeSwarmModel takes nothing returns integer
return 'h000'
endfunction
//dummy unit model
private constant function BeeSwarmSFX takes nothing returns string
return "Abilities\\Weapons\\CryptFiendMissile\\CryptFiendMissile.mdl"
endfunction
//base damage per second
private function BeeSwarmBaseDPS takes integer lvl returns real
return 5.0*lvl
endfunction
//increase in damage per second for every second the target is moving
private function BeeSwarmIncDPS takes integer lvl returns real
return 0.5*lvl
endfunction
//decrease in damage per second for every second the target is moving
private constant function BeeSwarmDecDPS takes nothing returns real
return 0.5
endfunction
//duration of spell
private constant function BeeSwarmDur takes nothing returns real
return 20.0
endfunction
//the movement and effects interval
private constant function BeeSwarmInterval takes nothing returns real
return 0.03
endfunction
//distance moved by projectile each interval
private constant function BeeSwarmDist takes nothing returns real
return 15.0
endfunction
//===============================EndSetup====================================//
//==================NOTE: DO NOT EDIT ANYTHING BEYOND HERE===================//
struct BeeSwarm_Data
unit cast
unit targ
unit u
real x
real y
real dmg
real time
effect sfx
endstruct
globals
private timer t = CreateTimer()
private BeeSwarm_Data array ar
private integer total = 0
endglobals
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == BeeSwarmRawCode()
endfunction
private function Effects takes nothing returns nothing
local BeeSwarm_Data dat
local integer i=0
local real x1
local real y1
local real x2
local real y2
local real a
local real mx
local real my
local integer lvl
loop
exitwhen i>=total
set dat=ar[i]
set x1=GetUnitX(dat.u)
set y1=GetUnitY(dat.u)
set x2=GetUnitX(dat.targ)
set y2=GetUnitY(dat.targ)
set a=Atan2(y2-y1, x2-x1)
set mx=BeeSwarmDist()*Cos(a)
set my=BeeSwarmDist()*Sin(a)
set lvl=GetUnitAbilityLevel(dat.cast, BeeSwarmRawCode())
if not IsUnitInRange(dat.u, dat.targ, 50) then
call SetUnitX(dat.u, x1+mx)
call SetUnitY(dat.u, y1+my)
call SetUnitFacing(dat.u, 57.29583*a)
endif
if IsUnitInRange(dat.u, dat.targ, 50) and (not IsUnitType(dat.targ, UNIT_TYPE_DEAD)) then
call SetUnitX(dat.u, x2)
call SetUnitY(dat.u, y2)
call UnitDamageTarget(dat.cast, dat.targ, (BeeSwarmBaseDPS(lvl)*BeeSwarmInterval())+dat.dmg, true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
if dat.x!=null then
if IsUnitInRangeXY(dat.targ, dat.x, dat.y, 5) then
set dat.dmg=dat.dmg-(BeeSwarmDecDPS()*BeeSwarmInterval())
else
set dat.dmg=dat.dmg+(BeeSwarmIncDPS(lvl)*BeeSwarmInterval())
endif
endif
set dat.x=x2
set dat.y=y2
endif
if (BeeSwarmBaseDPS(lvl)+dat.dmg<=0) or (dat.time>=BeeSwarmDur()) or (IsUnitInRange(dat.u, dat.targ, 50) and IsUnitType(dat.targ, UNIT_TYPE_DEAD)) then
call DestroyEffect(dat.sfx)
call RemoveUnit(dat.u)
set ar[i]=ar[total-1]
set total=total-1
call dat.destroy()
endif
set dat.time=dat.time+(1*BeeSwarmInterval())
set i=i+1
endloop
if total==0 then
call PauseTimer(t)
endif
endfunction
private function Actions takes nothing returns BeeSwarm_Data
local BeeSwarm_Data dat=BeeSwarm_Data.create()
local player p
set dat.cast=GetTriggerUnit()
set p = GetOwningPlayer(dat.cast)
set dat.targ=GetSpellTargetUnit()
set dat.u=CreateUnit(p, BeeSwarmModel(), GetUnitX(dat.cast), GetUnitY(dat.cast), 57.29583*Atan2(GetUnitY(dat.targ)-GetUnitY(dat.cast), GetUnitX(dat.targ)-GetUnitX(dat.cast)))
set dat.sfx=AddSpecialEffectTarget(BeeSwarmSFX(), dat.u, "chest")
set dat.dmg=0
set dat.time=0
set p=null
if total==0 then
call TimerStart(t, BeeSwarmInterval(), true, function Effects)
endif
set total=total+1
set ar[total-1]=dat
return dat
endfunction
private function Init takes nothing returns nothing
local trigger T = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(T, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(T, function Actions)
call TriggerAddCondition(T, Condition(function Conditions))
endfunction
endscope
Earthliving WeaponEnchants the users weapon with power from nature, giving it the power to leech seed an enemy unit. The Leech Seed will leech the very life from the target, regenerating nearby allied units by distributing the life leeched equally. Damage Leeched increases with level.
where can i find the hall of fame for this contest?
Aye, because the Mini Contests are not archived there. You can find them here
http://www.hiveworkshop.com/forums/f269/spells-systems-hall-fame-34111/
Hmm... I finally got some decent coding done
Im making a shield which is absorbing damage and returns the damage dealt as 'small missiles' moving towards the attacking unit. It may not be the best but its better than nothing. Here is how the shield looks so far. (note, Paladin is just a test unit atm, also note that i have the lowest quality and resolution on my pc :_![]()
however it also says:All work should be done by the contestant and original to this contest, started after the contest started.
You would probably need to ask Poot if you are unsure of the system (what kind of system is it?), if it is counting as a Large System or not.You may use utilities (that do small jobs), but no large do-it-for-you systems.
Examples of utilities:
* Local Handle Variables
* CSCache
* Armor Detection System
* Vector System
Examples of large do-it-for-you systems:
* Particle System
* Caster System
well here is my entry, its the first version since there is no mush time left it may be the only one![]()