Re: New NitroVehicles
Posted: Thu 30 Dec , 2010 6:07 pm
Sure is rage in here.
Code: Select all
VehicleReplacementConfig=(OldClassName="ScorpionType4.ScorpionT4Plasma",NewClassName="NitroVehicles2.NitroRVPlasma")
Code: Select all
//=============================================================================
// NitroVehiclesInteractions.
//=============================================================================
class NitroVehiclesInteractions extends Interaction
config(NitroVehicles);
var config EInputKey NitroKey;
var config EInputKey RepairKey;
var config EInputKey ShieldKey;
var config bool bNitroKeyEnabled, bRepairKeyEnabled, bShieldKeyEnabled;
var bool bShowWheeledDebug;
var localized string MenuName;
var localized string MenuHelp;
// Needed so that we don't call ModifyMenu again even when when it already added the new tab.
var private editconst bool bMenuModified;
final private function ModifyMenu()
{
local UT2K4PlayerLoginMenu Menu;
local GUITabPanel Panel;
// Try get the menu, will return none if the menu is not open!.
Menu = UT2K4PlayerLoginMenu(GUIController(ViewportOwner.Actor.Player.GUIController).FindPersistentMenuByName( UnrealPlayer(ViewportOwner.Actor).LoginMenuClass ));
if( Menu != none )
{
// You can use the panel reference to do the modifications to the tab etc.
Panel = Menu.c_Main.AddTab(MenuName, string( class'NitroVehiclesMenuPanel' ),, MenuHelp);
bMenuModified = true;
// Uncomment if tick is not needed for anything else than ModifyMenu.
Disable('Tick');
bRequiresTick = false;
}
}
function Tick( float DeltaTime )
{
if( !bMenuModified )
ModifyMenu();
}
function bool KeyEvent(EInputKey Key, EInputAction Action, FLOAT Delta )
{
if (ViewPortOwner.Actor.Pawn == None)
return Super.KeyEvent(Key,Action,Delta);
//Check for ONS vehicle -> coz this is the superclass of them
//If it exists then send console commands
if (ViewPortOwner.Actor.Pawn.IsA('ONSVehicle'))
{
if ((Action == IST_Press) && bNitroKeyEnabled && (Key == class'NitroVehiclesInteractions'.default.NitroKey))
ConsoleCommand("NitroOn");
else if ((Action == IST_Release) && bNitroKeyEnabled && (Key == class'NitroVehiclesInteractions'.default.NitroKey))
ConsoleCommand("NitroOff");
else if ((Action == IST_Press) && bRepairKeyEnabled && (Key == class'NitroVehiclesInteractions'.default.RepairKey))
ConsoleCommand("Repair");
else if ((Action == IST_Press) && bShieldKeyEnabled && (Key == class'NitroVehiclesInteractions'.default.ShieldKey))
ConsoleCommand("Shield");
}
return Super.KeyEvent(Key,Action,Delta);
}
exec function NVWheelDebug()
{
//don't bother if someone wishes to use it on server
//doesn't show anything "forbidden"
//instead if something fails, it would be good if this is noted
bShowWheeledDebug = !bShowWheeledDebug;
}
exec function NVSaveConfig()
{
StaticSaveConfig();
}
function PostRender( canvas Canvas )
{
local float XL, YL, PosY;
local ONSWheeledCraft Veh;
local InterpCurve BoostForceMagnitude;
local InterpCurve SlopeForceModifier;
local bool CountBoostForce;
local float BoostForce, SlopeModifier;
if (!bShowWheeledDebug || ViewPortOwner.Actor.ViewTarget == None)
return;
if (ViewPortOwner.Actor.ViewTarget.IsA('ONSWheeledCraft'))
Veh = ONSWheeledCraft(ViewPortOwner.Actor.Pawn);
else if (ViewPortOwner.Actor.ViewTarget.IsA('ONSWeaponPawn') && ONSWeaponPawn(ViewPortOwner.Actor.ViewTarget).VehicleBase != None && ONSWeaponPawn(ViewPortOwner.Actor.ViewTarget).VehicleBase.IsA('ONSWheeledCraft'))
Veh = ONSWheeledCraft(ONSWeaponPawn(ViewPortOwner.Actor.ViewTarget).VehicleBase);
if (Veh != None)
{
Canvas.Font = ViewPortOwner.Actor.MyHud.GetConsoleFont(Canvas);
Canvas.SetDrawColor(0, 255, 0);
Canvas.SetPos(5, 0.55 * Canvas.ClipY + PosY);
Canvas.TextSize("Nitro Vehicles v3 Debug Info", XL, YL);
Canvas.DrawText("Nitro Vehicles v3 Debug Info");
PosY += YL + 5;
//plot some properties
Canvas.SetDrawColor(255, 255, 255);
Canvas.SetPos(5, 0.55 * Canvas.ClipY + PosY);
Canvas.TextSize("EngineRPM: ", XL, YL);
Canvas.DrawText("EngineRPM: ");
Canvas.SetDrawColor(255, 255, 0);
Canvas.SetPos(5 + XL, 0.55 * Canvas.ClipY + PosY);
Canvas.DrawText(Veh.EngineRPM);
PosY += YL + 5;
Canvas.SetDrawColor(255, 255, 255);
Canvas.SetPos(5, 0.55 * Canvas.ClipY + PosY);
Canvas.TextSize("CarMPH: ", XL, YL);
Canvas.DrawText("CarMPH: ");
Canvas.SetDrawColor(255, 255, 0);
Canvas.SetPos(5 + XL, 0.55 * Canvas.ClipY + PosY);
Canvas.DrawText(Veh.CarMPH);
PosY += YL + 5;
Canvas.SetDrawColor(255, 255, 255);
Canvas.SetPos(5, 0.55 * Canvas.ClipY + PosY);
Canvas.TextSize("Throttle: ", XL, YL);
Canvas.DrawText("Throttle: ");
Canvas.SetDrawColor(255, 255, 0);
Canvas.SetPos(5 + XL, 0.55 * Canvas.ClipY + PosY);
Canvas.DrawText(Veh.Throttle);
PosY += YL + 5;
Canvas.SetDrawColor(255, 255, 255);
Canvas.SetPos(5, 0.55 * Canvas.ClipY + PosY);
Canvas.TextSize("ForwardVel: ", XL, YL);
Canvas.DrawText("ForwardVel: ");
Canvas.SetDrawColor(255, 255, 0);
Canvas.SetPos(5 + XL, 0.55 * Canvas.ClipY + PosY);
Canvas.DrawText(Veh.ForwardVel);
PosY += YL + 5;
Canvas.SetDrawColor(255, 255, 255);
Canvas.SetPos(5, 0.55 * Canvas.ClipY + PosY);
Canvas.TextSize("Gear: ", XL, YL);
Canvas.DrawText("Gear: ");
Canvas.SetDrawColor(255, 255, 0);
Canvas.SetPos(5 + XL, 0.55 * Canvas.ClipY + PosY);
Canvas.DrawText(Veh.Gear);
PosY += YL + 5;
Canvas.SetDrawColor(255, 255, 255);
Canvas.SetPos(5, 0.55 * Canvas.ClipY + PosY);
Canvas.TextSize("Pitch: ", XL, YL);
Canvas.DrawText("Pitch: ");
Canvas.SetDrawColor(255, 255, 0);
Canvas.SetPos(5 + XL, 0.55 * Canvas.ClipY + PosY);
Canvas.DrawText(Veh.Rotation.Pitch);
PosY += YL + 5;
CountBoostForce = false;
if (Veh.IsA('NitroPRV'))
{
BoostForceMagnitude = NitroPRV(Veh).BoostForceMagnitude;
SlopeForceModifier = NitroPRV(Veh).SlopeForceModifier;
CountBoostForce = true;
}
else if (Veh.IsA('NitroRV'))
{
BoostForceMagnitude = NitroRV(Veh).BoostForceMagnitude;
SlopeForceModifier = NitroRV(Veh).SlopeForceModifier;
CountBoostForce = true;
}
else if (Veh.IsA('NitroSPMA'))
{
BoostForceMagnitude = NitroSPMA(Veh).BoostForceMagnitude;
SlopeForceModifier = NitroSPMA(Veh).SlopeForceModifier;
CountBoostForce = true;
}
if (CountBoostForce)
{
if (Veh.Gear == 0)
BoostForce = InterpCurveEval(BoostForceMagnitude, 0);
else
BoostForce = InterpCurveEval(BoostForceMagnitude, Veh.CarMPH);
if (Veh.Rotation.Pitch < 0)
SlopeModifier = InterpCurveEval(SlopeForceModifier, 0);
else
SlopeModifier = InterpCurveEval(SlopeForceModifier, Veh.Rotation.Pitch);
//not below zero
BoostForce = FMax(BoostForce, 0);
SlopeModifier = FMax(SlopeModifier, 0);
Canvas.SetDrawColor(255, 255, 255);
Canvas.SetPos(5, 0.55 * Canvas.ClipY + PosY);
Canvas.TextSize("BoostForce: ", XL, YL);
Canvas.DrawText("BoostForce: ");
Canvas.SetDrawColor(255, 255, 0);
Canvas.SetPos(5 + XL, 0.55 * Canvas.ClipY + PosY);
Canvas.DrawText(BoostForce);
PosY += YL + 5;
Canvas.SetDrawColor(255, 255, 255);
Canvas.SetPos(5, 0.55 * Canvas.ClipY + PosY);
Canvas.TextSize("SlopeModifier: ", XL, YL);
Canvas.DrawText("SlopeModifier: ");
Canvas.SetDrawColor(255, 255, 0);
Canvas.SetPos(5 + XL, 0.55 * Canvas.ClipY + PosY);
Canvas.DrawText(SlopeModifier);
PosY += YL + 5;
}
}
}
//remove myself if level changed
event NotifyLevelChange()
{
Master.RemoveInteraction(self);
}
defaultproperties
{
bNitroKeyEnabled=true
bRepairKeyEnabled=true
bShieldKeyEnabled=true
NitroKey=IK_Shift
RepairKey=IK_J
ShieldKey=IK_K
bVisible=true
bRequiresTick=true
MenuName="Nitro Vehicles"
MenuHelp="Nitro Vehicles Configuration"
}
Code: Select all
class NitroVehiclesMenuPanel extends MidGamePanel
dependsOn(Interactions);
var automated KeyBindEdit e_NitroEdit;
var automated KeyBindEdit e_RepairEdit;
var automated KeyBindEdit e_ShieldEdit;
var automated GUILabel l_NitroLabel;
var automated GUILabel l_RepairLabel;
var automated GUILabel l_ShieldLabel;
var automated GUIEditBox b_Caption;
var localized string NitroText;
var localized string RepairText;
var localized string ShieldText;
var localized string CaptionText;
function InitComponent( GUIController InController, GUIComponent InOwner )
{
b_Caption.Caption = CaptionText;
l_NitroLabel.Caption = NitroText;
l_RepairLabel.Caption = RepairText;
l_ShieldLabel.Caption = ShieldText;
Super.InitComponent(InController, InOwner);
}
function NitroKeyInit(out byte keyCode)
{
keyCode = class'NitroVehiclesInteractions'.default.NitroKey;
}
function RepairKeyInit(out byte keyCode)
{
keyCode = class'NitroVehiclesInteractions'.default.RepairKey;
}
function ShieldKeyInit(out byte keyCode)
{
keyCode = class'NitroVehiclesInteractions'.default.ShieldKey;
}
function NitroKeyChanged(byte keyCode)
{
class'NitroVehiclesInteractions'.default.NitroKey = EInputKey(keyCode);
class'NitroVehiclesInteractions'.static.StaticSaveConfig();
}
function RepairKeyChanged(byte keyCode)
{
class'NitroVehiclesInteractions'.default.RepairKey = EInputKey(keyCode);
class'NitroVehiclesInteractions'.static.StaticSaveConfig();
}
function ShieldKeyChanged(byte keyCode)
{
class'NitroVehiclesInteractions'.default.ShieldKey = EInputKey(keyCode);
class'NitroVehiclesInteractions'.static.StaticSaveConfig();
}
defaultProperties
{
CaptionText="Key Assignments"
NitroText="Nitro"
RepairText="Repair"
ShieldText="Shield"
Begin Object Class=GUIEditBox Name=MyBorder
WinWidth = 0.980000
WinHeight = 0.040000
WinLeft = 0.010000
WinTop = 0.025000
bReadOnly = true
bTabStop = false
bNeverFocus = true
End Object
b_Caption=MyBorder
Begin Object Class=GUILabel Name=NitroLabel
TextColor = (R=255,G=255,B=255,A=255)
WinWidth = 0.150000
WinHeight = 0.040000
WinLeft = 0.345000
WinTop = 0.090000
bBoundToParent = False
bScaleToParent = False
End Object
l_NitroLabel=NitroLabel
Begin Object Class=KeyBindEdit Name=NitroEdit
WinWidth = 0.150000
WinHeight = 0.040000
WinLeft = 0.550000
WinTop = 0.090000
OnInitKey = NitroKeyInit
OnKeyChanged = NitroKeyChanged
bBoundToParent = False
bScaleToParent = False
End Object
e_NitroEdit=NitroEdit
Begin Object Class=GUILabel Name=RepairLabel
TextColor = (R=255,G=255,B=255,A=255)
WinWidth = 0.150000
WinHeight = 0.040000
WinLeft = 0.345000
WinTop = 0.155000
bBoundToParent = False
bScaleToParent = False
End Object
l_RepairLabel=RepairLabel
Begin Object Class=KeyBindEdit Name=RepairEdit
WinWidth = 0.150000
WinHeight = 0.040000
WinLeft = 0.550000
WinTop = 0.155000
OnInitKey = RepairKeyInit
OnKeyChanged = RepairKeyChanged
bBoundToParent = False
bScaleToParent = False
End Object
e_RepairEdit=RepairEdit
Begin Object Class=GUILabel Name=ShieldLabel
TextColor = (R=255,G=255,B=255,A=255)
WinWidth = 0.150000
WinHeight = 0.040000
WinLeft = 0.345000
WinTop = 0.220000
bBoundToParent = False
bScaleToParent = False
End Object
l_ShieldLabel=ShieldLabel
Begin Object Class=KeyBindEdit Name=ShieldEdit
WinWidth = 0.150000
WinHeight = 0.040000
WinLeft = 0.550000
WinTop = 0.220000
OnInitKey = ShieldKeyInit
OnKeyChanged = ShieldKeyChanged
bBoundToParent = False
bScaleToParent = False
End Object
e_ShieldEdit=ShieldEdit
}
Code: Select all
class KeyBindEdit extends GUIEditBox
dependsOn(Interactions);
var byte KeyCode;
var string KeyStr;
var bool bCapturing;
Delegate OnInitKey(out byte Key) { Key = 0; }
Delegate OnKeyChanged(byte Key) {}
function InitComponent( GUIController InController, GUIComponent InOwner )
{
OnInitKey(KeyCode);
KeyStr = class'Interactions'.static.GetFriendlyName(EInputKey(KeyCode));
if (InStr(KeyStr, "Unknown") != -1 || KeyStr == "Escape")
KeyStr = "None";
Caption = KeyStr;
bReadOnly = true;
Super.InitComponent(InController, InOwner);
}
function MenuStateChange(eMenuState Newstate)
{
Super.MenuStateChange(Newstate);
if(Newstate == MSAT_Blurry)
{
bCapturing = false;
Caption = KeyStr;
}
}
function bool MouseClick(GUIComponent Sender)
{
bCapturing = true;
Caption = "";
return true;
}
function bool InternalOnKeyType(out byte Key, optional string Unicode)
{
return false;
}
function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
{
local string keyName;
if (State != 1 || !bCapturing)
return false;
//get the keyName from the interaction
keyName = class'Interactions'.static.GetFriendlyName(EInputKey(Key));
if (InStr(keyName, "Unknown") != -1 || keyName == "Escape")
{
KeyCode = 0;
KeyStr = "None";
}
else
{
KeyCode = Key;
KeyStr = keyName;
}
Caption = KeyStr;
OnKeyChanged(KeyCode);
bCapturing = false;
return true;
}
defaultproperties
{
bCaptureMouse=True
OnClick=MouseClick;
}