Jump to content

Vehicle Projectile In Single Player


Colt

Recommended Posts

Hello Everyone.

I have started working on Jedi Academy Source, The first thing what i want to Add is the Vehicle projectile generated from vwp files. I think Raven have missed it in SP, 'cause in MP it works Perfectly. In SP all projectiles from vehicles are generated from WP_BLASTER but..i found the affectable Muzzle Flash that is worked and it read from vwp file. So for now there is no ShotFX code and i have build my own Code for that ShotFX :

the file is g_weapon.cpp

						if ( vehWeapon->iMuzzleFX )
						{
							G_PlayEffect( vehWeapon->iMuzzleFX, pVeh->m_Muzzles[i].m_vMuzzlePos, pVeh->m_Muzzles[i].m_vMuzzleDir );
                            WP_FireVehicleWeapon( ent, start, dir, vehWeapon );
						}

						WP_FireVehicleWeapon( ent, start, dir, vehWeapon );
					}

This is an original structure for muzzle flash from vwp file

My code for ShotFX

 

						if ( vehWeapon->iShotFX )
						{

							G_PlayEffect( vehWeapon->iMuzzleFX, pVeh->m_Muzzles[i].m_vMuzzlePos, pVeh->m_Muzzles[i].m_vMuzzleDir );
							gentity_t	*missile;
		                    vec3_t		mins, maxs;

		                    VectorSet( maxs, vehWeapon->fWidth/2.0f,vehWeapon->fWidth/2.0f,vehWeapon->fHeight/2.0f );
		                    VectorScale( maxs, -1, mins );
						}

And here the problems starts.

I Really don't know what code i need to use for G_PlayEffect, because as you can see its almost the same code that is used for Muzzle Flash only iShotFX is changed to the structure 

But it works in game ! the Projectile is now read from vwp but.. its only attached for the model. This projectile don't flyin' it have the same function as Muzzle Flash and "default" projectile is still read from WP_BLASTER :| so if anyone knows what code i need to use Please help me with this One. Im Attach the link with screenshots how it looks in game

http://www26.zippyshare.com/v/32018668/file.html

Thank You in Advance

Link to comment

The muzzle flash would likely be handled in cg_weapons.cpp or somewhere on the client. I'm not sure how SP handles it but you might try and use the "Find All References" tool to see where WP_BLASTER is being used in the vehicle code.

Also, please use an image sharing service like Photobucket, Imageshack (or even Dropbox) for hosting your image.

Link to comment

Already did That and it wont work.It Only read from G_playEffect and the Vehicle code is used right in this file 
 

void WP_FireVehicleWeapon( gentity_t *ent, vec3_t start, vec3_t dir, vehWeaponInfo_t *vehWeapon )
{
	if ( !vehWeapon )
	{//invalid vehicle weapon
		return;
	}
	else if ( vehWeapon->bIsProjectile )
	{//projectile entity
		gentity_t	*missile;
		vec3_t		mins, maxs;

		VectorSet( maxs, vehWeapon->fWidth/2.0f,vehWeapon->fWidth/2.0f,vehWeapon->fHeight/2.0f );
		VectorScale( maxs, -1, mins );

		//make sure our start point isn't on the other side of a wall
		WP_TraceSetStart( ent, start, mins, maxs );
		
		//QUERY: alt_fire true or not?  Does it matter?
		missile = CreateMissile( start, dir, vehWeapon->fSpeed, 10000, ent, qfalse );
		if ( vehWeapon->bHasGravity )
		{//TESTME: is this all we need to do?
			missile->s.pos.trType = TR_GRAVITY;
		}

		missile->classname = "vehicle_proj";
		
		missile->damage = vehWeapon->iDamage;
		missile->splashDamage = vehWeapon->iSplashDamage;
		missile->splashRadius = vehWeapon->fSplashRadius;

		// HUGE HORRIBLE HACK
		if (ent->owner && ent->owner->s.number==0)
		{
			missile->damage			*= 20.0f;
			missile->splashDamage	*= 20.0f;
			missile->splashRadius	*= 20.0f; 
		}

		//FIXME: externalize some of these properties?
		missile->dflags = DAMAGE_DEATH_KNOCKBACK;
		missile->clipmask = MASK_SHOT;
		//Maybe by checking flags...?
		if ( vehWeapon->bSaberBlockable )
		{
			missile->clipmask |= CONTENTS_LIGHTSABER;
		}
		/*
		if ( (vehWeapon->iFlags&VWF_KNOCKBACK) )
		{
			missile->dflags &= ~DAMAGE_DEATH_KNOCKBACK;
		}
		if ( (vehWeapon->iFlags&VWF_DISTORTION_TRAIL) )
		{
			missile->s.eFlags |= EF_DISTORTION_TRAIL;
		}
		if ( (vehWeapon->iFlags&VWF_RADAR) )
		{
			missile->s.eFlags |= EF_RADAROBJECT;
		}
		*/
		missile->s.weapon = WP_BLASTER;//does this really matter?

		// Make it easier to hit things
		VectorCopy( mins, missile->mins );
		VectorCopy( maxs, missile->maxs );
		//some slightly different stuff for things with bboxes
		if ( vehWeapon->fWidth || vehWeapon->fHeight )
		{//we assume it's a rocket-like thing
			missile->methodOfDeath = MOD_ROCKET;
			missile->splashMethodOfDeath = MOD_ROCKET;// ?SPLASH;

			// we don't want it to ever bounce
			missile->bounceCount = 0;

			missile->mass = 10;
		}
		else
		{//a blaster-laser-like thing
			missile->s.weapon = WP_BLASTER;//does this really matter?
			missile->methodOfDeath = MOD_EMPLACED;//MOD_TURBLAST; //count as a heavy weap
			missile->splashMethodOfDeath = MOD_EMPLACED;//MOD_TURBLAST;// ?SPLASH;
			// we don't want it to bounce forever
			missile->bounceCount = 8;
		}

and for example i changed it from WP_BLASTER to WP_REPEATER and it working.

i tryed that structure
 

G_PlayEffect( vehWeapon->iShotFX )

But it cant be read so..this is really strange process for vehicles, much diffrent when adding a projectile for new weap

Link to comment

Because that's not where the muzzle effect is handled, for any weapon at all actually. The game sends an event to the client with the missile->s.weapon as a parameter. You'll need to overwrite this behavior to handle vehicles specifically.

https://github.com/JACoders/OpenJK/blob/master/code/cgame/cg_event.cpp#L525

Follow the chain of function calls here until you find the code that handles muzzle flashes. As you'll note, CG_FireWeapon sets cent->muzzleFlashTime so that the client can then draw the effect. Just scanning around here, it appears to be used for this chunk of code here:

https://github.com/JACoders/OpenJK/blob/master/code/cgame/cg_weapons.cpp#L912-946

 

Somewhere in this if(){} block, you'll want to add a check for it being in a vehicle (maybe set missile->s.eFlags in that function you posted, and then checking it here?) and then playing the effect from the .vwp.

Link to comment

Well i just...tryed that commands what are you advised and i just cant configure that commands correctly : | always an errors so.. i dunno what is wrong i have added the #includes , voids etc and no result or maybe im just doing wrong...as always and i dont know how to configure it to be read for vehicle for me the only one way is the G_playeffect, others just cannot be because it still errors :( 

Link to comment

So i have add missile->s.eFlags i function and it reads well , no errors and Compiled but in game there is no visible projectile effect and when "invisible"  projectile hits player or npc or hits wall the game crashes or maybe i did that in wrong place ; |
 

		{//a blaster-laser-like thing
			missile = CreateMissile( start, dir, vehWeapon->fSpeed, 10000, ent, qfalse );
			missile->s.eFlags;            // missile->s.weapon = WP_BLASTER;
			missile->methodOfDeath = MOD_EMPLACED;//MOD_TURBLAST; //count as a heavy weap
			missile->splashMethodOfDeath = MOD_EMPLACED;//MOD_TURBLAST;// ?SPLASH;
			// we don't want it to bounce forever
			missile->bounceCount = 8;
		}
Link to comment

Okay but i have check this file and how can i add this effect handle for vehicle there is no effects for vehicles there only based for weapons for example case WP_BLASTER so so i dont know how to figure it out for vehicle

Link to comment

case WP_BLASTER:
cgs.effects.blasterShotEffect = theFxScheduler.RegisterEffect( "blaster/shot" );
theFxScheduler.RegisterEffect( "blaster/NPCshot" );
// cgs.effects.blasterOverchargeEffect = theFxScheduler.RegisterEffect( "blaster/overcharge" );
cgs.effects.blasterWallImpactEffect = theFxScheduler.RegisterEffect( "blaster/wall_impact" );
cgs.effects.blasterFleshImpactEffect = theFxScheduler.RegisterEffect( "blaster/flesh_impact" );
theFxScheduler.RegisterEffect( "blaster/deflect" );
theFxScheduler.RegisterEffect( "blaster/smoke_bolton" ); // note: this will be called game side
break;
Link to comment

Well im not understand correctly what you mean about .vwp loading code but i found some structures are read from .vwp

 

vehField_t vehWeaponFields[NUM_VWEAP_PARMS] = 
{
	{"name", VWFOFS(name), VF_LSTRING},	//unique name of the vehicle
	{"projectile", VWFOFS(bIsProjectile), VF_BOOL},	//traceline or entity?
	{"hasGravity", VWFOFS(bHasGravity), VF_BOOL},	//if a projectile, drops
	{"ionWeapon", VWFOFS(bIonWeapon), VF_BOOL},	//disables ship shields and sends them out of control
	{"saberBlockable", VWFOFS(bSaberBlockable), VF_BOOL},	//lightsabers can deflect this projectile
	{"muzzleFX", VWFOFS(iMuzzleFX), VF_EFFECT_CLIENT},	//index of Muzzle Effect
	{"model", VWFOFS(iModel), VF_MODEL_CLIENT},	//handle to the model used by this projectile
	{"shotFX", VWFOFS(iShotFX), VF_EFFECT_CLIENT},	//index of Shot Effect
	{"impactFX", VWFOFS(iImpactFX), VF_EFFECT_CLIENT},	//index of Impact Effect
	{"g2MarkShader", VWFOFS(iG2MarkShaderHandle), VF_SHADER},	//index of shader to use for G2 marks made on other models when hit by this projectile
	{"g2MarkSize", VWFOFS(fG2MarkSize), VF_FLOAT},	//size (diameter) of the ghoul2 mark
	{"loopSound", VWFOFS(iLoopSound), VF_SOUND_CLIENT},	//index of loopSound
	{"speed", VWFOFS(fSpeed), VF_FLOAT},		//speed of projectile/range of traceline
	{"homing", VWFOFS(fHoming), VF_FLOAT},		//0.0 = not homing, 0.5 = half vel to targ, half cur vel, 1.0 = all vel to targ
	{"homingFOV", VWFOFS(fHomingFOV), VF_FLOAT},//missile will lose lock on if DotProduct of missile direction and direction to target ever drops below this (-1 to 1, -1 = never lose target, 0 = lose if ship gets behind missile, 1 = pretty much will lose it's target right away)
	{"lockOnTime", VWFOFS(iLockOnTime), VF_INT},	//0 = no lock time needed, else # of ms needed to lock on
	{"damage", VWFOFS(iDamage), VF_INT},		//damage done when traceline or projectile directly hits target
	{"splashDamage", VWFOFS(iSplashDamage), VF_INT},//damage done to ents in splashRadius of end of traceline or projectile origin on impact
	{"splashRadius", VWFOFS(fSplashRadius), VF_FLOAT},//radius that ent must be in to take splashDamage (linear fall-off)
	{"ammoPerShot", VWFOFS(iAmmoPerShot), VF_INT},//how much "ammo" each shot takes
	{"health", VWFOFS(iHealth), VF_INT},		//if non-zero, projectile can be shot, takes this much damage before being destroyed
	{"width", VWFOFS(fWidth), VF_FLOAT},		//width of traceline or bounding box of projecile (non-rotating!)
	{"height", VWFOFS(fHeight), VF_FLOAT},		//height of traceline or bounding box of projecile (non-rotating!)
	{"lifetime", VWFOFS(iLifeTime), VF_INT},	//removes itself after this amount of time
	{"explodeOnExpire", VWFOFS(bExplodeOnExpire), VF_BOOL},	//when iLifeTime is up, explodes rather than simply removing itself
};

and some weapon stuffs but im not sure it is that 
 

	// Weapon stuff:
	{"weap1", VFOFS(weapon[0].ID), VF_WEAPON},	//weapon used when press fire
	{"weap2", VFOFS(weapon[1].ID), VF_WEAPON},//weapon used when press alt-fire

and .vwp load

#else
//		len = gi.FS_ReadFile( va( "ext_data/vehicles/weapons/%s", holdChar), (void **) &buffer );
		len = gi.FS_FOpenFile(va( "ext_data/vehicles/weapons/%s", holdChar), &f, FS_READ);
#endif

this structures are in bg_vehicleLoad.cpp

but as i said i dont understand it correctly what you mean vwp load code so i gaved you this what i found about this

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...