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