if monsters killed = 10

Discuss programming in the QuakeC language.
Post Reply
ThePlasticBling
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

if monsters killed = 10

Post by ThePlasticBling »

i want to make my game so if i kill 10 zombies, then something happens. I have tried just about everything i could think of. this won't work:

Code: Select all

if (monsters_killed = 10)
{
something happens
};
and i have tried alot of similar stuff. nothing works! a little help?
Mexicouger
Posts: 514
Joined: Sat May 01, 2010 10:12 pm
Contact:

Post by Mexicouger »

Well, The easiest way to do something would be like this:

Open up Zombie.qc and Find this Function:

Code: Select all

void() zombie_die =
{
	sound (self, CHAN_VOICE, "zombie/z_gib.wav", 1, ATTN_NORM);
	ThrowHead ("progs/h_zombie.mdl", self.health);
	ThrowGib ("progs/gib1.mdl", self.health);
	ThrowGib ("progs/gib2.mdl", self.health);
	ThrowGib ("progs/gib3.mdl", self.health);
};
Then you could add your if statement:
void() zombie_die =
{
if (killed_monsters == 10) //Plays a sound if a Zombie is killed
sound (self, CHAN_VOICE, "zombie/z_miss.wav", 1, ATTN_NORM)


sound (self, CHAN_VOICE, "zombie/z_gib.wav", 1, ATTN_NORM);
ThrowHead ("progs/h_zombie.mdl", self.health);
ThrowGib ("progs/gib1.mdl", self.health);
ThrowGib ("progs/gib2.mdl", self.health);
ThrowGib ("progs/gib3.mdl", self.health);
};
I am not so sure about printing a message to the player, coming from a Zombie death, but I know a way to do it.

If you want to print a message to the player when monster_kills = 10;, then open up client.qc, and scroll down to
/*
================
PlayerPreThink

Called every frame before physics are run
================
*/
void() PlayerPreThink =
Add your code Somewhere after this:
if (self.deadflag >= DEAD_DEAD)
{
PlayerDeathThink ();
return;
}
Maybe do something like this:
/*
================
PlayerPreThink

Called every frame before physics are run
================
*/
void() PlayerPreThink =
{

if (BotPreFrame()) // FrikBot
return;

if (intermission_running)
{
IntermissionThink (); // otherwise a button could be missed between
return; // the think tics
}

if (self.view_ofs == '0 0 0')
return; // intermission or finale


makevectors (self.v_angle); // is this still used

CheckRules ();
WaterMove ();

if (self.waterlevel == 2)
CheckWaterJump ();
}
if (self.deadflag >= DEAD_DEAD)
{
PlayerDeathThink ();
return;
}

if (self.deadflag == DEAD_DYING)
return; // dying, so do nothing

if (killed_monsters == 10)
centerprint (self, "10 Monster are outta this world!\n");


if (self.button2)
{
PlayerJump ();
}
else
self.flags = self.flags | FL_JUMPRELEASED;

// teleporters can force a non-moving pause time
if (time < self.pausetime)
self.velocity = '0 0 0';

if(time > self.attack_finished && self.currentammo == 0 && self.weapon != IT_AXE)
{
//self.weapon = W_BestWeapon ();
W_SetCurrentAmmo ();
}
};
FYI: The last method Is more temporary. In my opinion, it isn't good to clutter player_pre_think because it is kinda memory intensive.

FIXED
Last edited by Mexicouger on Tue Nov 02, 2010 12:33 am, edited 2 times in total.
ThePlasticBling
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Post by ThePlasticBling »

it says unkown value "monsters killed"
Mexicouger
Posts: 514
Joined: Sat May 01, 2010 10:12 pm
Contact:

Post by Mexicouger »

ThePlasticBling wrote:it says unkown value "monsters killed"
Man, you need to learn more about Quakec. The definition is a float that applies to the world, and it is actually killed_monsters. You need to figure some stuff out. I will fix the Function to suit the definition. I was just going more off what you were saying.
mrmmaclean
Posts: 33
Joined: Sun Aug 22, 2010 2:49 am

Re: if monsters killed = 10

Post by mrmmaclean »

ThePlasticBling wrote:if (monsters_killed = 10)
This should be == not = anyway. You are assigning the value of '10' to the variable 'monsters_killed' when you should be comparing the values with the double equals sign.
DusterdooSmock
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Post by DusterdooSmock »

ThePlasticBling wrote:it says unkown value "monsters killed"
Like i said before, learn some basic coding skills before you try to make a mod of something that you have no clue about.
Post Reply