Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Alcohol Rework #4

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CVARINFO
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
server int uas_alcohol_intox_effects = 2047;
1 change: 1 addition & 0 deletions KEYCONF
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alias uas_alcohol_reset_cvars = "resetcvar uas_alcohol_intox_effects;";
24 changes: 24 additions & 0 deletions LANGUAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[en default]

UAS_ALCOHOL_DISPLAY_INTOX = "\ce%i Proof\n";

// STANDARD MENU LABELS
MENU_RESETALLOPTIONS = "Reset all Options";

// MENU LABELS
UAS_ALCOHOL_MENU = "Ugly as Sin: Alcohol";
UAS_ALCOHOL_INTOX_EFFECTS = "Intoxication Effects:";

// INTOX EFFECTS LABELS
UAS_ALCOHOL_INTOX_SHADERS = "Intox Shaders";
UAS_ALCOHOL_INTOX_BLOODPRESSURE = "Increased Blood Pressure";
UAS_ALCOHOL_INTOX_BLACKOUT = "Blackout Drunk";
UAS_ALCOHOL_INTOX_DEATH = "Alcohol Poisoning (Death)";
UAS_ALCOHOL_INTOX_STUMBLING = "Drunken Stumbling";
UAS_ALCOHOL_INTOX_SOUNDS = "Uncontrollable Taunting";
UAS_ALCOHOL_INTOX_HEALING = "Improved Healing";
UAS_ALCOHOL_INTOX_STUN = "Reduced Stun";
UAS_ALCOHOL_INTOX_INCAP = "Reduced Incap";
UAS_ALCOHOL_INTOX_FATIGUE = "Reduced Fatigue";
UAS_ALCOHOL_INTOX_MELEE_DAMAGE = "Drink hard, hit hard";
UAS_ALCOHOL_INTOX_ADDICTION = "Alcohol Addiction";
3 changes: 2 additions & 1 deletion MAPINFO
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
GameInfo {
AddEventHandlers = "UaS_AlcoholEventHandler"
/* AddEventHandlers = "UaS_AlcoholEventHandler" */
AddEventHandlers = "UaS_Alcohol_Bootstrap"
}
34 changes: 34 additions & 0 deletions MENUDEF
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
AddOptionMenu "OptionsMenu"
{
Submenu "$UAS_ALCOHOL_MENU", "UasAlcoholMenu"
}

AddOptionMenu "HDAddonMenu"
{
Submenu "$UAS_ALCOHOL_MENU", "UasAlcoholMenu"
}

OptionMenu "UasAlcoholMenu"
{
Title "$UAS_ALCOHOL_MENU"

StaticText "$UAS_ALCOHOL_INTOX_EFFECTS", "White"
StaticText ""

FlagOption "$UAS_ALCOHOL_INTOX_SHADERS", "uas_alcohol_intox_effects", "OnOff", 0
FlagOption "$UAS_ALCOHOL_INTOX_BLOODPRESSURE", "uas_alcohol_intox_effects", "OnOff", 1
FlagOption "$UAS_ALCOHOL_INTOX_BLACKOUT", "uas_alcohol_intox_effects", "OnOff", 2
FlagOption "$UAS_ALCOHOL_INTOX_DEATH", "uas_alcohol_intox_effects", "OnOff", 3
FlagOption "$UAS_ALCOHOL_INTOX_STUMBLING", "uas_alcohol_intox_effects", "OnOff", 4
FlagOption "$UAS_ALCOHOL_INTOX_SOUNDS", "uas_alcohol_intox_effects", "OnOff", 5
FlagOption "$UAS_ALCOHOL_INTOX_HEALING", "uas_alcohol_intox_effects", "OnOff", 6
FlagOption "$UAS_ALCOHOL_INTOX_INCAP", "uas_alcohol_intox_effects", "OnOff", 7
FlagOption "$UAS_ALCOHOL_INTOX_STUN", "uas_alcohol_intox_effects", "OnOff", 8
FlagOption "$UAS_ALCOHOL_INTOX_FATIGUE", "uas_alcohol_intox_effects", "OnOff", 9
FlagOption "$UAS_ALCOHOL_INTOX_MELEE_DAMAGE", "uas_alcohol_intox_effects", "OnOff", 10
FlagOption "$UAS_ALCOHOL_INTOX_ADDICTION", "uas_alcohol_intox_effects", "OnOff", 11
StaticText ""

SafeCommand "$MENU_RESETALLOPTIONS", "uas_alcohol_reset_cvars"
StaticText ""
}
11 changes: 8 additions & 3 deletions ZSCRIPT.zs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
version "4.11.0"
version "4.12"

#include "zscript/uas/AlcoholHandler.zs"
// #include "zscript/uas/AlcoholHandler.zs"
#include "zscript/uas/alcohol/AlcoholBootstrap.zs"
#include "zscript/uas/alcohol/IntoxShader.zs"

#include "zscript/uas/alcohol/UaS_Alcohol.zs"
#include "zscript/uas/alcohol/IntoxToken.zs"

#include "zscript/uas/alcohol/IntoxDrugs.zs"
#include "zscript/uas/alcohol/IntoxToken.zs"
#include "zscript/uas/alcohol/AlcoholTracker.zs"
26 changes: 11 additions & 15 deletions zscript/uas/AlcoholHandler.zs
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
// Updated handler (3/26/22) for edge-case desyncs. Thanks Cali, Phantom, & FDA.

class UaS_AlcoholEventHandler : StaticEventHandler {
override void WorldTick()
{
let shouldEnable = false;
bool enableshader = false;
if(playeringame[consoleplayer]) {
override void WorldTick() {
bool enableShader = false;

if (playeringame[consoleplayer]) {
PlayerInfo player = players[consoleplayer];

Actor playerCam = player.mo;

if(player.camera)
playerCam = player.camera;
Actor playerCam = player.mo;

if(player.camera) playerCam = player.camera;

if(playerCam) enableShader = playerCam.countInv("UasAlcohol_IntoxDrug") >= UaSAlcohol_IntoxDrug.min_effect_amt;

if(playerCam)
enableShader = playerCam.countInv("UasAlcohol_IntoxToken") >= UasAlcohol_IntoxToken.min_effect_amt;
IntoxShader.SetEnabled(player, enableShader);
}
Shader.SetEnabled(players[consoleplayer], "UASAlcohol_Intoxication", enableShader);
//PPShader.SetEnabled("UASAlcohol_Intoxication", enableShader);
}
}
}
10 changes: 10 additions & 0 deletions zscript/uas/alcohol/AlcoholBootstrap.zs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class UaS_Alcohol_Bootstrap : EventHandler {
override void WorldTick() {
for (int i = 0; i < MAXPLAYERS; i++) {
if (!playeringame[i]) continue;
PlayerInfo p = players[i];
if (!p.mo) return;
if (!p.mo.countinv("UaS_AlcoholTracker")) p.mo.giveinventory("UaS_AlcoholTracker", 1);
}
}
}
87 changes: 87 additions & 0 deletions zscript/uas/alcohol/AlcoholTracker.zs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
class UaS_AlcoholTracker : Inventory {
int intox;
int mouth_intox;
int pending_intox;
float intox_quality;

int jogged;
bool drinking;

default {
+INVENTORY.PERSISTENTPOWER;
+INVENTORY.UNTOSSABLE;
-INVENTORY.INVBAR;
}

override void DoEffect() {
if (owner.health <= 0) return;

ProcessIntox();
}

void ProcessIntox() {
HDPlayerPawn o = HDPlayerPawn(owner);
if (!o) return;

if (o.runwalksprint >= 0) jogged++;
if (o.beatcount > 0) return;

let intoxTokens = o.CountInv('UaSAlcohol_IntoxDrug');
let addictTokens = o.CountInv('UaSAlcohol_AddictDrug');

// Base Intox Drain
if (intox > 0 && o.beatcounter % 2 == 0) {
let burnoff = int(ceil(min(intox * frandom(0.001, 0.01), intox * frandom(0.001, 0.01))));

if (hd_debug) console.printf("Burning off "..burnoff.." units of Intoxication");

intox = max(intox - burnoff, -100);

// Quality of Alcohol determines chances of addicition:
// -100% -> 2x chance
// 0% -> 1x chance
// +100% -> 0x chance

if (uas_alcohol_intox_effects & (1 << 11)) {
if (hd_debug) console.printf('[UaS Alcohol] Addicition Enabled');
let addictRatio = (2.0 - (intox_quality + 1.0));
if ((random() * addictRatio) > burnoff) {
let newAddict = int(ceil(addictRatio));

if (hd_debug) console.printf("Gained a point of addiction, current: "..(addictTokens + newAddict));

o.GiveInventory('UaSAlcohol_AddictDrug', newAddict);
}
}
}

// Transfer Pending Intox
if (pending_intox > 0 && o.beatcounter % 2 == 0) {
let diffIntox = min(random(1, pending_intox * 0.5), random(1, pending_intox * 0.5));

if (hd_debug) console.printf("Processing "..diffIntox.." units of intox from pending ("..pending_intox.."), current ("..intox..").");

intox += diffIntox;
pending_intox -= diffIntox;
}

// Sync up IntoxToken Counts
let diffIntox = abs(intoxTokens - intox);
if (intoxTokens < intox) o.GiveInventory('UaSAlcohol_IntoxDrug', diffIntox);
else if (intoxTokens > intox) o.TakeInventory('UaSAlcohol_IntoxDrug', diffIntox);
}

void Consume(int addIntox = 0, float intoxQuality = 0.0) {

// If we've disabled every effect, quit.
if (!uas_alcohol_intox_effects) return;

let currentIntox = pending_intox;

if (hd_debug) console.printf("Comsuming "..addIntox.." units of intox...");

// Add new amount of intox, then adjust the pending amount of quality of that intox by averaging it against what's already there.
pending_intox += addIntox;
intox_quality = ((intox_quality * currentIntox) + (addIntox * intoxQuality)) / pending_intox;
}
}
Loading