HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Failed "detect nearest unit" trigger, need halp

08-25-2009, 02:49 AM#1
TwistedFirestarter
So this is what its supposed to do:
The targeted hero is tied up to the nearest object within 250 range, whether its a tree, a unit, or a building.
If there are no units, trees, or buildings the targeted hero will be ensnared.

Currently the effects are all over the place. From my tests, the code in the destructible and "no units, tree or building" part is sound a.k.a the beginning and end are fine. Just the massive bulk in the middle is riddled with bugs that i cannot seem to see.

I think the bug(s) have/has got to do with detecting whether or not the system has picked up a "nearest unit" and how it stores this info. Anyway, please and thank you.

Warning: Following is a massive wall of code
Code

Trigger:
Tie em up
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Tie em up!
Collapse Actions
Unit - Kill TieemupDummy
Unit - Kill TieemupDummy2
Set TieemupUnitCaster = (Casting unit)
Set TieemupTarget = (Target unit of ability being cast)
Set TieemupPositionZ = (Position of TieemupTarget)
Collapse Destructible - Pick every destructible within 250.00 of (Position of TieemupTarget) and do (Actions)
Collapse Loop - Actions
Set TieemupNearestDoodad = (Picked destructible)
Set TieemupPositionX = (Position of TieemupNearestDoodad)
Collapse Destructible - Pick every destructible within 250.00 of (Position of TieemupTarget) and do (Actions)
Collapse Loop - Actions
Set TieemupPositionY = (Position of (Picked destructible))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Distance between TieemupPositionZ and TieemupPositionY) Less than (Distance between TieemupPositionZ and TieemupPositionX)
Collapse Then - Actions
Set TieemupNearestDoodad = (Picked destructible)
Else - Actions
Custom script: call RemoveLocation(udg_TieemupPositionY)
Unit - Create 1 Tie em up! Dummy for (Owner of TieemupUnitCaster) at (Position of TieemupNearestDoodad) facing Default building facing degrees
Set TieemupDummy = (Last created unit)
Unit - Order TieemupDummy to Human Dragonhawk Rider - Aerial Shackles TieemupTarget
Custom script: call RemoveLocation(udg_TieemupPositionX)
Custom script: call RemoveLocation(udg_TieemupPositionZ)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
TieemupNearestDoodad Equal to No destructible
Collapse Then - Actions
Set TieemupNearestUnit = (Random unit from (Units within 250.00 of (Position of TieemupTarget) matching (((Matching unit) Not equal to TieemupTarget) and (((Matching unit) belongs to an enemy of (Owner of TieemupUnitCaster)) Equal to True))))
Set TieemupPositionX = (Position of TieemupNearestUnit)
Collapse Unit Group - Pick every unit in (Units within 250.00 of (Position of TieemupTarget)) and do (Actions)
Collapse Loop - Actions
Set TieemupPositionY = (Position of (Picked unit))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Distance between TieemupPositionZ and TieemupPositionY) Less than (Distance between TieemupPositionZ and TieemupPositionX)
Collapse Then - Actions
Set TieemupNearestUnit = (Picked unit)
Else - Actions
Custom script: call RemoveLocation(udg_TieemupPositionY)
Unit - Create 1 Tie em up! Dummy for (Owner of TieemupUnitCaster) at (Position of TieemupNearestUnit) facing Default building facing degrees
Set TieemupDummy = (Last created unit)
Unit - Order TieemupDummy to Human Dragonhawk Rider - Aerial Shackles TieemupTarget
Unit - Create 1 Tie em up! Dummy for (Owner of TieemupUnitCaster) at (Position of TieemupTarget) facing Default building facing degrees
Set TieemupDummy2 = (Last created unit)
Unit - Order TieemupDummy2 to Human Dragonhawk Rider - Aerial Shackles TieemupNearestUnit
Custom script: call RemoveLocation(udg_TieemupPositionX)
Custom script: call RemoveLocation(udg_TieemupPositionZ)
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
TieemupNearestUnit Equal to No unit
Collapse Then - Actions
Unit - Create 1 Tie em up! Dummy for (Owner of TieemupUnitCaster) at (Position of TieemupTarget) facing Default building facing degrees
Unit - Order TieemupDummy to Orc Raider - Ensnare TieemupTarget
Set TieemupDummy = (Last created unit)
Collapse Else - Actions
Do nothing
Set TieemupNearestDoodad = No destructible
Set TieemupNearestUnit = No unit



…
08-25-2009, 09:12 AM#2
Fluff
In your big, long "If, Then, Else" section you use the Condition:

TieemupNearestDoodad Equal to No destructible

But, I think that it won't be equal to No Destructible, because you set that variable to a destructible in the first section. I think you meant to use a condition to check if:

TieemupNearestUnit Equal to No unit

Hope that's not too confusing, but basically you use your 'destructible' variable in your 'unit' section of the trigger. That's as far as I got right now, but I'll check back later.