Shooting Dummies

 

Although really designed for testing weapons for, I suppose you could use this as the stating point for a bot (I don't really see a reason too, but you might want to); or maybe you think it would be funny to allow teams to set up dummies round their base to scare away sneaking people. It uses the insane marine model as the dummy, as I can't quite figure out how to make a model use a skin which isn't linked to it. (If I was creating a bot, then maybe I could do it, but without USERINFO i don't know i you can. engine limitation?) from a distance it would work. alterntivly you could copy the male model and link a skin to it; or any othe model for that matter.


Most of the code is in dummy.c which is available at the bottom of the page. there are a couple of changes which you will need to do to make that code accesible by the player. Add dummy.c to your project/makefile.

Next open up g_local.h Close to the bottom of the file you should find the line

        monsterinfo_t  monsterinfo;

just before the } after it, add in the definitions below

        vec3_t         dummypoint;
        int            dummypointset;

The first is a check to make sure that there is a point set for the dummy to spawn at, the second holds the position you want the dummy to spawn at.


Now open up g_cmds.c. you need to prototyper the two functions that will be called from dummy.c, add these lines in after #include "g_local.h"

void Mark_Dummy_Spawn_Point(edict_t *ent);
void Spawn_Dummy(edict_t *ent);

Next scroll down to the bottom of the file, you should find this code

        else if (Q_stricmp(cmd, "playerlist") == 0)
               Cmd_PlayerList_f(ent);
        else    // anything that doesn't match a command will be a chat
               Cmd_Say_f (ent, false, true);
}

Modify it to read

        else if (Q_stricmp(cmd, "playerlist") == 0)
               Cmd_PlayerList_f(ent);
        else if (Q_stricmp (cmd, "markpoint") == 0)
               Mark_Dummy_Spawn_Point(ent);
        else if (Q_stricmp (cmd, "spawndummy") == 0)
               Spawn_Dummy(ent);
        else    // anything that doesn't match a command will be a chat
               Cmd_Say_f (ent, false, true);
}

Compile it. that should now work when you type 'markpoint' and then move then type 'spawndummy'; A dummy should be spawned.

The dummies will tell anyone who shoots them how much health they have left. if you want to get rid of that feature, then go into dummy.c look fir dummypain and remove the gi.cprintf statement. If someone that is not a player (i.e. a monster) shoots them, the game will crash.


I may modify this tut later to allow for the creation of sentries who do not move much (turn in place probably) and shoot anyone they see on another team. I'd probably use a soldier model for that. If you want to give that a try but don't know how, then mail me and I'll send you some (fairly basic) guidelines. Basicly it involves a trace and a turning of the model. Primitive at best.



Skunkworks Tutorial