-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add media
- Loading branch information
Showing
7 changed files
with
202 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.png filter=lfs diff=lfs merge=lfs -text | ||
*.jpg filter=lfs diff=lfs merge=lfs -text |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,125 @@ | ||
// Eddies Received Multiplier by pMarK | ||
// v1.1 | ||
|
||
module EddiesReceivedMult.Base | ||
|
||
public class EddiesReceivedMult { | ||
private let multiplier: Float; | ||
private let player: wref<PlayerPuppet>; | ||
private let transactionSystem: ref<TransactionSystem>; | ||
private let blackboard: ref<IBlackboard>; | ||
private let flag: Bool; | ||
private let debugMode: Bool; | ||
public func Setup(player: wref<PlayerPuppet>) -> Void { | ||
this.player = player; | ||
this.transactionSystem = GameInstance.GetTransactionSystem(player.GetGame()); | ||
this.blackboard = GameInstance.GetBlackboardSystem(player.GetGame()).Get(GetAllBlackboardDefs().UI_Notifications); | ||
this.SetupSettings(); | ||
} | ||
protected func SetupSettings() -> Void { | ||
// ------ Settings Start ------ | ||
this.debugMode = false; // Show debug message every time the player receives eddies. | ||
this.multiplier = 1.0; | ||
// ------ Settings End ------ | ||
} | ||
public func DeltaEddies(itemDataQuantity: Int32, currentQuantity: Int32) -> Void { | ||
let originalValue: Int32; | ||
let newTotalValue: Int32; | ||
let delta: Int32; | ||
let msg: String; | ||
let multValue: Float = this.GetMultiplier(); | ||
if this.ShouldDeltaEddies(multValue) { | ||
originalValue = itemDataQuantity - currentQuantity; | ||
newTotalValue = Cast<Int32>(Cast<Float>(originalValue) * multValue); | ||
delta = newTotalValue - originalValue; | ||
if originalValue == 0 { | ||
// For some reason the game invokes 0 eddies received events. | ||
// I noticed this when fighting enemies with bounties. At every kill a 0 eddie event is consumed. | ||
// You actually get the total money when the fight is over. | ||
return; | ||
} | ||
if delta < 0 { | ||
this.transactionSystem.RemoveItem(this.player, MarketSystem.Money(), -delta); | ||
} | ||
else { | ||
this.transactionSystem.GiveItem(this.player, MarketSystem.Money(), delta); | ||
this.flag = true; | ||
} | ||
if this.GetShowDebugMsg() { | ||
msg = "Original value: " + originalValue + "\\n" + "New total: " + newTotalValue + "\\n" + "Delta: " + delta + "\\n" + "Multiplier: " + Cast<Int32>(multValue * 100.0) + "%"; | ||
this.ShowMessage(msg); | ||
} | ||
module ERM.Base | ||
import ERM.Settings.ERMSettings | ||
import ERM.Settings.Menu | ||
|
||
public class ERMSystem extends ScriptableSystem { | ||
private let player: ref<PlayerPuppet>; | ||
private let transactionSystem: ref<TransactionSystem>; | ||
private let ermCallback: ref<ERMCallback>; | ||
private let inventoryListener: ref<InventoryScriptListener>; | ||
private let lastRequestHandled: Bool; | ||
private let settings: ref<ERMSettings>; | ||
private func OnPlayerAttach(request: ref<PlayerAttachRequest>) -> Void { | ||
this.player = GameInstance.GetPlayerSystem(request.owner.GetGame()).GetLocalPlayerMainGameObject() as PlayerPuppet; | ||
this.transactionSystem = GameInstance.GetTransactionSystem(this.GetGameInstance()); | ||
this.ermCallback = new ERMCallback(); | ||
this.ermCallback.ermSys = this; | ||
this.inventoryListener = this.transactionSystem.RegisterInventoryListener(this.player, this.ermCallback); | ||
this.settings = GetSettings(); | ||
this.settings.Setup(); | ||
// this.Log("::OnPlayerAttach"); | ||
} | ||
else { | ||
this.flag = false; | ||
private func OnPlayerDetach(request: ref<PlayerDetachRequest>) -> Void { | ||
this.transactionSystem.UnregisterInventoryListener(this.player, this.inventoryListener); | ||
this.inventoryListener = null; | ||
// this.Log("::OnPlayerDetach"); | ||
} | ||
} | ||
protected func GetIsEnabled() -> Bool { | ||
return true; | ||
} | ||
public func OnEddiesChanged(request: ref<ERMHandleEddiesChangedRequest>) -> Void { | ||
let delta: Int32; | ||
let multiplier: Float; | ||
// this.Log("::OnEddiesChanged"); | ||
if !this.settings.GetIsEnabled() { | ||
// this.Log("ERM is disabled."); | ||
return; | ||
} | ||
if request.diffAmount < 1 { | ||
// this.Log("diffAmount was 0 or negative. Ignoring..."); | ||
return; | ||
} | ||
if !this.lastRequestHandled { | ||
multiplier = this.settings.GetMultiplier(); | ||
if multiplier < 0.1 { | ||
multiplier = 1.0; | ||
// this.Log("Multiplier < 0.1, defaulting to 1.0"); | ||
} | ||
if Equals(multiplier, 1.0) { | ||
// this.Log("Multiplier == 1.0, no delta..."); | ||
return; | ||
} | ||
delta = Cast<Int32>(Cast<Float>(request.diffAmount) * multiplier) - request.diffAmount; | ||
protected func GetMultiplier() -> Float { | ||
return this.multiplier; | ||
} | ||
if delta > 0 { | ||
this.transactionSystem.GiveItem(this.player, MarketSystem.Money(), delta); | ||
} | ||
else { | ||
this.transactionSystem.RemoveItem(this.player, MarketSystem.Money(), -delta); | ||
} | ||
protected func GetShowDebugMsg() -> Bool { | ||
return this.debugMode; | ||
} | ||
if this.settings.GetShowExtraEddiesMsg() { | ||
GameInstance.GetActivityLogSystem(this.GetGameInstance()).AddLog("[ERM] Received " + delta + " extra eddies."); | ||
} | ||
protected func GetDebugMsgDuration() -> Float { | ||
return 12.0; | ||
} | ||
this.lastRequestHandled = true; | ||
private func ShouldDeltaEddies(multiplier: Float) -> Bool { | ||
if multiplier == 1.0 || multiplier < 0.0 { | ||
return false; | ||
// this.Log("Request handled. " + request.diffAmount + " * " + multiplier + " = " + (delta + request.diffAmount)); | ||
} | ||
else { | ||
this.lastRequestHandled = false; | ||
// this.Log("request not handled."); | ||
} | ||
} | ||
private func Log(msg: String) -> Void { | ||
LogChannel(n"ERMSystem", msg); | ||
} | ||
} | ||
|
||
public class ERMCallback extends InventoryScriptCallback { | ||
public let ermSys: ref<ERMSystem>; | ||
public func OnItemQuantityChanged(item: ItemID, diff: Int32, total: Uint32, flaggedAsSilent: Bool) -> Void { | ||
let request: ref<ERMHandleEddiesChangedRequest>; | ||
if Equals(MarketSystem.Money(), item) { | ||
if IsDefined(this.ermSys) { | ||
request = new ERMHandleEddiesChangedRequest(); | ||
request.diffAmount = diff; | ||
this.ermSys.QueueRequest(request); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return !this.flag && this.GetIsEnabled(); | ||
} | ||
public class ERMHandleEddiesChangedRequest extends ScriptableSystemRequest { | ||
public let diffAmount: Int32; | ||
} | ||
|
||
protected func ShowMessage(message : String) -> Void { | ||
let warningMsg: SimpleScreenMessage; | ||
warningMsg.isShown = true; | ||
warningMsg.duration = this.GetDebugMsgDuration(); | ||
warningMsg.message = message; | ||
this.blackboard.SetVariant(GetAllBlackboardDefs().UI_Notifications.WarningMessage, ToVariant(warningMsg), true); | ||
} | ||
@if(!ModuleExists("ModSettingsModule")) | ||
public func GetSettings() -> ref<ERMSettings> { | ||
return new ERMSettings(); | ||
} | ||
|
||
@if(ModuleExists("ModSettingsModule")) | ||
public func GetSettings() -> ref<ERMSettings> { | ||
return new Menu(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
module ERM.Settings | ||
|
||
public class Menu extends ERMSettings { | ||
@runtimeProperty("ModSettings.mod", "Eddies Received Mult") | ||
@runtimeProperty("ModSettings.category", "Main") | ||
@runtimeProperty("ModSettings.displayName", "Enabled") | ||
@runtimeProperty("ModSettings.description", "Enable/Disable mod.") | ||
public let IsEnabled: Bool = true; | ||
@runtimeProperty("ModSettings.mod", "Eddies Received Mult") | ||
@runtimeProperty("ModSettings.category", "Main") | ||
@runtimeProperty("ModSettings.displayName", "Multiplier") | ||
@runtimeProperty("ModSettings.description", "Eddies received will be multiplied by this value.") | ||
@runtimeProperty("ModSettings.step", "0.1") | ||
@runtimeProperty("ModSettings.min", "0.1") | ||
@runtimeProperty("ModSettings.max", "5.0") | ||
public let EddiesMultiplier: Float = 1.0; | ||
@runtimeProperty("ModSettings.mod", "Eddies Received Mult") | ||
@runtimeProperty("ModSettings.category", "Extra") | ||
@runtimeProperty("ModSettings.displayName", "Show Extra Eddies Msg") | ||
@runtimeProperty("ModSettings.description", "Enable/Disable the showing of an extra eddies received activity log notification.") | ||
public let ShowExtraEddiesMsg: Bool = false; | ||
public func Setup() -> Void { | ||
RegisterMenu(this); | ||
LogChannel(n"ERMSystem", "ModSettingsModule found. Using menu."); | ||
} | ||
public func GetIsEnabled() -> Bool { | ||
return this.IsEnabled; | ||
} | ||
public func GetMultiplier() -> Float { | ||
return this.EddiesMultiplier; | ||
} | ||
public func GetShowExtraEddiesMsg() -> Bool { | ||
return this.ShowExtraEddiesMsg; | ||
} | ||
} | ||
|
||
@if(!ModuleExists("ModSettingsModule")) | ||
public func RegisterMenu(listener: ref<IScriptable>) {} | ||
|
||
@if(ModuleExists("ModSettingsModule")) | ||
public func RegisterMenu(listener: ref<IScriptable>) { | ||
ModSettings.RegisterListenerToClass(listener); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module ERM.Settings | ||
|
||
public class ERMSettings { | ||
private let multiplier: Float; | ||
private let showExtraEddiesMsg: Bool; | ||
public func Setup() -> Void { | ||
// ------ Settings Start ------ | ||
// Eddies received will be multiplied by this value. Default = 1.0 | ||
this.multiplier = 1.0; | ||
// Show an extra eddies received activity log notification. Default = false | ||
this.showExtraEddiesMsg = false; | ||
// ------ Settings End ------ | ||
} | ||
public func GetMultiplier() -> Float { | ||
return this.multiplier; | ||
} | ||
public func GetIsEnabled() -> Bool { | ||
return true; | ||
} | ||
public func GetShowExtraEddiesMsg() -> Bool { | ||
return this.showExtraEddiesMsg; | ||
} | ||
} |