Merge pull request #1735 from Sir-Skurpsalot/damageModel-fix

Damage model fix
This commit is contained in:
Brian Roberts 2026-05-13 12:08:48 -05:00 committed by GitHub
commit bcce7e7c09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 10 deletions

View file

@ -9,6 +9,7 @@ function DamageModel::onDestroy(%this)
//This is called when the server is initially set up by the game application
function DamageModel::initServer(%this)
{
%this.queueExec("./scripts/server/player");
}
//This is called when the server is created for an actual game/map to be played
@ -22,7 +23,6 @@ function DamageModel::onCreateGameServer(%this)
%this.queueExec("./scripts/server/weapon");
%this.queueExec("./scripts/server/shapeBase");
%this.queueExec("./scripts/server/vehicle");
%this.queueExec("./scripts/server/player");
%this.queueExec("./scripts/server/commands");
}

View file

@ -2,27 +2,31 @@ function PlayerData::damage(%this, %obj, %sourceObject, %position, %damage, %dam
{
if (!isObject(%obj) || %obj.getDamageState() !$= "Enabled" || !%damage)
return;
%rootObj = %obj;
if (%obj.healthFromMount)
%rootObj = findRootObject(%obj);
%this.setDamageDirection(%rootObj, %sourceObject, %position);
if (%damageType !$= "Suicide") {
%getDamageLoc = %rootObj.getDamageLocation(%position);
%damageLoc = firstWord(%getDamageLoc);
}
%rootObj.applyDamage(%damage);
%this.onDamage(%rootObj, %damage);
%this.setDamageDirection(%rootObj, %sourceObject, %position);
// Deal with client callbacks here because we don't have this
// information in the onDamage or onDisable methods
%client = %rootObj.client;
%sourceClient = %sourceObject ? %sourceObject.client : 0;
%location = "Body";
if (isObject(%client))
{
if (%rootObj.getDamageState() !$= "Enabled")
{
callGamemodeFunction("onDeath", %client, %sourceObject, %sourceClient, %damageType, %location);
callGamemodeFunction("onDeath", %client, %sourceObject, %sourceClient, %damageType, %damageLoc);
}
}
}
@ -30,7 +34,7 @@ function PlayerData::damage(%this, %obj, %sourceObject, %position, %damage, %dam
function PlayerData::onDamage(%this, %obj, %delta)
{
Parent::onDamage(%this, %obj, %delta);
// This method is invoked by the ShapeBase code whenever the
// object's damage level changes.
if (%delta > 0 && %obj.getDamageState() !$= "Destroyed")
@ -39,4 +43,4 @@ function PlayerData::onDamage(%this, %obj, %delta)
if (%delta > 10)
%obj.playPain();
}
}
}