- Joined
- Mar 14, 2011
- Messages
- 9
[SOLVED] Problem with units in Group?
[SOLVED]
Hi everyone,
I'm very nooby at vJASS and this is my very first try of creating a spell with it.
Spell background:
Increase Agility of all Heroes by an amount of 10% of the intelligence of the caster.
This is my try:
I Added some Debug Texts to see at which position the script is, in game it shows me that, when i activate the spell:
In function Conditions
In function create
In function GroupFilter
TRUE
In function GroupFilter
TRUE
In function BonusAdd
In function BonusAdd
[12 sec]
In function BonusSub
Only the SpecialEffect In function create works, the rest does nothing.
I really think the problem is after the line
"call BJDebugMsg("In function BonusAdd")"
because i'm not really understanding the UnitGroups in JASS..
And why the fuck GroupFilter and BonusAdd are called 2 times?
Hope you can help!
Thanks
[SOLVED]
Hi everyone,
I'm very nooby at vJASS and this is my very first try of creating a spell with it.
Spell background:
Increase Agility of all Heroes by an amount of 10% of the intelligence of the caster.
This is my try:
I Added some Debug Texts to see at which position the script is, in game it shows me that, when i activate the spell:
In function Conditions
In function create
In function GroupFilter
TRUE
In function GroupFilter
TRUE
In function BonusAdd
In function BonusAdd
[12 sec]
In function BonusSub
Only the SpecialEffect In function create works, the rest does nothing.
I really think the problem is after the line
"call BJDebugMsg("In function BonusAdd")"
because i'm not really understanding the UnitGroups in JASS..
And why the fuck GroupFilter and BonusAdd are called 2 times?
Hope you can help!
Thanks
JASS:
scope RuneDerMentalenStaerke initializer init
globals
private constant integer SpellID = 'A003'
private constant real Duration = 12.00
private constant string CasterEffect = "Objects\\InventoryItems\\runicobject\\runicobject.mdl"
private constant string TargetEffect = "Abilities\\Spells\\NightElf\\FaerieFire\\FaerieFireTarget.mdl"
private effect array dmgEffects[5]
private effect casterEffect
private unit array TempUnit[5]
private player TempPlayer = null
endglobals
private struct Spell
real BonusAgi
real TargetAgi
timer Timer
unit caster
group targets
static Spell tempthis
static method BonusAdd takes nothing returns nothing
local Spell tempthis
local integer i = 1
call BJDebugMsg("In function BonusAdd")
set i = 0
loop
exitwhen i > 5
set TempUnit[i] = GetEnumUnit()
call ModifyHeroStat( bj_HEROSTAT_AGI, TempUnit[i] , bj_MODIFYMETHOD_ADD, R2I( tempthis.BonusAgi ) )
//set dmgEffects[i] = AddSpecialEffectTargetUnitBJ("head",TempUnit[i],TargetEffect)
set dmgEffects[i] = AddSpecialEffectTarget(TargetEffect,TempUnit[i],"head")
set i = i + 1
endloop
endmethod
static method BonusSub takes nothing returns nothing
local Spell tempthis
local integer i = 1
call BJDebugMsg("In function BonusSub")
set i = 1
loop
exitwhen i > 5
call ModifyHeroStat( bj_HEROSTAT_AGI, TempUnit[i] , bj_MODIFYMETHOD_SUB, R2I( tempthis.BonusAgi ) )
call DestroyEffect(dmgEffects[i])
set i = i + 1
endloop
endmethod
static method GroupFilter takes nothing returns boolean
local unit u = GetFilterUnit()
call BJDebugMsg("In function GroupFilter")
if (u == UNIT_TYPE_HERO) then
call BJDebugMsg("TRUE")
return TRUE
endif
call BJDebugMsg("FALSE")
return FALSE
endmethod
static method create takes unit u returns Spell
local Spell this = Spell.allocate()
local integer i = 1
set .caster = u
set .targets = CreateGroup()
set .BonusAgi = GetHeroAgi( caster,TRUE ) * 0.10
set .Timer = CreateTimer()
call BJDebugMsg("In function create")
call GroupEnumUnitsInRect(.targets, bj_mapInitialPlayableArea, Filter(function Spell.GroupFilter))
//set casterEffect = AddSpecialEffectTargetUnitBJ("overhead", .caster ,CasterEffect)
set casterEffect = AddSpecialEffectTarget(CasterEffect,.caster,"overhead")
call ForGroup( .targets, function Spell.BonusAdd )
call TimerStart( .Timer, Duration, false, function Spell.BonusSub )
return this
endmethod
method onDestroy takes nothing returns nothing
call DestroyTimer( .Timer )
call DestroyEffect( casterEffect )
endmethod
endstruct
private function Conditions takes nothing returns boolean
call BJDebugMsg("In function Conditions")
if ( GetSpellAbilityId() == SpellID ) then
call Spell.create(GetTriggerUnit())
endif
return false
endfunction
private function init takes nothing returns nothing
local trigger t = null
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition( function Conditions ) )
endfunction
endscope
Last edited: