Page 1 of 2
broke script
Posted: 18 Oct 2007, 21:55
by rcdraco
Code: Select all
#define TA // This is a TA script
#include "sfxtype.h"
#include "exptype.h"
piece base, top;
static-var ACTIVATE;
// Signal definitions
#define SIG_AIM 2
SmokeUnit(healthpercent, sleeptime, smoketype)
{
while( get BUILD_PERCENT_LEFT )
{
sleep 400;
}
while( TRUE )
{
healthpercent = get HEALTH;
if( healthpercent < 66 )
{
smoketype = 256 | 2;
if( Rand( 1, 66 ) < healthpercent )
{
smoketype = 256 | 1;
}
emit-sfx smoketype from base;
}
sleeptime = healthpercent * 50;
if( sleeptime < 200 )
{
sleeptime = 200;
}
sleep sleeptime;
}
}
Activate()
{
set ACTIVATE to 1;
spin top around y-axis speed <300> accelerate <15>;
while(ACTIVATE==1);
{
move top to y-axis [5] speed [10];
sleep 100;
move top to y-axis [0] speed [10];
}
}
Deactivate()
{
set ACTIVATE to 0;
stop-spin top around y-axis decelerate <25>;
wait-for-turn top around y-axis;
}
Create()
{
start-script SmokeUnit();
set ACTIVATE to 0;
}
AimPrimary(heading, pitch)
{
}
FirePrimary()
{
}
AimFromPrimary(piecenum)
{
}
QueryPrimary(piecenum)
{
}
SweetSpot(piecenum)
{
piecenum = base;
}
Killed(severity, corpsetype)
{
hide top;
if( severity <= 25 )
{
corpsetype = 1;
explode top type BITMAPONLY | BITMAP1;
explode base type BITMAPONLY | BITMAP2;
return (0);
}
if( severity <= 50 )
{
corpsetype = 2;
explode top type FALL | BITMAP1;
explode base type BITMAPONLY | BITMAP2;
return (0);
}
if( severity <= 99 )
{
corpsetype = 3;
explode top type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode base type BITMAPONLY | BITMAP2;
return (0);
}
corpsetype = 3;
explode top type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode base type BITMAPONLY | BITMAP2;
}
Posted: 18 Oct 2007, 22:05
by rattle
Compiles fine.
- what's broken?
- any error messages?
- what did you do?
well
Posted: 18 Oct 2007, 22:19
by rcdraco
In the game, I hit On, it pops up once, comes up with CobError: Unknown Set Constant 0.
Posted: 18 Oct 2007, 22:41
by rattle
uh oh
Posted: 18 Oct 2007, 23:15
by rcdraco
Now I have errors on line 41, and 42.
Code: Select all
Error (41): Expected '=', got '(' [ C:\New BloX\scripts\hydrocomp.bos ]
Error (42): Script Declaration Expected [ C:\New BloX\scripts\hydrocomp.bos ]
Posted: 18 Oct 2007, 23:19
by Peet
Why exactly are you using set on a static-var?
Posted: 18 Oct 2007, 23:20
by FLOZi
Should be
while (get ACTIVATION == 1)
{}
No semicolon.
oh
Posted: 18 Oct 2007, 23:38
by rcdraco
So, I have to do that because it is making a new script thing in the script? I think I kinda understand it more.
Posted: 19 Oct 2007, 00:00
by rattle
This is a preprocessor definition which reflects the value 1. Has nothing to do with the unit's activation state.
This is an empty variable. Has nothing to do with the unit's activation state.
This is a function. Has nothing to do with the unit's activation state.
"set 1 to 1;" makes spring run the COB function Activate()
"set 1 to 0;" makes spring run the COB function Deactivate()
For better readability we use preprocessor definitions of these values. Hence, "set 1 to 1;" becomes "set ACTIVATION to TRUE;" for example.
Posted: 19 Oct 2007, 06:41
by Archangel of Death
Rattle: Why are you saying the #define ACTIVATION and Activate() function have nothing to do with a unit's activation state? They constitute the entirety of a scripts interaction with its parent unit's activation state.
rcdraco: #define ACTIVATION 1 comes from exptype.h, the value it is followed by is immaterial to you so long as you include that file or a replacement for it, infact you don't want to care. You only need to know that to alter your units activation state, set ACTIVATION to 1 or 0 (that part you understood).
ACTIVATION isn't a variable, or a function. "set" and "get" are special identifiers that Spring understands, and ACTIVATION (or rather its numerical equivalent) has a special meaning when paired with one of them. That meaning you already seem to understand, so no need to discuss it.
Heres hoping that somewhere between me and rattle you figured out how it all works.

Posted: 19 Oct 2007, 07:13
by TheRegisteredOne
you have "#define ACTIVATION 1" so that "get 1" means "get ACTIVATION". This is just so it is clearer to someone reading the code. also, read your error message; they might actually tell you useful info (ie, the number is the line number, and text after it tells you the error!).
let's list all the errors you have in that script:
1. you have a variable with the same name as a function ("Activate") scriptor is not case sensitive (TA/Spring is, and as the script calls the property "ACTIVATION" inside the engine, it needs to be capitalized), it will mistake the two.
2. your variable "activate" is meaningless. It is not the same as "ACTIVATION", which is a property that is inside the engine. You cannot get or set your variable. If you want to change the value of a variable, use the '=' operator.
3. While loop doesn't need a semicolon. it cannot have one.
4. This here is retarded:
Code: Select all
while(ACTIVATE==1);
{
move top to y-axis [5] speed [10];
sleep 100;
move top to y-axis [0] speed [10];
}
it will move top to [5] and not do anything, as you move top to [5] right after moving top to [0]. This is what the game will do:
Code: Select all
...
move top to y-axis [5] speed [10];
sleep 100;
move top to y-axis [0] speed [10];
move top to y-axis [5] speed [10];
sleep 100;
move top to y-axis [0] speed [10];
move top to y-axis [5] speed [10];
sleep 100;
move top to y-axis [0] speed [10];
....
5. You didn't set the parameter of QueryPrimary. Your weapon doesn't have a firing point.
Posted: 19 Oct 2007, 12:19
by KDR_11k
I'm not sure about == but some operators take preceedence over get/set so e.g. get ACTIVATION + 1 is read as get (ACTIVATION + 1).
Posted: 19 Oct 2007, 17:27
by rattle
Rattle: Why are you saying the #define ACTIVATION and Activate() function have nothing to do with a unit's activation state? They constitute the entirety of a scripts interaction with its parent unit's activation state.
Scratch the Activate() part then. It's just a toggle-able function, nothing more.
Well draco's been making a mess by defining static-vars having the same name of a function or a define. He also tried to change the value the define ACTIVATION reflects in order to change the value of the state by redefining it.
Anyway scriptor tells you what's wrong in the most cases.
I'm all for a C course in preschool tbh. :P
new one
Posted: 25 Oct 2007, 04:03
by rcdraco
This one has aiming issues with all guns but weapon1. They all shoot at the same target, but the top guns aim at weird angles.
Code: Select all
#define TA // This is a TA script
#include "sfxtype.h"
#include "exptype.h"
piece base, gun, barrel, bridge, gun1, barrel1, gun2, barrel2, gun3, barrel3;
static-var Exp;
// Signal definitions
#define SIG_AIM 2
#define SIG_AIM_2 4
#define SIG_AIM_3 8
#define SIG_AIM_4 16
SmokeUnit(healthpercent, sleeptime, smoketype)
{
while( get BUILD_PERCENT_LEFT )
{
sleep 400;
}
while( TRUE )
{
healthpercent = get HEALTH;
if( healthpercent < 66 )
{
smoketype = 256 | 2;
if( Rand( 1, 66 ) < healthpercent )
{
smoketype = 256 | 1;
}
emit-sfx smoketype from base;
}
sleeptime = healthpercent * 50;
if( sleeptime < 200 )
{
sleeptime = 200;
}
sleep sleeptime;
}
}
GetExp()
{
Exp = Get VETERAN_LEVEL;
if (Exp > 20)
{
show gun1;
show barrel1;
}
if (Exp > 40)
{
show bridge;
show gun2;
show barrel2;
}
if (Exp > 60)
{
show gun3;
show barrel3;
}
sleep 600;
start-script GetExp();
}
Create()
{
start-script SmokeUnit();
start-script GetExp();
hide barrel1;
hide barrel2;
hide barrel3;
hide gun1;
hide gun2;
hide gun3;
hide bridge;
}
AimWeapon1(heading, pitch)
{
signal SIG_AIM;
set-signal-mask SIG_AIM;
turn gun to y-axis heading speed <300>;
turn barrel to x-axis <0> - pitch speed <300>;
wait-for-turn gun around y-axis;
wait-for-turn barrel around x-axis;
return (1);
}
FireWeapon1()
{
move barrel to z-axis [-3] now;
sleep 100;
move barrel to z-axis [0] now;
}
AimFromWeapon1(piecenum)
{
piecenum = gun;
}
QueryWeapon1(piecenum)
{
piecenum = barrel;
}
AimWeapon2(heading, pitch)
{
While (Exp > 20)
{
signal SIG_AIM_2;
set-signal-mask SIG_AIM_2;
turn gun1 to y-axis heading speed <300>;
turn barrel1 to x-axis <0> - pitch speed <300>;
wait-for-turn gun1 around y-axis;
wait-for-turn barrel1 around x-axis;
return (1);
}
}
FireWeapon2()
{
}
AimFromWeapon2(piecenum)
{
piecenum = gun1;
}
QueryWeapon2(piecenum)
{
piecenum = barrel1;
}
AimWeapon3(heading, pitch)
{
While (Exp > 40)
{
signal SIG_AIM_3;
set-signal-mask SIG_AIM_3;
turn gun2 to y-axis heading speed <300>;
turn barrel2 to x-axis <0> - pitch speed <300>;
wait-for-turn gun2 around y-axis;
wait-for-turn barrel2 around x-axis;
return (1);
}
}
FireWeapon3()
{
}
AimFromWeapon3(piecenum)
{
piecenum = gun2;
}
QueryWeapon3(piecenum)
{
piecenum = barrel2;
}
AimWeapon4(heading, pitch)
{
While (Exp > 60)
{
signal SIG_AIM_4;
set-signal-mask SIG_AIM_4;
turn gun3 to y-axis heading speed <300>;
turn barrel3 to x-axis <0> - pitch speed <300>;
wait-for-turn gun3 around y-axis;
wait-for-turn barrel3 around x-axis;
return (1);
}
}
FireWeapon4()
{
}
AimFromWeapon4(piecenum)
{
piecenum = gun3;
}
QueryWeapon4(piecenum)
{
piecenum = barrel3;
}
SweetSpot(piecenum)
{
piecenum = gun;
}
Killed(severity, corpsetype)
{
hide barrel;
if( severity <= 25 )
{
corpsetype = 1;
explode gun type BITMAPONLY | BITMAP1;
explode base type BITMAPONLY | BITMAP2;
explode barrel type BITMAPONLY | BITMAP3;
explode gun type BITMAPONLY | BITMAP4;
return (0);
}
if( severity <= 50 )
{
corpsetype = 2;
explode gun type FALL | BITMAP1;
explode base type BITMAPONLY | BITMAP2;
explode barrel type FALL | BITMAP3;
explode gun type FALL | BITMAP4;
return (0);
}
if( severity <= 99 )
{
corpsetype = 3;
explode gun type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode base type BITMAPONLY | BITMAP2;
explode barrel type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
explode gun type SHATTER | BITMAP4;
return (0);
}
corpsetype = 3;
explode gun type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode base type BITMAPONLY | BITMAP2;
explode barrel type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
explode gun type SHATTER | BITMAP4;
}
Posted: 25 Oct 2007, 04:04
by Snipawolf
Top? Do you have a turret on top of a turret? If so, it fucks up your aiming.
If top turret aims, then bottom turret aims, then the top turret will be displaced by the angle the bottom turret aimed at.
WTF
Posted: 25 Oct 2007, 04:06
by rcdraco
How do I fix that? That is what it is, the top 3 guns are on top of the main turret.
Posted: 25 Oct 2007, 04:11
by Snipawolf
Ouch, I am not sure...
I had that issue once before, but I was so newbish back then, I don't think I even tried to fix it... Maybe have a call in there.
Like, a variable, maybe? If you had a variable for the other turrets that asked when the main turret was done turning, then perhaps allow them to aim?
Like
AimWeapon1(heading, pitch)
{
signal SIG_AIM;
set-signal-mask SIG_AIM;
turningturret1=1; //Snipa's added variable
turn gun to y-axis heading speed <300>;
turn barrel to x-axis <0> - pitch speed <300>;
wait-for-turn gun around y-axis;
wait-for-turn barrel around x-axis;
turningturret1=0;
return (1);
}
AimWeapon2(heading, pitch)
{
While (Exp > 20)
{
if(turningturret1=1)
{return 0;}
if(turningturret1=0)
{
signal SIG_AIM_2;
set-signal-mask SIG_AIM_2;
turn gun1 to y-axis heading speed <300>;
turn barrel1 to x-axis <0> - pitch speed <300>;
wait-for-turn gun1 around y-axis;
wait-for-turn barrel1 around x-axis;
return (1);
}
}
}
and repeat for all the other ones. Not sure if it will work, good luck.
EDIT: Just make the three turrets not children of the large turret... Duh.. >__< Should've thought of that myself. Then they will face straight ahead while it turns, which may look bad, but still, a lot better than doing anything else!
nah
Posted: 25 Oct 2007, 18:51
by rcdraco
I'm dropping that setup for a hide and replace setup, so instead of 4 guns it can upgrade the main cannon twice, and at level 4 it gets a minigun on top, model centered, child of the base.
So it'll be cannon->better cannon->double barrel->double barrel + minigun
It's a gun, not a tank so you know, just a turret on an empty base object, with the cannon's main point as it's "base", now I don't know what I'll do for this. >_<
oh no
Posted: 26 Oct 2007, 19:10
by rcdraco
Is SweetSpot till used? My new ideas might end up making the gun impossible to hit.
Posted: 26 Oct 2007, 20:45
by KDR_11k
Nope, Sweetspot means nothing. Spring always aims for the center of the hitsphere.