diff --git a/sources/Commands/ACommandDB.uc b/sources/Commands/ACommandDB.uc index dfd7687..80c7ae7 100644 --- a/sources/Commands/ACommandDB.uc +++ b/sources/Commands/ACommandDB.uc @@ -1,6 +1,6 @@ /** * Command for working with databases. - * Copyright 2021 Anton Tarasenko + * Copyright 2021-2022 Anton Tarasenko *------------------------------------------------------------------------------ * This file is part of Acedia. * @@ -188,7 +188,7 @@ protected function Executed(CallData result, EPlayer callerPlayer) pair = TryLoadingDB(result.parameters.GetText(T(TDATABASE_LINK))); if (pair.database == none) { - callerPlayer.BorrowConsole().WriteLine(T(TBAD_DBLINK)); + callerConsole.WriteLine(T(TBAD_DBLINK)); return; } // Remember the last player we are making a query to and make that query @@ -230,7 +230,7 @@ private function bool TryAPICallCommands( { if (subCommand.IsEmpty()) { - callerPlayer.BorrowConsole().WriteLine(T(TNO_DEFAULT_COMMAND)); + callerConsole.WriteLine(T(TNO_DEFAULT_COMMAND)); return true; } else if (subCommand.Compare(T(TLIST))) @@ -275,14 +275,14 @@ protected function CreateDatabase(EPlayer callerPlayer, Text databaseName) } if (_.db.ExistsLocal(databaseName)) { - callerPlayer.BorrowConsole().WriteLine(T(TDB_ALREADY_EXISTS)); + callerConsole.WriteLine(T(TDB_ALREADY_EXISTS)); return; } if (_.db.NewLocal(databaseName) != none) { - callerPlayer.BorrowConsole().WriteLine(T(TDB_CREATED)); + callerConsole.WriteLine(T(TDB_CREATED)); } else { - callerPlayer.BorrowConsole().WriteLine(T(TDB_CANNOT_BE_CREATED)); + callerConsole.WriteLine(T(TDB_CANNOT_BE_CREATED)); } } @@ -292,10 +292,10 @@ protected function DeleteDatabase(EPlayer callerPlayer, Text databaseName) return; } if (_.db.DeleteLocal(databaseName)) { - callerPlayer.BorrowConsole().WriteLine(T(TDA_DELETED)); + callerConsole.WriteLine(T(TDA_DELETED)); } else { - callerPlayer.BorrowConsole().WriteLine(T(TDB_DOESNT_EXIST)); + callerConsole.WriteLine(T(TDB_DOESNT_EXIST)); } } @@ -308,7 +308,7 @@ protected function ListDatabases(EPlayer callerPlayer) return; } availableDatabases = _.db.ListLocal(); - console = callerPlayer.BorrowConsole(); + console = callerConsole; console.Write(T(TAVAILABLE_DATABASES)); for (i = 0; i < availableDatabases.length; i += 1) { @@ -329,16 +329,16 @@ protected function OutputStatus( return; } if (error == DBR_Success) { - callerPlayer.BorrowConsole().WriteLine(T(TQUERY_COMPLETED)); + callerConsole.WriteLine(T(TQUERY_COMPLETED)); } if (error == DBR_InvalidPointer) { - callerPlayer.BorrowConsole().WriteLine(T(TQUERY_INVALID_POINTER)); + callerConsole.WriteLine(T(TQUERY_INVALID_POINTER)); } if (error == DBR_InvalidDatabase) { - callerPlayer.BorrowConsole().WriteLine(T(TQUERY_INVALID_DB)); + callerConsole.WriteLine(T(TQUERY_INVALID_DB)); } if (error == DBR_InvalidData) { - callerPlayer.BorrowConsole().WriteLine(T(TQUERY_INVALID_DATA)); + callerConsole.WriteLine(T(TQUERY_INVALID_DATA)); } } @@ -355,7 +355,7 @@ protected function DisplayData( if (callerPlayer != none && result == DBR_Success) { printedJSON = _.json.PrettyPrint(data); - callerPlayer.BorrowConsole().Write(printedJSON).Flush(); + callerConsole.Write(printedJSON).Flush(); _.memory.Free(printedJSON); _.memory.Free(callerPlayer); callerPlayer = none; @@ -379,7 +379,7 @@ protected function DisplaySize( if (callerPlayer != none && result == DBR_Success) { sizeAsText = _.text.FromInt(size); - callerPlayer.BorrowConsole() + callerConsole .Write(T(TOBJECT_SIZE_IS)) .Write(sizeAsText) .Flush(); @@ -404,7 +404,7 @@ protected function DisplayKeys( } if (callerPlayer != none && result == DBR_Success) { - console = callerPlayer.BorrowConsole(); + console = callerConsole; console.Write(T(TOBJECT_KEYS_ARE)); for (i = 0; i < keys.GetLength(); i += 1) { diff --git a/sources/Commands/ACommandDosh.uc b/sources/Commands/ACommandDosh.uc index 5317fd2..014c201 100644 --- a/sources/Commands/ACommandDosh.uc +++ b/sources/Commands/ACommandDosh.uc @@ -19,7 +19,9 @@ */ class ACommandDosh extends Command; -var protected const int TGOTTEN, TLOST, TDOSH; +var protected const int TGOTTEN, TLOST, TYOU_GAVE, TYOU_TAKEN, TOTHER_GAVE; +var protected const int TOTHER_TAKEN, TDOSH_FROM, TDOSH_TO, TYOURSELF, TDOSH; +var protected const int TTHEMSELVES; protected function BuildData(CommandDataBuilder builder) { @@ -31,9 +33,6 @@ protected function BuildData(CommandDataBuilder builder) builder.SubCommand(P("set")) .ParamInteger(P("amount")) .Describe(P("Sets player's money to a specified .")); - builder.Option(P("silent")) - .Describe(P("If specified - players won't receive a notification about" - @ "obtaining/losing dosh.")); builder.Option(P("min")) .ParamInteger(P("minValue")) .Describe(F("Players will retain at least this amount of dosh after" @@ -72,40 +71,97 @@ protected function ExecutedFor( newAmount = Clamp(newAmount, minValue, maxValue); // Announce dosh change, if necessary if (!result.options.HasKey(P("silent"))) { - AnnounceDoshChange(player.BorrowConsole(), oldAmount, newAmount); + AnnounceDoshChange(player, callerPlayer, oldAmount, newAmount); } player.SetDosh(newAmount); } protected function AnnounceDoshChange( - ConsoleWriter console, - int oldAmount, - int newAmount) + EPlayer player, + EPlayer callerPlayer, + int oldAmount, + int newAmount) { + local bool affectingSelf; local Text amountDeltaAsText; + local Text targetName, yourTargetName, callerName; + callerName = callerPlayer.GetName(); + affectingSelf = callerPlayer.SameAs(player); + if (affectingSelf) + { + yourTargetName = T(TYOURSELF).Copy(); + targetName = player.GetName(); + } + else + { + yourTargetName = T(TTHEMSELVES).Copy(); + targetName = player.GetName(); + } if (newAmount > oldAmount) { amountDeltaAsText = _.text.FromInt(newAmount - oldAmount); - console.Write(T(TGOTTEN)) + if (!affectingSelf) + { + targetConsole.Write(T(TGOTTEN)) + .Write(amountDeltaAsText) + .WriteLine(T(TDOSH)); + } + callerConsole.Write(T(TYOU_GAVE)) + .Write(amountDeltaAsText) + .Write(T(TDOSH_TO)) + .WriteLine(yourTargetName); + othersConsole.Write(callerName) + .Write(T(TOTHER_GAVE)) .Write(amountDeltaAsText) - .WriteLine(T(TDOSH)); + .Write(T(TDOSH_TO)) + .WriteLine(targetName); } if (newAmount < oldAmount) { amountDeltaAsText = _.text.FromInt(oldAmount - newAmount); - console.Write(T(TLOST)) + if (!affectingSelf) + { + targetConsole.Write(T(TLOST)) + .Write(amountDeltaAsText) + .WriteLine(T(TDOSH)); + } + callerConsole.Write(T(TYOU_TAKEN)) + .Write(amountDeltaAsText) + .Write(T(TDOSH_FROM)) + .WriteLine(yourTargetName); + othersConsole.Write(callerName) + .Write(T(TOTHER_TAKEN)) .Write(amountDeltaAsText) - .WriteLine(T(TDOSH)); + .Write(T(TDOSH_FROM)) + .WriteLine(targetName); } _.memory.Free(amountDeltaAsText); + _.memory.Free(targetname); + _.memory.Free(callerName); } defaultproperties { - TGOTTEN = 0 + TGOTTEN = 0 stringConstants(0) = "You've {$TextPositive gotten} " - TLOST = 1 + TLOST = 1 stringConstants(1) = "You've {$TextNegative lost} " - TDOSH = 2 - stringConstants(2) = " dosh!" + TYOU_GAVE = 2 + stringConstants(2) = "You {$TextPositive gave} " + TYOU_TAKEN = 3 + stringConstants(3) = "You {$TextNegative took} " + TOTHER_GAVE = 4 + stringConstants(4) = " {$TextPositive gave} " + TOTHER_TAKEN = 5 + stringConstants(5) = " {$TextNegative taken} " + TDOSH = 6 + stringConstants(6) = " dosh" + TDOSH_FROM = 7 + stringConstants(7) = " dosh from " + TDOSH_TO = 8 + stringConstants(8) = " dosh to " + TYOURSELF = 9 + stringConstants(9) = "yourself" + TTHEMSELVES = 10 + stringConstants(10) = "themselves" } \ No newline at end of file diff --git a/sources/Commands/ACommandInventory.uc b/sources/Commands/ACommandInventory.uc index f7bfbb8..b1fa1ca 100644 --- a/sources/Commands/ACommandInventory.uc +++ b/sources/Commands/ACommandInventory.uc @@ -119,8 +119,10 @@ protected function ExecutedFor( tool.RemoveAllItems(flagKeep, flagForce, flagHidden); SubCommandAdd(tool, itemsArray, specifiedLists); } + if (!callerPlayer.SameAs(player)) { + tool.ReportChanges(callerPlayer, targetConsole, IRT_Target); + } tool.ReportChanges(callerPlayer, callerConsole, IRT_Caller); - tool.ReportChanges(callerPlayer, targetConsole, IRT_Target); tool.ReportChanges(callerPlayer, othersConsole, IRT_Others); _.memory.Free(tool); } diff --git a/sources/Futility_Feature.uc b/sources/Futility_Feature.uc index f4ed30a..740cb6e 100644 --- a/sources/Futility_Feature.uc +++ b/sources/Futility_Feature.uc @@ -33,7 +33,6 @@ protected function OnEnabled() return; } commandsFeature.RegisterCommand(class'ACommandDosh'); - commandsFeature.RegisterCommand(class'ACommandGive'); commandsFeature.RegisterCommand(class'ACommandNick'); commandsFeature.RegisterCommand(class'ACommandTrader'); commandsFeature.RegisterCommand(class'ACommandDB'); @@ -48,7 +47,6 @@ protected function OnDisabled() if (commandsFeature != none) { commandsFeature.RemoveCommand(class'ACommandDosh'); - commandsFeature.RemoveCommand(class'ACommandGive'); commandsFeature.RemoveCommand(class'ACommandNick'); commandsFeature.RemoveCommand(class'ACommandTrader'); commandsFeature.RemoveCommand(class'ACommandDB'); diff --git a/sources/Tools/InventoryTool.uc b/sources/Tools/InventoryTool.uc index 5860af6..947137b 100644 --- a/sources/Tools/InventoryTool.uc +++ b/sources/Tools/InventoryTool.uc @@ -70,6 +70,7 @@ var const int TRESOLVED_INTO, TTILDE_QUOTE, TFAULTY_INVENTORY_IMPLEMENTATION; var const int TITEM_MISSING, TITEM_NOT_REMOVABLE, TUNKNOWN, TVISIBLE; var const int TDISPLAYING_INVENTORY, THEADER_COLON, TDOT_SPACE, TCOLON_SPACE; var const int TCOMMA_SPACE, TSPACE, TOUT_OF, THIDDEN_ITEMS, TDOLLAR, TYOU; +var const int TYOURSELF, TTHEMSELVES; protected function Constructor() { @@ -479,12 +480,21 @@ public final function ReportChanges( InventoryReportTarget reportTarget) { local Text blamedName, targetName; - if (TargetPlayerIsInvalid()) { - return; + if (TargetPlayerIsInvalid()) return; + if (blamedPlayer == none) return; + + blamedName = blamedPlayer.GetName(); + if (!targetPlayer.SameAs(blamedPlayer)) { + targetName = targetPlayer.GetName(); } - targetName = targetPlayer.GetName(); - if (blamedPlayer != none) { - blamedName = blamedPlayer.GetName(); + else + { + if (reportTarget == IRT_Caller) { + targetName = T(TYOURSELF).Copy(); + } + else { + targetName = T(TTHEMSELVES).Copy(); + } } if (reportTarget == IRT_Others) { @@ -498,6 +508,11 @@ public final function ReportChanges( } else if (reportTarget == IRT_Caller) { + if (targetPlayer.SameAs(blamedPlayer)) + { + _.memory.Free(targetName); + targetName = T(TYOURSELF).Copy(); + } itemsAddedPrivate.Report(writer, blamedName, targetName); itemsRemovedPrivate.Report(writer, blamedName, targetName); itemsAdditionFailed.Report(writer, blamedName, targetName); @@ -675,4 +690,8 @@ defaultproperties stringConstants(21) = "$" TYOU = 22 stringConstants(22) = "you" + TYOURSELF = 23 + stringConstants(23) = "yourself" + TTHEMSELVES = 24 + stringConstants(24) = "themselves" } \ No newline at end of file