HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

A few problems with this spell...

01-25-2006, 09:51 PM#1
Moss
I have a few problems with this Maelstrom spell I am trying to make. The main one is that in the middle of this trigger where I set the variable p to equal the position of a random unit most of the time it doesn't work and p ends up equalling 0,0. The point of this spell is to create a large lightning storm where most of the time lightning just hits the ground around the caster but occaisionally a unit it is randomly selected and struck. Here is the code.

Trigger:
Maelstrom Running
Events
Collapse Conditions
((Triggering unit) is in xMaelstromCasters) Equal to True
Collapse Actions
Custom script: local effect udg_e
Set b = False
Set p = (Position of (Triggering unit))
Set r = (((Real((Level of Maelstrom for (Triggering unit)))) + 3.00) x 300.00)
Set ug = (Units within r of p matching ((((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True) and (((Matching unit) is alive) Equal to True)))
Custom script: call RemoveLocation(udg_p)
Collapse Unit Group - Pick every unit in ug and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Random real number between 0.00 and 1.00) Greater than or equal to 0.95
Collapse Then - Actions
Set b = True
Else - Actions
Custom script: if (udg_b) then
Set u = (Random unit from ug)
Set p = (Position of u)
Unit - Cause (Triggering unit) to damage u, dealing (((Real((Level of Maelstrom for (Triggering unit)))) x 200.00) + 100.00) damage of attack type Spells and damage type Lightning
Custom script: else
Set p = ((Position of (Triggering unit)) offset by (Random real number between 0.00 and r) towards (Random real number between 0.00 and 360.00) degrees)
Custom script: endif
Special Effect - Create a special effect at p using Doodads\Cinematic\Lightningbolt\Lightningbolt.mdl
Set e = (Last created special effect)
Sound - Play LightningBolt <gen> at 80.00% volume, located at p with Z offset 0.00
Wait (Random real number between 1.00 and 2.00) seconds
Special Effect - Destroy e
Trigger - Run Maelstrom Running <gen> (checking conditions)
Custom script: call RemoveLocation(udg_p)
Custom script: call DestroyGroup(udg_ug)

Sometimes it works fine. It always does damage to the random unit, but usually the lightning effect doesn't show. When I tell it to make floating text at p it puts it in the middle of the map, but strangely the lightning doesn't even show up there.

Another question I have is to do with the sound effect. Howcome if I tell it to destroy the last created sound right after triggering it it doesn't play even though the note says it will remove the sound when it is done playing. Now that I think about it I probably need to set the sound to a local variable and then wait and then remove the sound after it has had enough time to get started. Would that be right?

Third question: the dummy spell is based on Channel, how do I make it so that if the hero goes invisible or invincible the channeling is cancelled? That is what happens with most or all other channeling spells I think. Why doesn't it happen with anything I base off of Channel?
01-26-2006, 09:46 AM#2
Moss
I don't know why nobody has any answers to any of my questions. I spent a few more hours looking into this problem. It turns out everything works if I create an effect directly at "Position of u" instead of setting p to equal Position of u and then creating an effect at p. But that way will leak, correct? How can I do this without leaking and without bugging???

Also, my theory with waiting for the sound to start wasn't true. How are you supposed to trigger sounds? And why does it seem like you can't play the same sound twice in quick succession? It waits for the previous sound to play all the way through before that sound can play again. And why doesn't putting a sound effect on an ability in the object editor do anything? Oops, that's not a trigger question.
01-26-2006, 11:01 AM#3
Earth-Fury
that code just confuses me.... but 1 see 1 major issue right off the bat:

your declaring a local as "udg_". (udg is the prefix for globals, and as i see, you alredy have a global "e" (thus "udg_e"))

convert it to JASS and post it again, and ill try to help.
01-26-2006, 12:26 PM#4
qwertyui
This code makes my eyes hurt :/
Why did you make IFs in Custom script?
01-26-2006, 06:05 PM#5
iNfraNe
Quote:
Originally Posted by Earth-Fury
that code just confuses me.... but 1 see 1 major issue right off the bat:

your declaring a local as "udg_". (udg is the prefix for globals, and as i see, you alredy have a global "e" (thus "udg_e"))

convert it to JASS and post it again, and ill try to help.
I've heard that if you declare a local over a global you can use the global in the trigger as it was a local.
01-26-2006, 06:06 PM#6
oNdizZ
actually, you can do like this:
local effect udg_e

it gives you the possibility to use gui actions to the local effect. I only think it works for 1 global per function though.

custom script ifs are often used when you need to check... locals for example, or when you dont need the else.


If you want to make it stop just make a timer or something checking if the unit got those buffs, and then order it to stop.

To your TextTag problem, i suggest you check so that the TriggeringUnit actually is your unit after every loop.
01-26-2006, 09:25 PM#7
Moss
Sorry if the code makes your eyes hurt, but as I said, the problem boils down to this: "myPos = Position of myUnit" doesn't work. At least not in my situation there, and it makes no sense. I forget what the custom Ifs were for but I was doing things different before, I think I was using an elseif or something. At least this way I can say "If udg_b" instead of "If b == True". And yes, I made a local with udg_ so I could access it with GUI functions, I haven't bothered to learn all of JASS so I find that the easiest way to do things.
01-26-2006, 09:26 PM#8
Earth-Fury
Quote:
Originally Posted by Moss
Sorry if the code makes your eyes hurt, but as I said, the problem boils down to this: "myPos = Position of myUnit" doesn't work. At least not in my situation there, and it makes no sense. I forget what the custom Ifs were for but I was doing things different before, I think I was using an elseif or something. At least this way I can say "If udg_b" instead of "If b == True". And yes, I made a local with udg_ so I could access it with GUI functions, I haven't bothered to learn all of JASS so I find that the easiest way to do things.

my origional request stands: please post the trigger in full JASS.
01-26-2006, 10:33 PM#9
Vexorian
The Unit Group - Pick every unit in unit group thing, it uses another function, so locals won't work, you would be setting the value of the global b instead of the local udg_b

for the record you don't even need to make it local, cause there are no waits during the time you use that variable.

You need a local for the effect variable instead

And you have a leak, In this part:
Trigger:
Set p = ((Position of (Triggering unit)) offset by (Random real number between 0.00 and r) towards (Random real number between 0.00 and 360.00) degrees)

Position of (triggering unit) is creating a point you are not cleaning
01-26-2006, 11:27 PM#10
Moss
The boolean "b" isn't a local. The only local I am using is for the effect, as needed.

Thanks for the tip Vex but how would I prevent that from leaking?

So I take it nobody knows why you can't set a point to the position of a unit variable? Or how to trigger sounds without them leaking?
01-27-2006, 01:30 PM#11
Thunder_Eye
You dont have any events -.- so you cant use triggering unit..
01-27-2006, 02:57 PM#12
Vexorian
the trigger is probably executed by another trigger that has an event
01-27-2006, 02:58 PM#13
Thunder_Eye
Well then he cant use "triggering unit" as it doesnt referr to any unit or can he?
01-27-2006, 03:01 PM#14
Earth-Fury
Quote:
Originally Posted by Thunder_Eye
Well then he cant use "triggering unit" as it doesnt referr to any unit or can he?

if that trigger was fired off by another trigger that had a compatable event (eg: unit enters reigon) then yes, he can. (its how allot of people did "if then else" statements for RoC (before multiple conditions / actions where given to us))
01-27-2006, 03:21 PM#15
Thunder_Eye
ok thats new to me :P