|
|
|
Editor: New code in RED Old code in YELLOW Here is a little tutorial on CS-style weapon dropping. Well... not really like in CS, this one will only drop the ammo in the clip, not all ammo for that weapon. Goto PlayerDeathThink in CBasePlayer (player.cpp), then find this: if ( HasWeapons() ) { etc etc } Change it to this: if ( HasWeapons() ) { DropPlayerItem(""); // drop the weapon that the player is using RemoveAllItems(true); // Remove every thing else including the HEV } Now, open DropPlayerItem in the same file and goto this stuff: if ( pWeapon ) { blah blah } Remove all the blah blah-stuff and add this: if ( pWeapon ) { // Don't drop the melee weapon. You need do replace "weapon_knife" with your melee weapon... if ((char *)STRING(pWeapon->pev->classname)=="weapon_knife") return; g_pGameRules->GetNextBestWeapon( this, pWeapon ); UTIL_MakeVectors ( pev->angles ); pev->weapons &= ~(1<< pWeapon->m_iId);// take item off hud // Create a new weapon and toss it away CBaseEntity *pItem = CBaseEntity::Create((char *)STRING(pWeapon->pev->classname), pev->origin + gpGlobals->v_forward * 10, pev->angles, edict() ); pItem->pev->velocity = gpGlobals->v_forward * RANDOM_LONG(150,300) + gpGlobals->v_forward * RANDOM_LONG(80,110); pItem->pev->spawnflags |= SF_NORESPAWN; // don't respawn // Convect our weapons (they are CBasePlayerItems) to CBasePlayerWeapons CBasePlayerWeapon *weap = (CBasePlayerWeapon *)pItem; // the new weapon CBasePlayerWeapon *OldWeap = (CBasePlayerWeapon *)pWeapon; // the old weapon int AmmoLeftInClip; // if the weapon doesn't have any clip then save all ammo in the new weapon, // else just save the ammo in the clip if (OldWeap->iMaxClip()==WEAPON_NOCLIP) { AmmoLeftInClip = m_rgAmmo[OldWeap->m_iPrimaryAmmoType]; weap->m_iDefaultAmmo = AmmoLeftInClip; } else { AmmoLeftInClip = OldWeap->m_iClip; weap->m_iClip = AmmoLeftInClip; weap->m_iDefaultAmmo = 0; } RemovePlayerItem(pWeapon); return; }
Any questions or suggestions should be sent to me:
nexus@SoftHome.net
//////////////////////////////////////////////////////////////////////// Surreals code: //////////////////////////////////////////////////////////////////////// In weapons.cpp go to the function PackWeapon and right before the code... pWeapon->pev->spawnflags |= SF_NORESPAWN;// never respawn pWeapon->pev->movetype = MOVETYPE_NONE; pWeapon->pev->solid = SOLID_NOT; pWeapon->pev->effects = EF_NODRAW; pWeapon->pev->modelindex = 0; pWeapon->pev->model = iStringNull; pWeapon->pev->owner = edict(); pWeapon->SetThink( NULL );// crowbar may be trying to swing again, etc. pWeapon->SetTouch( NULL ); pWeapon->m_pPlayer = NULL; plug this chunk o code in.... // the "real" thing" if ((!strcmp((char *)STRING( pWeapon->pev->classname ), "weapon_crowbar"))) SET_MODEL( ENT(pev), "models/w_crowbar.mdl"); else if ((!strcmp((char *)STRING( pWeapon->pev->classname ), "weapon_9mmhandgun"))) SET_MODEL( ENT(pev), "models/w_9mmhandgun.mdl"); else if ((!strcmp((char *)STRING( pWeapon->pev->classname ), "weapon_357"))) SET_MODEL( ENT(pev), "models/w_357.mdl"); else if ((!strcmp((char *)STRING( pWeapon->pev->classname ), "weapon_shotgun"))) SET_MODEL( ENT(pev), "models/w_shotgun.mdl"); else if ((!strcmp((char *)STRING( pWeapon->pev->classname ), "weapon_9mmAR"))) SET_MODEL( ENT(pev), "models/w_9mmar.mdl"); else if ((!strcmp((char *)STRING( pWeapon->pev->classname ), "weapon_crossbow"))) SET_MODEL( ENT(pev), "models/w_crossbow.mdl"); else if ((!strcmp((char *)STRING( pWeapon->pev->classname ), "weapon_rpg"))) SET_MODEL( ENT(pev), "models/w_rpg.mdl"); else if ((!strcmp((char *)STRING( pWeapon->pev->classname ), "weapon_gauss"))) SET_MODEL( ENT(pev), "models/w_gauss.mdl"); else if ((!strcmp((char *)STRING( pWeapon->pev->classname ), "weapon_hornetgun"))) SET_MODEL( ENT(pev), "models/w_hgun.mdl"); else if ((!strcmp((char *)STRING( pWeapon->pev->classname ), "weapon_egon"))) SET_MODEL( ENT(pev), "models/w_egon.mdl"); else if ((!strcmp((char *)STRING( pWeapon->pev->classname ), "weapon_snark"))) SET_MODEL( ENT(pev), "models/w_squeak.mdl"); else if ((!strcmp((char *)STRING( pWeapon->pev->classname ), "weapon_tripmine"))) { pev->body = 3; pev->sequence = 8; pev->absmin = pev->origin + Vector(-16, -16, -5); pev->absmax = pev->origin + Vector(16, 16, 28); SET_MODEL( ENT(pev), "models/v_tripmine.mdl"); } else if ((!strcmp((char *)STRING( pWeapon->pev->classname ), "weapon_handgrenade"))) SET_MODEL( ENT(pev), "models/w_grenade.mdl"); else if ((!strcmp((char *)STRING( pWeapon->pev->classname ), "weapon_satchel"))) SET_MODEL( ENT(pev), "models/w_satchel.mdl"); }There is a easier way to do this... use a sprintf function and store the classname of that current weapon then SET_MODEL to that array. (add 7 to chop off the weapon_ class) Its a hell of alot smaller (about 3 lines of code...) but there is a bug in it... the model flickers on and off... (cant convert const chars into *chars... blah blah blah..)
Any questions or suggestions should be sent to me:
darcuri@optonline.net