Crosshair issue and Gun follow
I'm having an issue displaying the crosshair. After working with some custom HUD testing, my crosshair disappeared, any idea what is happening? :/. Speaking of which, how does the crosshair work with following the mouse like that? Is there a way to have the gun follow the crosshair as well???
class ChadHUDTester extends GFxMoviePlayer;
var float LastHealthpc, LastAmmoCount;
var GFxObject HealthMC, HealthBarMC, HealthTF, AmmoBarMC, GunTF;
function Init(optional LocalPlayer PC)
{
Start();
Advance(0);
LastHealthpc = -201;
LastAmmoCount = -201;
HealthMC = GetVariableObject("_root.playerstats.health");
HealthBarMC = GetVariableObject("_root.playerstats.health.bar");
HealthTF = GetVariableObject("_root.playerstats.health.text");
AmmoBarMC = GetVariableObject("_root.playerstats.ammo.ammoBar");
GunTF = GetVariableObject("_root.playerstats.ammo.gunName");
super.Init(PC);
}
function float getPercentage(int val, int max)
{
return (float(val) / float(max)) * 100.0f;
}
function SetHUDPos_Health(float x, float y)
{
HealthMC.SetFloat("_x", x);
HealthMC.SetFloat("_y", y);
}
function TickHUD()
{
local IronsightPawn ISP;
ISP = IronsightPawn(GetPC().Pawn);
GunTF.SetText(UTWeapon(ISP.Weapon).AmmoCount);
HealthTF.SetText("Health");
if(ISP != none)
{
if(LastHealthpc != getPercentage(ISP.Health, ISP.HealthMax))
{
LastHealthpc = getPercentage(ISP.Health, ISP.HealthMax);
HealthBarMC.SetFloat("_xscale", (LastHealthpc > 100) ? 100.0f : LastHealthpc);
}
if(LastAmmoCount != UTWeapon(ISP.Weapon).AmmoCount)
{
LastAmmoCount = UTWeapon(ISP.Weapon).AmmoCount;
AmmoBarMC.SetFloat("_xscale", LastAmmoCount);
}
//SetHUDPos_Health(425,100);
}
}
DefaultProperties
{
bDisplayWithHudOff=false
MovieInfo=SwfMovie'ChadHUD.ChadHUD'
bEnableGammaCorrection=false
}
class IronsightHUD extends UTGFxHudWrapper;
var int healthAmount;
var ChadHUDTester HudMovie;
singular event Destroyed()
{
if(HudMovie != none)
{
HudMovie.Close(true);
HudMovie = none;
}
}
simulated function PostBeginPlay()
{
super.PostBeginPlay();
HudMovie = new class'ChadHUDTester';
HudMovie.SetTimingMode(TM_Real);
HudMovie.Init(LocalPlayer(PlayerOwner.Player));
}
event PostRender()
{
HudMovie.TickHUD();
}
DefaultProperties
{
}
class IronsightPlayerController extends UTPlayerController;
simulated exec function Ironsight()
{
if((IronsightPawn(Pawn) != none) && IronsightPawn(Pawn).CanIronsight())
{
IronsightPawn(Pawn).SetIronsight(true);
}
else
{
IronsightPawn(Pawn).SetIronsight(false);
}
}
// Alternate fire now toggles Ironsights.
exec function StartAltFire(optional Byte FireModeNum)
{
Ironsight();
//locks aiming to the middle
ConsoleCommand("SetAimMode 0");
}
exec function StopAltFire(optional byte FireModeNum)
{
if(IronsightPawn(Pawn) != none)
{
IronsightPawn(Pawn).SetIronsight(false);
}
//puts aiming back to normal
ConsoleCommand("SetAimMode 1");
}
reliable client function ClientSetHUD(class<HUD> newHUDType)
{
if(myHUD != none)
{
myHUD.Destroy();
}
myHUD = Spawn(class'IronsightHUD', self);
}
exec function RequestReload()
{
local UTWeap_Shotgun mywp;
local int shells;
local int clips;
local UTWeap_Assault AssaultRifle;
local IronsightPawn ip;
ip = IronsightPawn(Pawn);
mywp = UTWeap_Shotgun(Pawn.Weapon);
AssaultRifle = UTWeap_Assault(Pawn.Weapon);
if(mywp !=none && ip != none)
{
shells = mywp.clips;
if(shells > 0 && !mywp.bIsReloading && mywp.AmmoCount != mywp.MaxAmmoCount)
{
mywp.bIsReloading = true;
mywp.bStartReloading = true;
ip.bSprinting = false;
mywp.PlayWeaponAnimation('ReloadStart', 0.7);
mywp.SetTimer(0.7, false, 'AddMoreAmmo');
}
}
if(AssaultRifle != none && ip != none)
{
clips = AssaultRifle.clips;
if(clips > 0 && !AssaultRifle.bIsReloading && AssaultRifle.AmmoCount != AssaultRifle.MaxAmmoCount)
{
AssaultRifle.bIsReloading = true;
AssaultRifle.bStartReloading = true;
ip.bSprinting = false;
AssaultRifle.PlayWeaponAnimation('Assault_Reload',1.2);
AssaultRifle.SetTimer(0.7,false,'AddMoreAmmo');
AssaultRifle.WeaponPlaySound(SoundCue'WP_Cx_Assault.Sounds.A_WP_Cx_Assault_ClipOutCue');
}
}
}
defaultproperties
{
}
class IronsightGame extends UTGame;
simulated function PostBeginPlay()
{
//this is to fix the green box around the scope problem. courtesy of Oculus VR help
ConsoleCommand("scale set scalepercentage 100");
}
defaultproperties
{
PlayerControllerClass=class'IronsightPlayerController'
DefaultPawnClass=class'IronsightPawn'
DefaultInventory(0)=class'UTWeap_Fists'
bGivePhysicsGun=false
bUseClassicHUD=true
HUDType=class'IronsightHUD'
}
