.qc (dot qc) - the group for quake c coders of all denominations. If you make quake one mods and write code in quake c, join our group! I'll try to answer any quake c questions - please post your inquiry in the forums...

Forum Thread
  Posts  
Random monsters - the count (Groups : qc : Forum : vault() : Random monsters - the count) Locked
Thread Options
numbersix
numbersix quake-c coder++
Dec 6 2013 Anchor

The wandering monster is a concept from roleplaying games - an unplanned encounter with random consequences.

With a slight retool of quake-c you can have random monsters in singleplayer or deathmatch.
(The full code set is going to be the subject of a later tutorial...just be patient.)

Here we will cover updating the clients total monster count.

// defs.qc:

float total_monsters;
float MSG_BROADCAST = 0; // unreliable to all
void(float to, float f) WriteByte = #52;
void(float to, float f) WriteLong = #55;

// hipdefs.qc - defined for the horn of conjuring

float STAT_TOTALMONSTERS = 12;
float SVC_UPDATESTAT = 3;

You can have the server tell how many random monsters you have made:

// this code is contained in a function that makes a random monster

float t_monsters;

// save count - *_monster_start() functions bumps the count and we might fail this monster attempt in our code
// in the event of a fail, total_monsters will be re-assigned the value in t_monsters

t_monsters = total_monsters;

//
// code segment to make a random monster on the map goes here - this will be covered in a tutorial later
//

// at this point we have made a new monster
total_monsters = t_monsters + 1; // the "real" bump

// builtin function used to send network messages to the clients
// tell all clients the new monster count

WriteByte (MSG_BROADCAST, SVC_UPDATESTAT);
WriteByte (MSG_BROADCAST, STAT_TOTALMONSTERS);
WriteLong (MSG_BROADCAST, total_monsters);

Edited by: numbersix

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.