SC2Mapster Forums

Development > Triggers

reading catalog values after they've been changed

  • 5 posts
    #1 Mar 30, 2014 at 22:29 UTC - 0 likes

    Hey, I have a custom action that reads and changes a bunch of catalogue values.
    It runs once just fine, but the second time it runs, it gives me a "cannot be read" error, and then since im setting it based on its own value, it gets set to 0.

    Is this common, is there a way around it?

    Eldrad initiative function
        Options: Action
        Return Type: (None)
        Parameters
            Hero = No Unit <Unit>
        Grammar Text: Do Eldrad Ulthran initiative functions for Unit
        Hint Text: (None)
        Custom Script Code
        Local Variables
            initiative = (Custom value Initiative of Hero) <Real>
            Base Attack Speed = 1.7 <Real>
            Scry cooldown = 0.0 <Real[6]>
            guide cooldown = 0.0 <Real[6]>
            fortune cooldown = 0.0 <Real[6]>
            doom cooldown = 0.0 <Real[6]>
            path cooldown = 0.0 <Real[6]>
            storm cooldown = 0.0 <Real[6]>
            staff cooldown = 0.0 <Real[6]>
            int = 0 <Integer>
        Actions
            Catalog - Set value of Weapons PsychicDischarge Period for player (Owner of Hero) to (String((Base Attack Speed * (1.0 - (initiative * attack time per init)))) with Any Precision decimal places)
            General - For each integer int from 0 to 6 with increment 1, do (Actions)
                Actions
                    Variable - Set Scry cooldown[int] = (Value of Abilities ScryersGaze Cost[int].Cooldown.TimeUse for player (Owner of Hero) as an integer)
                    Catalog - Set value of Abilities ScryersGaze Cost[int].Cooldown.TimeUse for player (Owner of Hero) to (String((Scry cooldown[int] * (1.0 - (initiative * cdr per init)))) with Any Precision decimal places)
            General - For each integer int from 0 to 5 with increment 1, do (Actions)
                Actions
                    Variable - Set guide cooldown[int] = (Value of Abilities Guide Cost[int].Cooldown.TimeUse for player (Owner of Hero) as an integer)
                    Catalog - Set value of Abilities Guide Cost[int].Cooldown.TimeUse for player (Owner of Hero) to (String((guide cooldown[int] * (1.0 - (initiative * cdr per init)))) with Any Precision decimal places)
            General - For each integer int from 0 to 5 with increment 1, do (Actions)
                Actions
                    Variable - Set fortune cooldown[int] = (Value of Abilities Fortune Cost[int].Cooldown.TimeUse for player (Owner of Hero) as an integer)
                    Catalog - Set value of Abilities Fortune Cost[int].Cooldown.TimeUse for player (Owner of Hero) to (String((fortune cooldown[int] * (1.0 - (initiative * cdr per init)))) with Any Precision decimal places)
            General - For each integer int from 0 to 5 with increment 1, do (Actions)
                Actions
                    Variable - Set doom cooldown[int] = (Value of Abilities Doom Cost[int].Cooldown.TimeUse for player (Owner of Hero) as an integer)
                    Catalog - Set value of Abilities Doom Cost[int].Cooldown.TimeUse for player (Owner of Hero) to (String((doom cooldown[int] * (1.0 - (initiative * cdr per init)))) with Any Precision decimal places)
            General - For each integer int from 0 to 5 with increment 1, do (Actions)
                Actions
                    Variable - Set path cooldown[int] = (Value of Abilities ThePathBeyond Cost[int].Cooldown.TimeUse for player (Owner of Hero) as an integer)
                    Catalog - Set value of Abilities ThePathBeyond Cost[int].Cooldown.TimeUse for player (Owner of Hero) to (String((path cooldown[int] * (1.0 - (initiative * cdr per init)))) with Any Precision decimal places)
            General - For each integer int from 0 to 5 with increment 1, do (Actions)
                Actions
                    Variable - Set storm cooldown[int] = (Value of Abilities EldritchStorm Cost[int].Cooldown.TimeUse for player (Owner of Hero) as an integer)
                    Catalog - Set value of Abilities EldritchStorm Cost[int].Cooldown.TimeUse for player (Owner of Hero) to (String((storm cooldown[int] * (1.0 - (initiative * cdr per init)))) with Any Precision decimal places)
            General - For each integer int from 0 to 2 with increment 1, do (Actions)
                Actions
                    Variable - Set staff cooldown[int] = (Value of Abilities StaffofUlthamar Cost[int].Cooldown.TimeUse for player (Owner of Hero) as an integer)
                    Catalog - Set value of Abilities StaffofUlthamar Cost[int].Cooldown.TimeUse for player (Owner of Hero) to (String((staff cooldown[int] * (1.0 - (initiative * cdr per init)))) with Any Precision decimal places)
    
    #2 Mar 30, 2014 at 23:17 UTC - 0 likes

    @Grasshopper721: Go

    Curious, are you running it the first time on map initialization?

    #3 Mar 30, 2014 at 23:29 UTC - 0 likes

    Yes I am

    #4 Apr 02, 2014 at 22:30 UTC - 0 likes

    So, i took it out my map init trigger, and it started working.
    but now its called when a hero is spawned, and now doesnt work the second time again.

    what may be causing this problem?

    #5 Apr 02, 2014 at 23:26 UTC - 0 likes

    @Grasshopper721: Go

    I don't see anything particularly wrong, but it is a lot to look at.

    I would have it display the field values that have been changed after the change, so you know what to expect the second time. It's possible they're being rounded to an incorrect value or something (like 0 or negative).

    A few days ago, I had a line of all reals arithmetic, and for some reason, no matter what, it would give me 0. I broke it up into multiple lines with the same order of operations and it worked fine. Because it's impossible that the computer was miscalculating, my point is that there are things you could possibly keep missing/not thinking of. The only way to know is to follow the path of calculations. If you've tried it already, disregard this.

    edit: The reason I asked if you ran it on map initialization, was that some fields can't be altered after map initialization. I didn't think it would be a problem because you don't have any of those problem fields being altered.

    Last edited Apr 02, 2014 by Charysmatic
  • 5 posts

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