HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Destructibles

06-04-2008, 02:13 AM#1
ronaldedkin
Trigger:
Events
Unit - A unit Begins casting an ability
Conditions
Actions
Collapse Destructible - Pick every destructible in ((Region centered at (Target point of ability being cast) with size (125.00, 125.00)) offset by (800.00, 800.00)) and do (Actions)
Collapse Loop - Actions
Destructible - Kill (Picked destructible)

Hello everyone. This is my first post on these forums and I am a noob map editor. I'm looking forward to learning all that I can about triggers from this community.

ATM, I am just messing around with triggers. And was wondering how I could fix this one. What I am trying to do is have my ability destroy all destructibles that it comes across using an ability similar to a "Shockwave".

I got the 125 from the Area of Effect and the 800 from the Distance. I read the tutorial made by Earth-Fury about "Offsets and Polar Offsets. But I'm pretty sure I'm doing something wrong. Can anyone help me?
06-04-2008, 03:47 AM#2
Vexorian
right now , all your trigger is doing is kill all the destructibles on a rect of side 125.0 that's off by 800.0 units both horizontally and vertically.

1) Continue towards the tutorial and read the part about polar off set.
2) You probably want a line, and not a rectangle?
06-04-2008, 04:56 AM#3
ronaldedkin
Of course a Polar Offset would be what I am looking for. But the only options it gives me are the following:

- Current Camera Bounds
- Initial Camera Bounds
- Playable Map Area
- Entire Map
- Region Offset
- Conversion - Convert Point With Size to Region
- Conversion - Convert Coordinates to Region
- Conversion - Convert Points to Region

It never gave me an option for Polar Offset. Unless I have a corrupted WE or I am becoming blind. I am at a fault with no idea on how to approach this.
06-04-2008, 05:39 AM#4
rulerofiron99
Get out of region mentality.

Polar Offset is under POINTS, the same as regions.
06-04-2008, 03:35 PM#5
ronaldedkin
Awesome! I found it. But I came across something I don't understand. This is my trigger so far.

Trigger:
Destructible - Pick every destructible in (Region(((Target point of ability being cast) offset by 800.00 towards (Facing of (Triggering unit)) degrees), (Point(0.00, 0.00)))) and do (Actions)
Collapse Loop - Actions
Destructible - Kill (Picked destructible)

What do I do with the other Point? Or am I, at this moment, even doing this trigger correctly?
(Note: 800 will be adjusted later. Just used that number to look for a reaction in the destructibles.)
06-05-2008, 06:39 AM#6
Pyrogasm
Well, you have to use some point variables, like so:
Trigger:
Set TempPoint1 = (Target point of ability being cast)
Set TempPoint2 = (TempPoint1 offset by 800.00 towards (Facing of (Triggering unit)) degrees)
Set TempRegion = Region Centered at TempPoint2 with dimensions 100.00, 100.00 <I'm pretty sure that's not the right wording, but it's close enough>
Collapse Destructible - Pick every destructible in TempRegion and do (Actions)
Collapse Loop - Actions
Destructible - Kill (Picked destructible)
Custom Script: call RemoveLocation(udg_TempPoint1)
Custom Script: call RemoveLocation(udg_TempPoint2)
Custom Script: call RemoveRegion(udg_TempRegion)
Now, my intuition tells me that this leaks a rect because of how GUI handles region/rect things, so this might be a better approach:
Trigger:
Custom script: local rect R
------- Make the above line the FIRST line of this trigger, no matter what else is there -------
Set TempPoint1 = (Target point of ability being cast)
Set TempPoint2 = (TempPoint1 offset by 800.00 towards (Facing of (Triggering unit)) degrees)
Custom script: set R = RectFromCenterSizeBJ(udg_TempPoint2, 200.00, 200.00)
Custom script: call RegionAddRect(udg_TempRegion, R_=)
Collapse Destructible - Pick every destructible in TempRegion and do (Actions)
Collapse Loop - Actions
Destructible - Kill (Picked destructible)
Custom Script: call RemoveLocation(udg_TempPoint1)
Custom Script: call RemoveLocation(udg_TempPoint2)
Custom Script: call RemoveRegion(udg_TempRegion)
Custom Script: call RemoveRect(R)
Custom Script: set R = null
06-05-2008, 06:41 AM#7
Rising_Dusk
Why do you even post it as GUI when it might as well be jass? Just convert it and tell him to CnP it. :p
06-05-2008, 07:08 AM#8
Pyrogasm
Because I personally like to have things presented to me an at least a vaguely decipherable manner and so I assume others would too. Anyway...
Collapse JASS:
library DestructibleEnums initializer Init //You can do either circle or square with this
    globals
        private real CX = 0.00
        private real CY = 0.00
        private rect R = null
        constant integer DENUM_TYPE_CIRCLE = 1
        constant integer DENUM_TYPE_SQUARE = 2
        private boolexpr B = null
        private integer T = 0
        private real R = 0.00
    endglobals

    private function True takes nothing returns boolean
        return true
    endfunction

    private function Enum takes nothing returns nothing
        local destructible D
        local real X
        local real Y

        if T == DENUM_TYPE_CIRCLE then
            set D = GetEnumDestructible()
            set X = GetDestructibleX(D)
            set Y = GetDestructibleY(D)

            if (CX-X)*(CX-X)+(CY-Y)*(CY-Y) < R then
                call KillDestructible(D)
            endif

            set D = null
        elseif T == DENUM_TYPE_SQUARE then
            call KillDestructible(GetEnumDestructible())
        debug else
            debug call BJDebugMsg("Error: Unknown type in DestructibleEnums; check "Type" argument.")
        endif
    endfunction

    function KillDestructibleArea takes location L, real Width, real Height, integer Type returns nothing
        set CX = GetLocationX(L)
        set CY = GetLocationY(L)
        set Width = Width/2
        set Height = Height/2
        set T = Type

        if Type == 1 then
            set R = Width*Height
        endif

        call SetRect(R, CX-Width, CY-Height, CX+Width, CY+Height)
        call EnumDestructiblesInRect(R, B, function Enum)
    endfunction

    private function Init takes nothing returns nothing
        set R = Rect(0.00, 0.00, 0.00, 0.00)
        set B = Condition(function True)
    endfunction
endlibrary
And you would call it like so:
Trigger:
Set TempPoint1 = (Target point of ability being cast)
Set TempPoint2 = (TempPoint1 offset by 800.00 towards (Facing of (Triggering unit)) degrees)
Custom script: call KillDestructibleArea(TempPoint2, 250.00, 500.00, DENUM_TYPE_SQUARE)
------- Or Perhaps: -------
Set TempPoint1 = (Target point of ability being cast)
Set TempPoint2 = (TempPoint1 offset by 800.00 towards (Facing of (Triggering unit)) degrees)
Custom script: call KillDestructibleArea(TempPoint2, 300.00, 300.00, DENUM_TYPE_CIRCLE)
If you use circles, make sure that both the Height and Width are equal when calling the function.
06-05-2008, 07:27 AM#9
Rising_Dusk
Quote:
Originally Posted by Pyrogasm
Because I personally like to have things presented to me an at least a vaguely decipherable manner and so I assume others would too.
He apparently speaks English, which is mostly all that's necessary to decipher the difference between your GUI and the JASS result.
06-05-2008, 07:52 AM#10
ronaldedkin
Unfortunately I have put in and tried to use any of your triggers Pyrogasm. It seems to be the custom scripts that give me the fatal error when I test the map through WE. Maybe I did something wrong, but it looks very similar to what is posted.

And, I can understand GUI far better than I can JASS. I don't know much about JASS and how to use it, but this is a different topic.
06-06-2008, 01:14 AM#11
Pyrogasm
Fatal error...? Hmm...
If you're using the 2nd GUI one, change this:
Trigger:
Custom script: call RegionAddRect(udg_TempRegion, R_=)
------- Should be -------
Custom script: call RegionAddRect(udg_TempRegion, R)
06-06-2008, 02:53 AM#12
ronaldedkin
Woo! Got it to work. Appreciate the help guys. :)