• 0

    posted a message on Calculating pathing distance

    A unit with a fixed speed being timed traveling a distance would give you a pretty accurate Pathing cost I think, so long as this invisible unit has the same collision flags, and radius as the unit that it is plotting the pathing cost for. Make sure to give the invisible unit the same collision flags and radii (inner radius, movement radius, etc.).

    One obstacle is that the smallest iteration of timing in Triggers is 1/16 Second (or, 0.0625 Second). This could also lead to some inaccuracies. (More inaccuracies the faster the speed of the unit.)

    As far as making a unit completely invisible, try the "No Draw" flag in the Data Editor - Under unit. Furthermore, you can send an actor message to a unit to ModelSwap for the Invisible Target Dummy unit. As Rommsteinz said, it would be a good idea to set the unit's state to Unselectable, Uncommandable, and Invulnerable.

    Posted in: Triggers
  • 0

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

    I think that your problem may be either that you're using the wrong type of variable, or potentially your variable isn't actually not 0. Try manually setting a Real variable to 15, and test if it works then. Otherwise I'll check it out when I get a chance. You might need to use an integer variable, but like I said, try testing it a bit.

    Posted in: Triggers
  • 0

    posted a message on Simple Question - reset map

    Hey I've uploaded a Demo map that resets when you type the first letter of a race. It's set up to be a Build-Order tester. By typing either t, z or p into a chat message, the map will reset. You can see the three actions I've created, Spawn Zerg, Spawn Terran, and Spawn Protoss. I've also made an Action that clears the map for player 1.

    If you copy the Actions to your map, you can modify them to fit what you need. You would have to mod the Spawn Location Points (by creating points in your map that are relative to the spawn locations), and you'd have to make an Action that replaces the minerals and vespene geysers with fresh new ones. All of the basic functionality is there in this test map, however.

    I hope this helps you out.

    PS: Typically, if you need help with a Trigger, go to the Triggers forum instead of the Galaxy Scripting one.

    Good Luck!

    Posted in: Galaxy Scripting
  • 0

    posted a message on How to make a unit cheer through triggers

    Like I said before, you can Open the Cutscene Editor to preview the names of any and every unit's animations. Going into the Cutscene Editor, I opened up the Marine's Unit Model, and was able to find that the name of it's cheer animations were Stand Dance with additional variations called Stand Dance 01, Stand Dance 02, and Stand Dance 03.

    If you send an actor message to Play Animation Stand Dance, it will randomize between the different animations. (Stand Dance 00 - 04)

    I've attached a map that has a demo of making a unit cheer. Notice, though, that after the unit has started the animation, you can still move it. That could be a problem for you, or maybe not.

    Posted in: Triggers
  • 0

    posted a message on How to make a unit cheer through triggers

    I believe you can make this happen by sending an Actor message to the unit - If you go to the Cutscene Editor, where you can preview the 3d models of the units, you can look through their animations to check what the actual names the Cheer anim is named. But going off of memory, it's called Taunt, and all you have to do is a line like this:

    Send Actor Message to (Main Actor of (TheUnit)) to "AnimationPlay Taunt"
    

    If I had the editor open I could give you a test map, but hopefully you can get that far.

    You might have to make the unit uncommandable and immobile for the duration of the Animation if you want the unit to be unable to move during the Animation.

    Posted in: Triggers
  • 0

    posted a message on Is there a way to make r.click attack allies too if clicked?

    So... do you want it to function exactly like the built in Attack command?

    Attack does Not acquire allies, unless they're directly targeted via a deliberate mouse-click. Are you trying to remap Attack to the R key?... that wouldn't be very hard, all you'd have to do is go into the Ability tab and change the Attack ability's Hotkey to R.

    If that's not what you're trying to do, then please be very specific. There's a sub-Reddit on Reddit.com called "Explain It Like I'm 5 [years old]"

    Explain what you're trying to do like I'm 5 years old.

    Posted in: Data
  • 0

    posted a message on Some trigger problems

    I've attached a test map that successfully calculates Winrate when you type "- winrate" into chat.

    Check out my code to see how I did it. At Melee Initialization, I set up a fake statistic of Games Played = 7, I won = 4, and it successfully prints out "57"

    Posted in: Triggers
  • 0

    posted a message on (solved)Unit regenerates % of his max hp per sec.

    Like I said in the previous post near the 4806th paragraph, all you have to do is set the Hero Unit variable to a unit. Once you do that, the code will start healing them every per-second.

    At the code where your actual selected Hero unit is put onto the map (via Create Units), put this afterwards to set the Hero Unit to it:

         Create 1 Marine for Player 1 at Point(5,5)
         Set Variable - Hero Unit = Unit Last Created
    

    Don't use the Trigger Unit Is Created; just use the Set Variable command right after the line where you create the Hero Unit on the map to do so.

    Posted in: Triggers
  • 0

    posted a message on (solved)Unit regenerates % of his max hp per sec.

    Sure, this isn't too hard to whip up.

    You'll need to make 3 Global variables (by creating them in the Left-List, the List where your Triggers and Actions are located) and a new Trigger:

    • 1 Unit variable
    • 1 Timer variable
    • 1 Real variable
    • 1 Trigger

    For this example, we'll name the Unit variable HeroUnit, the Timer variable HP Timer, the Real variable HP Heal Percent and the Trigger to HP Timer Tick.

    First, start off by setting the Real HP Heal Percent value to a percentile of how much you'd like the hero to heal every time period. Make sure to divide your actual percent by 100 for the actual value, however. For example, to set the heal percent to 4%, you'd set this variable to 0.04. For 60%, you'd set it to 0.60. 100% would be simply just 1.00. Basically, take whatever Percent you'd like, and divide it by 100; that's what you'll set your Real variable to.

    Now, for the Timer. All we have to do is add one line of code to the Melee Initialization Trigger (which runs when your map is first loaded). This line of code will start our timer for us. The timer is initially not running, so we have to turn it on ourselves when the game starts. So, within the Melee Initialization Trigger, we'll add:

    Melee Initialization
            Timer - Start HP Timer as a Repeating timer that will expire in 1.0 Game Time seconds
    

    Now, if you want your timer to fire more often than 1 second, or less often (like once every 4 seconds), just change the "that will expire in X Game Time seconds" to however many seconds you'd like.

    So, now that the timer will be started, let's make sure that it actually does something now that is it going.

    In the HP Timer Tick Trigger, we'll first start by adding an event. The event will be "Timer Expires", and the Timer that will be checked is our HP Timer. We will also create a Local variable (with the type Real) here that we will use to calculate the amount of life that the unit receives. Also, we'll make one more variable called LifeMax that we will set to hold the value of our unit's Maximum Life property

    HP Timer Tick
         Events+
            Timer - HP Timer expires
    
         Local Variables
             Add Amount = 0.0 <Real>
             LifeMax = 0.0 <Real>
    

    So, what we will do is check to make sure that our variable Hero Unit is actually a valid unit, that is alive and kicking. Right now, as the game stands, Hero Unit is actually set to nothing (ie. No Unit). So, if we add 4% of No Units max life to No Unit, we'll probably get an error. So, just to be safe, we will add an If Then Else at the beginning of the Trigger to check if our Hero Unit is set to an actual alive-unit. If the unit is alive, then we will do the math and add our percentage to its health.

    The way we will do this is by multiplying the unit's Maximum Life property by our HP Heal Percent Real we created. Then, we'll store that answer in the Local Varable Add Amount that we made at the top of our trigger. And that'll pretty much do it!

    (Note: This the part of our HP Timer Tick Trigger)

         If   Unit Is Alive(Hero Unit) == True    Then
                    Variable - Set LifeMax = (Hero Unit Maximum Life (Current))
                    Variable - Set Add Amount = {LifeMax * HP Heal Percent}
                    Unit - Set Hero Unit Life to (Min({(Hero Unit Life (Current)) + Add Amount}, LifeMax))
         End If
    

    (notice I used a Min() function on the Set Unit Life. I didn't really get a chance to test this, so I just wanted to make sure that the Unit's life didn't heal up past its Maximum Life property. Hence the Min() function.)

    Now, everything is set up, and it should be ready to go! All you have to do now to get it to work: Whenever you create your unit that you'd like to be the one healed every whatever seconds by the percent, just use a Set Variable command, and set Hero Unit to that unit. Then, the timer will be running, and the Hero will automatically start being healed by our timer. If you don't Set Variable the Hero Unit, then when the timer ticks every second, if Hero Unit isn't a unit (or, is a Dead unit), the timer will essentially be doing nothing every 1 second (or however long you set the timer to.

    If you'd like, you can go through the HP Timer Tick code and replace my Hero Unit variable with any other valid Unit variable. I don't know if you already made a Player Hero variable or something, but all you have to do is replace my Hero Unit with your actual variable.

    Hope that gets you what you need!

    Posted in: Triggers
  • 0

    posted a message on Disable/destroy visibility revealer doesnt work :/
    Quote from Azzaaer: Go

    p.s. offtopic do i need to use global variables for such triggers like i did here (i wasnt sure if local variable isnt the problem so i have used global)? Are the local variables for triggers reseted each time the triggering event tuns the trigger?

    Correct; you should be using a Global variable for this function. To make a Global variable, do as SoulTaker916 posted:

    Quote from SoulTaker916: Go

    on the left make a new variable. the type needs to be revealer

    and make sure that after you create the variable, and give it a relevant name, like "Cheat Map Hack Revealer" or whatever you'll call it, definitely set the type of variable it is (there is a drop down list on the right window that is displayed, after you've selected the Global variable, to change what type it is) to Revealer.

    Then, when the cheat is entered, you'll end up doing something like this: (mind you this is pseudocode, and is meant for interpretation; you shouldn't copy-paste this directly into the Editor, and should instead read it and after understanding what it is meant to say then create the code)

    If map == 0 then
         Display "Maphack On"
         Create revealer for player (Triggering Player) within (Entire Map)
         SetVariable Cheat Map Hack Revealer = (Last created revealer)
         Enable Revealer (Cheat Map Hack Revealer)
         SetVariable map == 1
    Else
        Display "Maphack Off"
        **Disable** Revealer (Cheat Map Hack Revealer)
        Destroy Revealer(Cheat Map Hack Revealer)
        SetVariable map == 0
    End If
    

    Now, the reason you have to use a Global variable (one that is created on the master Left-List) as opposed to a Local variable (one that is created at the Top of the GUI Code editing window) is that when the Trigger is fully executed, and has finished its last line, the computer will destroy all of the local variables that were created in that function. If you created Cheat Map Hack Revealer in the Local scope, after the last line, "End If", the computer will have finished the code, and clear that Revealer variable out of memory, only to re-create an entirely new local variable the next time that the trigger is run.

    What you're trying to do, I can tell, is use that Same Revealer every time the code is run, turning it on and off depending on what state the Cheat is currently in. Since you want that Trigger, every time it runs, to turn on or off a single Revealer, make the Revealer variable Global. This way, it can be created and stay in memory, without being deleted and cleared out, and instead be saved for the next time when it is time to shut it off or on.

    Think about this:

    If map==1, and it is now time to shut our revealer off, how are we going to tell the computer which revealer to shut off? We could potentially have 100's of revealers! If we tell it to turn off a Local Variable, Cheat Map Hack Revealer, remember this: the Cheat Map Hack Revealer variable is created new every time (staring out referencing Nothing as its set revealer) the Trigger is run - therefore, there is no possible way that Cheat Map Hack Revealer is referencing the revealer that we created when the cheat was turned on; the reference was deleted after the End If of when we turned it on, so there is no longer a way to control it!

    BUT

    If we used a Global Variable, there is a never-deleted Cheat Map Hack Revealer variable that won't be erased and recreated automatically. So, in the code, if we have the Global variable (Global being shared between all code, referencing one-unique revealer that never gets deleted) then when we say 'Disable Revealer (Cheat Map Hack Revealer), we are for-sure shutting off the one that we created last time the trigger made one.

    Hope that didn't confuse you, and hopefully you don't have trouble reading my pseudocode ;)

    Posted in: Triggers
  • 0

    posted a message on Some trigger problems

    It could be two things: If I won[1] is set to 0, then pretty simply you'll be getting a 0 as the answer.

    OR...

    If the Winrate[] variable is an integer, sometimes the parsing of Set Variable function will take each element into account as an integer. For example, the I won[1] / Games played[1] part could be getting truncated/rounded down to 0 when you do the calculation; truncated/rounded because you are implicitly telling the computer to turn a Lower-Than-1 number (eg. 0.4) into an integer, so it is stripping off the decimal section of the number. You could try explicitly naming the entire set-value to a real like so to make sure it does the division calculation as a Real, and after the 100 times multiplication, only then turns it into an integer:

    • Variable - Set Winrate[1] = Convert Real To Integer(100 * I(I won[1] / Games played[1]))

    Alternatively:

    • Variable - Set Winrate[1] = ((I won[1] * 100) / (Games played[1] * 100))
      • EDIT - The above code should actually be:
    • Variable - Set Winrate[1] = ((I won[1] * 100) / (Games played[1]))

    Let me know if that's what the problem was.

    Posted in: Triggers
  • 0

    posted a message on Automatic Scrolling Textbox

    I just whipped one up, it's a bit different in how it works. The text scrolls by itself, sort of like how Diablo II's scrolling text worked. This is an already finished up thread, but hey, might as well post it! Maybe someone will get use from it.

    The demo of the map (if you run it) shows whatever you type in scroll in 4 different ways (Scroll Down and Scroll Left with two styles of both). The styles are as follows:

    • Scroll: Text will scroll through the dialog, without stopping, and dissapear after it has scrolled entirely through to the other side.
    • Scroll Into View: Text will scroll unitil it reaches the point where the entire text fits into view, and then stop. It will then wait for a moment and then dissapear.

    4 Action definitions in this demo:

    • Scroll Text Horizontal
    • Scroll Text Vertical
    • Scroll Text Into View Horizontal
    • Scroll Text Into View Vertical

    You can have the text scroll up, down, left or right, in both of the previously mentioned styles. For the scroll into view functions, you can specify how long the text will linger after it has made it into view (Specified in seconds by a Real parameter).

    If there is too much text to fit into the dialog, you may have to break up the message into multiple Text Scrolls.

    Hope someone gets some use from this!

    EDIT: Hah, seems like I just kind of missed the point with my version: My browser wasn't letting me play the game, so I just assumed that you meant what I had posted. Lol, regardless.. I guess it's here now! Sorry for the irrelevance!

    Posted in: Triggers
  • 0

    posted a message on Custom Script Question

    It is pretty easy to use a String variable to play whatever files you want on the fly for this application.

    What you'll need is:

    • A String Variable (or, if you want to make an Action/Function that does the action via a parameter, a String Parameter)
    • One simple line of code that executes a Sound via input of a String (ie. name of sound link)

    I have attached a map that has two functions in it:

    • RunSoundLink
    • RunSoundTrack

    To use the two actions, just give it a string, and it plays the SoundLink, or starts the SoundTrack with that exact name. You can also play the map for a demo of how it works, and then look at the code under the "Chat" trigger to see how I am executing the code.

    For future reference, in the trigger editor, you can press CTRL+ F11 to view the Custom Script source of any GUI Code you make. If you make a command with the GUI, and would like to see what that command looks like in Custom Script, just push CTRL + F11. You will be shown a window containing ALL of the trigger code in your map organized by the order from top to bottom of all of your GUI and Custom Scripts. You can scroll down to find any code you have in the Map, including the Custom Script view of all GUI code.

    So, if you want to know how to do a GUI command in Custom Script, first write the code with the GUI editor, and then push CTRL + F11 to scroll down to where that code is to see how it looks in Custom Script.

    Hope that helps!

    Posted in: Triggers
  • 0

    posted a message on "Unit is attacked" not working?

    The GUI editor, although convenient, sometimes doesn't properly display what functions work for specific events. Although it is greyed out, it should still work.

    For example, a lot of triggers have the "Triggering Player" function greyed out, but it will still return you the "Triggering Player" if you use the greyed out version. Give it a shot and let me know if it works.

    Posted in: Triggers
  • 0

    posted a message on Custom Script Question

    Hey man, I want to help too, but you're going to have to tell us exactly what it is you're trying to do here:

    I just can't understand what you want. You said: "About making a pick how do I change the Custom Script? thanks for the reply btw." I just don't quite understand what you mean about making a Pick.... do you mean, you'd like to Pick a different sound? You'd like to be able to change which sound the custom script will play while the game is running? What it kind of sounds like you want might be...

    Do you want to be able to specify what sound to play on the fly? Maybe... using a String variable?

    Tell us what exactly you want and we'll be happy to help you.

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