T.Zealot Posted December 17, 2014 Posted December 17, 2014 I've been trying to make it so that if the repeater trooper loses his repeater he'll switch to the generic pistol, with no success so far.I added this to NPC_Spawn.cpp yet when I use force pull/grip on him he's still unarmed and surrendering. This is driving me nuts! Can someone tell me what I'm doing wrong here? if (Q_stricmp("stcommander", NPC_type) == 0) { return (1 << WP_REPEATER); if (NPC->client->ps.weapon == WP_NONE) { return (1 << WP_BLASTER_PISTOL); //Stormtrooper Commander should whip out his sidearm after weapon is pulled... } }
Dusty Posted December 21, 2014 Posted December 21, 2014 He may not be able to switch to a pistol if he doesn't have one. Grenadiers I'm pretty sure can't switch to melee if they don't have it. You could probably just copy the AI_Grenadier.cpp code for Grans switching back and forth between melee and thermal dets. That code implies that they must possess WP_MELEE to be able to switch to it, so I would recommend using that code and then editing the st_commander NPC file to give them a blaster pistol.
T.Zealot Posted December 22, 2014 Author Posted December 22, 2014 Strangely I was able to do this in wp_saber.cpp. I added this to it and it partially works. if (dropper->client->NPC_class == CLASS_STORMTROOPER && oldWeap == WP_REPEATER) //111111 (1s are here so I can jump to this later) { replaceWeap = WP_BLASTER_PISTOL; } But for some odd reason the pistol's model doesn't load and the stcommander shoots the lasers out of his head. Is there a way to load the pistol model when the repeater is pulled?
Xycaleth Posted December 22, 2014 Posted December 22, 2014 if (Q_stricmp("stcommander", NPC_type) == 0) { return (1 << WP_REPEATER); // *** All code after this line never gets executed because you've returned from the function *** if (NPC->client->ps.weapon == WP_NONE) { return (1 << WP_BLASTER_PISTOL); //Stormtrooper Commander should whip out his sidearm after weapon is pulled... } }I've added a code comment inline. You need to add your check before the return. So, like this: if (Q_stricmp("stcommander", NPC_type) == 0) { if (NPC->client->ps.weapon == WP_NONE) { return (1 << WP_BLASTER_PISTOL); //Stormtrooper Commander should whip out his sidearm after weapon is pulled... } return (1 << WP_REPEATER); }
T.Zealot Posted December 22, 2014 Author Posted December 22, 2014 When I use that, the game crashes when the stcommander is spawned. Am I missing something?
Xycaleth Posted December 22, 2014 Posted December 22, 2014 You'll need to attach a debugger and find out why it's crashing
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now