• 0

    posted a message on Preserving existing orders while loading a unit - I can't figure this one out!

    I've done a bit more research on this particular problem and it looks like there are multiple behaviors that are (or were formerly, based on the date of the posts I was reading) applied to units that are targeted by the load command and the game chooses between them based on how close the transport is. I've been looking for these behaviors though and haven't found anything yet. Ideally I'll be able to suppress the one the target recieves and force the game to use the other one, but I don't know if such a thing is actually possible.

    Posted in: Triggers
  • 0

    posted a message on (Solved) Modifying an attribute behavior stat while moving

    I'm trying to create a "fuel" stat for certain units that is consumed when the unit is moving. When fuel hits zero, the unit should no longer be able to move. What's the best way to go about implementing this in Data? I've made a Fuel attribute behavior, as well as an Out of Fuel one that suppresses movement. Unfortunately, I don't know how to change the initial value of the Fuel attribute (it always starts at zero, at the moment) and I don't know how to decrement it only while moving.

    Any suggestions on what steps I should take to produce this effect would be much appreciated!

    edit: typo

    Posted in: Data
  • 0

    posted a message on Preserving existing orders while loading a unit - I can't figure this one out!

    I apologize for a first post that's probably little more than a dumb question already answered elsewhere, but I'm really killing myself over this bug!

    I've been attempting to create a functionality for a unit that allows it to load up a unit with existing orders and then have it continue to follow those orders when it is later unloaded. To this end, I've been trying to write a trigger that saves a unit's standing orders in a variable when loaded. It seems like it'd be pretty simple stuff, but I've run into some problems. Here's what I have so far:

    (saving the order before loading)

        Events
            Unit - mech_player1 is issued an order to  Load (Medivac)
        Local Variables
        Conditions
        Actions
            Variable - Set savedOrder_player1 = ((Target unit for (Triggering order)) order at index 0)
            UI - Display "save order for loaded unit fired" for (All players) to Chat area
    

    (reissuing the order after unloading)

        Events
            Unit - mech_player1 Unloads cargo
        Local Variables
        Conditions
        Actions
            Unit - Order (Triggering cargo unit) to savedOrder_player1 (Replace Existing Orders)
    

    This code works fairly well, but a problem occurs in the case where the unit to be placed in cargo is targeted at an extremely close range. In this case, the target unit apparently performs a sort of load command on its own before the saving trigger reaches the variable changing statement, causing the saved order to be said load command instead of whatever it was doing before. This results in the unit instantly loading itself back up whenever I try to unload it.

    If anyone has any ideas on what I can do to avoid this issue, I'd be extremely appreciative. I thought it might have something to do with a race condition between the order being saved and the target unit's load command being automatically issued, so I surrounded it with the Critical Section block, but it doesn't seem to make much of a difference, presumably because the actual event itself isn't guaranteed to be flagged first.

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