System Open Close Gate

H34DhUnT3r

Ultra Cool Member
Reaction score
36
Hello,

I'm not sure where to post this kind of stuff, but here it goes:

==============================================

Gate Demo by H34DhUnT3r[NL]

This gives a buildable gate with an open and close ability

Uses:
- 3 triggers
- 3 variables
- 2 regions
- 1 custom unit (the gate)
- 1 custom ability (open and close)

The triggers:

This trigger will create pathing blockers at the place where a gate is build.. It also gives the gate the Open Close ability and sets the ability to 1.. The open close ability is one ability with 2 levels.. 1 level for open and one level for close..

Code:
PlaceGate
    Events
        Unit - A unit Finishes construction
    Conditions
        (Unit-type of (Constructed structure)) Equal to Horizontal Gate
    Actions
        Set GatePlaceTmp = (Position of (Constructed structure))
        Destructible - Create a Pathing Blocker (Both) (Large) at GatePlaceTmp facing (Random angle) with scale 1.00 and variation 0
        Destructible - Create a Pathing Blocker (Both) (Large) at (GatePlaceTmp offset by 128.00 towards 0.00 degrees) facing (Random angle) with scale 1.00 and variation 0
        Destructible - Create a Pathing Blocker (Both) (Large) at (GatePlaceTmp offset by 256.00 towards 0.00 degrees) facing (Random angle) with scale 1.00 and variation 0
        Destructible - Create a Pathing Blocker (Both) (Large) at (GatePlaceTmp offset by 128.00 towards 180.00 degrees) facing (Random angle) with scale 1.00 and variation 0
        Destructible - Create a Pathing Blocker (Both) (Large) at (GatePlaceTmp offset by 256.00 towards 180.00 degrees) facing (Random angle) with scale 1.00 and variation 0
        Unit - Add OpenClose Gate  to (Constructed structure)
        Unit - Set level of OpenClose Gate  for (Constructed structure) to 1
        Custom script:   call RemoveLocation(udg_GatePlaceTmp)

This trigger will remove the pathing blockers when the gate is destroyed.. this has to be done with a region, because the offset action can only place not remove.. It also creates (and destroys) a special effect (an explosion)..

Code:
DestroyGate
    Events
        Unit - A unit Dies
    Conditions
        (Unit-type of (Dying unit)) Equal to Gate
    Actions
        Set GateDieTmp = (Position of (Dying unit))
        Region - Center GateRegionHori <gen> on GateDieTmp
        Destructible - Pick every destructible in GateRegionHori <gen> and do (Destructible - Remove (Picked destructible))
        Special Effect - Create a special effect at GateDieTmp using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
        Custom script:   call RemoveLocation(udg_GateDieTmp)
        Special Effect - Destroy (Last created special effect)

This trigger controls the open close ability when the open gate (level 1) is casted it opens the gate with a animation and destroys the middle 3 pathing blockers (with a region).. it doesn't destroys the pathing blockers at the end (those are placed on the "towers") this way you can walk trough the gate, but it doesn't let you to walk trough both ends..
when the open gate is cast it sets the ability to 2 so that the close gate ability gets available.. same way if it's closed then the level will be set back to 1..

Code:
OpenCloseGate
    Events
        Unit - A unit Finishes casting an ability
    Conditions
        (Ability being cast) Equal to OpenClose Gate 
    Actions
        Set GateOpenCloseTmp = (Position of (Casting unit))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Level of OpenClose Gate  for (Casting unit)) Equal to 1
            Then - Actions
                Region - Center GateRegionHoriOpenClose <gen> on GateOpenCloseTmp
                Animation - Play (Casting unit)'s death alternate animation
                Destructible - Pick every destructible in GateRegionHoriOpenClose <gen> and do (Destructible - Kill (Picked destructible))
                Unit - Set level of OpenClose Gate  for (Casting unit) to 2
                Game - Display to (Player group((Owner of (Casting unit)))) the text: Gate Opened
                Custom script:   call RemoveLocation(udg_GateOpenCloseTmp)
                Skip remaining actions
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Level of OpenClose Gate  for (Casting unit)) Equal to 2
            Then - Actions
                Region - Center GateRegionHoriOpenClose <gen> on GateOpenCloseTmp
                Animation - Play (Casting unit)'s stand animation
                Destructible - Pick every destructible in GateRegionHoriOpenClose <gen> and do (Destructible - Resurrect (Picked destructible) with (Max life of (Picked destructible)) life and Hide birth animation)
                Unit - Set level of OpenClose Gate  for (Casting unit) to 1
                Game - Display to (Player group((Owner of (Casting unit)))) the text: Gate Closed
                Custom script:   call RemoveLocation(udg_GateOpenCloseTmp)
            Else - Actions

I know that there are people that think that this is not needed as you have the "destructible" gate.. but with that one there isn't an open and close gate like this and it can't be used in battle, cuz you cant build/attack it (yes you can attack it, but it's still a neutral passive (or something like that).. this way you can actually build, open and close the gate.. with the risk of it being destroyed by other players..

Hope you like it.. Plz comment

Greetings,
H34DhUnT3r[NL]

H34DhUnT3r[NL]'s Custom War 3 TFT Maps

P.S. Not sure if it's leak free.. can someone check plz?
 

Attachments

  • GateDemo.w3x
    18.5 KB · Views: 263

Tinki3

Special Member
Reaction score
418
>I'm not sure where to post this kind of stuff

In this forum - Tutorials, Spells and Trigger Code.

Could you please explain what each trigger does, that'll at least give you more points for the written part, and will help people understand what's going on in each one.
 

Sim

Forum Administrator
Staff member
Reaction score
534
In the second trigger:

> (Unit-type of (Dying unit)) Equal to Horizontal Gate
> If - Conditions
> (Unit-type of (Dying unit)) Equal to Horizontal Gate

Why check 2 times? Once in the trigger conditions is enough.

On a side note: Try not to end all your sentences with 2 dots. Looks bad when trying to explain the system :p You also have a couple spelling mistakes, such as "with the risc of it being destroyed by other players.."
It should be "risk".
 

H34DhUnT3r

Ultra Cool Member
Reaction score
36
>Why check 2 times? Once in the trigger conditions is enough.

I first wanted to create a Horizontal and a Vertical Gate, but that didn't work and i forgot to erase the 2nd condition

>You also have a couple spelling mistakes

I count one and i don't think that risc or risk is important, i mean you have corrected it so you damn sure knew what i meant..

And if that is all you can find (1 condition to many and a spelling mistake), why not compliment me cuz that's is one reason why i putted here. If I've done right I pretty much want to hear it :p

Greetings,
H34DhUnT3r[NL]
 

Sim

Forum Administrator
Staff member
Reaction score
534
> And if that is all you can find

Alright Mr.Headhunter, now that I tested it more... efficiently, here we go:

1. When I place my gate the pathing blockers don't get removed unless I place it at the entrance of the hallway. Pathing blockers are not that easy to play with and so if you build the gate while it touches the mountain sides, the pathing blockers will bug. You need to tell the player to build the gate correctly, it must not touch the mountains.

For better testing I suggest you enlarge a bit the space used to test the gate.

2. You shouldn't block both air and ground units. Why should a air unit be blocked by a door? ;)

3.
Code:
Destructible - Create a Pathing Blocker (Both) (Large) at [B](GatePlaceTmp offset by 128.00 towards 0.00 degrees)[/B] facing (Random angle) with scale 1.00 and variation 0
Destructible - Create a Pathing Blocker (Both) (Large) at [B](GatePlaceTmp offset by 256.00 towards 0.00 degrees)[/B] facing (Random angle) with scale 1.00 and variation 0
Destructible - Create a Pathing Blocker (Both) (Large) at [B](GatePlaceTmp offset by 128.00 towards 180.00 degrees)[/B] facing (Random angle) with scale 1.00 and variation 0
Destructible - Create a Pathing Blocker (Both) (Large) at [B](GatePlaceTmp offset by 256.00 towards 180.00 degrees)[/B] facing (Random angle) with scale 1.00 and variation 0

Point leaks.

4. Once I destroyed the gate, peasant wouldn't build an additional gate. He would just stand there.

5.
Code:
Special Effect - Create a special effect at GateDieTmp using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
Custom script:   call RemoveLocation(udg_GateDieTmp)
[B]Wait 1.00 seconds[/B]
Special Effect - Destroy (Last created special effect)

Don't wait.

6. This system is far from being MUI. Indeed, only one gate can be built at any time, and not even more than one!

One gate in a map is far from being useful, unfortunately, and rendering this system MUI would be rather complicated.

7.
Code:
DestroyGate
    Events
        Unit - A unit Dies
    Conditions
        (Unit-type of (Dying unit)) Equal to Horizontal Gate
    Actions
        Set GateDieTmp = (Position of (Dying unit))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Unit-type of (Dying unit)) Equal to Horizontal Gate
            Then - Actions
                Region - Center GateRegionHori <gen> on GateDieTmp
                Destructible - Pick every destructible in GateRegionHori <gen> and do (Destructible - Remove (Picked destructible))
                Special Effect - Create a special effect at GateDieTmp using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
                Custom script:   call RemoveLocation(udg_GateDieTmp)
                Special Effect - Destroy (Last created special effect)
            Else - Actions

Becomes

Code:
DestroyGate
    Events
        Unit - A unit Dies
    Conditions
        (Unit-type of (Dying unit)) Equal to Horizontal Gate
    Actions
        Set GateDieTmp = (Position of (Dying unit))
        Region - Center GateRegionHori <gen> on GateDieTmp
        Destructible - Pick every destructible in GateRegionHori <gen> and do (Destructible - Remove (Picked destructible))
        Special Effect - Create a special effect at GateDieTmp using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
        Custom script:   call RemoveLocation(udg_GateDieTmp)
        Special Effect - Destroy (Last created special effect)

And fix that spelling mistake.
 

H34DhUnT3r

Ultra Cool Member
Reaction score
36
Now,, this is useful

With this kind of replies I can work on it..

2. You shouldn't block both air and ground units. Why should a air unit be blocked by a door?

4. Once I destroyed the gate, peasant wouldn't build an additional gate. He would just stand there.

5. Don't wait

6. This system is far from being MUI. Indeed, only one gate can be built at any time, and not even more than one!

One gate in a map is far from being useful, unfortunately, and rendering this system MUI would be rather complicated.

7. <Code etc>

Risc->Risk

All Fixed

1. When I place my gate the pathing blockers don't get removed unless I place it at the entrance of the hallway. Pathing blockers are not that easy to play with and so if you build the gate while it touches the mountain sides, the pathing blockers will bug. You need to tell the player to build the gate correctly, it must not touch the mountains.

I see, well i tried to fix it, but it's just that on some places the tmppoint of the constructed unit isn't completely in the middle so the "Region - Center GateRegionHoriOpenClose <gen> on GateOpenCloseTmp" doesn't always come in the middle and that way it doesn't remove the pathing blockers..

3. Point Leaks

Well if you can tell me how to fix this i'll be glad to. I'm not really familiar with memory leaks, so if you can tell me how to fix it, then i'll do it:)

I think i've made all the changes or explanations so plz take a look at it and give me some feedback, like the one from Daxtreme.. That's useful :)

Greetings,
H34DhUnT3r[NL]
 

Sim

Forum Administrator
Staff member
Reaction score
534
Points with offset are a bit more complicated. At least, the way it is right now you have 1 leak of the 2 removed in each case, but there are still 4 leaks remaining.

Code:
Destructible - Create a Pathing Blocker (Ground) (Large) at [B](GatePlaceTmp offset by 128.00 towards 0.00 degrees)[/B] facing (Random angle) with scale 1.00 and variation 0
Destructible - Create a Pathing Blocker (Ground) (Large) at [B](GatePlaceTmp offset by 256.00 towards 0.00 degrees)[/B] facing (Random angle) with scale 1.00 and variation 0
Destructible - Create a Pathing Blocker (Ground) (Large) at [B](GatePlaceTmp offset by 128.00 towards 180.00 degrees)[/B] facing (Random angle) with scale 1.00 and variation 0
Destructible - Create a Pathing Blocker (Ground) (Large) at [B](GatePlaceTmp offset by 256.00 towards 180.00 degrees)[/B] facing (Random angle) with scale 1.00 and variation 0

Set a point variable to that value (Yes, you need 2 points. The first one being the origin and the second one the first one offset by a value towards an angle) and remove it. Like this:

Code:
Actions
    Set GatePlaceTmp = (Position of (Constructed structure))
    Set GatePlaceTmp2[1] = (GatePlaceTmp offset by 128.00 towards 0.00 degrees)
    Destructible - Create a Pathing Blocker (Ground) (Large) at [B]GatePlaceTmp2[1][/B] facing (Random angle) with scale 1.00 and variation 0
    Set GatePlaceTmp2[2] = (GatePlaceTmp offset by 256.00 towards 0.00 degrees)
    Destructible - Create a Pathing Blocker (Ground) (Large) at [B]GatePlaceTmp2[2][/B] facing (Random angle) with scale 1.00 and variation 0
    Set GatePlaceTmp2[3] = (GatePlaceTmp offset by 128.00 towards 180.00 degrees)
    Destructible - Create a Pathing Blocker (Ground) (Large) at [B]GatePlaceTmp2[3][/B] facing (Random angle) with scale 1.00 and variation 0
    Set GatePlaceTmp2[4] = (GatePlaceTmp offset by 256.00 towards 180.00 degrees)
    Destructible - Create a Pathing Blocker (Ground) (Large) at [B]GatePlaceTmp2[4][/B] facing (Random angle) with scale 1.00 and variation 0
    Custom script:   call RemoveLocation(udg_GatePlaceTmp)
    For each (Integer A) from 1 to 4, do (Actions)
        Loop - Actions
            Custom script:    call RemoveLocation(udg_GatePlaceTmp2[bj_forLoopAIndex])

----------------

I'm curious as to how you even test your map too...

Code:
Melee Initialization
    Events
        Map initialization
    Conditions
    Actions
        Melee Game - Use melee time of day (for all players)
        Melee Game - Limit Heroes to 1 per Hero-type (for all players)
        Melee Game - Give trained Heroes a Scroll of Town Portal (for all players)
        Melee Game - Set starting resources (for all players)
        Melee Game - Remove creeps and critters from used start locations (for all players)
        Melee Game - Create starting units (for all players)
        Melee Game - Run melee AI scripts (for computer players)
       [B] Melee Game - Enforce victory/defeat conditions (for all players)[/B]

This line ends the game right away. How do you know everything is fixed?

As a matter of fact, almost nothing important got fixed.

1. When I place my gate the pathing blockers don't get removed unless I place it at the entrance of the hallway. Pathing blockers are not that easy to play with and so if you build the gate while it touches the mountain sides, the pathing blockers will bug. You need to tell the player to build the gate correctly, it must not touch the mountains.

As far as I can tell the gate still didn't work. Tested twice.

2. You shouldn't block both air and ground units. Why should a air unit be blocked by a door? ;)

This got fixed.

3.
Code:
Destructible - Create a Pathing Blocker (Both) (Large) at [B](GatePlaceTmp offset by 128.00 towards 0.00 degrees)[/B] facing (Random angle) with scale 1.00 and variation 0
Destructible - Create a Pathing Blocker (Both) (Large) at [B](GatePlaceTmp offset by 256.00 towards 0.00 degrees)[/B] facing (Random angle) with scale 1.00 and variation 0
Destructible - Create a Pathing Blocker (Both) (Large) at [B](GatePlaceTmp offset by 128.00 towards 180.00 degrees)[/B] facing (Random angle) with scale 1.00 and variation 0
Destructible - Create a Pathing Blocker (Both) (Large) at [B](GatePlaceTmp offset by 256.00 towards 180.00 degrees)[/B] facing (Random angle) with scale 1.00 and variation 0

Point leaks.

Just explained to you how to fix them.

4. Once I destroyed the gate, peasant wouldn't build an additional gate. He would just stand there.

I couldn't build a second gate once the first one died.

5.
Code:
Special Effect - Create a special effect at GateDieTmp using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
Custom script:   call RemoveLocation(udg_GateDieTmp)
[B]Wait 1.00 seconds[/B]
Special Effect - Destroy (Last created special effect)

Don't wait.

Fixed.

6. This system is far from being MUI. Indeed, only one gate can be built at any time, and not even more than one!

One gate in a map is far from being useful, unfortunately, and rendering this system MUI would be rather complicated.

This is still a problem,

7.
Code:
DestroyGate
    Events
        Unit - A unit Dies
    Conditions
        (Unit-type of (Dying unit)) Equal to Horizontal Gate
    Actions
        Set GateDieTmp = (Position of (Dying unit))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Unit-type of (Dying unit)) Equal to Horizontal Gate
            Then - Actions
                Region - Center GateRegionHori <gen> on GateDieTmp
                Destructible - Pick every destructible in GateRegionHori <gen> and do (Destructible - Remove (Picked destructible))
                Special Effect - Create a special effect at GateDieTmp using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
                Custom script:   call RemoveLocation(udg_GateDieTmp)
                Special Effect - Destroy (Last created special effect)
            Else - Actions

Becomes

Code:
DestroyGate
    Events
        Unit - A unit Dies
    Conditions
        (Unit-type of (Dying unit)) Equal to Horizontal Gate
    Actions
        Set GateDieTmp = (Position of (Dying unit))
        Region - Center GateRegionHori <gen> on GateDieTmp
        Destructible - Pick every destructible in GateRegionHori <gen> and do (Destructible - Remove (Picked destructible))
        Special Effect - Create a special effect at GateDieTmp using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
        Custom script:   call RemoveLocation(udg_GateDieTmp)
        Special Effect - Destroy (Last created special effect)

It got fixed.

There are still 3 important matters that simply prevent this system from working.

> Now,, this is useful

Wait wait wait... Are you saying my other post was useless?

> With this kind of replies I can work on it..

Indeed, there's work to do!
 

H34DhUnT3r

Ultra Cool Member
Reaction score
36
Well if you can tell me how to fix this i'll be glad to. I'm not really familiar with memory leaks, so if you can tell me how to fix it, then i'll do it

I quote myself here... you are complaining that this isn't fixed. Duh.. i told you it wasn't fixed and with the question "how the hell do i fix it"?

This line ends the game right away. How do you know everything is fixed?

Uhm.. ever saw the continue game button? It's right above the quit button -_-

I couldn't build a second gate once the first one died.

Well, for some reason I can.

Wait wait wait... Are you saying my other post was useless?

yes i do, but you made it all good with the 2nd post ;)

>Indeed, there's work to do!

Yes there is but at the moment i don't have the time so.. will update soon though

Anyway thank you Daxtreme and i'll keep you posted :)

Greetings,
H34DhUnT3r[NL]
 

Sim

Forum Administrator
Staff member
Reaction score
534
You said everything was fixed.

In truth it wasn't.

All Fixed

> I quote myself here... you are complaining that this isn't fixed. Duh.. i told you it wasn't fixed and with the question "how the hell do i fix it"?

Where the hell did you get that complaining?

> yes i do, but you made it all good with the 2nd post

...

> Well, for some reason I can.

The peasant just stops right away, after I destroyed one gate.

Anyways, I'm eager to see those "fixes".
 

Hero

─║╣ero─
Reaction score
250
Why did you make this so complicated...it can be done much easier in many ways
 

Linear88

New Member
Reaction score
2
Couldn't you just switch off the gate's collision size? It would be easier. Don't use points for gates because you'll block a large amount of space(the gate's small).
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top