Question about building placement
by Sean Taylor · in RTS Starter Kit · 06/24/2009 (11:26 pm) · 4 replies
Ok, firstly I decided to use a different technique of having peons building buildings. My technique would have the player simply put the builging on the terrain, then the peons would check a global list of buildings that need to be built then move to the building.
so my question is: how do i have an idle peon check a global variable, and if not 0, send them to the coordinates to build.
i have already read it needs to be in the processTick function. so far ive put into the RTSUnit::processTick method, having this:
unfortunately i really dont want it checking every 1/10th of a second, so how can i add an onIdle function to be used in script into the server's processTick.
secondly, the above insert doesnt work, it only gives the script the ID of the datablock and not the unit like I need it to. after those are answered i caan prolly get the rest working
thanks in advance!
so my question is: how do i have an idle peon check a global variable, and if not 0, send them to the coordinates to build.
i have already read it needs to be in the processTick function. so far ive put into the RTSUnit::processTick method, having this:
if (isServerObject()) {
Con::executef(mDataBlock, 1, "onIdle");
}unfortunately i really dont want it checking every 1/10th of a second, so how can i add an onIdle function to be used in script into the server's processTick.
secondly, the above insert doesnt work, it only gives the script the ID of the datablock and not the unit like I need it to. after those are answered i caan prolly get the rest working
thanks in advance!
About the author
#2
I'll try to use the .status field to manage the status of the unit, but where would I allow it to check the status without the code calling an onIdle method somewhere.
06/25/2009 (2:48 pm)
Firstly, I tried the "this" approach and it still only passes the Datablock ID, or gives me a compiling error.I'll try to use the .status field to manage the status of the unit, but where would I allow it to check the status without the code calling an onIdle method somewhere.
#3
About the status field, thats the idea of the unit controlling its own actions, call onIdle by itself when finish any other job.
06/25/2009 (6:11 pm)
If you use "this" inside the "RTSUnit::" namespace, you should always get the unit id. Is not something to be playing with, though, if you dont have it clear.About the status field, thats the idea of the unit controlling its own actions, call onIdle by itself when finish any other job.
#4
06/26/2009 (5:05 pm)
Oh thanks bunches! I always overlook things, just needed to put it into the Player:: namespace in the script and it works perfectly :) at least the way i was trying to do it. ill try and see how i can get it to work with the sttatus field and where to call it. thanks for the help novack!
Torque 3D Owner Novack
CyberianSoftware
if (isServerObject()) { Con::executef(this, 1, "onIdle"); }However, that code will not work magically... I mean, you'll have a method executing terrribly often with no purpose, because the OnIdle is just a name, it will run always, despite the unit beeing doing something or not.
What you really need is some back support for that, a system for managing the status of the units. You can found some inspiration code on that, on the WD Mod, take a look at how the .status field is used on the units.
You could easily manage the status from the unit itself, and let the unit be the one that execute onIdle.