I use a pretty basic function to spawn in physics props within my plugins. It's not the most elegant method, but it's been enough for what I want up until now:
Code:
public Action:spawnpropangle(char item[64], char origin[128], char angle[128], float scale)
{
new ent = CreateEntityByName("prop_physics_override");
DispatchKeyValue(ent, "count", "1");
DispatchKeyValue(ent, "collisions", "1");
DispatchKeyValue(ent, "spawnflags", "3");
DispatchKeyValue(ent, "origin", origin);
DispatchKeyValue(ent, "angles", angle);
DispatchKeyValue(ent, "model", item);
DispatchSpawn(ent);
AcceptEntityInput(ent, "EnableMotion");
SetEntPropFloat(ent, Prop_Send, "m_flModelScale", scale);
}
I now want to go a little further, and create a wooden box which will break into fragments based on the model (and gibs):
Code:
PrecacheModel("models/props_junk/wood_crate002a.mdl", 1);
PrecacheModel("models/props_junk/wood_crate001a_chunk01.mdl", 1);
PrecacheModel("models/props_junk/wood_crate001a_chunk02.mdl", 1);
PrecacheModel("models/props_junk/wood_crate001a_chunk03.mdl", 1);
PrecacheModel("models/props_junk/wood_crate001a_chunk04.mdl", 1);
PrecacheModel("models/props_junk/wood_crate001a_chunk05.mdl", 1);
I have no idea how to do this - I'm guessing using the brush entity func_breakable. It doesnt have to be perfect, I just want to be able to spawn regular breakable boxes.
edit: okay that was silly, i just added health keyvalue to the original function and it breaks into peices