New COB constants?
Moderator: Moderators
New COB constants?
What, exactly do POW and PRINT do? PRINT looks like it's for debugging (useful!), POW, though... is that for hit-by-weapon?
Here's what they do:
POW is 80, PRINT 81, HEADING 82.
yuritch is correct about POW, however, the numbers need to be passed as *2^16, and are returned in such a format. This allows for floats to some degree. i.e. get POW (262144, 32768) = 131072, meaning pow(4,0.5)=2.
PRINT is indeed for debugging only - it prints the 4 get arguments to the chat. The main use of course being to check the value of some variable during the script. i.e.
Would print:
"Value 1: 131072, 2: 0, 3: 0, 4: 0"
to chat.
HEADING does what it says on the tin - returns unit->heading. This is of course possible already using the trig functions and piece locations, but this is just... neater.
POW is 80, PRINT 81, HEADING 82.
yuritch is correct about POW, however, the numbers need to be passed as *2^16, and are returned in such a format. This allows for floats to some degree. i.e. get POW (262144, 32768) = 131072, meaning pow(4,0.5)=2.
PRINT is indeed for debugging only - it prints the 4 get arguments to the chat. The main use of course being to check the value of some variable during the script. i.e.
Code: Select all
var myTest;
myTest = get POW (262144, 32768);
get PRINT (myTest)
"Value 1: 131072, 2: 0, 3: 0, 4: 0"
to chat.
HEADING does what it says on the tin - returns unit->heading. This is of course possible already using the trig functions and piece locations, but this is just... neater.
- Guessmyname
- Posts: 3301
- Joined: 28 Apr 2005, 21:07
What's with GROUNDHEIGHT?to see if a plane has landed
Oh and I would use a macro for POW by the way.
Code: Select all
#define POWER(x, y) get POW(x * 65536, y * 65536)
They do, I used macros like that before.
Last edited by rattle on 02 Jun 2007, 19:17, edited 2 times in total.
No, I mean
A. #define doesn't respect variables, it's a simple replace action and won't see that POW(x,y) means look for POW(<value>,<value>) and move the values to the appropriate places.
B. #define sees its keyword as the first bunch of characters without whitespace, in Rattle's example "POW(x," would be replaced with "y) get POW(x * 65536, y * 65536)".
A. #define doesn't respect variables, it's a simple replace action and won't see that POW(x,y) means look for POW(<value>,<value>) and move the values to the appropriate places.
B. #define sees its keyword as the first bunch of characters without whitespace, in Rattle's example "POW(x," would be replaced with "y) get POW(x * 65536, y * 65536)".
Bump for great justice!
Just added:
TARGET_ID (83)
- usage: get TARGET_ID (weaponNum)
- returns the ID of the currently targetted unit by the passed weapon
- returns -1 if no target
- returns -2 if a force fire position target
- returns -3 if it's an intercept target
- returns -4 if the weapon doesn't exist
and LAST_ATTACKER_ID(83)
- usage: get LAST_ATTACKER_ID
- returns the ID of the last unit to attack
- returns -1 if there is no last attacker (unit has yet to be attacked) or last attacking unit is dead.
Just need to check them over with someone and I'll commit them to SVN. Hope they are useful for someone!
Just added:
TARGET_ID (83)
- usage: get TARGET_ID (weaponNum)
- returns the ID of the currently targetted unit by the passed weapon
- returns -1 if no target
- returns -2 if a force fire position target
- returns -3 if it's an intercept target
- returns -4 if the weapon doesn't exist
and LAST_ATTACKER_ID(83)
- usage: get LAST_ATTACKER_ID
- returns the ID of the last unit to attack
- returns -1 if there is no last attacker (unit has yet to be attacked) or last attacking unit is dead.
Just need to check them over with someone and I'll commit them to SVN. Hope they are useful for someone!

Triple post for HUGE justice!
Just added:
LOS_RADIUS (85)
- usage: get LOS_RADIUS, set LOS_RADIUS to (radius)
- sets the LOS to the given radius, and sets the values held by the unit to that radius (Anyone familiar with the code will see why this distinction is important, otherwise, don't worry about it, it'll behave as you would expect)
AIR_LOS_RADIUS (86)
- usage: get AIR_LOS_RADIUS, set AIR_LOS_RADIUS to (radius)
- As for LOS_RADIUS but for air los.
EDIT: yes, I finally used edit.
set HEADING now works. Just for you Arghy-wargy.
Just added:
LOS_RADIUS (85)
- usage: get LOS_RADIUS, set LOS_RADIUS to (radius)
- sets the LOS to the given radius, and sets the values held by the unit to that radius (Anyone familiar with the code will see why this distinction is important, otherwise, don't worry about it, it'll behave as you would expect)
AIR_LOS_RADIUS (86)
- usage: get AIR_LOS_RADIUS, set AIR_LOS_RADIUS to (radius)
- As for LOS_RADIUS but for air los.
EDIT: yes, I finally used edit.
set HEADING now works. Just for you Arghy-wargy.

So, if I write code like this:
... will this completely immobilize the Unit?
Code: Select all
Stay_Put(Heading_Then)
{
SET MAX_SPEED 1;
Heading_Then = get HEADING;
sleep 30;
set HEADING (Heading_Then);
}