• 0

    posted a message on Dialog Pulldown Selection Not Appearing

    Tried making one from scratch just now, which worked. My code still doesn't and I have no idea why. Here's an excerpt of my code.

    PerkDialog = DialogCreate(Width, Height, c_anchorBottomLeft, 6, 187, true);
    	DialogSetVisible(PerkDialog, PlayerGroupAll(), true);
    	string[nPerks] perkitems;
    	perkitems[0] = "Arcane Affinity";
    	perkitems[1] = "Dark Affinity";
    	perkitems[2] = "Earth Affinity";
    	perkitems[3] = "Energy Affinity";
    	perkitems[4] = "Fire Affinity";
    	perkitems[5] = "Force Affinity";
    	perkitems[6] = "Ice Affinity";
    	perkitems[7] = "Light Affinity";
    	for (int i = 0; i < 3; i++)
    	{
    		PerkDropdown[i] = DialogCreateItem(PerkDialog, c_triggerControlTypePulldown, Width - 80, 40, c_anchorCenter, 6, -25+(42*i), "Perk " + IntToString(i+1));
    		for (int i2 = 0; i2 < nPerks; i2++)
    		{
    			DialogControlAddItem(PerkDropdown[i], PlayerGroupAll(), perkitems[i2]);
    		}
    	}
    
    Posted in: Triggers
  • 0

    posted a message on Dialog Pulldown Selection Not Appearing

    I set up a pulldown in a dialog, but the selection won't appear. That is, when I select one of the list items, nothing shows up when the pulldown is contracted. The item remains highlighted when it's expanded. Not sure what exactly is wrong here.

    Posted in: Triggers
  • 0

    posted a message on Dynamic Array Unit Indexer

    Yes! Thank you! This was exactly what I was looking for. I remember using hashtables in WC3 for this purpose but couldn't find a similar way to do it.

    Posted in: Galaxy Scripting
  • 0

    posted a message on Galaxy++ editor

    How do you use mod methods such as from the Campaign or GAx3? The include doesn't work either.

    Posted in: Third Party Tools
  • 0

    posted a message on Dynamic Array Unit Indexer

    Huh. Interesting. Should look into that. Is it compatible with G+ +?

    Posted in: Galaxy Scripting
  • 0

    posted a message on Is Boolean a Bit or Byte?

    Wait, so are ALL variables 4 bytes? I'm using quite a bit of global variables, so I'm trying to see if I can conserve some.

    Posted in: Triggers
  • 0

    posted a message on Is Boolean a Bit or Byte?

    The title says all. Does a bool type take up 1 full byte or does it take up 1 bit?

    Is there a place where I can find how many variables allocate memory? I know byte is 1 byte and int is 4 bytes, but what about game types like units?

    Posted in: Triggers
  • 0

    posted a message on Dynamic Array Unit Indexer

    Yup. Exactly that. I'm trying to extend the custom value of a unit. The game I'm creating requires a lot of variables for each unit unfortunately (The game is based on 8 different elements, so things get multiplied quite a bit). I'm also hoping to code and implement a sort of a physics library, and that'll take up a lot of memory too since each projectile would need its own set of data (mass, radius, velocity, etc.) I might be able to use byte instead of int for some of the variables to cut down on memory, but even then it gets pretty taxing.

    For the majority of the game, the number of units in a single instance won't exceed 50 (Far less probably), but there may be instances where can go up far higher (Probably not even up to 150, but games can be pretty dynamic and unpredictable). I'm still in the early stages of the game, but I want to make sure that my foundations are solid so that I don't go back and change something so fundamental. A unit indexing system tends to be rather fundamental. :/

    Posted in: Galaxy Scripting
  • 0

    posted a message on Dynamic Array Unit Indexer

    EDIT: It posted twice for some reason. Ignore this.

    Posted in: Galaxy Scripting
  • 0

    posted a message on Dynamic Array Unit Indexer

    Well, sure it's a big array, but the length of the array varies, and that's what matters. Even if the variable is "empty," it still allocates memory for it. Using this method allows me to adjust the length of the array, meaning that the variables only use as much space as necessary. Static, predefined array lengths don't allow that.

    Posted in: Galaxy Scripting
  • 0

    posted a message on Dynamic Array Unit Indexer

    Can you explain why I shouldn't use it? I only know that it uses strings to store the variables, but I'm clueless beyond that.

    Posted in: Galaxy Scripting
  • 0

    posted a message on Dynamic Array Unit Indexer

    Unit groups don't work because it doesn't let me track each individual unit efficiently. Each unit needs to have its own unique index so that it can be used to call the specific array on a variable. The process does loop quite a bit, but only so far as it needs to (as many units there are and again if a unit is dead). So that means that if there's only 50 units present, then it'll only loop 50 times, which isn't too bad. It was fine even when I set it static to 500. Still, games tend to be dynamic and it's possible to have an instance when there are over 500 units (especially since projectiles are considered units as well). On the other hand, if there's only 50 units, then I would rather loop 50 times and use memory for 50 instances rather than 500.

    Posted in: Galaxy Scripting
  • 0

    posted a message on Dynamic Array Unit Indexer

    I'm trying to construct a unit indexer using dynamic arrays in galaxy+ +, but ran into a problem.

    The concept is simple: If a new unit enters the game, extend the variable's array by one and set the variable to the new unit. Then, give the new unit the same index in one of its custom values. Add 1 to the variable holding the maximum count of indexes used. A periodic trigger runs each second to see if any unit is no longer alive, and if so, shift down all subsequent indexes by one and remove the last array.

    The part I have trouble with is the recycling part. The code thinks that the unit with the final index is dead and ends up reducing the array by one every time the recycling trigger runs (That is, every second). I can't figure out what's wrong.

    Here's the code:

    unit[] Lib_UIS_Unit = new unit[16]();
    int Lib_UIS_MaxIndex = 15;
    
    //--------------------------------------------------------------------------------------------------
    
    unit GetIndexUnit (int whichIndex) {
        return Lib_UIS_Unit[whichIndex];
    }
    int GetUnitIndex (unit whichUnit) {
        return FixedToInt(UnitGetCustomValue(whichUnit, 32));
    }
    
    //--------------------------------------------------------------------------------------------------
    
    bool Lib_UIS_UnitCreated (bool testConds, bool runActions) // If unit enters game, run 
    { 
    	Lib_UIS_Unit->Resize(++Lib_UIS_MaxIndex);
    	Lib_UIS_Unit[Lib_UIS_MaxIndex] = EventUnit(); // Reference to get unit from integer
        UnitSetCustomValue(EventUnit(), 32, IntToFixed(Lib_UIS_MaxIndex));
        return true;
    }
    
    void Lib_UIS_UnitCreated_Init () {
        trigger t = TriggerCreate("Lib_UIS_UnitCreated");
        TriggerAddEventUnitRegion(t, null, RegionEntireMap(), true);
    }
    
    //--------------------------------------------------------------------------------------------------
    
    bool Lib_UIS_Recycle (bool testConds, bool runActions)
    {
    	for (int i = 16; i < Lib_UIS_MaxIndex; i++)
    	{
    		if (UnitIsAlive(Lib_UIS_Unit[i]) == false) { // If a unit is gone from the game, bring down array
    			TriggerDebugOutput(1, "i = " + IntToText(i), true);
    			for (int i2 = i; i2 < Lib_UIS_MaxIndex; i2++)
    			{
    				UnitSetCustomValue(Lib_UIS_Unit[i2+1], 32, IntToFixed(i2));
    				Lib_UIS_Unit[i2] = Lib_UIS_Unit[i2 + 1];
    				//TriggerDebugOutput(1, "i2 = " + IntToText(i2), true);
    			}
    			Lib_UIS_Unit->Resize(--Lib_UIS_MaxIndex);
            }
    	}
        return true;
    }
    
    void Lib_UIS_Recycle_Init () {
        trigger t = TriggerCreate("Lib_UIS_Recycle");
        TriggerAddEventTimePeriodic(t, 1, c_timeGame); // 1 is enough since units aren't going to be created that rapidly. If necessary, make it smaller.
    }
    
    //--------------------------------------------------------------------------------------------------
    
    void Lib_UIS_Init () {
        Lib_UIS_UnitCreated_Init();
        Lib_UIS_Recycle_Init();
    }
    

    I considered using a static system, but I'm trying to set up a system to link other dynamic array variables to store values. Considering the sheer number of units potentially used in a game, I figured dynamic would be best for the memory.

    Posted in: Galaxy Scripting
  • 0

    posted a message on Galaxy++ editor

    O_o Doesn't take longer than 5 seconds for me. But then again, I only have around 4000 lines so far.

    I found another function that doesn't work: libNtve_gf_SetDialogItemToggled. The program doesn't recognize it as a valid method (It doesn't highlight it, can't compile it, etc.) It seems to work in 3.1.0, but that version doesn't let me inject. I tried using the native, but the native uses the constant c_triggerControlPropertyToggled, which for some reason is also unrecognized by galaxy + +. :/

    Posted in: Third Party Tools
  • 0

    posted a message on Lag reduction tips

    Not entirely sure if this would work (and you might not like it), but if it causes a great enough of a frame rate drop, you can try just removing the unit as soon as it dies so that the death animation doesn't play. I don't know if this will actually reduce lag or how by how much if it actually does work. This relies on the fact that people would be lagging so badly that they can't tell the difference between units disappearing through death animations and just being removed from the game. I mean, if it's going to lag, you might as well take advantage of it and make your game run slightly better. ;) You can always set a condition for this so that it'll only execute if there are more than 500 units on the field or something. Again, this probably is not the best option but if you're out of ideas, why not try it?.

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