OK, so before I ask for everyone's help.. again.. I just wanna say sorry for being a leech on here. I will try and help more people with their problems.
Anyways, I'm working on adding destructible items into QC. See, my mapper need it to be a function. So, I was thinking of just making whatever object he attaches the function to, to become an entity. Then making that entity have health. When the health is < 0 then the object is removed. So, the problem is that I don't know if you can remove brushwork. Also, if he uses models instead, then you would have to make a separate function for each model you would think. So that you could load the model in-game. I just don't know. Any help is appreciated.
Again sorry for always asking for help. I'm still in my "noob" stages.
EDIT: Also, I'm kind of confused on how to add particles for when the item breaks also...
Adding Destructible Items help?
Re: Adding Destructible Items help?
Last edited by Nahuel on Sat Nov 02, 2013 9:31 pm, edited 1 time in total.
Re: Adding Destructible Items help?
Well
1- try this "func_destruible" is a simple brush that can die , you can remove the brush entities with simple code
Particles are added by different ways , for example in darkplaces engine you can add the pointparticles to the death function.
otherwise you can add some gibs just like the monsters (when they are destroyed for a rocket ) .you know some models that spawn , see ThrowGib function in player.qc.
For a model just see the code of the barrel_explode in misc
1- try this "func_destruible" is a simple brush that can die , you can remove the brush entities with simple code
Code: Select all
void () remove_wall =
{
activator = self.enemy;
self.model = string_null;
self.solid = SOLID_NOT;
self.movetype = MOVETYPE_NONE;
self.takedamage = DAMAGE_NO;
SUB_UseTargets ();
sound (self, CHAN_VOICE, "misc/removewall.wav", 1, ATTN_NORM);
};
void() func_destruible =
{
self.solid = SOLID_BSP;
self.movetype = MOVETYPE_PUSH;
self.angles = VEC_ORIGIN;
setmodel (self, self.model);
self.classname = "func_destruible";
if (!self.health)
{
self.health = 100;
}
self.max_health = self.health;
self.takedamage = DAMAGE_YES;
self.th_die = remove_wall; //remove wall
self.use = remove_wall ; //remove wall
};//////////////
Code: Select all
pointparticles(particleeffectnum("someeffect"), self.origin, '0 0 0', 1);
For a model just see the code of the barrel_explode in misc
hi, I am nahuel, I love quake and qc.
-
- Posts: 2126
- Joined: Sat Nov 25, 2006 1:49 pm
Re: Adding Destructible Items help?
To QuakeC is irrelevant if an entity uses an alilas (.mdl) or brush based (.bsp) model in most of the cases (the main exception being how to set the MOVETYPE_* and SOLID_* flags).
You can of course make an entity using a .bsp model destructible. Here's an example from a mod I've been working:
The nice part here is that when destroyed the object will throw a random number of rubble parts flying in several directions, and you can even set the rubble model skin accordingly the general .BSP texture, so it looks coherent.
You can of course make an entity using a .bsp model destructible. Here's an example from a mod I've been working:
Code: Select all
void () explode_use =
{
local entity rubble;
local float r, z;
local vector l, o;
l_x = self.absmax_x - self.absmin_x;
l_y = self.absmax_y - self.absmin_y;
l_z = self.absmax_z - self.absmin_z;
setorigin (self, o);
r = 15 + random () * 15;
while (r > 0)
{
rubble = spawn();
o_x = self.absmin_x + (random () * l_x);
o_y = self.absmin_y + (random () * l_y);
o_z = self.absmin_z + (random () * l_z);
rubble.origin = o;
z = random ();
if (z > 0.66)
{
setmodel (rubble, "progs/rubble3.mdl");
}
else if (z > 0.33)
{
setmodel (rubble, "progs/rubble2.mdl");
}
else
{
setmodel (rubble, "progs/rubble1.mdl");
}
setsize (rubble, '0 0 0', '0 0 0');
rubble.skin = self.skin;
rubble.velocity = VelocityForDamage (-175);
rubble.movetype = MOVETYPE_BOUNCE;
rubble.solid = SOLID_NOT;
rubble.avelocity_x = random()*600;
rubble.avelocity_y = random()*600;
rubble.avelocity_z = random()*600;
rubble.think = SUB_Remove;
rubble.ltime = time;
rubble.nextthink = time + 10 + random()*10;
rubble.frame = 0;
rubble.flags = 0;
r = r - 1;
}
sound (self, CHAN_VOICE, "misc/wcrumble.wav", 1, ATTN_NORM);
BecomeExplosion ();
};
void () func_explode =
{
self.angles = '0 0 0';
self.movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything
self.solid = SOLID_BSP;
self.use = explode_use;
setmodel (self, self.model);
setsize (self, self.mins , self.maxs);
precache_model ("progs/rubble1.mdl");
precache_model ("progs/rubble2.mdl");
precache_model ("progs/rubble3.mdl");
precache_sound ("misc/wcrumble.wav");
};
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC (LordHavoc)
-
- Posts: 50
- Joined: Sun Oct 13, 2013 7:53 pm
Re: Adding Destructible Items help?
Wow, I learned a lot from this post! Thanks! So, really it doesn't matter if it's pertaining to a brush or a .mdl.. the function will work either way?frag.machine wrote:To QuakeC is irrelevant if an entity uses an alilas (.mdl) or brush based (.bsp) model in most of the cases (the main exception being how to set the MOVETYPE_* and SOLID_* flags).
You can of course make an entity using a .bsp model destructible. Here's an example from a mod I've been working:The nice part here is that when destroyed the object will throw a random number of rubble parts flying in several directions, and you can even set the rubble model skin accordingly the general .BSP texture, so it looks coherent.Code: Select all
void () explode_use = { local entity rubble; local float r, z; local vector l, o; l_x = self.absmax_x - self.absmin_x; l_y = self.absmax_y - self.absmin_y; l_z = self.absmax_z - self.absmin_z; setorigin (self, o); r = 15 + random () * 15; while (r > 0) { rubble = spawn(); o_x = self.absmin_x + (random () * l_x); o_y = self.absmin_y + (random () * l_y); o_z = self.absmin_z + (random () * l_z); rubble.origin = o; z = random (); if (z > 0.66) { setmodel (rubble, "progs/rubble3.mdl"); } else if (z > 0.33) { setmodel (rubble, "progs/rubble2.mdl"); } else { setmodel (rubble, "progs/rubble1.mdl"); } setsize (rubble, '0 0 0', '0 0 0'); rubble.skin = self.skin; rubble.velocity = VelocityForDamage (-175); rubble.movetype = MOVETYPE_BOUNCE; rubble.solid = SOLID_NOT; rubble.avelocity_x = random()*600; rubble.avelocity_y = random()*600; rubble.avelocity_z = random()*600; rubble.think = SUB_Remove; rubble.ltime = time; rubble.nextthink = time + 10 + random()*10; rubble.frame = 0; rubble.flags = 0; r = r - 1; } sound (self, CHAN_VOICE, "misc/wcrumble.wav", 1, ATTN_NORM); BecomeExplosion (); }; void () func_explode = { self.angles = '0 0 0'; self.movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything self.solid = SOLID_BSP; self.use = explode_use; setmodel (self, self.model); setsize (self, self.mins , self.maxs); precache_model ("progs/rubble1.mdl"); precache_model ("progs/rubble2.mdl"); precache_model ("progs/rubble3.mdl"); precache_sound ("misc/wcrumble.wav"); };