Mod Question Repository... Questions come in, answers go out
Moderator: Moderators
Re: Mod Question Repository... Questions come in, answers go out
If it hits zero, it will fly to the nearest refueling point, IIRC.
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: Mod Question Repository... Questions come in, answers go out
yes that works. now if some one could please take a look at that script to see what is up with the setsfx error.
thanks
thanks
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: Mod Question Repository... Questions come in, answers go out
nvm got it
I just had to re arrange so it didnt have 2 set sfx's
I just had to re arrange so it didnt have 2 set sfx's
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: Mod Question Repository... Questions come in, answers go out
Halp! I messed with a ton of junk, and now spring is crashing, from what it seems right after loading tiles
its not that wav because i haven't changed that at all, and it was loading just fine earlier. any ideas on what causes crashes right about here that i should check?
its not that wav because i haven't changed that at all, and it was loading just fine earlier. any ideas on what causes crashes right about here that i should check?
Last edited by bobthedinosaur on 14 Jun 2009, 02:10, edited 1 time in total.
- Pressure Line
- Posts: 2283
- Joined: 21 May 2007, 02:09
Re: Mod Question Repository... Questions come in, answers go out
try loading without an AI? (/endgraph to kill the game ends screen)
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: Mod Question Repository... Questions come in, answers go out
i fixed it, but now none of my lasers or laser like weapons are lasers! they all look like ugly cannon blobs, but have thier old sounds and CEG's. Wtf did i do! 

Re: Mod Question Repository... Questions come in, answers go out
Does your mod have a weapondefs_post.lua? If it has, and that file does not include the code found in similar file in springbase, then borked weapons are to be expected.
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: Mod Question Repository... Questions come in, answers go out
for some reason spring was like where is it, so i made one and then i jacked up my lasers. so i dont need it really, but what would the weapondef do or more importantly why would i need one?
Re: Mod Question Repository... Questions come in, answers go out
This is the file that is used to change your weapons before game starts (so you can for ex. apply a range multiplier based on modoptions set via lobby). More importantly, this file is also used to set some values in weapondefs (as can be seen in Spring\base\springcontent.sdz\gamedata\weapondefs_post.lua), and if you have a weapondefs_post.lua in your mod and it does not include the code from that base fle, then weapons will be borked (lasers turn into cannons and some more odd things).
This was not always like so, the borkedness only started to show up during Spring 0.78 or so.
This was not always like so, the borkedness only started to show up during Spring 0.78 or so.
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: Mod Question Repository... Questions come in, answers go out
2 questions:
-would it be hard to make a multiple choice of transformations, like 4 options?
-what is the simplest method to restrict a tranformation of a unit with in a certain range of another unit. ie next to it like that defence mod i cant remember the name?
-would it be hard to make a multiple choice of transformations, like 4 options?
-what is the simplest method to restrict a tranformation of a unit with in a certain range of another unit. ie next to it like that defence mod i cant remember the name?
Re: Mod Question Repository... Questions come in, answers go out
morph and you can check unit distances from things yes.
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: Mod Question Repository... Questions come in, answers go out
got a stumper. for some reason this 3 missile launcher jumps to fireweapon2 during it spawn, and made the weapon unable to fire because it takes a missile away. weapon 1 is one missile at a time weapon 2 is all 3 in a fast burst, however I can not make this work at all. i thought the checks to see if all the missiles are there so weapon 2 will be ready to fire was doing it but removing them did not help.
any one want to take a stab at it?
any one want to take a stab at it?
Code: Select all
#define TA // This is a TA script
#include "sfxtype.h"
#include "exptype.h"
piece base, m1, sleeve, turret, m2, m3;
static-var smode, aimer, restore_delay, miz, mx1, mx2, mx3, mxt, gun2, ready;
// Signal definitions
#define SIG_AIM 2
#define SIG_AIM2 4
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;
}
}
undeploy()
{
if (smode == 1)
{
smode = 0;
aimer = 0;
turn turret to y-axis <0> speed <100.071429>;
turn sleeve to x-axis <0> speed <50.043956>;
sleep 2000;
aimer = 1;
}
}
deploy()
{
if (smode == 0)
{
smode = 1;
aimer = 0;
turn turret to y-axis <0> speed <100.071429>;
turn sleeve to x-axis <0> speed <50.043956>;
sleep 2000;
aimer = 2;
}
}
Toggle(t,value)
{
if(t==1)
{
if(value==0)
{
call-script deploy();
}
if(value==1)
{
call-script undeploy();
}
}
}
Create()
{
mx1 = 1;
mx2 = 1;
mx3 = 1;
mxt = 3;
miz = 1;
gun2 = 1;
smode = 0;
aimer = 1;
ready = 0;
start-script SmokeUnit();
}
SetMaxReloadTime(Func_Var_1)
{
restore_delay = Func_Var_1 * 2;
}
RestoreAfterDelay()
{
sleep restore_delay;
turn turret to y-axis <0> speed <100.071429>;
turn sleeve to x-axis <0.000000> speed <50.043956>;
}
Reload1()
{
sleep 12000;
show m1;
mx1 = 1;
}
Reload2()
{
sleep 12000;
show m2;
mx2 = 1;
}
Reload3()
{
sleep 12000;
show m3;
mx3 = 1;
}
ReloadAll()
{
sleep 12000;
show m1;
mx1 = 1;
sleep 12000;
show m2;
mx2 = 1;
sleep 8000;
show m3;
mx3 = 1;
}
AimFromPrimary(piecenum)
{
piecenum = turret;
}
QueryPrimary(piecenum)
{
if (miz == 1)
{
piecenum = m3; //was m1 then 2 then 3
}
if (miz == 2)
{
piecenum = m1;
}
if (miz == 3)
{
piecenum = m2;
}
}
AimPrimary(heading, pitch)
{
signal SIG_AIM;
set-signal-mask SIG_AIM;
start-script restoreafterdelay();
if (aimer == 1)
{
turn turret to y-axis heading speed <100.071429>;
turn sleeve to x-axis <0.000000> - pitch speed <50.043956>;
wait-for-turn turret around y-axis;
wait-for-turn sleeve around x-axis;
return (1);
}
}
FirePrimary()
{
if (miz == 1)
{
hide m1;
mx1 = 0;
miz = 2;
start-script reload1();
return 0;
}
if (miz == 2)
{
hide m2;
mx2 = 0;
miz = 3;
start-script reload2();
return 0;
}
if (miz == 3)
{
hide m3;
mx3 = 0;
miz = 1;
start-script reload3();
return 0;
}
}
checkready()
{
mxt = (mx1 + mx2 + mx3);
if ( mxt == 3)
{
ready = 1;
}
if (mxt < 3)
{
ready = 0;
}
sleep 500;
}
AimWeapon2(heading, pitch)
{
signal SIG_AIM2;
set-signal-mask SIG_AIM2;
start-script checkready();
start-script restoreafterdelay();
if (aimer == 2 )
{
if (ready == 0)
{
call-script reloadAll();
sleep 800;
}
turn turret to y-axis heading speed <100.071429>;
turn sleeve to x-axis <0.000000> - pitch speed <50.043956>;
wait-for-turn turret around y-axis;
wait-for-turn sleeve around x-axis;
if ( ready == 1)
{
return (1);
}
}
}
Shot2()
{
if (gun2 == 1)
{
hide base; //wtf are you hiding the base for!?
mx1 = 0;
gun2 = 2;
return 0;
}
if (gun2 == 2)
{
//hide m2;
mx2 = 0;
gun2 = 3;
return 0;
}
if (gun2 == 3)
{
//hide m3;
mx3 = 0;
gun2 = 1;
return 0;
}
}
AimFromSecondary(piecenum)
{
piecenum = turret;
}
QuerySecondary(piecenum)
{
if (gun2 == 1)
{
piecenum = m3; //was m1 then 2 then 3
}
if (gun2 == 2)
{
piecenum = m1;
}
if (gun2 == 3)
{
piecenum = m2;
}
}
SweetSpot(piecenum)
{
piecenum = base;
}
Killed(severity, corpsetype)
{
if( severity <= 25 )
{
corpsetype = 1;
explode m1 type BITMAPONLY | BITMAP1;
explode base type BITMAPONLY | BITMAP2;
explode sleeve type BITMAPONLY | BITMAP3;
explode turret type BITMAPONLY | BITMAP5;
return (0);
}
if( severity <= 50 )
{
corpsetype = 2;
explode m1 type FALL | BITMAP1;
explode base type BITMAPONLY | BITMAP2;
explode sleeve type FALL | BITMAP3;
explode turret type FALL | BITMAP5;
return (0);
}
if( severity <= 99 )
{
corpsetype = 3;
explode m1 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode base type BITMAPONLY | BITMAP2;
explode sleeve type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
explode turret type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP5;
return (0);
}
corpsetype = 3;
explode m1 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode base type BITMAPONLY | BITMAP2;
explode sleeve type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
explode turret type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP5;
}
Re: Mod Question Repository... Questions come in, answers go out
Question: is the weapon1 and weapon2 supposed to be, visually, the same thing?
If yes... then write a Lua Gadget and invoke it through COB, depending on a user-sent command, and use Spring.SetUnitWeaponState to control whether it fires a burst of all the weapons or just one at a time, reload, etc., instead of trying to let two weapons control the same Pieces.
If yes... then write a Lua Gadget and invoke it through COB, depending on a user-sent command, and use Spring.SetUnitWeaponState to control whether it fires a burst of all the weapons or just one at a time, reload, etc., instead of trying to let two weapons control the same Pieces.
-
- Posts: 916
- Joined: 27 Jun 2009, 01:32
Re: Mod Question Repository... Questions come in, answers go out
Would have been nice if you would have described things more well here. So if I understood things right you want to do a unit that can deploy. When undeployed it uses a single shot weapon1 and when deployed it should use weapon2. For determining if the unit is deployed or not you have this toggle function which gets a variable. I don't really know where the variable comes from and the toggle function seems to not be called at all (or is that a hardcoded one linked to the on/off button - I thought that was "activated" though)...
Your behaviour now is what exactly? The unit pops up with a missing missile and is in aimer state for weapon 2 and doesn't get the missing missile back?
Apart from that I just found some small oddities I want to bring up:
Your behaviour now is what exactly? The unit pops up with a missing missile and is in aimer state for weapon 2 and doesn't get the missing missile back?
Apart from that I just found some small oddities I want to bring up:
- Isn't the entire smode checking in your deployment stuff totally superfluous? As deployment is triggered by the toggle function I see no real need to doublecheck here.
- The last sleep in ReloadAll() just is 8000 - probably should be 12000
- I'm not 100% sure about this one as I never learned COB from a real manual but shouldn't you use else ifs in e.g. FirePrimary as you change the miz value in every if section and afaik this always gave me the problem that this would lead to a case where the entire primary function list will be done in every shot. I.e. the first if part sets miz to 2 but then this part is followed by a miz == 2 part which then would be called too and so on. Another argument for this would be that I saw many people either doing a ++whatevervalue at the very end of the fire function or use else ifs everywhere.
- Why is there this "huge" sleep time in checkready? It just will delay firing. Maybe also use call-script in the aim function instead of start script...
- In the AimWeapon2 function why is there a sleep 800 after the ReloadAll call?
- Shouldn't "ready" be = 1 in the create function?
- To make things "more nice" to understand you should rename "miz" to "gun1" or something and I also found it more clean to use a piecenum = firepoint; in the query function for the burst weapon and then e.g. do a firepoint = m3 in the Shot2 function.
- Why sometimes using brackets for return like "return (1)" and sometimes not?
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: Mod Question Repository... Questions come in, answers go out
okay weapon1 is on normally and is a to air missile weapon, that is a 1 shot and cycles thru the 3 missiles on the model.
weapon 2 when the switch is on jams 1 and allows the missiles to be fired in a burst at ground targets, but has no guidance (hence dumb fire). weapon 2 needs to wait for all 3 missiles to be loaded on the model before it can fire, because its fires in a burst of 3. so i tried to add a detector to check if the 3 missiles where all up and then let weapon 2 fire when the unit is in weapon 2 mode (jammed 1). how ever when the unit is built it jumps to weapon2's shot2() script and starts hiding pieces. and not calling for a reload script to put the missiles back.
weapon 2 when the switch is on jams 1 and allows the missiles to be fired in a burst at ground targets, but has no guidance (hence dumb fire). weapon 2 needs to wait for all 3 missiles to be loaded on the model before it can fire, because its fires in a burst of 3. so i tried to add a detector to check if the 3 missiles where all up and then let weapon 2 fire when the unit is in weapon 2 mode (jammed 1). how ever when the unit is built it jumps to weapon2's shot2() script and starts hiding pieces. and not calling for a reload script to put the missiles back.
Re: Mod Question Repository... Questions come in, answers go out
Bob, make sure that all of the Shot(), Fire() etc. have a return 0 at the end. I forgot about this, but if you don't, that tends to bork stuff.
Re: Mod Question Repository... Questions come in, answers go out
It never does for me.
-
- Posts: 916
- Joined: 27 Jun 2009, 01:32
Re: Mod Question Repository... Questions come in, answers go out
Returning also never had any importance for me - in fact you can leave the entire Fire() / Shot() function empty if you simply want nothing to happen...
@bobthedinosaur:
I've looked your code through for a couple of times now but I cannot find any logic mistake in there. So I suggest you comment out that entire deployment part and then e.g. comment out the entire weapon2 functions and give the right values in the create() part so weapon1 should be chosen. Test if weapon1 works and continue to do the same with just weapon2 being active. You should be able to get a clue of where things start to go wrong that way...
@bobthedinosaur:
I've looked your code through for a couple of times now but I cannot find any logic mistake in there. So I suggest you comment out that entire deployment part and then e.g. comment out the entire weapon2 functions and give the right values in the create() part so weapon1 should be chosen. Test if weapon1 works and continue to do the same with just weapon2 being active. You should be able to get a clue of where things start to go wrong that way...
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: Mod Question Repository... Questions come in, answers go out
Having trouble with air repaid pads and getting aircraft to land when 0 on fuel. How do you define the point it lands, and what are the must have fbi parts?
And what the hell are these functions?
And what the hell are these functions?
Code: Select all
QueryLandingland(Func_Var_1, Func_Var_2)
{
Func_Var_1 = 1;
Func_Var_2 = 1;
}
Re: Mod Question Repository... Questions come in, answers go out
Code: Select all
piece GP, base, pad, cranesupports, cranebody, cord1, cord2, crate1a, crate2a, crate1b, crate2b, crate1c, crate2c;
static-var ISBUILDING;
#define SIG_BUILD 4
#define SMOKEPIECE1 base
#define SMOKEPIECE2 cranebody
#define SMOKEPIECE3 GP
//------------------------------------------------------
//start ups :)
//------------------------------------------------------
Create()
{
ISBUILDING = FALSE;
}
SweetSpot(piecenum)
{ piecenum=GP; }
QueryNanoPiece(piecenum)
{ piecenum=base; }
QueryLandingPad(pad1)
{ pad1 = pad; }
/*==============================================
//nano functions
==============================================*/
StartBuilding(heading,pitch)
{
ISBUILDING = TRUE;
sleep 1200;
set INBUILDSTANCE to TRUE;
}
TargetCleared(which)
{
signal SIG_BUILD;
set-signal-mask SIG_BUILD;
sleep 500;
ISBUILDING = FALSE;
}
StopBuilding()
{
set INBUILDSTANCE to FALSE;
signal SIG_BUILD;
set-signal-mask SIG_BUILD;
sleep 500;
ISBUILDING = FALSE;
}
/*=============================================\
| Death function |
\=============================================*/
Killed( severity, corpsetype )
{
corpsetype = 1;
// explode base type SHATTER;
return( 0 );
}