Unreales / UDK Español

Problema al actualizar el AmmoCount

« Older   Newer »
  Share  
MultiKiller
view post Posted on 25/4/2014, 18:53




Que tal Unreales, vengo a ver si alguien puede echarme una mano con este problema (en parte un problema, no totalmente XD)
El problema que tengo, es que no logro actualizar la barra de munición a tiempo real, solo se actualiza al recargar el arma (al hacer un cambio en la variable MaxAmmoCount, la variable que necesito obtener es AmmoCount), a ver si alguien sabe como puedo resolver esto?


Unas caps:



Este es mi código:
SPOILER (click to view)
Class ZGFxHUD Extends GFxSampleHUD; //GFxMoviePlayer;

var float LastHealthpc;
var GFxObject AmmoMC, /*MagMC,*/ BlackBar, BlueBar, RedBar;
var PlayerController PlayerOwner;
var int MyAmmoCount, MobHealth, MobHealthMax;
var bool bGammaCorrection;
var float LastShadowPercentage, LastAmmoPercentage;
var int LastAmmoCount;
var UTWeapon LastWeapon;




function Init(optional LocalPlayer LocPlay)
{
Start();
Advance(0.f);
LastAmmoPercentage = -221;
LastShadowPercentage = -1000;
//LastHealthpc = -1337;
//HealthBarMC = GetVariableObject("_root.DFBar_mc");
//AmmoCount = GetVariableObject("_root.Ammo_txt");
AmmoMC = GetVariableObject("_root.DFBar_mc");
BlackBar = GetVariableObject("_root.BlackBar");
BlueBar = GetVariableObject("_root.BlueBar");
RedBar = GetVariableObject("_root.RedBar");
//MagMC = GetVariableObject("_root.BulletBarMC");
}

// Function to round a float value to an int
function int roundNum(float NumIn) {
local int iNum;
local float fNum;

fNum = NumIn;
iNum = int(fNum);
fNum -= iNum;
if (fNum >= 0.5f) {
return (iNum + 1);
}
else {
return iNum;
}
}

// Function to return a percentage from a value and a maximum
function int getPercentage(int val, int max) {
return roundNum((float(val) / float(max)) * 100.0f);
}

function TickHUD()
{
Local PlayerController PC;
local UTWeapon Weapon;
local UTWeaponPlus Weapon2;
local UTPawn UTP;

//local int AmmoCount;
local int i;
// local float f;
PC = GetPC();
UTP = PointPawn(PC.Pawn);

//AmmoCount = W.GetAmmoCount();
Weapon = UTWeapon(UTP.Weapon);
Weapon2 = UTWeaponPlus(Weapon);
//AmmoCount = Weapon.GetAmmoCount();

if (UTP != none)
{
if(UTP.Health < 30)
{
ShowRed();
}

if(UTP.Health > 30)
{
ShowBlack();
}

if(UTP.Health > 80)
{
ShowBlue();
}
}
if (Weapon != none)
{
if (Weapon != LastWeapon)
{
LastShadowPercentage = getPercentage(Weapon.GetAmmoCount(), Weapon.MaxAmmoCount);
LastAmmoPercentage = getPercentage(Weapon2.GetClipCount(), Weapon2.AmmoCount);
//AmmoMC.SetFloat("_xscale", (LastAmmoPercentage > 100) ? 100.0f : LastAmmoPercentage);
AmmoMC.SetFloat("_xscale", (100.0 * float(Weapon2.AmmoCount)));
AmmoMC.SetVisible(true);
AmmoMC.GotoAndStopI(Weapon.InventoryGroup);
LastWeapon = Weapon;
}
i = Weapon.GetAmmoCount();
if (i != LastAmmoCount)
{
`Log("LastAmmoCount: "$LastAmmoCount);
LastAmmoCount = i;
LastShadowPercentage = getPercentage(Weapon.GetAmmoCount(), Weapon.MaxAmmoCount);
LastAmmoPercentage = getPercentage(Weapon2.GetClipCount(), Weapon2.AmmoCount);
AmmoMC.SetFloat("_xscale", (1.0 * float(Weapon2.AmmoCount)));
// AmmoMC.SetFloat("_xscale", (30.0 * float(Weapon.AmmoCount)) / float(Weapon.MaxAmmoCount));
// AmmoMC.SetFloat("_xscale", (LastAmmoPercentage > 100) ? 100.0f : LastAmmoPercentage);
}
}
else if (Weapon != LastWeapon)
{
`Log("HideWeapon");
//AmmoCountTF.SetText("");
AmmoMC.SetVisible(false);
// MagMC.SetVisible(false);
//ShadowMC.SetVisible(false);
}
}
 
Top
acadis
view post Posted on 25/4/2014, 20:50




Hola,has probado Poner en tu Hud base en event PostRender()

var ZGFxHUD ZGF;


event PostRender()
{
if (ZGF != none)
{
ZGF.TickHud();
}

}
 
Top
MultiKiller
view post Posted on 25/4/2014, 22:03




QUOTE (acadis @ 25/4/2014, 16:50) 
Hola,has probado Poner en tu Hud base en event PostRender()

var ZGFxHUD ZGF;


event PostRender()
{
if (ZGF != none)
{
ZGF.TickHud();
}

}

Sí, de hecho lo tengo así
QUOTE
Class ZHUD Extends UTHUD;
var ZGFxHUD HudMovie;


simulated function PostBeginPlay(){
super.PostBeginPlay();

HudMovie = new class'ZGFxHUD';
HudMovie.SetTimingMode(TM_Real);
HudMovie.Init();
}

event PostRender()
{
HudMovie.TickHUD();
}
 
Top
2 replies since 25/4/2014, 18:53   303 views
  Share