mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
Script changes for the Full PhysX Template to remove the scripted numerical health hud, replacing it with the c++ GuiHealthTextHud GuiControl.
This commit is contained in:
parent
00f72f1325
commit
f73655782c
5 changed files with 23 additions and 123 deletions
|
|
@ -240,57 +240,31 @@
|
||||||
canSaveDynamicFields = "0";
|
canSaveDynamicFields = "0";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
new GuiBitmapBorderCtrl(HealthHUD) {
|
new GuiHealthTextHud() {
|
||||||
isContainer = "0";
|
fillColor = "0 0 0 0.65";
|
||||||
Profile = "ChatHudBorderProfile";
|
frameColor = "0 0 0 1";
|
||||||
HorizSizing = "right";
|
textColor = "1 1 1 1";
|
||||||
VertSizing = "top";
|
warningColor = "1 0 0 1";
|
||||||
position = "6 693";
|
showFill = "1";
|
||||||
Extent = "72 72";
|
showFrame = "1";
|
||||||
MinExtent = "8 8";
|
showTrueValue = "0";
|
||||||
canSave = "1";
|
showEnergy = "0";
|
||||||
Visible = "1";
|
warnThreshold = "25";
|
||||||
tooltipprofile = "GuiToolTipProfile";
|
pulseThreshold = "15";
|
||||||
|
pulseRate = "750";
|
||||||
|
position = "5 693";
|
||||||
|
extent = "72 72";
|
||||||
|
minExtent = "8 2";
|
||||||
|
horizSizing = "right";
|
||||||
|
vertSizing = "top";
|
||||||
|
profile = "GuiBigTextProfile";
|
||||||
|
visible = "1";
|
||||||
|
active = "1";
|
||||||
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
hovertime = "1000";
|
hovertime = "1000";
|
||||||
|
isContainer = "0";
|
||||||
|
canSave = "1";
|
||||||
canSaveDynamicFields = "0";
|
canSaveDynamicFields = "0";
|
||||||
|
|
||||||
new GuiBitmapCtrl() {
|
|
||||||
bitmap = "core/art/gui/images/hudfill.png";
|
|
||||||
wrap = "0";
|
|
||||||
isContainer = "0";
|
|
||||||
Profile = "GuiDefaultProfile";
|
|
||||||
HorizSizing = "width";
|
|
||||||
VertSizing = "height";
|
|
||||||
position = "8 8";
|
|
||||||
Extent = "56 56";
|
|
||||||
MinExtent = "8 8";
|
|
||||||
canSave = "1";
|
|
||||||
Visible = "1";
|
|
||||||
tooltipprofile = "GuiToolTipProfile";
|
|
||||||
hovertime = "1000";
|
|
||||||
canSaveDynamicFields = "0";
|
|
||||||
};
|
|
||||||
new GuiTextCtrl(numericalHealthHUD) {
|
|
||||||
maxLength = "255";
|
|
||||||
Margin = "0 0 0 0";
|
|
||||||
Padding = "0 0 0 0";
|
|
||||||
AnchorTop = "0";
|
|
||||||
AnchorBottom = "0";
|
|
||||||
AnchorLeft = "0";
|
|
||||||
AnchorRight = "0";
|
|
||||||
isContainer = "0";
|
|
||||||
Profile = "NumericHealthProfile";
|
|
||||||
HorizSizing = "center";
|
|
||||||
VertSizing = "center";
|
|
||||||
position = "0 22";
|
|
||||||
Extent = "72 32";
|
|
||||||
MinExtent = "8 8";
|
|
||||||
canSave = "1";
|
|
||||||
Visible = "1";
|
|
||||||
tooltipprofile = "GuiToolTipProfile";
|
|
||||||
hovertime = "1000";
|
|
||||||
canSaveDynamicFields = "0";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
new GuiBitmapCtrl(OOBSign) {
|
new GuiBitmapCtrl(OOBSign) {
|
||||||
bitmap = "art/gui/playHud/missionAreaWarning.png";
|
bitmap = "art/gui/playHud/missionAreaWarning.png";
|
||||||
|
|
|
||||||
|
|
@ -45,26 +45,6 @@ function clientCmdSyncClock(%time)
|
||||||
// or when a client joins a game in progress.
|
// or when a client joins a game in progress.
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Numerical Health Counter
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
function clientCmdSetNumericalHealthHUD(%curHealth)
|
|
||||||
{
|
|
||||||
// Skip if the hud is missing.
|
|
||||||
if (!isObject(numericalHealthHUD))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// The server has sent us our current health, display it on the HUD
|
|
||||||
numericalHealthHUD.setValue(%curHealth);
|
|
||||||
|
|
||||||
// Ensure the HUD is set to visible while we have health / are alive
|
|
||||||
if (%curHealth)
|
|
||||||
HealthHUD.setVisible(true);
|
|
||||||
else
|
|
||||||
HealthHUD.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Damage Direction Indicator
|
// Damage Direction Indicator
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -681,9 +681,6 @@ function GameCore::onDeath(%game, %client, %sourceObject, %sourceClient, %damage
|
||||||
// Clear out the name on the corpse
|
// Clear out the name on the corpse
|
||||||
%client.player.setShapeName("");
|
%client.player.setShapeName("");
|
||||||
|
|
||||||
// Update the numerical Health HUD
|
|
||||||
%client.player.updateHealth();
|
|
||||||
|
|
||||||
// Switch the client over to the death cam and unhook the player object.
|
// Switch the client over to the death cam and unhook the player object.
|
||||||
if (isObject(%client.camera) && isObject(%client.player))
|
if (isObject(%client.camera) && isObject(%client.player))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,6 @@ function HealthPatch::onCollision(%this, %obj, %col)
|
||||||
{
|
{
|
||||||
%col.applyRepair(%this.repairAmount);
|
%col.applyRepair(%this.repairAmount);
|
||||||
|
|
||||||
// Update the Health GUI while repairing
|
|
||||||
%this.doHealthUpdate(%col);
|
|
||||||
|
|
||||||
%obj.respawn();
|
%obj.respawn();
|
||||||
if (%col.client)
|
if (%col.client)
|
||||||
messageClient(%col.client, 'MsgHealthPatchUsed', '\c2Health Patch Applied');
|
messageClient(%col.client, 'MsgHealthPatchUsed', '\c2Health Patch Applied');
|
||||||
|
|
@ -46,28 +43,6 @@ function HealthPatch::onCollision(%this, %obj, %col)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function HealthPatch::doHealthUpdate(%this, %obj)
|
|
||||||
{
|
|
||||||
// Would be better to add a onRepair() callback to shapeBase.cpp in order to
|
|
||||||
// prevent any excess/unneccesary schedules from this. But for the time
|
|
||||||
// being....
|
|
||||||
|
|
||||||
// This is just a rough timer to update the Health HUD every 250 ms. From
|
|
||||||
// my tests a large health pack will fully heal a player from 10 health in
|
|
||||||
// 36 iterations (ie. 9 seconds). If either the scheduling time, the repair
|
|
||||||
// amount, or the repair rate is changed then the healthTimer counter should
|
|
||||||
// be changed also.
|
|
||||||
|
|
||||||
if (%obj.healthTimer < 40) // 40 = 10 seconds at 1 iteration per 250 ms.
|
|
||||||
{
|
|
||||||
%obj.UpdateHealth();
|
|
||||||
%this.schedule(250, doHealthUpdate, %obj);
|
|
||||||
%obj.healthTimer++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
%obj.healthTimer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ShapeBase::tossPatch(%this)
|
function ShapeBase::tossPatch(%this)
|
||||||
{
|
{
|
||||||
//error("ShapeBase::tossPatch(" SPC %this.client.nameBase SPC ")");
|
//error("ShapeBase::tossPatch(" SPC %this.client.nameBase SPC ")");
|
||||||
|
|
|
||||||
|
|
@ -53,12 +53,6 @@ function Armor::onAdd(%this, %obj)
|
||||||
// Default dynamic armor stats
|
// Default dynamic armor stats
|
||||||
%obj.setRechargeRate(%this.rechargeRate);
|
%obj.setRechargeRate(%this.rechargeRate);
|
||||||
%obj.setRepairRate(0);
|
%obj.setRepairRate(0);
|
||||||
|
|
||||||
// Set the numerical Health HUD
|
|
||||||
//%obj.updateHealth();
|
|
||||||
|
|
||||||
// Calling updateHealth() must be delayed now... for some reason
|
|
||||||
%obj.schedule(50, "updateHealth");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Armor::onRemove(%this, %obj)
|
function Armor::onRemove(%this, %obj)
|
||||||
|
|
@ -227,9 +221,6 @@ function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageTy
|
||||||
|
|
||||||
%location = "Body";
|
%location = "Body";
|
||||||
|
|
||||||
// Update the numerical Health HUD
|
|
||||||
%obj.updateHealth();
|
|
||||||
|
|
||||||
// Deal with client callbacks here because we don't have this
|
// Deal with client callbacks here because we don't have this
|
||||||
// information in the onDamage or onDisable methods
|
// information in the onDamage or onDisable methods
|
||||||
%client = %obj.client;
|
%client = %obj.client;
|
||||||
|
|
@ -435,23 +426,6 @@ function Player::playPain(%this)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Numerical Health Counter
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
function Player::updateHealth(%player)
|
|
||||||
{
|
|
||||||
//echo("\c4Player::updateHealth() -> Player Health changed, updating HUD!");
|
|
||||||
|
|
||||||
// Calcualte player health
|
|
||||||
%maxDamage = %player.getDatablock().maxDamage;
|
|
||||||
%damageLevel = %player.getDamageLevel();
|
|
||||||
%curHealth = %maxDamage - %damageLevel;
|
|
||||||
%curHealth = mceil(%curHealth);
|
|
||||||
|
|
||||||
// Send the player object's current health level to the client, where it
|
|
||||||
// will Update the numericalHealth HUD.
|
|
||||||
commandToClient(%player.client, 'setNumericalHealthHUD', %curHealth);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Player::setDamageDirection(%player, %sourceObject, %damagePos)
|
function Player::setDamageDirection(%player, %sourceObject, %damagePos)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue