So,how do these SET/GET Cob functions work(speed and other)?

So,how do these SET/GET Cob functions work(speed and other)?

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
alik83
Posts: 82
Joined: 08 Sep 2004, 15:32

So,how do these SET/GET Cob functions work(speed and other)?

Post by alik83 »

Anyone can give an example on how these SET/GET Cob functions work(speed and other) for ex. if I would want to change current unit speed of a unit in my AI?
Will it also allow for a group of units to move at same speed(of slowest unit) like in TAK, and the way it was supposed to work with ALT key in SelectedUnitsAI.cpp?

And I'm totally for implementing other TAK SET/GET functions and other function that would allow change movement class and other unit parameters to transform it totally :) Just hoping it would be a complete scripting system, with extendable and addable functions, not just a one-time hack, although temporary hack might be fine if done fast.
I also wish TAK mode will turn out really good ;)
And thanks Zaphod for keeping TAS growing and evolving :wink:
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

if I would want to change current unit speed of a unit in my AI?
hmmm, setting c->id = CMD_SET_WANTED_MAX_SPEED followed by the actual speed as the first parameter....... But that's C code.
alik83
Posts: 82
Joined: 08 Sep 2004, 15:32

well

Post by alik83 »

hmmm, setting c->id = CMD_SET_WANTED_MAX_SPEED followed by the actual speed as the first parameter....... But that's C code.
These are not exactly the COB SET/GET functions, but did the above command work for you? I onced tried using it to make fast units move slow and it didn't work for me...
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Post by zwzsg »

I think set/get are for unit script, not for AI. In a bos you would write:

#include exptype.h

set CURRENT_SPEED to 2*get CURRENT_SPEED;
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

I havent tested it out properly yet. I know the following definately dotn work in an AI dll tho..

CMD_MOVE_STATE
CMD_FIRE_STATE
CMD_REPEAT
CMD_TRAJECTORY
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

AF wrote:I havent tested it out properly yet. I know the following definately dotn work in an AI dll tho..

CMD_MOVE_STATE
CMD_FIRE_STATE
CMD_REPEAT
CMD_TRAJECTORY
Is this still the case? CMD_TRAJECTORY looks pretty useful.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

NTai uses all of them save CMD_REPEAT which I couldnt figure out atm and gave up on after 5 minutes. It probably works the same way as CMD_ONOFF though.
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

Anyone can give an example on how these SET/GET Cob functions work(speed and other) for ex. if I would want to change current unit speed of a unit in my AI?
Will it also allow for a group of units to move at same speed(of slowest unit) like in TAK, and the way it was supposed to work with ALT key in SelectedUnitsAI.cpp?

Code: Select all

#define MAX_SPEED 75

// VELOCITY initially will represent the value from the definition or the current
#define VELOCITY (get MAX_SPEED)/65536

// CHG_SPEED takes velocity parameters which are being used in the definition files
#define CHG_SPEED(i) set MAX_SPEED(i \ *65536)

CHG_SPEED(rand(0, VELOCITY));
Wondering what will happen if you define negative values... :-)
edit: Nothing. Same as setting it to 0, only that the speed value is in the negatives. :cry:

Oh yeah, it works now. Thanks to whoever fixed it...


Ugh, sorry you probably wanted the C++ code for that, didn't read the post in all entirety... :oops:
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

If you're using raw interface calls:

Code: Select all

Command c;
c.id = CMD_SET_WANTED_MAX_SPEED;
c.params.push_back(maxspeedvalue);
int result = cb->GiveCommand(unit,&c);
if(result == -1){
    //command failed!
}else{
    // command issued!
}
If you're using the COrderRouter class I gave you from NTai

Code: Select all

TCommand tc(unit);
tc.ID(CMD_SET_WANTED_MAX_SPEED);
tc.Push(maxspeedvalue);
bool result = OrderRouter->GiveOrder(tc,false);
You may be interested in looking further through the command.h file.
An example of setting the movestate to roam

Code: Select all

TCommand tc(unit,"setting firing state/movestate");
tc.ID(CMD_MOVE_STATE);
tc.Push(2);
bool result = G->OrderRouter->GiveOrder(tc,false);
User avatar
EXit_W0und
Posts: 164
Joined: 22 Dec 2005, 01:33

Post by EXit_W0und »

I realise this post is ancient but this might help someone referring back to this...

#define CHG_SPEED(i) set MAX_SPEED(i \ *65536)
Should be:

#define CHG_SPEED(i) set MAX_SPEED to (i \ *65536)

or you get an syntax error where trying to use this macro.
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

Hm indeed, small oversight. Scriptor tells you what's missing anway so no worries.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Post by FLOZi »

EXit_W0und wrote:I realise this post is ancient but this might help someone referring back to this...

#define CHG_SPEED(i) set MAX_SPEED(i \ *65536)
Should be:

#define CHG_SPEED(i) set MAX_SPEED to (i \ *65536)

or you get an syntax error where trying to use this macro.
Wasn't it you that was writing the patch for paradropping units from air trans?
Post Reply

Return to “Engine”