I’m making a custom scenario with essentially a custom race and I’m trying to implement a different system of unit upgrades that involves sending the unit you want to upgrade to the appropriate training facility directly rather than an across the board unit type upgrade. Ex: A Villager can be sent to the Workshop to become a Tradesperson or to the Academy to become a Scholor and you can keep the rest of your Villagers.
What i’ve come up with is reducing the buildings collision size and putting a region that overlaps it. When specific unit type enters the region they are “hidden”, their training cost resources are removed (only triggers if player has enough resources) and a message indicates they have begun training. Wait ‘x’ amount of time and replace triggering unit with new unit type and unhide them with a training complete message. This works quite well, except now I want the region to appear wherever the player chooses to place the buildings. I figured Id have an array of regions (as they must already exist to be referenced in other triggers) in a hidden inaccessible part of the map and a trigger for when a building of type x is constructed the corresponding region is moved to its center, but have not been able to make that work. I’ve tried a handful of things my best guess being:
Trigger
Event
A Unit (i’ve tried ‘player owned’ And ‘generic’) finished construction
Condition
Unit Type of (i’ve tried ‘triggering unit’ And ‘constructed structure’) is equal to ‘[building type, Ex ‘Workshop’]’
Action
Region - center ‘[region, Ex ‘Trade School’]’ on (I’ve tried ‘triggering unit’ And ‘constructed structure’)
This makes the most logical sense to me given the code snippets they provide, but does not work the regions remain in their original locations. Does this make any sense? Does anyone have any suggestions? Please and Thank You!
Head over to thee Hive discord server for help on this. It’s too tedious here.
I did not see your messages in Hive; was not watching it at the time.
But for you or anyone else who sees this in the future, the problem is due to the functions the GUI is using. The function call to create a “Unit Enters Region” event under the hood deals with 2 separate lower level type objects: rects and regions. In that lower level system, what you call “regions” from the user interface are actually “rects” which are a set of {X,Y,Width,Height} data. By contrast, there is also something called Region which can have multiple shapes or contain many rects.
Because of that distinction, “Unit Enters Region” event under the hood will convert your “rect” to a “region” and then listen for units entering the “region.” Accordingly, if you move your “rect” to a different X and Y, the automatically generated “region” type object (in this lower level sense, created only for the event) does not update.
Whether you update your region, or add and remove trigger events, generally the best solutions that come to mind for me require turning the trigger into custom script mode. Maybe I’m just getting old, but custom scripts are certainly how I suppose I would do it.
1 Like
This makes sense, thank you! Unfortunately I have 0 experience with the custom script feature, so will have to do a deep dive to even attempt making that work. I feel you on getting old, lol, I (don’t flog me) don’t even really use discord, heh. I do have one though I suppose I ought to pose this there at some point but that would be why you didn’t see it there. What is involved with this custom script business? Need I write my own code for it? Speaking of old my coding knowledge comes from Q-Basic with a dabble in C++, so i understand the concepts but as far as usable language these days I highly doubt my effectiveness. Thank you for the reply!