Entity Problem


(S. Monkey) #1

The following code doesn’t produce any errors, but the parachute isn’t appearing.

The model is fine - I’ve tested it as a misc_gamemodel and it’s registered it with cgs.media

void CreateParachute(gentity_t *owner) {
	gentity_t *chute;
	vec3_t velocity,chute_origin;

	VectorClear(velocity);
	velocity[2]=-PARA_SPEED;

	chute=G_Spawn();

	chute->classname="parachute";
	chute->think=ParachuteThink;
	chute->nextthink=100;
	chute->enemy=owner;
	chute->s.pos.trType=TR_LINEAR;
	VectorCopy( velocity, chute->s.pos.trDelta );

	VectorCopy( owner->r.currentOrigin, chute_origin );
	chute_origin[2]+=72;
	G_SetOrigin(chute,chute_origin);
}

Any Ideas?


(bani) #2

you need to set the entity type, the model index, and link the entity.


(bacon) #3

Do this:

chute->s.eType = ET_GAMEMODEL;
chute->s.modelindex = G_ModelIndex( "path/to/model.extension" );
chute->model = " path/to/model.extension";
chute->s.modelindex2 = G_ModelIndex( "path/to/model.extension" );
trap_LinkEntity( chute );

At least that’s how I’d do it…


(S. Monkey) #4

Thanks for the help. I’ve tried that code, but it doesn’t help. The parachute still isn’t appearing.

Does it matter where in the directory structure the md3 file is?


(TwentySeven) #5

Make sure you breakpoint the client and see if your chute is coming through along with the other ET_GAMEMODEL’s


(Magik) #6

Make sure you are using the correct path. Try it with “pure” off and be sure to set the correct origin before you link the entity.
Use something like that:


vec3_t myorigin;
VectorCopy(myorigin, chute->s.origin);
G_SetOrigin(chute, chute->s.origin);


([RW]FRED) #7

No change the velocity[2]=-PARA_SPEED to velocity[2]=PARA_SPEED and change TR_LINEAR by TR_GRAVITY
set ur entity type to ET_MISSILE or ET_ITEM, create an entry into bg_itemlist, set min/max for colission detection affect ent->s.modelinex = BG_FindByClassName(“parachute”)
because only ET_MISSILE are a moveable entity and ET_ITEM too. Move is done in G_RunMissile or G_RunItem, if u want that ur dropped item is solid, u must care also with the clipmask passing thru missileclip & playerclip…

Also set the good stuff into ent->s…

and last call trap_Linkentity(ent);
Regards


(S. Monkey) #8

The parachute isn’t affected by normal gravity (it moves down with constant speed rather than accelerating), so I’d assumed TR_LINEAR was appropriate. velocity[2]=-PARA_SPEED works on the player entity so I assume it is correct here.

I’ll just try altering the type to ET_MISSILE.


([RW]FRED) #9

I have coded too parachute & dropzone in my mod.

If you declare ur entity as ET_MISSILE, u must modify G_RunMissile & CG_Missile.

In fact in CG_Missile, the code suppose that u have a weapon attached to that mlssile, not a simple model.

In G_RunMissile u must care that if ur parachute impact a player, ur item still in place and float in air… And after Missile Impact don’t G_RunMissile to free ur entity…

For dropped players take care about player clip, in ur first test they will be probably sticked in the sky… --> bg_move.c, but u can’t remove CONTENTS_PLAYERCLIP from playerclip mask else they can go outside opened map and go behind structural worldspawn. Except if u build ur own map dedicated for drop.

velocity[2] = -80 & TR_LINEAR is a good value.

Regards


(S. Monkey) #10

Thanks.

Would not having it set as ET_MISSLE stop the entity being drawn completely, or just stop it moving? If it only stops it moving, then my problem is elsewhere.

Incidentally, how come you settled on -80 for the speed? I’m using 220.


([RW]FRED) #11

By default in G_RunMissile, the code assume that when the missile hit something it will be freed after the call of G_MissileImpact. ent->think = G_ExplodeMissile. But ur think is not that call. First in the top of G_RunMissile do something like LandmineCheckGround to restore TR_LINEAR when groundentitynum is negatif as for dropped Landmine but u must adapt the code.

Second before the ent->freeAfterEvent put code like if (ent is parachute) return;

Another consideration, ur dropped item hit a player think what u must do… for my case he is crushed.

I take 80 for vertical velocity for item and 40 for players. 220 looks too quick

regards