Skip to content

Commit

Permalink
Altered Game Detection and Tweaked Height compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Lemon-King committed Aug 16, 2024
1 parent b63747e commit 08b8b3e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ class GameModeCompat: Inventory {
override void PostBeginPlay() {
Super.PostBeginPlay();

self.RefreshGameMode();
}

override void Travelled() {
self.RefreshGameMode();
}

override void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive, Actor inflictor, Actor source, int flags) {
if (!passive && damage > 0) {
newdamage = max(0, ApplyDamageFactors(GetClass(), damageType, damage, damage * DamageMult));
}
}

void RefreshGameMode() {
int cvarGameMode = LemonUtil.GetOptionGameMode();
if (LemonUtil.IsGameType(GAME_Doom) || cvarGameMode == GAME_Heretic) {
SetDamageScale_Standard();
Expand All @@ -35,12 +49,6 @@ class GameModeCompat: Inventory {
}
}

override void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive, Actor inflictor, Actor source, int flags) {
if (!passive && damage > 0) {
newdamage = max(0, ApplyDamageFactors(GetClass(), damageType, damage, damage * DamageMult));
}
}

void SetDamageScale_Standard() {
if (!(owner.player.mo is "DoomPlayer" || owner.player.mo is "HereticPlayer" || owner.player.mo is "HXDDHexenIIPlayerPawn")) {
DamageMult = 0.5;
Expand All @@ -52,31 +60,32 @@ class GameModeCompat: Inventory {
}
}
void SetPlayerSize_Standard() {
PlayerPawn p = PlayerPawn(owner.player.mo);
if (p.Height == 56) {
return;
// Doom / Heretic Bounds
int targetHeight = 56;
PlayerClass primaryPlayerClass;
primaryPlayerClass = PlayerClasses[0];
let playerDefaults = GetDefaultByType(primaryPlayerClass.Type);
if (playerDefaults) {
targetHeight = playerDefaults.Height;
}
// Doom & Heretic Bounds
p.A_SetSize(p.Radius, 56);
//p.Viewheight = 41;
//owner.player.ViewHeight = p.Viewheight;
double nextScale = 56.0 / 64.0;
p.A_SetScale(nextScale,nextScale);
p.Viewheight = p.Viewheight * nextScale;
owner.player.ViewHeight = p.Viewheight;
self.ScalePlayerPawn(targetHeight);
}
void SetPlayerSize_Hexen() {
PlayerPawn p = PlayerPawn(owner.player.mo);
if (p.Height == 64) {
// Hexen Bounds
self.ScalePlayerPawn(64);
}

void ScalePlayerPawn(int targetHeight) {
PlayerPawn pp = PlayerPawn(owner.player.mo);
if (pp.Height == targetHeight) {
return;
}
// Hexen Bounds
//p.Viewheight = 48
//owner.player.ViewHeight = p.Viewheight;
p.A_SetSize(p.Radius, 64);
double nextScale = 64.0 / 56.0;
p.Viewheight = p.Viewheight * nextScale;
owner.player.ViewHeight = p.Viewheight;
p.A_SetScale(nextScale,nextScale);

let ppDefault = GetDefaultByType(pp.GetClass());
double nextScale = targetHeight / ppDefault.height;
pp.A_SetSize(ppDefault.Radius, targetHeight);
pp.A_SetScale(nextScale,nextScale);
pp.Viewheight = ppDefault.Viewheight * nextScale;
owner.player.ViewHeight = ppDefault.Viewheight;
}
}
2 changes: 1 addition & 1 deletion resources/assets/zscript/menu/newgame.zs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ZFPreGameSetupHandler : HXDD_ZF_Handler {
Menu.MenuSound("menu/choose");
if (menu.selectedGameMode == 0) {
EpisodeInfo episode = menu.frameGameOptions.gameinfo.episodes[menu.selectedEpisode];
menu.selectedGameMode = LemonUtil.GetGameType(episode.gametype);
//menu.selectedGameMode = LemonUtil.GetGameType(episode.gametype);
}
LemonUtil.CVAR_SetInt("hxdd_gamemode", menu.selectedGameMode);
LemonUtil.CVAR_SetInt("hxdd_armor_mode", menu.selectedArmorMode);
Expand Down

0 comments on commit 08b8b3e

Please sign in to comment.