SC2Mapster Forums

Development > Triggers

Detect when Custom Value is changed?

  • 4 posts
    #1 Dec 09, 2012 at 23:33 UTC - 0 likes

    I'm using custom values within triggers to store custom unit data like health and magic in a special system I'm working on.

    Is there any way to detect when a unit's custom value changes? I thought it was with "unit property changes" but apparently it isn't. I need to be able to change a unit's custom value in one trigger, and then have a second trigger that detects that the custom value changed, and then respond accordingly.

    Thanks!

    #2 Dec 09, 2012 at 23:39 UTC - 0 likes

    Create an action definition that has the unit as parameter that reacts to it accordingly and call it after every change that needs to be handled.

    http://img42.imageshack.us/img42/7586/signaturemj.jpg

    #3 Dec 10, 2012 at 00:14 UTC - 0 likes

    @Ahli634: Go

    Oh god, I didn't even know these existed in sc2 and have no idea what they are. Any good tutorials for these? I found one, but I didn't understand what he was trying to even do with his trigger :S

    EDIT: Oh wait a minute.. I THINK I understand the concept. For example: when the custom value representing the health for my unit changes in an action, I COULD create a bunch of actions following that that would be like "if this units custom value 'health' is less than zero, kill the unit", and then I would have to do this everywhere health changes.

    OR

    You create the response for health changing inside of the action definition, and then you just put that action after a unit is damaged so you dont have to do all the actions every single time.

    Is that the main gist of it?

    DOUBLE EDIT: Sorry for editing twice, but YES.. action definitions are bad-ass, and your recommendation worked like a charm! Thanks :)

    Last edited Dec 10, 2012 by watterboy1
    #4 Dec 10, 2012 at 13:04 UTC - 0 likes

    @watterboy1: Go

    Yep, action definitions are basically the same as putting duplicate actions in every trigger, except that they save both time (for you) and memory (for the map.)

    My Projects:
    Malum Ruina: SC2Mapster
    Eternal Exile: SC2Mapster
    Spine Crawler Madness: SC2Mapster
    Xeno Crisis: SC2Mapster

  • 4 posts

You must login to post a comment. Don't have an account? Register to get one!