Jump to content

stcommander won't switch weapon after pulled


Recommended Posts

Posted

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...
}
}
Posted

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.

Posted

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?

Posted

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);
}

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...