wraithseeker
Tired.
- Reaction score
- 122
Stated above.
I wrote the problems in the comments but to sum it up. Right now it's not stackable and how do I make it so? Making huge arrays in the struct make less instances possible.
EDIT: Would using table for a struct instance work well or is there any other good alternatives?
EDIT2:
Tried a Table verison but I got confused and it wouldn't work, when would I set d.Count to d.Count - 1, I don't want to modify the UP Delayed Script.
JASS:
scope Overseermight initializer Init
globals
private constant integer DMGAURA = 039;A00F039;
private constant integer SPELLBOOK = 039;A00V039;
private constant integer SPELL = 039;A00U039;
private constant string EFFECT = "Abilities\\Spells\\Items\\AIco\\CrownOfCmndTarget.mdl"
private constant string BLINK = "Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl"
endglobals
private struct data
implement AutoData
static group Done = CreateGroup()
unit target
integer instances
integer agi
integer atkspeed
integer life
static method create takes unit target returns data
local data d = data.allocate()
set d.instances = 0
set d.agi = 0
set d.atkspeed = 0
set d.life = 0
set data[target] = d
return d
endmethod
endstruct
private function LConditions takes nothing returns boolean
return GetLearnedSkill() == SPELL
endfunction
private function LActions takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer i = GetUnitAbilityLevel(u,SPELL)
if GetLearnedSkill() > 0 then
call UnitAddAbility(u,SPELLBOOK)
endif
call SetUnitAbilityLevel(u,DMGAURA,i)
set u = null
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL
endfunction
private function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local data d = data<u>
local unit t = GetSpellTargetUnit()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real tx = GetUnitX(t)
local real ty = GetUnitY(t)
if d == 0 then
set d = data.create(u)
endif
call SetUnitX(t,x)
call SetUnitY(t,y)
call DestroyEffect(AddSpecialEffect(BLINK,x,y))
call SetUnitX(u,tx)
call SetUnitY(u,ty)
call DestroyEffect(AddSpecialEffect(BLINK,tx,ty))
call AddTimedEffectTarget(EFFECT,u,"overhead",5)
set d.agi = DelayedAgi(u,15,5) // d.agi is the struct instance of the agi struct and same goes for the rest
set d.life = DelayedMaxLife(u,200,5)
set d.atkspeed = DelayedAttackSpeed(u,40,5)
set d.instances = d.instances + 1 // what am I doing with this and not using a boolean? Well I don't know, i am currently thinking of how to make it stackable
set u = null
set t = null
endfunction
private function ConditionDeath takes nothing returns boolean
local unit u = GetKillingUnit()
local unit a = GetTriggerUnit()
local integer i = GetUnitAbilityLevel(u,SPELL)
local data d = data<u>
if IsUnitEnemy(a,GetOwningPlayer(u)) and i > 0 and d.instances > 0 then
call BJDebugMsg("Adding")
call AddAgiDuration(d.agi,1) // increase duration of the instance by 1
call AddMaxLifeDuration(d.life,1) // same thing..
call AddAttackSpeedDuration(d.atkspeed,1)
// auto data overwrites the existing struct so it isn't multiple unit instances for a specific unit 2 times and more
endif
set u = null
set a = null
return false
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i > 12
call SetPlayerAbilityAvailable(Player(i),SPELLBOOK,false)
set i = i + 1
endloop
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_HERO_SKILL)
call TriggerAddAction(t, function LActions )
call TriggerAddCondition(t,Condition(function LConditions))
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(t, function Actions)
call TriggerAddCondition(t,Condition(function Conditions))
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(t,Condition(function ConditionDeath))
endfunction
endscope</u></u>
I wrote the problems in the comments but to sum it up. Right now it's not stackable and how do I make it so? Making huge arrays in the struct make less instances possible.
EDIT: Would using table for a struct instance work well or is there any other good alternatives?
EDIT2:
JASS:
scope Overseermight initializer Init
globals
private constant integer DMGAURA = 039;A00F039;
private constant integer SPELLBOOK = 039;A00V039;
private constant integer SPELL = 039;A00U039;
private constant string EFFECT = "Abilities\\Spells\\Items\\AIco\\CrownOfCmndTarget.mdl"
private constant string BLINK = "Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl"
endglobals
private struct data
implement AutoData
static group Done = CreateGroup()
Table Agi
Table AttackSpeed
Table MaxLife
unit target
integer Count = 0
static method create takes unit target returns data
local data d = data.allocate()
set d.target = target
set d.Agi = Table.create()
set d.MaxLife = Table.create()
set d.AttackSpeed = Table.create()
set data[target] = d
return d
endmethod
endstruct
private function LConditions takes nothing returns boolean
return GetLearnedSkill() == SPELL
endfunction
private function LActions takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer i = GetUnitAbilityLevel(u,SPELL)
if GetLearnedSkill() > 0 then
call UnitAddAbility(u,SPELLBOOK)
endif
call SetUnitAbilityLevel(u,DMGAURA,i)
set u = null
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL
endfunction
private function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local data d = data<u>
local unit t = GetSpellTargetUnit()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real tx = GetUnitX(t)
local real ty = GetUnitY(t)
if d == 0 then
set d = data.create(u)
endif
call SetUnitX(t,x)
call SetUnitY(t,y)
call DestroyEffect(AddSpecialEffect(BLINK,x,y))
call SetUnitX(u,tx)
call SetUnitY(u,ty)
call DestroyEffect(AddSpecialEffect(BLINK,tx,ty))
call AddTimedEffectTarget(EFFECT,u,"overhead",5)
set d.Agi[d.Count] = DelayedAgi(u,15,5)
set d.MaxLife[d.Count] = DelayedMaxLife(u,200,5)
set d.AttackSpeed[d.Count] = DelayedAttackSpeed(u,40,5)
set d.Count = d.Count + 1
set u = null
set t = null
endfunction
private function ConditionDeath takes nothing returns boolean
local unit u = GetKillingUnit()
local unit a = GetTriggerUnit()
local integer i = GetUnitAbilityLevel(u,SPELL)
local integer j = 0
local data d = data<u>
if IsUnitEnemy(a,GetOwningPlayer(u)) and i > 0 and d.instances > 0 then
loop
exitwhen j >= d.Count
call AddAgiDuration(d.agi,1)
call AddMaxLifeDuration(d.life,1)
call AddAttackSpeedDuration(d.atkspeed,1)
set j = j + 1
endloop
endif
set u = null
set a = null
return false
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i > 12
call SetPlayerAbilityAvailable(Player(i),SPELLBOOK,false)
set i = i + 1
endloop
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_HERO_SKILL)
call TriggerAddAction(t, function LActions )
call TriggerAddCondition(t,Condition(function LConditions))
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(t, function Actions)
call TriggerAddCondition(t,Condition(function Conditions))
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(t,Condition(function ConditionDeath))
endfunction
endscope
</u></u>
Tried a Table verison but I got confused and it wouldn't work, when would I set d.Count to d.Count - 1, I don't want to modify the UP Delayed Script.