Skip to content

Commit

Permalink
fix #27 life increasing bug, small optimisations to MonsterShadow (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimpza authored Jun 19, 2022
1 parent e8b33d4 commit 3c69c3f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 611 to 612:
- Deaths via traps reduce the life count, rather than increasing it
- Performance optimisations for monster shadows

## 610 to 611:
- Moved logic for several actions into separate "extension" classes:
- `MonsterHuntScoreExtension`: Allows implementation of custom scoring for monster kills and player deaths
Expand Down
4 changes: 2 additions & 2 deletions buildscript/buildconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ SCRIPTS_DIR=$(dirname $(realpath $0))

export name="Monster Hunt"
export package=MonsterHunt
export build=611
export version=611
export build=612
export version=612
export packagefull=$package
export packagedist=$package$version
export debug=1
Expand Down
6 changes: 5 additions & 1 deletion src/Classes/MonsterHunt.uc
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,17 @@ function CheckEndGame() {
function Killed(Pawn killer, Pawn other, name damageType) {
Super.Killed(killer, other, damageType);

if (killer == None || other == None) return;
if (other == None) return;

if (other.PlayerReplicationInfo == None) return;

if (scoreExtension != None) other.PlayerReplicationInfo.Score += scoreExtension.PlayerKilled(killer, other);

if (MonsterReplicationInfo(GameReplicationInfo).bUseLives && other.bIsPlayer) {
// if there was no killer (trap death), super increases the deaths count, while we're decreasing it here.
// avoiding introduction of a new PRI value for life countdown, since some things elsewhere may now rely on it.
// so we need to decrease it by two, as a giant hack :(
if (killer == None) other.PlayerReplicationInfo.Deaths -= 1;
other.PlayerReplicationInfo.Deaths -= 1;
CheckEndGame();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Classes/MonsterHuntScoreExtension.uc
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ function int ScoreKill(Pawn killer, Pawn other) {
}

function int PlayerKilled(Pawn killer, Pawn other) {
// suicide
if (Killer == Other) return -4;
// suicide, or death by traps
if (killer == None || killer == Other) return -4;

// player was killed by a monster
if (Killer.IsA('ScriptedPawn') && Other.bIsPlayer && !MonsterReplicationInfo(GameReplicationInfo).bUseLives) {
if (killer.IsA('ScriptedPawn') && Other.bIsPlayer && !MonsterReplicationInfo(GameReplicationInfo).bUseLives) {
return -5;
}

Expand Down
23 changes: 13 additions & 10 deletions src/Classes/MonsterShadow.uc
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,28 @@
// For more info, https://shrimpworks.za.net
// ============================================================

class MonsterShadow extends Decal;
class MonsterShadow extends Decal
config(MonsterHunt);

#exec TEXTURE IMPORT NAME=MHShadow FILE=Textures\MHShadow.pcx LODSET=2

var vector OldOwnerLocation;
var vector offset;

const ShadowDir = vect(0.1, 0.1, 0);
const ShadowDrop = vect(0, 0, 300);

function AttachToSurface() {
}

simulated event PostBeginPlay() {
DrawScale = 0.03 * Owner.CollisionRadius;
if (Owner.IsA('Nali') || Owner.IsA('Slith')) DrawScale *= 0.75;
if (Owner.IsA('Pupae')) DrawScale = 0.03 * (Owner.CollisionRadius / 2);
DrawScale = 0.09 * Owner.CollisionRadius;
if (Owner.IsA('Nali') || Owner.IsA('Slith')) DrawScale *= 1.0;
if (Owner.IsA('Pupae')) DrawScale = 0.12 * (Owner.CollisionRadius / 2);
}

simulated function Tick(float DeltaTime) {
local Actor HitActor;
local Vector HitNormal, HitLocation, ShadowStart, ShadowDir;
local Vector HitNormal, HitLocation, ShadowStart;

if (Owner == None) {
Destroy();
Expand All @@ -36,10 +41,8 @@ simulated function Tick(float DeltaTime) {

DetachDecal();

ShadowDir = vect(0.1, 0.1, 0);

ShadowStart = Owner.Location + Owner.CollisionRadius * ShadowDir;
HitActor = Trace(HitLocation, HitNormal, ShadowStart - vect(0, 0, 300), ShadowStart, false);
HitActor = Trace(HitLocation, HitNormal, ShadowStart - ShadowDrop, ShadowStart, false);

if (HitActor == None) return;

Expand All @@ -50,6 +53,6 @@ simulated function Tick(float DeltaTime) {

defaultproperties {
MultiDecalLevel=3
Texture=Texture'Botpack.energymark'
Texture=Texture'MHShadow'
DrawScale=0.500000
}
Binary file added src/Textures/MHShadow.pcx
Binary file not shown.

0 comments on commit 3c69c3f

Please sign in to comment.