Forum

Killing Spree

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Killing Spree

Postby redrum » Tue Aug 28, 2007 1:05 am

How would I go about creating a killing spree message.
I tried this:

if (1 <= time <= 5 && self.frags >= 3)
sprint (self, PRINT_HIGH, "you are on a killing spree!\n");


Trying to get the message to print if you have 3 or more kills in a 5 second span.

It didn't quite work although it compiled :)

Any words of wisdom?
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby Orion » Tue Aug 28, 2007 1:44 am

Well, you should remove the code you created.
Open client.qc and before ClientObituary() add:

Code: Select all
.float kill_time, kill_amount;
void(entity dude, float howmany) killmsg =
{
   if (howmany == 11)
      centerprint(dude, "Humongous Hemorraghe!\n");
   else if (howmany == 10)
      centerprint(dude, "Ultra Violence!\n");
   else if (howmany == 9)
      centerprint(dude, "Serious Dismemberment!\n");
   else if (howmany == 8)
      centerprint(dude, "Massive Destruction!\n");
   else if (howmany == 7)
      centerprint(dude, "Major Demolish!\n");
   else if (howmany == 6)
      centerprint(dude, "Death wake!\n");
   else if (howmany == 5)
      centerprint(dude, "Monster kill!\n");
   else if (howmany == 4)
      centerprint(dude, "Riot kill!\n");
   else if (howmany == 3)
      centerprint(dude, "Multi kill!\n");
   else if (howmany == 2)
      centerprint(dude, "Double kill!\n");
   else
      return;
};


Notice the dot floats (.float) I created. kill_time will be the time between your kills, and kill_amount will be your individual kills, that aren't frags. And if you use time itself for those messages, it will only work at the first 5 seconds of game for example.
The time float will increase every frame, that's why it only works at the beginning of game, and that's why I've created a kill_time.

You can change the messages in the centerprints if you want.
Now at ClientObituary(), before (if (rnum == IT_AXE)) add:

Code: Select all
if (attacker.kill_time >= time)
{
   attacker.kill_amount = attacker.kill_amount + 1;
   killmsg (attacker, attacker.kill_amount);
}
else
   attacker.kill_amount = 1;
if (targ.classname == "player")
   attacker.kill_time = time + 3;


The kill_time you can change to some other number of seconds too.
Now compile and it should work.
User avatar
Orion
 
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil

Postby redrum » Tue Aug 28, 2007 2:52 am

Thanks Orion! It works great!
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest