Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CL_MuzzleFlash( cl_entity_t *entity, vec3_t pos, int type, int attachmentnum )
- {
- const char *muzzleflash;
- TEMPENTITY *pTemp;
- int index, frameCount;
- float scale;
- extern int g_weaponselect_frames;
- if( g_weaponselect_frames )
- return;
- index = bound( 0, type % 5, MAX_MUZZLEFLASH - 1 );
- scale = (type / 10) * 0.1f;
- if( scale == 0.0f ) scale = 0.5f;
- switch( index )
- {
- case 0:
- muzzleflash = "sprites/muzzleflash1.spr";
- break;
- case 1:
- muzzleflash = "sprites/muzzleflash2.spr";
- break;
- case 2:
- muzzleflash = "sprites/muzzleflash3.spr";
- break;
- case 3:
- muzzleflash = "sprites/muzzleflash.spr";
- break;
- }
- int modelIndex = gEngfuncs.pEventAPI->EV_FindModelIndex(muzzleflash);
- model_t* modelchar = gEngfuncs.hudGetModelByIndex(modelIndex);
- //gEngfuncs.Con_DPrintf("DEBUG: SHOULD DO A MUZZLEFLASH!, model = %i, char = %s\n", modelIndex, modelchar);
- model_t* model = gEngfuncs.CL_LoadModel(muzzleflash, &modelIndex);
- if( !model ) return;
- frameCount = model->numframes;
- // must set position for right culling on render
- pTemp = gEngfuncs.pEfxAPI->CL_TempEntAllocHigh( pos, model);
- if( !pTemp ) return;
- pTemp->clientIndex = entity->curstate.owner;
- pTemp->entity.curstate.rendermode = kRenderTransAdd;
- pTemp->entity.curstate.renderamt = 32;
- pTemp->entity.curstate.framerate = 100;
- pTemp->entity.curstate.renderfx = 0;
- pTemp->die = gEngfuncs.GetClientTime() + 2.0f; // gHUD.m_flTimeDelta * 1000.5f; // die at next frame
- pTemp->entity.curstate.frame = Com_RandomLong( 0, frameCount - 1 );
- //pTemp->flags |= FTENT_SPRANIMATE|FTENT_SPRANIMATELOOP;
- pTemp->flags = FTENT_CLIENTCUSTOM;
- pTemp->frameMax = frameCount - 1;
- //VectorCopy(entity->curstate.velocity, pTemp->entity.curstate.velocity);
- pTemp->entity.curstate.effects = EF_MUZZLEFLASH;
- //cl_entity_s* player = gEngfuncs.GetLocalPlayer();
- //gEngfuncs.Con_DPrintf("DEBUG: MUZZLEFLASH FUNC!!!, vel = %f %f %f\n", player->curstate.velocity.x, player->curstate.velocity.y, player->curstate.velocity.z);
- pTemp->entity.curstate.iuser4 = attachmentnum;
- entity->curstate.eflags |= EF_UPDATE_ATTACHMENTS;
- gEngfuncs.Con_DPrintf("DEBUG: MUZZLEFLASH start, index = %i attachment num = %i, pos = %f %f %f\n", entity->index, attachmentnum, pos.x, pos.y, pos.z);
- pTemp->entity.curstate.owner = entity->index;
- pTemp->callback = [](struct tempent_s* te, float frametime, float currenttime) -> void
- {
- cl_entity_t *owner = gEngfuncs.GetEntityByIndex(te->entity.curstate.owner);
- Vector dir;
- gEngfuncs.Con_DPrintf("DEBUG: MUZZLEFLASH callback, owner index = %i, attachmentnum = %i pos = %f %f %f\n", te->entity.curstate.owner, te->entity.curstate.iuser4, owner->attachment[te->entity.curstate.iuser4].x, owner->attachment[te->entity.curstate.iuser4].y, owner->attachment[te->entity.curstate.iuser4].z);
- VectorSubtract(owner->attachment[te->entity.curstate.iuser4], te->entity.origin, dir);
- VectorCopy(owner->attachment[te->entity.curstate.iuser4], te->entity.origin);
- VectorNormalize(dir);
- //VectorMA(te->entity.origin, frametime * 0.0f, dir, te->entity.origin);
- //
- //gEngfuncs.Con_DPrintf("DEBUG: MUZZLEFLASH FUNC!!! gun att origin = %f %f %f mf origin = %f %f %f\n", gun->attachment[te->entity.curstate.iuser4].x, gun->attachment[te->entity.curstate.iuser4].y, gun->attachment[te->entity.curstate.iuser4].z, te->entity.curstate.origin.x, te->entity.curstate.origin.y, te->entity.curstate.origin.z);
- //VectorCopy(gun->curstate.velocity, te->entity.curstate.velocity);
- if (te->entity.curstate.team == 0)
- {
- te->entity.curstate.renderamt += frametime * 7649.0 * 0.75f;
- if (te->entity.curstate.renderamt > 255)
- {
- te->entity.curstate.renderamt = 255;
- te->entity.curstate.team = 1;
- //gEngfuncs.Con_DPrintf("DEBUG: MUZZLEFLASH CALLBACK MORE VISIBLE!\n");
- }
- }
- else if (te->entity.curstate.team == 1)
- {
- te->entity.curstate.renderamt -= frametime * 7649.0f * 0.75f;
- //gEngfuncs.Con_DPrintf("DEBUG: MUZZLEFLASH CALLBACK LESS VISIBLE!\n");
- }
- te->entity.curstate.scale += frametime * 10.0f * 0.0625f * 0.5f;
- //Con_DPrintf("debug: frametime = %f \n", cl_clientframetime());
- if (te->entity.curstate.renderamt <= 0.0f)
- te->die = gEngfuncs.GetClientTime() + 0.0001f;
- //if(!te->entity.curstate.iuser1)
- //gEngfuncs.Con_DPrintf("DEBUG: MUZZLEFLASH CALLBACK FUNC!!!, attachment vec = %f %f %f, number = %i, origin = %f %f %f\n", gun->attachment[te->entity.curstate.iuser4].x, gun->attachment[te->entity.curstate.iuser4].y, gun->attachment[te->entity.curstate.iuser4].z,
- // te->entity.curstate.iuser4, gun->origin.x, gun->origin.y, gun->origin.z);
- //te->entity.curstate.iuser1 = 1; // what is this for??? FIXME
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement