Skip to content

Commit 3c69c3f

Browse files
authored
fix #27 life increasing bug, small optimisations to MonsterShadow (#28)
1 parent e8b33d4 commit 3c69c3f

File tree

6 files changed

+27
-16
lines changed

6 files changed

+27
-16
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 611 to 612:
4+
- Deaths via traps reduce the life count, rather than increasing it
5+
- Performance optimisations for monster shadows
6+
37
## 610 to 611:
48
- Moved logic for several actions into separate "extension" classes:
59
- `MonsterHuntScoreExtension`: Allows implementation of custom scoring for monster kills and player deaths

buildscript/buildconfig.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ SCRIPTS_DIR=$(dirname $(realpath $0))
77

88
export name="Monster Hunt"
99
export package=MonsterHunt
10-
export build=611
11-
export version=611
10+
export build=612
11+
export version=612
1212
export packagefull=$package
1313
export packagedist=$package$version
1414
export debug=1

src/Classes/MonsterHunt.uc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,17 @@ function CheckEndGame() {
404404
function Killed(Pawn killer, Pawn other, name damageType) {
405405
Super.Killed(killer, other, damageType);
406406

407-
if (killer == None || other == None) return;
407+
if (other == None) return;
408408

409409
if (other.PlayerReplicationInfo == None) return;
410410

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

413413
if (MonsterReplicationInfo(GameReplicationInfo).bUseLives && other.bIsPlayer) {
414+
// if there was no killer (trap death), super increases the deaths count, while we're decreasing it here.
415+
// avoiding introduction of a new PRI value for life countdown, since some things elsewhere may now rely on it.
416+
// so we need to decrease it by two, as a giant hack :(
417+
if (killer == None) other.PlayerReplicationInfo.Deaths -= 1;
414418
other.PlayerReplicationInfo.Deaths -= 1;
415419
CheckEndGame();
416420
}

src/Classes/MonsterHuntScoreExtension.uc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ function int ScoreKill(Pawn killer, Pawn other) {
5353
}
5454

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

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

src/Classes/MonsterShadow.uc

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,28 @@
77
// For more info, https://shrimpworks.za.net
88
// ============================================================
99

10-
class MonsterShadow extends Decal;
10+
class MonsterShadow extends Decal
11+
config(MonsterHunt);
12+
13+
#exec TEXTURE IMPORT NAME=MHShadow FILE=Textures\MHShadow.pcx LODSET=2
1114

1215
var vector OldOwnerLocation;
13-
var vector offset;
16+
17+
const ShadowDir = vect(0.1, 0.1, 0);
18+
const ShadowDrop = vect(0, 0, 300);
1419

1520
function AttachToSurface() {
1621
}
1722

1823
simulated event PostBeginPlay() {
19-
DrawScale = 0.03 * Owner.CollisionRadius;
20-
if (Owner.IsA('Nali') || Owner.IsA('Slith')) DrawScale *= 0.75;
21-
if (Owner.IsA('Pupae')) DrawScale = 0.03 * (Owner.CollisionRadius / 2);
24+
DrawScale = 0.09 * Owner.CollisionRadius;
25+
if (Owner.IsA('Nali') || Owner.IsA('Slith')) DrawScale *= 1.0;
26+
if (Owner.IsA('Pupae')) DrawScale = 0.12 * (Owner.CollisionRadius / 2);
2227
}
2328

2429
simulated function Tick(float DeltaTime) {
2530
local Actor HitActor;
26-
local Vector HitNormal, HitLocation, ShadowStart, ShadowDir;
31+
local Vector HitNormal, HitLocation, ShadowStart;
2732

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

3742
DetachDecal();
3843

39-
ShadowDir = vect(0.1, 0.1, 0);
40-
4144
ShadowStart = Owner.Location + Owner.CollisionRadius * ShadowDir;
42-
HitActor = Trace(HitLocation, HitNormal, ShadowStart - vect(0, 0, 300), ShadowStart, false);
45+
HitActor = Trace(HitLocation, HitNormal, ShadowStart - ShadowDrop, ShadowStart, false);
4346

4447
if (HitActor == None) return;
4548

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

5154
defaultproperties {
5255
MultiDecalLevel=3
53-
Texture=Texture'Botpack.energymark'
56+
Texture=Texture'MHShadow'
5457
DrawScale=0.500000
5558
}

src/Textures/MHShadow.pcx

2.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)