• 0

    posted a message on Detecting unit ownership change - Possible?

    @Fullachain: Go

    I dont think theres a built in event for this specifically, but im not 100% positive. You could of course keep track of every unit manually and detect when a unit has a new owner, but thats not very elegant. You could probably make a "custom event" yourself to do it, as shown here: http://rileystarcraft.blogspot.com/2010/06/tutorial-create-custom-trigger-hooks.html However, if you are using triggers to change unit ownership, wouldnt it be much easier to put your code there, or are you doing it some other way or something?

    Posted in: Miscellaneous Development
  • 0

    posted a message on Hardcore triggering...Connect the dots!

    @ctccromer: Go

    Yeah you dont explain very well at all exactly what you mean by connect the dots. Is the user supposed to pick 2 dots to connect, and need to draw lines between them and only "unlock" when a door outline is made, or what? Either way, seems like it could be done pretty easily to me.

    Posted in: Miscellaneous Development
  • 0

    posted a message on Ability to gain minerals? Help :(

    @LeetBox: Go

    You can do this purely in the data editor too, its really simple and does what you want. And since this is so simple you really should use the data editor instead of a trigger so you have one less trigger running and hurting performance, this way is more efficient. I assume you already have your ability set up somewhere with a button that you click in game?

    Then just go to data editor, go to the"Effects" data type tab, right-click the top-left list box and choose "Add Object...". Name it like "Add Minerals" and click the suggest button, then in the "Effect Type:" drop down box, choose "Modify Player" and click OK. Now make sure you have table view selected (menu View->Show Table View, its just easier) and select the newly created "Add Minerals" effect on the left if it isnt already. Now look at the table on the right, find the "Effect - Resources" field, double click the cell next to it, choose Minerals, and type the value you want in the box below, and hit OK. Now go to the "Abilities" data type tab and select your ability. Make sure its of the type "Effect - Instant", if it isnt, double click it and you can change the ability type. Now double click next to the "Effect - Effect" field, click the green button to add a new entry, find "Add Minerals" in the list, hit ok, and should be all set to go.

    Seems like alot, but thats only because I explained every step. Takes like 10 seconds.

    Posted in: Miscellaneous Development
  • 0

    posted a message on Serious Item Problem

    @Jinxxx123: Go

    I figured out a crude work around for disabling purchasing items from a shop if your heroes inventory is full. This works with one player, might need to be modified for multiple heroes/players slightly, im sure some other people can improve on this greatly.

    I created a Hero Inventory Full Buff that utilizes a Search Area effect that applies the buff onto nearby neutral structure/etc (the shop), use filter to filter out everything but the shops. So thats a Behavior buff, a search area effect, and an apply behavior effect so far. Then I made a requirement InventoryNotFull that does (!CountBehavior(HeroInventoryFullBuff,CompleteOnlyAtUnit)). Then change the shop item commands to use this requirement. So when the heros inventory is full, he gets the inventory full buff, which scans small area around him and applies it also to any shops, when you try to use the shop with inventory full, it requires itself to NOT have the buff so you cant buy anything. Clear an inventory space and the buff goes away. Then I made a trigger:

    Global vars:

    EmptySlots = (Number of Items Empty for Hero) <Integer>
    Hero = Hero [63.04, 64.30] <Unit>
    

    Trigger:

        Events
            Timer - Every 2.0 seconds of Game Time
        Local Variables
        Conditions
        Actions
            Unit - Remove 1 Hero Inventory Full Buff from Pawn Shop [70.50, 68.50] from 1
            Variable - Set EmptySlots = (Number of Items Empty for Hero)
            General - If (Conditions) then do (Actions) else do (Actions)
                If
                    EmptySlots < 6
                Then
                    Unit - Add 1 Hero Inventory Full Buff to Hero from 1
                Else
                    Unit - Remove 1 Hero Inventory Full Buff from Hero from 1
    

    I had empty slots < 6 because I was using Bifuu's hero tutorial map and it has 5 slots that regular items cant be put into so. Also I was still fooling around with how exactly to apply and remove the buff from the shop and stuff since I couldnt figure out how to have the shop check the hero for the buff instead of itself. But anyways, like I said, this works like a charm for 1 hero/1 player, besides the removing from the shop every 2 seconds that is. Put a low period on the search area effect. Using this way each player and hero would have to have their own buff type so they could be distinguished, unless a slightly more clever way of distinguishing when the hero has the buff is made, but I dont want to spend the time heh. The function to get inventory items is:

    UnitInventoryCount (unit Unit, int CountType);
    
    Where Unit is the hero, and CountType is an integer of one of the following:
    c_unitInventoryCountCarried   = 0;  // Number of carried items
    c_unitInventoryCountEmpty     = 1; // Number of item slots open
    c_unitInventoryCountTotal       = 2; // I assume this is total number of inventory slots
    

    Hope this helps some of you to improve on this.

    Posted in: Miscellaneous Development
  • 0

    posted a message on Help with Rescources

    @RobertMinson: Go

    This should work. Just change the loop increment to how many you want spawned, the variable x controls how much resources it gets, and the point/offsets determine position, etc.

    Map Init
        Events
            Game - Map initialization
        Local Variables
            i = 0 <Integer>
            offsetY = 0.0 <Real>
            offsetX = 0.0 <Real>
            center = (Center of (Playable map area)) <Point>
            x = 1000.0 <Real>
        Conditions
        Actions
            General - For each integer i from 1 to 10 with increment 1, do (Actions)
                Actions
                    Unit - Create 1 Mineral Field for player 1 at (center offset by (offsetX, offsetY)) facing 180.0 degrees (No Options)
                    Unit - Set (Last created unit) Resources to x
                    Variable - Set x = (* (0.9, x))
                    Variable - Set offsetX = (offsetX + 1.0)
                    Variable - Set offsetY = (offsetY + 1.0)
    
    Posted in: Miscellaneous Development
  • 0

    posted a message on Text question

    @Thalassicus: Go

    I havent been able to reproduce your problem lol. All of my < and > show up correctly, even inside of a colored tag. I used UI - Display text to display a text variable that i set to some random letters and <> and tags and it comes out perfectly fine. Even a regular string does too. Not sure why it isnt working for you, perhaps its the way you are doing it or the functions you are using? Also you could try StringToText("bl<a>h") and see if that works for you.

    Posted in: Miscellaneous Development
  • 0

    posted a message on Getting the region of overlapping regions

    @kaji2: Go

    Seems like your best bet to me would be to write a custom function to procedurally generate all the regions for you since you know where they need to be. You could have a 2 dimensional region array to store the intersections and write a loop that loops from 0 to 12, (or 0 to 11 depending on how exactly youre defining the intersections, basically however many there are) then another loop inside that one that loops the same. Then in the innermost loop calculate the new region position based on say i and j (the loop counters), then use something like convert rectangle to region based on those variables and a hard coded width/height and set the Regions[i][j] = to that region. Now you have 144 regions with a few lines of code and can use them in your triggers. Also if you didnt mind using circles you could make it slightly simpler and make the array points instead of regions and store a single point for each intersection then use the trigger unit enters within X of point[][].

    Not sure exactly how you would set up the triggers in a nice way using the array, since i havent played around with triggers much yet, but im sure there is a solution like above where you could write a minimal amount of code to handle it all, im not sure.

    Posted in: Miscellaneous Development
  • 0

    posted a message on Action as a Result of This?

    @Quickshot14: Go

    Wouldnt this be much more efficient and work better?

    Make a global variable BeaconUnit of type Unit. Set it to the beacon you want to use this for. Create a trigger like before, but instead of Any Unit, use BeaconUnit, and in actions set the variable. Then copy that trigger to a new one, and change "Selected" to "Deselected" and change the boolean from true to false, done. Not sure if this works, but seems like it would and be exactly what you want, without running a trigger for EVERY unit selected too.

    Events
       Unit Selection - BeaconUnit is Selected by player Any Player
    Actions
       Set variable = true
    
    Events
       Unit Selection - BeaconUnit is Deselected by player Any Player
    Actions
       Set variable = false
    
    Posted in: Miscellaneous Development
  • 0

    posted a message on Need some trigger help

    @Zero0018: Go

    Have you tested this outside of that trigger? For example, create a new trigger with only that in it, or change that trigger and wait for a unit to die, but use the hard coded player number instead: Leaderboard - Minimize Leaderboard for (Player group(1)) and see if that still minimizes for all players? If it does then it would seem its the minimize function itself, but if not then its your trigger thats to blame.

    Posted in: Miscellaneous Development
  • 0

    posted a message on Need some trigger help

    I would imagine you should be able to. I havent tried to decrypt what youre trying to do from the mess above too much so im not sure exactly on the problem, but it seems to me that this block of text:

     General - If (Conditions) then do (Actions) else do (Actions)
                If
                    (Unit type of (Triggering unit)) != Auto Turret (Lv1)
                    (Unit type of (Triggering unit)) != Auto Turret (Lv2)
                    (Unit type of (Triggering unit)) != Auto Turret (Lv3)
                    (Unit type of (Triggering unit)) != Teleporter Entrance
                    (Unit type of (Triggering unit)) != Teleporter Exit
                Then
    ********THIS BLOCK************
                      \/ \/ \/
                    Variable - Set Dying Unit[(Owner of (Triggering unit))] = (Unit type of (Triggering unit))
                    Variable - Set Unit Alive[(Owner of (Triggering unit))] = false
                    Timer - Start Respawn Timer[(Owner of (Triggering unit))] as a One Shot timer that will expire in 15.0 Real Time seconds
                    Variable - Set Respawn Timer[(Owner of (Triggering unit))] = (Last started timer)
                    Timer - Create a timer window for Respawn Timer[(Owner of (Triggering unit))], with the title "Repawn In:", using Remaining time (initially Visible)
                    Variable - Set Respawn Timer Window[(Owner of (Triggering unit))] = (Last created timer window)
                    Timer - Show Respawn Timer Window[(Owner of (Triggering unit))] for (Player group((Owner of (Triggering unit))))
                    Leaderboard - Minimize Leaderboard for (Player group((Owner of (Triggering unit))))
                    General - Wait 15.0 Real Time seconds
                    General - For each integer A from 1 to 12 with increment 1, do (Actions)
    

    is part of the first if..then..else statement and that is why its being triggered for everyone because its being told to.

    That what it seems like anyways. Either way, my advice to you is to disable that large trigger, make a new one to use, and strip it down to only what the problem is so you can better see what is happening, then come back with that so its not cluttered with the rest of your stuff. Also you can look at the script code perhaps to get a more clean look at the logic.

    Edit: Also you could add in some debugging messages in places to see how the code is being run, for example, by the leaderboard minimize action, put a UI Display message action for example that spits out some variables, like the owner of triggering unit, etc, that way you can see where the problem is.

    Posted in: Miscellaneous Development
  • 0

    posted a message on Creating a Unit Respawn Trigger [Solved]

    @Dekuleaf: Go

    Deku, I think something such as this is what you are looking for, quite simple really (make sure you play around with events/actions, search for functions youre looking for, etc.)

    Make a global variable say PlayerUnits of type Unit, make it an array of size 15 (1 for each possible player, doesnt matter how many players you actually are going to have):

    PlayerUnits = No Unit <Unit[15]>
    

    In your trigger where you spawn the unit for a player, make an action that adds that unit to the variable, something like:

    Variable - Set PlayerUnits[(Owner of (Last created unit))] = (Last created unit)
    

    Im not sure if this next part works exactly, but it would be something very similar if not. Make a new trigger, Player Unit Dies or whatever. Make the event:

    Unit - PlayerUnits[(Triggering player)] dies
    

    Now in the actions, respawn the unit.

    Posted in: Miscellaneous Development
  • 0

    posted a message on When to use timers vs wait? Or action queues?
    Quote from ChewableProzac: Go

    Thanks. I just tried playing around with some action definitions, but I didn't foresee it stalling the trigger until the actions were complete. Is there any way to continue a trigger without waiting until action definition finishes?

    Perhaps try making the action definition its own "thread". Click the action definition its in the list of checkbox options (create thread). Not sure if this will do the trick, but may.

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