by Spike » Wed Apr 08, 2015 3:45 am
//DP_ENT_EXTERIORMODELTOCLIENT
//idea: LordHavoc
//darkplaces implementation: LordHavoc
//fields:
.entity exteriormodeltoclient;
//description:
//the entity is visible to all clients with one exception: if the specified client is using first person view (not using chase_active) the entity will not be shown.
//DP_GFX_QUAKE3MODELTAGS
//idea: id Software
//darkplaces implementation: LordHavoc
//field definitions:
.entity tag_entity; // entity this is attached to (call setattachment to set this)
.float tag_index; // which tag on that entity (0 is relative to the entity, > 0 is an index into the tags on the model if it has any) (call setattachment to set this)
//builtin definitions:
void(entity e, entity tagentity, string tagname) setattachment = #443; // attachs e to a tag on tagentity (note: use "" to attach to entity origin/angles instead of a tag)
//description:
//allows entities to be visually attached to model tags (which follow animations perfectly) on other entities, for example attaching a weapon to a player's hand, or upper body attached to lower body, allowing it to change angles and frame separately (note: origin and angles are relative to the tag, use '0 0 0' for both if you want it to follow exactly, this is similar to viewmodelforclient's behavior).
//note 2: if the tag is not found, it defaults to "" (attach to origin/angles of entity)
//note 3: attaching to world turns off attachment
//note 4: the entity that this is attached to must be visible for this to work
//note 5: if an entity is attached to the player entity it will not be drawn in first person.
vwep = spawn();
setmodel(vwep, "progs/v_foo.mdl");
setattachment(vwep, self, "");
self.exteriormodeltoclient = self;
you'll need to update the frame+model as appropriate, and to somehow remove the entity when the player disconnects. dying can be awkward too.
if you're dual wielding, you probably want to spawn an extra entity for viewmodelforclient too.
if you're using iqms, or md3s, or equivelent, you can just name a tag instead of the "" above (assuming its oriented properly in blender/equivelent), and then you can use the vwep's frame for private weapon firing/idle animations instead of having to copy the player's frame in order to keep it somewhere within the vacinity of the player's moving hands.
if you're going with csqc, you can just update the modelindex and call addentity an extra time, so that the player entity gets added twice with two different models. if skeletal/md3, you can find the origin+angles of the hand with gettaginfo.
.