 |   |  |  |
| World Editor Help Zone Need help with Blizzard's World Editor? Ask general questions about its features and use in this forum. README! |
 |
05-13-2007, 07:04 AM
|
#1 (permalink)
|
Brazil Fan
Join Date: Dec 2005
Posts: 415
|
Problem with Handle Var
Hello everyone!
I've been trying to make a spell that increases level with each attack. Ya, it's easy so far, but I also want to create Wisps around the hero for each level.
I'm using KaTTaNa's Local Handle Variables. I'm having trouble to keep the Group in the Attacker:
local group G = GetHandleGroup(Caster, "Group") local integer Counters = GetHandleInt(Caster, "Counters") local unit U set Counters = Counters + 1
if G == null then set G = CreateGroup() endif
set U = CreateUnit(GetOwningPlayer(Caster), 'e001', GetUnitX(Caster), GetUnitY(Caster), 72 * I) call GroupAddUnit(G, U) call SetHandleHandle(Caster, "Group", G) call SetHandleInt(Caster, "Counters", Counters) set G = null set U = null
G = Group of Wisps
Counters = Number of Wisps
e001 = Wisp
When G is null, the unit is added normally, but from the second attack on, the group has no units. The variable Counters is kept normally.
I've been trying this spell since a year ago =/
Thanks for your time
Hossomi
__________________
YIN-YANG BATTLE - remaking
too disorganized!
WIZARDS ARENA - active
TERRAINiii - HEROESiiii - EVENTSiiii
|
|
|
05-13-2007, 02:16 PM
|
#2 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
First note: you don't need a unit variable.
Second note: handles are only referenced with the Handle Vars, thus you shouldn't need to reattach them
Third note: the reference shouldn't asplode unless you run FlushHandleLocals() or just attach 'null' to "Group"
Fourth note: it's more efficient to store g as CreateGroup() when you create the group rather than running an if-statement every interval.
The code should come out something like this (assuming G was also attached as CreateGroup(), not null)
call GroupAddUnit(GetHandleGroup(Caster,"Group"),CreateUnit(GetOwningPlayer(Caster),'e001',GetUnitX(Caster),GetUnitY(Caster),72*I)) call SetHandleInt(Caster,"Counters",GetHandleInt(Caster,"Counters")+1)
(this assumes you don't reuse Counters in that execution. If you do, you can do the following instead of the above Counters line)
local integer Counters = GetHandleInt(Caster,"Counters")+1 call SetHandleInt(Caster,"Counters",Counters) //do other stuff with Counters here
EDIT: Please post in the JASS forum next time you have a JASS question ><. It helps keep the forums to order, and you'll also probably get more help there
|
|
|
05-13-2007, 06:50 PM
|
#3 (permalink)
|
Brazil Fan
Join Date: Dec 2005
Posts: 415
|
I guess you are getting tired of trying to help me xD
I'll try everything you said (you answered other three questions I was going to ask at once =P)
Indeed, thank you for helping me since wc3search!
Sorry for the inconvenience =P
EDIT:
Oh God... Here's the whole function:
function AddCounter takes nothing returns nothing local unit Caster = GetEventDamageSource () local integer Counters = GetHandleInt (Caster, "Counters") + 1 call DestroyTrigger (GetTriggeringTrigger ()) call BJDebugMsg (I2S (Counters )) // Shows Counters, which is alright if Counters > 5 then return endif call GroupAddUnit (GetHandleGroup (Caster, "Group"), CreateUnit (... 'e001' ... )) call BJDebugMsg (I2S (CountUnitsInGroup (GetHandleGroup (Caster, "Group")))) //Shows always 0 call SetHandleInt (Caster, "Counters", Counters ) set Caster = nullendfunction
This way it seems that the units are never added to the group. However, why should the "GroupAddUnit" be not working?
If I write this way...
function AddCounter takes nothing returns nothing local unit Caster = GetEventDamageSource () local integer Counters = GetHandleInt (Caster, "Counters") + 1 call DestroyTrigger (GetTriggeringTrigger ()) call BJDebugMsg (I2S (Counters )) // Shows Counters, which is alright if Counters > 5 then return endif if GetHandleGroup (Caster, "Group") == null then call SetHandleHandle (Caster, "Group", CreateGroup ()) endif call GroupAddUnit (GetHandleGroup (Caster, "Group"), CreateUnit (... 'e001' ... )) call BJDebugMsg (I2S (CountUnitsInGroup (GetHandleGroup (Caster, "Group")))) //Shows 1 for the first attack, then 0 call SetHandleInt (Caster, "Counters", Counters ) set Caster = nullendfunction
There will be 1 unit in the group, but from the second attack on, it seems that the group has not been initialized, because the DebugMsg will return 0. Why did the previous unit disappear?
Thanks for your time again... Actually you're losing your patience, I think...
__________________
YIN-YANG BATTLE - remaking
too disorganized!
WIZARDS ARENA - active
TERRAINiii - HEROESiiii - EVENTSiiii
Last edited by Marcelo Hossomi; 05-13-2007 at 08:30 PM..
Reason: Imma noob
|
|
|
05-13-2007, 08:44 PM
|
#4 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
Try posting the function that initializes the damage trigger for that as well
Quote:
|
Thanks for your time again... Actually you're losing your patience, I think...
|
What gave you that impression? ><
|
|
|
05-13-2007, 11:10 PM
|
#5 (permalink)
|
Brazil Fan
Join Date: Dec 2005
Posts: 415
|
Here's the initial function:
function Counters takes nothing returns nothing local trigger T = CreateTrigger () call TriggerAddAction ( T, function AddCounter ) call TriggerRegisterUnitEvent ( T, GetTriggerUnit (), EVENT_UNIT_DAMAGED ) set T = nullendfunction
Quote:
Originally Posted by PurplePoot
What gave you that impression? ><
|
It wasn't you, but I hate to keep asking the same thing for so much time =/
At wc3search my topic filled three pages with your posts and mine xD
__________________
YIN-YANG BATTLE - remaking
too disorganized!
WIZARDS ARENA - active
TERRAINiii - HEROESiiii - EVENTSiiii
|
|
|
05-14-2007, 12:07 AM
|
#6 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
As I said, with my way, that should be
function Counters takes nothing returns nothing local trigger T = CreateTrigger () call TriggerRegisterUnitEvent (T,GetTriggerUnit (),EVENT_UNIT_DAMAGED ) call TriggerAddAction (T, function AddCounter ) call SetHandleHandle (T, "Group",CreateGroup () set T = nullendfunction Since mine skipped out on the if/then
|
|
|
05-14-2007, 07:31 PM
|
#7 (permalink)
|
Brazil Fan
Join Date: Dec 2005
Posts: 415
|
I did as you said but, no use =/
I think you meant call SetHandleHandle(GetAttacker(), "Group", CreateGroup()) or am I wrong? Because I don't see why to do this to the trigger, since it will be destroyed =P
Greatest EDIT of my life:
MAN IT WORKS =D
I don't even know what I changed xD
But it works =D
(Thanks³)² PurplePoot =P
Yin-Yang will protect you for your life and eternity!
__________________
YIN-YANG BATTLE - remaking
too disorganized!
WIZARDS ARENA - active
TERRAINiii - HEROESiiii - EVENTSiiii
Last edited by Marcelo Hossomi; 05-14-2007 at 08:13 PM..
|
|
|
05-14-2007, 08:35 PM
|
#8 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
|
|
|
05-15-2007, 11:02 PM
|
#9 (permalink)
|
Spell and Map Moderator
The Helpful Personage
Join Date: Jan 2005
Posts: 4,269
|
This should be in the triggers(JASS) section not in the WEHZ.
|
|
|
05-15-2007, 11:49 PM
|
#10 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
Quote:
|
Originally Posted by PurplePoot
EDIT: Please post in the JASS forum next time you have a JASS question ><. It helps keep the forums to order, and you'll also probably get more help there
|
><
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|  |  |  |  |   |  |
|