HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

I can't solve the problem - Dizzyness

08-14-2008, 03:01 AM#1
SmileyJeff
This is a spell i made for my map.
Problem:
It work for most of the time but, sometimes the swaying and enable user control don't work, so when it is cast on the targeted person, it will forever be shaking his screen and its control disabled. I cant seem to find the problem myself, anyone can help me with this?

Heres a Replay i saved frm today while testing my map with online players. You might need the Map to view it.
If you do check the replay, keep an eye on teal, he was the 2nd victim, yellow was 1st but it went fine. (Early game)

Trigger:
Dizzy Learn
Collapse Events
Unit - A unit Learns a skill
Collapse Conditions
(Learned Hero Skill) Equal to Dizzyness (Illutionist)
Collapse Actions
Set Dizzy_Level = (Dizzy_Level + 1)

Trigger:
Diszzy Start
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Dizzyness (Illutionist)
Collapse Actions
Set Dizzy_Victim = (Target unit of ability being cast)
Camera - Shake the camera for (Owner of Dizzy_Victim) with magnitude 300.00
Cinematic - Disable user control for (Player group((Owner of Dizzy_Victim)))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Dizzy_Level Equal to 1
Collapse Then - Actions
Countdown Timer - Start Dizzy_Timer as a One-shot timer that will expire in 1.00 seconds
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Dizzy_Level Equal to 2
Collapse Then - Actions
Countdown Timer - Start Dizzy_Timer as a One-shot timer that will expire in 2.00 seconds
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Dizzy_Level Equal to 3
Collapse Then - Actions
Countdown Timer - Start Dizzy_Timer as a One-shot timer that will expire in 3.00 seconds
Else - Actions
Trigger - Turn on Dizzy Effect <gen>

Trigger:
Dizzy Effect (Initially Off)
Collapse Events
Time - Every 0.50 seconds of game time
Conditions
Collapse Actions
Set DizzyEffectAngle = (Random angle)
Unit - Order Dizzy_Victim to Move To ((Position of Dizzy_Victim) offset by 50.00 towards DizzyEffectAngle degrees)

Trigger:
Dizzy Dies
Collapse Events
Unit - A unit Dies
Collapse Conditions
(Dying unit) Equal to Dizzy_Victim
(Remaining time for Dizzy_Timer) Greater than 0.00
Collapse Actions
Trigger - Turn off Dizzy Effect <gen>
Camera - Stop swaying/shaking the camera for (Owner of (Dying unit))
Cinematic - Enable user control for (Player group((Owner of (Dying unit))))

Trigger:
Dizzy End
Collapse Events
Time - Dizzy_Timer expires
Conditions
Collapse Actions
Trigger - Turn off Dizzy Effect <gen>
Camera - Stop swaying/shaking the camera for (Owner of Dizzy_Victim)
Cinematic - Enable user control for (Player group((Owner of Dizzy_Victim)))
Selection - Select Dizzy_Victim for (Owner of Dizzy_Victim)
08-14-2008, 11:35 AM#2
rulerofiron99
The reason it won't work is because there is only 1 Dizzy_Victim unit, so if it is cast again on another unit before the timer expires, the previous unit will be dizzy forever.

There's a jass way to solve this which I don't know, and then there's a (slightly less efficient) GUI way to solve it:

-Make a dummy unit with locust and no model, shadow and collision.
-Make a new targeted spell with a casting time of 1 for level 1, 2 for level 2, etc. No mana cost, allies targetable, no damage, .01 duration, etc. Add this spell to the dummy unit you created.
-Delete / disable all your old triggers for this spell.
-Make a new trigger: Event - ability is cast, condition - spell is dizziness, actions:
make (dummy unit) at position of targeted unit
set level of (dummy spell) for (dummy unit) to level of ability being cast
order last created unit to cast (dummy spell) on (target of ability being cast)
camera - sway camera for owner of target of ability
disable user control, etc
add a 1 + (level of ability being cast) expiration timer to last created unit

New trigger:
event - spell is cast
condition - spell is equal to (dummy spell)
remove (triggering unit)
enable control, stop swaying for owner of target of ability being cast.


EDIT: for the running around randomly, add targeted units to a unit group called DizzyUnits and remove them when the dummy unit dies. then for the dizziness, just make a trigger that picks every unit in DizzyUnits and orders them to run around randomly.

You might also want to remove those memory leaks.
Like this:
set TempPoint = position of unit
set TempPoint = TempPoint offset by 50 towards random angle
order unit to move to TempPoint
custom script: call RemoveLocation(udg_TempPoint)
08-14-2008, 02:36 PM#3
SmileyJeff
Wow great help! Really solved my problem! and now it runs smooth!
A few questions,
1. Do i always have to remove variable points? What does the leak do?
2. Which is better for custom spells using at event? (A unit starts an effect of an ability OR A unit begins casting an ability)

Thanks again! added rep to u
08-14-2008, 07:02 PM#4
Sophismata
Quote:
Originally Posted by SmileyJeff
Wow great help! Really solved my problem! and now it runs smooth!
A few questions,
1. Do i always have to remove variable points? What does the leak do?

You don't have to, but you should. When you leak, you're basically adding data to memory, and then forgetting to remove it. The GUI does this all the time.

Eventually, you'll run out of memory.


Quote:
Originally Posted by SmileyJeff
2. Which is better for custom spells using at event? (A unit starts an effect of an ability OR A unit begins casting an ability)

They are both useful.

"Starts the effect of an ability" is used when you want something to take effect at the moment a spell is cast.

"Starts casting an ability" is used when you want something to take effect the moment the casting animation starts (or would start, if there's no animation).

All units have a Cast Point and Cast Backswing:

Unit ordered to cast spell ---- Event: Unit given an order
Unit Starts casting spell ---- Event: Starts casting an ability
Unit reaches its Cast Point ---- Event: Starts the effect of an ability
Unit finishes its Cast Backswing --- Event: Unit finishes casting an ability
08-15-2008, 12:06 AM#5
rulerofiron99
Players with amazing micro would be able to trigger off the spell without manacost and cooldown, so rather use Starts Effect of Ability.

For the sake of world peace, remove all memory leaks.
Most common memory leaks are:
locations (points) - call RemoveLocation(udg_loc)
groups (unit grounds) - call DestroyGroup(udg_group)
forces (player groups) - call DestroyForce(udg_force)

udg = user defined global, basically all variables in GUI.

If you have further questions about leaks and advanced code, consult the Tutorials section. A wealth of knowledge, there is.

Thanks for rep :)
08-15-2008, 05:55 AM#6
SmileyJeff
Ah.. so i get the problem now! Gonna fix all the leaks with points.
Thanks for the help guys! All those were very very helpful!