Gibs: Difference between revisions
Gammerman12 (talk | contribs) No edit summary |
TomEdwards (talk | contribs) (rm. swearing. Also rm "credit me": a) this is a wiki, b) the code hardly qualifies for a place in a mod's credits) |
||
Line 1: | Line 1: | ||
Hello there people of the coding world. Today, we are going to make gibs for the zombine. This can also work in other NPCs/Players if you do a bit of coding. | Hello there people of the coding world. Today, we are going to make gibs for the zombine. This can also work in other NPCs/Players if you do a bit of coding. | ||
== Editing Event_Killed == | == Editing Event_Killed == | ||
So first, open up the Zombine code (npc_zombine.cpp) and search for the void "Event_Killed" Delete everything in there except for | So first, open up the Zombine code (npc_zombine.cpp) and search for the void "Event_Killed" Delete everything in there except for <code>BaseClass::Event_Killed( info )</code>. This calls up the Regular Event_Killed so that we can still have a ragdoll and the zombine dies correctly. | ||
< | |||
</ | |||
This calls up the Regular Event_Killed so that we can still have a ragdoll and the zombine dies correctly. | |||
Next, create your gib models. | Next, create your gib models. You can download a pack from [http://www.garrysmod.org/downloads/?a=view&id=72352 Garrysmod.org] if you want. | ||
Put those in your mod folder, and in the Event_Killed section, add this: | Put those in your mod folder, and in the Event_Killed section, add this: | ||
<source lang=cpp> | |||
if( info.GetDamageType() & DMG_BUCKSHOT ) | |||
{ | |||
SetModel( "models/zombie/classic_legs.mdl" ); | |||
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/pgib_p1.mdl", 5); | |||
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/pgib_p2.mdl", 5); | |||
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/pgib_p3.mdl", 5); | |||
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/pgib_p4.mdl", 5); | |||
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/pgib_p5.mdl", 5); | |||
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/hgibs_jaw.mdl", 5); | |||
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/hgibs_scapula.mdl", 5); | |||
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/hgibs_scapula.mdl", 5); | |||
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/rgib_p1.mdl", 5); | |||
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/rgib_p2.mdl", 5); | |||
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/rgib_p3.mdl", 5); | |||
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/rgib_p4.mdl", 5); | |||
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/rgib_p5.mdl", 5); | |||
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/rgib_p6.mdl", 5); | |||
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/gibhead.mdl", 5); | |||
} | |||
</source> | |||
This will make it so that when you shoot the zombie with any gun that uses the Buckshot ammo (Shotgun), he will blow into many pieces, and will lose his torso. There are different DMGs in shareddefs.h, suck as DMG_BURN, DMG_BULLET, etc., and replace DMG_BUCKSHOT with whatever you want. | |||
Before you compile, make sure that you Precache the models your using, or you will get with errors. | |||
[[Category:Programming]] | [[Category:Programming]] |
Revision as of 16:01, 13 February 2010
Hello there people of the coding world. Today, we are going to make gibs for the zombine. This can also work in other NPCs/Players if you do a bit of coding.
Editing Event_Killed
So first, open up the Zombine code (npc_zombine.cpp) and search for the void "Event_Killed" Delete everything in there except for BaseClass::Event_Killed( info )
. This calls up the Regular Event_Killed so that we can still have a ragdoll and the zombine dies correctly.
Next, create your gib models. You can download a pack from Garrysmod.org if you want.
Put those in your mod folder, and in the Event_Killed section, add this:
if( info.GetDamageType() & DMG_BUCKSHOT )
{
SetModel( "models/zombie/classic_legs.mdl" );
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/pgib_p1.mdl", 5);
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/pgib_p2.mdl", 5);
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/pgib_p3.mdl", 5);
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/pgib_p4.mdl", 5);
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/pgib_p5.mdl", 5);
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/hgibs_jaw.mdl", 5);
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/hgibs_scapula.mdl", 5);
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/hgibs_scapula.mdl", 5);
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/rgib_p1.mdl", 5);
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/rgib_p2.mdl", 5);
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/rgib_p3.mdl", 5);
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/rgib_p4.mdl", 5);
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/rgib_p5.mdl", 5);
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/rgib_p6.mdl", 5);
CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/gibhead.mdl", 5);
}
This will make it so that when you shoot the zombie with any gun that uses the Buckshot ammo (Shotgun), he will blow into many pieces, and will lose his torso. There are different DMGs in shareddefs.h, suck as DMG_BURN, DMG_BULLET, etc., and replace DMG_BUCKSHOT with whatever you want.
Before you compile, make sure that you Precache the models your using, or you will get with errors.