Download

Replacing a function with a mod in UE2 games - help a total noob out?

I appreciate that UE2 is very old, but what I’m trying to achieve should be pretty universal. I’m trying to write a mod for the 2003 game Rainbow Six 3: Raven Shield, which still has an active mod scene and player base so many years after launch. One way the game is still showing its age is after you equip a grenade and throw it, the game equips another grenade and you have to wait for that to switch to your primary weapon. But the game does have a mechanic where after you throw your final grenade you auto-switch to your primary weapon. I’ve looked around in the source code and found the script responsible for that function, and I’d like to mod it so it happens no matter how many grenades you have left. The script is here and the relevant bit is:

state StandByToThrow
{
function BeginState()
{
local R6PlayerController PController;

  #ifdefDEBUG if(bShowLog) log("R6GrenadeWeapon::StandByToThrow::BeginState"); #endif
    R6Pawn(Owner).m_bIsFiringState = FALSE;
    if (bShowLog) log("**** IN  STANDBY TO THROW *******");

  if (m_iNbBulletsInWeapon==0)
  {
  	if (bShowLog) log("**** No more Grenades, Autoswitch to Primary Weapon *******");

  	// Auto switch to primary weapon!
  PController = R6PlayerController(Pawn(Owner).controller);
  if (PController!=none)
  {
  		if(R6Pawn(Owner).m_WeaponsCarried[0] != None)
  		    PController.PrimaryWeapon();
  		else
  		    PController.SecondaryWeapon();
    }
  }
}   

My understanding is that if I write a script that extends that script I can modify or replace functions of that script with my own. But I can’t get it to work. Basically all I want to do is remove or modify the “if (m_iNbBulletsInWeapon==0)” qualifier to make the weapon switching happen no matter how many grenades you have left. This was my attempt at the script but it doesn’t work. What am I missing?

class GrenadeSwitcher extends R6GrenadeWeapon;

state StandByToThrow
{
Function BeginState()
{
local R6PlayerController PController;

  PController = R6PlayerController(Pawn(Owner).controller);
  if (PController!=none)
  {
  	if(R6Pawn(Owner).m_WeaponsCarried[0] != None)
  	    PController.PrimaryWeapon();
  	else
  	    PController.SecondaryWeapon();
    }
  //}

}
}

defaultproperties
{
bHidden=true
bAlwaysRelevant=true

}

I’d place if in UE2 is possible a `log on PostBeginPlay() function if it is like UE3 to make sure that the weapon gets spawned, and overrides the funcionality.
Best of luck : P.

If it does it should print whatever you placed on the LOG function…

Are you just after the loading of the primary weapon. After the nade is thrown?

 if( (m_iNbBulletsInWeapon==0) || (m_iNbBulletsInWeapon !=0)) 

Should work
or just go

 if(m_iNbBulletsInWeapon !=0)