• 0

    posted a message on Drag-Build

    Try this.

    When "Key Pressed by user" happens, switch a boolean to either True or False that holds whether shift is being held.

    Then, when the mouse moves, do this in this order: First, you'll need a global variable - call it 'MouseOldPosition' or whatever makes sense for your map. You'll also need a global variable - 'ShiftWasDown'

    ( next part is psuedocode ):

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

    if ( ShiftWasDown AND MousePosNow IS NOT EQUAL TO MouseOldPosition )
    {
    
        /* we try to put a barracks at every point between MouseOldPosition and MousePosNow*/
        real variable ANGLE = angle between points (MouseOldPosition and MousePosNew);
        real variable DIST = DistanceBeteweenPoints(MouseOldPosition, MousePosNew);
        real variable X_PLUS = 0.75 * SizeOfOneBulildingSquare;
        real variable X = 0.0;
    
        LOOP WHILE ( X < DIST)
        {
    
           Create A "BARRACKS" at  PointOffsetByAngle (MouseOldPosition, ANGLE, X);
           
            X = X + X_PLUS;
        }
    }
    
    MouseOldPosition = MousePosNow;
    

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

    That is the general idea of the algorithm. It will do exactly what you want, and will not have any problems with mouse laginess, regardless of how fast you move your cursor around. The idea is that the algorithm doesn't care if you move your mouse super fast - it will fill in the path between the OLD positiona nd the NEW position in a line with the building.

    Posted in: Triggers
  • 0

    posted a message on Path calculation problem

    I think the answer here to your question is pretty obvious:

    The position of the structure is NON pathable, becase there is a structure there. The hexes the structure sits on is unpathable - a unit cannot walk to the center of a building. A unit CAN, however walk to the edge of a building.

    If you path to the center of a building, and say a unit actually tires, it will never reach the destination. It will walk to the structure, bump into the edge, and try to force itself inside the building to the center. Impossible. Answer = 65,535.

    Path to the edge of the building. Problem solved.

    Posted in: Triggers
  • 0

    posted a message on Equation for horizontal jump

    Here's a parabolic graph that is created when you give it two parameters: Height, and Time.

    If you plan on making a Jump Ability, though, try looking at Missile Movers. Here's a mini tutorial that I'm just remembering off the top of my head. This is entirely in the Data Editor, but is pretty simple:

    Open the Data Editor, and make your way into the Movers tab

    1. Create new mover (by right clicking and selecting Add New Mover or something...)
    2. Call it Jump Mover
    3. Go to sub property of this mover called Motion Phases, and double click it.
    4. There's a list at the top of this page that shows how many motion phases you have for the mover. We want to only have 1. Delete all extra Motion Phases if there are any extras.
    5. After deleting the extras, select the one that you have left by highlighting it. Scroll a tiny bit down to where the drop down box is and change the Motion Type to Ballistics

    There are only up to two properties on this window that you should look at. All the other ones are basically Irrelevant. The first one is Gravity. Gravity will determine how high the jump will go. Gravity at 10 will make for a short jump. Increase it to 100 and you'll have a higher jump.

    The other two properties are Flight Time, or Speed. You can only pick one of these two, and should leave the other one at its default setting. If you specify the Flight Time, this will determine how long the jump lasts for, and the speed will be calculated automatically. If you set the Flight Time to 0.1 second, the unit will jump really fast, and reach its landing target within that time. If you increase it to 10 seconds, the unit will jump to its landing target much slower, perhaps giving the impression of a slow-motion jump.

    If you leave Flight Time alone, and modify Speed, you will instead specify how fast the unit is going, and the Flight Time setting will be automatically calculated and irrelevant. Let's say your Unit is jumping to a very far away place. If you set the Speed setting to 1, it will take a very long time for the jump to be completed (slow-motion-esque). If you increase the speed, to say 15, the jump will happen much more fast and probably end up looking more realistic.

    After we've completed the tutorial, and you've got the jump basically working, you can come back later and tweak these settings to get them right. Once you've set this up, all you have to do now are 3 more simple things: Create an Effect, Create an Ability, and Add the Ability to the unit.

    To Create the Effect, in the Data Editor:

    1. Open the Effects tab
    2. Right click to Add New Effect (Type = Launch Missle)
    3. Call the effect Jump
    4. Once Created, set the Ammo Unit = None (if set to None, instead of launching a new ammo bullet unit, the Caster Unit itself is the ammo)
    5. Also set the Impact Death Type = None (this will make the unit not die when he lands)
    6. Set Target Location, or Impact Location = Target Point or something... I can't remember the name exactly. Should be easy to find.
    7. Set the Mover = Jump Mover (the one we created earlier)

    Now, in the Data Editor still, open the Abilities tab.

    1. Right click to Add New Ability (Type = Effect - Target)
    2. Name the Ability Jump
    3. Set the Effect field to our Jump effect.
    4. Now, set the Default Button up (with a picture and a hotkey, so that you can soon add it to your Unit's abilities).
    5. You can name it too if you want, or you can come in later and change it after you've confirmed it has worked.

    Now, lastly in the Data Editor, open the Units tab.

    1. Go to the unit that you want to add Jumping to, and go into that unit's abilities.
    2. Add the ability we made Jump to the list of the abilities the unit has.
    3. Open the units Command Card and make sure you put a button for the ability on the grid there. If you don't see the ability in the list of possible abilities for the command card, that's because your Ability itself in the Abilities tab doesn't have the Default Button set up properly. It's annoying, but you have to do that step of setting up the Default Button in order to add the ability to a Unit's command card.

    Now, give yourself a unit of that type, fire up the game, and see if when you use that ability and click a point on the ground, the Unit Jumps!

    Good Luck

    Posted in: Triggers
  • 0

    posted a message on evolving the WASD move system into an analog system

    I don't think this is a native thing you could do, but..

    Perhaps if you put Mouse Relative On, and then used the Mouse Moved event?

    You would then set up via your Control Panel (or System Preferences on mac) to have the joystick control mouse movement. In game, you would, anytime the mouse is moved, push the character in that direction.

    Maybe this would work?

    Posted in: Triggers
  • 0

    posted a message on [Solved] Need trigger for worker behavior

    @decemberscalm: Go

    Try to confirm that the custom value of the Mineral Patches is indeed 1 while an SCV is targeted on it, and 0 when no SCV is. I would do this by using SendActorMessageToUnit to the Minerals (to SetTintColor to a red) and removing the visual when the SCV's have ended mining on it (ClearTint). Or, you could run TextMessage to print out a message for visual feedback.

    You may potentially have to add Any unit uses gather at execute stage to get the second trigger to fire.

    Posted in: Triggers
  • 0

    posted a message on Setting variable arrays in one line?

    I know what you mean - in a regular programming language, you'd be able to do such a thing, but I'm just about 90% sure you cannot do that within a trigger. You'll have to break it up onto multiple lines, unfortunately...

    I often find small annoyances like this in the editor - simple things that, by lack of a basic feature, take excessive amounts of work-arounds and time.

    Posted in: Galaxy Scripting
  • 0

    posted a message on 45 second timed unit spawning from beacon that turns off after 3 turns

    Okay, so let's assume there are 5 countries. I would start off by making 3 global arrays with 5 size:

    • Countries <Regions>
    • CountryOwner <Integer>
    • TurnsOwned <Integer>

    ...and one preset:

    • CountryPreset <Preset> Set up the preset like so:
    • 0. None
    • 1. North America
    • 2. South America
    • 3. Africa
    • 4. Europe
    • 5. Asia

    (Make sure to make the first value preset (at position 0) named ''None)

    After you have these set up, run this code at the end of a turn, when the units would be spawned and the turn is over:

    Local Variables:
         i <integer>
    
    For Each Integer 1 to 5 Increment 1
         If TurnsOwned[i] < 3
              Create Units At Point (1 Marine for Owners[i] at Center of Region(Countries[i])
         End If
         TurnsOwned[i] += 1
    End For
    

    Now, when a player receives a country, run this Action (you will have to create this action):

    Give Country( Player <Integer>, Country <CountryPreset>){
              c = ConvertPresetToInteger( Country )
    
              If( Player != CountryOwner[c])){
                   TurnsOwned[c] = 0
                   CountryOwner[c] = Player
              }
         
         }
    }
    

    That should do the trick for ya, or at least get you close. There might be a change that you want to make: If a player steals a country, BUT the original player takes back the country Before the turn ends, should that player have his spawns reset? If so, you'll have to mod it a little bit.

    Good Luck

    Posted in: Triggers
  • 0

    posted a message on Upgrade max. Ammo Problem

    Is the ammo actually in the Data section? Or do you have an Integer variable holding the ammo amount that's checking to see if he can continue to shoot?...

    Posted in: Triggers
  • 0

    posted a message on [Solved] Need trigger for worker behavior

    Here is a quick mockup of something in Pseudocode. This is not REAL code, but if you translate it into code, it should work.

    Workers will, when told to mine, check to see if a Mineral Patch is occupied by another worker (this is done by changing the mineral patch's custom value at position 0 to 1). SCVs will avoid using this mineral patch if it is already targeted by another SCV. Now, if there are no open patches, the SCV will just go with its original target.

    Trigger - Unit uses Gather Ability at stage Execute
    
    	Local Variables:
    		MineralFields <UnitGroup>
    		BestPatch <Unit> = TargetedUnit
    		PathingDist <int>
    		PathingDistBest <int> = PathingcostBetweenPoints ( Position of TriggeringUnit, Position of BestPatch)
    
    
    if( Custom Value 0 of BestPatch == 1){
    
    	MineralFields = All MineralFields within 10 Radius from BestPatch
    
    	Pick Each Unit in MineralFields{
    		PathingDist = PathingCostbetweenPoints ( Position of TriggeringUnit, Position of PickedUnit)
    		if(Custom Value 0 of PickedUnit == 0){
    			if(PathingDist < PathingDistBest){
    				BestPatch = PickedUnit
    				PathingDistBest = PathingDist
    			}
    	
    	}
            if (BestPatch is NOT TargetedUnit){
                      Set Custom Value 0 of BestPatch to 1
            }
    }
    
    UnitIssueOrder( TriggeringUnit to Gather from BestPatch)
    

    The Trigger below is to reset the Custom Value of the mineral patch once it has been either Successfully mined, or mining has been canceled for whatever reason.

              Trigger - Unit uses Gather Ability at stage Complete
              Trigger - Unit uses Gather Ability at stage Cancel
    
    
              Set CustomValue 0 of Targeted Unit to 0
    

    You will have to add some more to the code to get it to work flawlessly, but this is a good starting point.

    Good Luck

    Posted in: Triggers
  • 0

    posted a message on Need help on galaxy scripting and more general problems

    The best way to figure out the Galaxy equivalent of GUI code is to write a line of code in the GUI, and then push CTRL + F11 to open up a Script window that shows you the raw code of all of your Triggers combined.

    1. There is a function "Convert Circle To Region" that you can look at here. The main parameters are a radius, and a point. You specify the center point, and a circular region is generated with a radius you specify around that point.

    You could create this in standard GUI Code, and after you've successfully created this line of code, press CTRL + F11 to open the Script window I was talking about and scroll down the window until you find the line of code you've written in the GUI. In this window, it will display the Galaxy Script version of that line of code.

    2. The function you're looking for to compare whether a point is in a region is "Point Is In Region" which is documented here. To use it, create an If statement, and as the condition, you should have If (Point Is In Region(pt, reg) == true) then.. Again, remember if you want to get the Galaxy Script version of this line of code, open up the Script Window.

    3. This one is a little hard to understand... You would like to make a visual effect fill up the area of this region, I take it... but for how long? If it's not a fixed amount of time, what condition will end the visual effect? This one is a little hard to follow... care to explain a little more?

    Posted in: Galaxy Scripting
  • 0

    posted a message on Unit Selection Trigger, Help Needed!!!

    ... Then set the player that pushed ENTER's selected unit type to the pickled unit.

    That is the basic gist of how it works. I'm assuming you are using variables to hold what unit belongs to what player. You can use these unit variables to check unit types. You can so this by using the "unit type of unit" function.

    Sorry about the formatting (and the misuse of the acronym FYI). I've made this reply from my phone.

    Hope that helps you out. Post again of you need more help.

    Posted in: Triggers
  • 0

    posted a message on Unit Selection Trigger, Help Needed!!!

    When a player makes a unit selection, you need to make it check to make sure the Unit they're trying FYI select hasn't been picked by any other player. If a unit has been selected, you need a way of making sure no one else can pick it. In order to check if a unit has been picked, you'll have to make either X boolean variables, or one array boolean variable with a size of X. These boolean will hold either true or false depending on whether the Unit has been selected.

    So, let's say you have five units, just for example's sake, and when a player presses ENTER you check to see if the player can select it.

    On the left windows pane, create a global boolean array with a size of five. Name this variable Unit Selected Now, when a player pushes ENTER,

    • check to see if the boolean is set to true, meaning the Unit is already selected (the Unit Selected boolean that is)
    • if it isn't true, set it to true. If it is true, display a message that says "unit is selected already"

    Now, only so the following if the variable was false when you did the check (that is, if the Unit wasn't selected yet)

    • after setting the boolean to true, wait 1 second
    • now check all players selected units. If no player's selected unit type equeals the Unit that the player pushed enter on,
    Posted in: Triggers
  • 0

    posted a message on Counter Clockwise Boolean

    This has to be a troll..

    There is no way to make a Counter-Clockwise Boolean, EVERYONE knows that.... so instead you convert the boolean to a clock, start it backwards.

    hope that helps!

    Posted in: Triggers
  • 0

    posted a message on Waiting for Player Dialog Box

    I like that you have a lot of questions, that's really cool! But you have to be more specific when you ask. Please, try to be more specific... what is a Waiting For Player dialog box, and what do you use it for?

    When you make a new Forum Post, you should Make the title "Waiting For Player Dialog Box", but then you should include "The Waiting for Player Dialog Box is a box that shows All the players in the game which players haven't selected their hero, blah blah blah~ and when the player has finally blah, the box disappears." It's very hard and it wastes me and YOU a lot of time when your first post doesn't explain. I post a question, "What do you mean"? Then you explain, then the next time I see what your answer is, I give you help.

    If you just be more specific in your initial post, I can give you the answer really fast!

    Posted in: Triggers
  • 0

    posted a message on [solved] Setting a unit exp value on creation.

    I also have tested this, and can confirm that setting some unit's Experience to anything, even explicitly setting the experience to "15" doesn't work. Some units, I think, don't have the ability to have experience. I believe the problem lies in the data editor somewhere.

    Using a test unit Marine, I tried setting the Experience property of the unit (via Set Unit Property - Experience "15", and also tried looping a Modify Unit effect that adds 1 experience 15 times. The output of the Unit's Property afterward was still "0". There must be a Data property somewhere that either enables experience, or changes the maximum experience of a Unit to greater than 0.

    Any experts out there?

    PS: I've read somewhere about a Behavior named "Veterancy", but the editor does not have such a behavior. I believe if you add this behavior to a unit, it will allow it to start gaining experience, but searching through the Data editor I couldn't find it. It may have been a problem that I only used Wings of Liberty as my only dependency, and maybe if I added Heart Of the Swarm in there as well, I would have the Behavior in my data editor...

    Posted in: Triggers
  • To post a comment, please or register a new account.