• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

The Destroy Sister Waygate Problem

Status
Not open for further replies.
Level 3
Joined
Aug 29, 2004
Messages
57
Hey guys, I got a rather complicated problem for u all.

I have a waygate connected to another waygate.
(You may know of this from my previous problems I've posted here.)

What I've been trying to do is make it so when u kill one of the waygates (I've set them so they can be attacked.) its sister waygate will automatically be destroyed via a trigger.

Of course I haven't been successful at doing this. There seems to be no trigger command that refers to sister waygates at all. Can any of you help me out here?
 
Level 4
Joined
Aug 31, 2004
Messages
106
You're making it more complicated for yourself than it needs to be. Just assign each waygate to a variable. Then when one of the pairs is destroyed, just destroy the variable you assigned the pair to. You do not need a special trigger for that.
 
Level 3
Joined
Aug 29, 2004
Messages
57
Actually make that a very complicated problem. I'm sure this could be rectified in Jass but I'm really hoping there's a simpler trigger solution. I guess JASS is still welcome though.

You see I have a map in which you can BUILD waygates. A trigger automatically makes sister waygates that are hooked up to the built waygates upon completion of their construction. That means u just don't have two waygates u must assign variables to but an undetermined amount that the player will build.

Technically you could use two arrays to hold the built waygates and their sister waygates. Then you could simply determine the index of the killed waygate and kill the corresponding index of its sister waygate (The two arrays must have corresponding indexes, entrance-exit style.) but that would require extremely large arrays and waste memoryspace, besides, I'm not even sure it's doable with triggers in the first place.

Any help on this?
 
Level 3
Joined
Mar 7, 2004
Messages
27
Err...again. You still make it sound too tough. Just make it like you said. Have two seperate arrays. Now, the problem with this is that the array has to be as large as how many pairs of waygates are possible to be out on the map at one time (Hopefully not many...)

Sooo...i'm going to JASS it for efficiency:

Code:
function your_trigger_actions takes nothing returns nothing
   local unit u = GetDyingUnit()
   local integer i = 0
   loop
      exitwhen ( GetBooleanOr( Waygate1[i] = u, Waygate2[i] = u )
      set i = ( i + 1 )
   endloop
   set u = null
   call ExplodeUnitBJ( Waygate1[i] )
   call ExplodeUnitBJ( Waygate2[i] )
endfunction

Just make sure you set the created waygates to UNASSIGNED vars in the Waygate1 and Waygate2 arrays.


That simple :D

Edit: Damn BJs :p
 
Level 3
Joined
Aug 29, 2004
Messages
57
With all due respect to your input there's still a memory space issue. Having a huge array with indexes that have nothing in them is a waste of memory. Even making new variables for each new waygate and sister waygate would save more space. :(
 
Level 3
Joined
Mar 7, 2004
Messages
27
You are going to waste more space by leaving an unused unit spell than a size-100 array.

I'm pretty sure you won't come NEAR that number. Explain the system to me, how many players can do it, and how long they last?
 
Level 3
Joined
Aug 29, 2004
Messages
57
Basically 8 players have builders who can build waygates on one half of the map I am making. When any waygate is completed a trigger will detect this and create a new waygate on a random point (stored in a variable) on the other half of the map and then proceed to link them up. That way units can move through the waygates between the map halves. The waygates last forever.

Then I had the idea that I presented here, which is that when you kill any of the waygates (built or created) then the waygate it is linked to will be automatically be destroyed via a trigger.

I think it's safe to say that each player will have several waygates, at least 1 per guy and around 6 max for any one person according to how I set my resources to allow this.

That's all there is to it.
 
Level 3
Joined
Aug 29, 2004
Messages
57
Hey about your JASS script:

Code:
function your_trigger_actions takes nothing returns nothing 
   local unit u = GetDyingUnit() 
   local integer i = 0 
   loop 
      exitwhen ( GetBooleanOr( Waygate1[i] = u, Waygate2[i] = u )   %<----Problem Area% 
      set i = ( i + 1 ) 
   endloop 
   set u = null 
   call ExplodeUnitBJ( Waygate1[i] )   %<----Problem Area% 
   call ExplodeUnitBJ( Waygate2[i] )   %<----Problem Area% 
endfunction

It errors up saying that 3 lines of it expected a name. I made sure all of the waygates are properly stored of course and substituted the right names in for your variables, however in every line that involves either variable, Waygate1 or Waygate2, the editor says it expects a name and won't run the trigger. I do have some programming experience and all of your code looks pretty sound. Maybe it's just a syntax problem? Damn BJs? I am not totally familiar with JASS keywords or format.

Or maybe it's just my variables? I named them WaygateA and WaygateB respectively and they are size 100 arrays. They were created the standard non-JASS way so I'm guessing they're global.

Everytime someone builds a waygate the constructed structure is stored within the index of WaygateA which goes up 1 each time via a counter (initialized at 0). The subsequent newly created sister waygate is also stored into WaygateB which also goes up by one each time via the same counter. This way built waygates and sister waygates will have the same index number in the 2 arrays. Which should work perfectly with the script but just doesn't.

Any thoughts on this?
 
Level 3
Joined
Mar 7, 2004
Messages
27
It was your variables. You named them A and B so update the code to:

JASS:
function your_trigger_actions takes nothing returns nothing
   local unit u = GetDyingUnit()
   local integer i = 0
   loop
      exitwhen ( GetBooleanOr( udg_WaygateA[i] = u, udg_WaygateB[i] = u )
      set i = ( i + 1 )
   endloop
   set u = null
   call ExplodeUnitBJ( udg_WaygateA[i] )   
   call ExplodeUnitBJ( udg_WaygateB[i] )   
endfunction
 
Level 3
Joined
Aug 29, 2004
Messages
57
Here we go again:

It errors up and says I need a "==" in this line:

exitwhen ( GetBooleanOr( udg_WaygateA = u, udg_WaygateB = u )

So I tried replacing the "=" signs with "==" signs and the problem went away. However then it said that the line needed a ")". So I inserted a ")" at the end and the trigger finally seemed to not have any problems. So I tried it in game and....yeah, it doesn't work.

I build and kill a waygate and well.. nothing happens. Its sister waygate is still up and running. It even teleports units to the now dead waygate's original spot.
Huh? Was this part of the complication you had earlier?
 
Status
Not open for further replies.
Top