Well, almost everything is working. I'm using vehicles in TDM with bots (bots don't know how to use it, ofc, they will be there just to get some people into the server)
The maps I'm using - mp_iceberg_v2 (planes and AA only), mp_iwo_jima_1, mp_gunslingers, zzz_vokbeta
and also El Alamein (planes and AA only - it's not bad for planes - no buildings, map limits are far away).
For the AA and jeep spawns I simply used fixed positions I chose in game.
I'm stuck with the following problem, though - when I eject from a plane and immediately try to use an AA / jeep, I don't get attached.
When plane pilots eject, the plane falls, explodes and, after a few seconds, it's removed.
What is happening exactly - I eject, I open the chute, I use an AA or jeep.
If the plane is still in the map (still in the air, falling, or on the ground, blown up), I don't get attached.
After the plane is removed, I get properly attached.
I noticed that, if I leave the AA and use it again while the plane is still in the map, I get attached properly.
I tested the original mod, it's CTF with random relative spawns around the flag. The bug does not happen then.
But if I set fix locations for the spawns, the bug will happen.
Can anybody help, please?
Here is the code for aa_spawn.
What has changed is this:
aa = spawn( "script_model", aaorigin );
That used to be like this:
aa = spawn( "script_model", origin );
I'm now giving the function the location for the spawn, instead of letting it get a random one.
PHP Code:
aa_spawn(team, plusAngles, aaorigin)
{
self endon("intermission");
if( !isDefined( team ) )
team = "axis";
if( !isDefined( plusAngles ) )
plusAngles = (0,0,0);
alliedf = getentarray("allied_flag", "targetname");
axisf = getentarray("axis_flag", "targetname");
originAllied = alliedf[0] getOrigin();
originAxis = axisf[0] getOrigin();
temp = (0,0,0);
if( team == "axis" )
{
tempOrigin = originAxis;
temp = vectorToAngles( originAxis - originAllied );
}
else
{
temp = vectorToAngles( originAllied - originAxis );
tempOrigin = originAllied;
}
tempF = anglesToForward( temp );
temp = vector_scale( tempF, randomIntRange( level.aaMinFarBack,level.aaMaxFarBack) );
temp += tempOrigin;
origin = temp;
wait( randomIntRange( 2,4 ) );
x = randomIntRange( level.aaMinX, level.aaMaxX);
y = randomIntRange( level.aaMinY, level.aaMaxY);
trace = bulletTrace( origin + (x,y,500), origin - (x, y, 11500 ), false, undefined );
origin = trace["position"] ;
aa = spawn( "script_model", aaorigin );
aa setModel( game["aa"] );
aa show();
aa.cannonRounds = [];
//aa.properties = [];
anglesF = anglesToForward( aa.angles );
anglesR = anglesToRight( aa.angles );
anglesU = anglesToUp( aa.angles );
// GUNS GUNS GUNS
aa.properties["gun0"]["f"] = 100;
aa.properties["gun0"]["r"] = -19;
aa.properties["gun0"]["u"] = 56.5;
aa.properties["gun1"]["f"] = 100;
aa.properties["gun1"]["r"] = 19;
aa.properties["gun1"]["u"] = 39.5;
aa.properties["gun2"]["f"] = 100;
aa.properties["gun2"]["r"] = -19;
aa.properties["gun2"]["u"] = 40;
aa.properties["gun3"]["f"] = 100;
aa.properties["gun3"]["r"] = 19;
aa.properties["gun3"]["u"] = 56;
maxRounds = 20;
aa.cannonRounds[ aa.cannonRounds.size ] = maxRounds;
aa.cannonRounds[ aa.cannonRounds.size ] = maxRounds;
aa.cannonRounds[ aa.cannonRounds.size ] = maxRounds;
aa.cannonRounds[ aa.cannonRounds.size ] = maxRounds;
/////////////////////////////////////
// GUNNER
aa.properties["gunner"]["f"] = -30;
aa.properties["gunner"]["r"] = 1;
aa.properties["gunner"]["u"] = 20;
aa.gunner = undefined;
aa.gunner = undefined;
// END GUNNER
aa.fireSetting = 1;
aa.team = team;
aa.weaponName = "aa_mp";
aa.angles += plusAngles;
aa.plusAngles = plusAngles;
aa.damage = 0;
aa.maxDamage = level.aaMaxDamage;
aa.vehicleType = "aa";
aa thread scriptedTrigger( 75.0);
aa thread onTrigger( );
aa thread trackDamage(aaorigin);
}
And this is spawn_jeep. New spawn location called jeeporigin now
PHP Code:
spawn_jeep( team, jeeporigin )
{
origin = (-39200, 11383, -320);
if( team == "allies")
spawnpointname = "mp_ctf_spawn_allied";
else
spawnpointname = "mp_ctf_spawn_axis";
sp = getentarray(spawnpointname, "classname");
for(j = 0; j < 1; j++ )
{
temp = sp[ randomIntRange(0, sp.size -1) ];
x = randomIntRange(1,2400);
y = randomIntRange( 1,2400 );
trace = bulletTrace( temp.origin + (x,y,550),temp.origin - (x,y,1000), false, undefined );
origin = trace["position"];
jeeps = level.jeeps;
gdist = true;
for(i = 0; i < jeeps.size; i++ )
{
if( !isDefined( jeeps[i] ) )
continue;
dist = distance( jeeps[i] getOrigin(), origin);
dist2 = distance( origin, temp.origin );
itemp = origin[2] - temp.origin[2];
if( ( itemp > -120 && itemp < 120 ) & dist > 1000 && dist2 > 140 )
{
gdist = false;
break;
}
}
if( gdist == true )
break;
wait(0.1);
}
wait 1;
origin = getRandomSpawn( team,80, 700 );
jeep = spawn("script_model", jeeporigin );
jeep setModel( game["jeep" + team] );
jeep show();
jeep.teamAlt = team;
anglesF = anglesToForward( jeep.angles );
anglesR = anglesToRight( jeep.angles );
temp = vector_scale( anglesR, -18);
temp += vector_scale( anglesF, -14);
jeep.driverTag = spawn("script_origin", jeep getOrigin() + (0,0,10 ));
jeep.driverTag linkTo(jeep);
//***********************************
// passenger location
//***********************************
if( team == "axis" )
temp = vector_scale( anglesF, -45);
else
temp = vector_scale( anglesF, -50);
jeep.passenger1Tag = spawn("script_origin", jeep getOrigin() + temp + (0,0,15 ));
jeep.passenger1Tag linkTo(jeep);
//***********************************
// turret Back passenger location
//***********************************
temp = vector_scale( anglesF, -50);
turrets = getentarray ("misc_turret","classname");
//***********************************
// Front Left Tire
//***********************************
temp = vector_scale( anglesF, 50 );
tireOrigin = origin + temp;
temp = vector_scale( anglesR, -25 );
tireOrigin += temp;
jeep.frontLeftTire = spawn("script_origin", tireOrigin + (0,0,1) );
jeep.frontLeftTire linkTo( jeep );
//***********************************
// Front Right Tire
//***********************************
temp = vector_scale( anglesF, 50 );
tireOrigin = origin + temp;
temp = vector_scale( anglesR, 25 );
tireOrigin += temp;
jeep.frontRightTire = spawn("script_origin", tireOrigin + (0,0,1) );
jeep.frontRightTire linkTo( jeep );
//***********************************
// Back Left Tire
//***********************************
temp = vector_scale( anglesF, -40 );
tireOrigin = origin + temp;
temp = vector_scale( anglesR, -25 );
tireOrigin += temp;
jeep.backLeftTire = spawn("script_origin", tireOrigin + (0,0,1) );
jeep.backLeftTire linkTo( jeep );
//***********************************
// Back Right Tire
//***********************************
temp = vector_scale( anglesF, -40 );
tireOrigin = origin + temp;
temp = vector_scale( anglesR, 25 );
tireOrigin += temp;
jeep.backRightTire = spawn("script_origin", tireOrigin + (0,0,1) );
jeep.backRightTire linkTo( jeep );
maxspeed = getCvarInt("dvar_jeepMaxSpeed");
minspeed = getCvarInt("dvar_jeepMinSpeed");
if( maxspeed == 0 )
maxspeed = 40;
if( minspeed == 0 )
minspeed = -30;
jeep.sounds = [];
jeep.sounds[0] = "jeep_start";
jeep.sounds[1] = "jeep_idle";
jeep.sounds[2] = "jeep_move";
jeep.sounds[3] = "jeep_horn";
jeep.sounds[4] = "jeep_crash";
jeep.team = team;
jeep.speed = 0;
jeep.maxSpeed = maxspeed;
jeep.minSpeed = minspeed;
jeep.jeepAngle = 0;
jeep.colPos = (0,0,0);
jeep.colSurf = "";
jeep.maxDamage = 10;
jeep.damage = 0;
jeep.vehicleType = "jeep";
jeep.jeepTimerSet = undefined;
level.jeeps[ level.jeeps.size ] = jeep;
jeep thread engineON(jeeporigin);
jeep thread jeepBackupTime();
return jeep;
}
P. S. Not getting attached means - I can still move with WASD after using AA or jeep, while shooting / driving it.