|
|
@ -67,14 +67,11 @@ var private TextTemplate templateItemsAdded, templateItemsRemoved; |
|
|
|
var private TextTemplate templateItemsAddedVerbose, templateItemsRemovedVerbose; |
|
|
|
var private TextTemplate templateItemsAddedVerbose, templateItemsRemovedVerbose; |
|
|
|
var private TextTemplate templateAdditionFailed, templateRemovalFailed; |
|
|
|
var private TextTemplate templateAdditionFailed, templateRemovalFailed; |
|
|
|
|
|
|
|
|
|
|
|
var const int TINSTIGATOR, TTARGET; |
|
|
|
var const int TINSTIGATOR, TTARGET, TRESOLVED_INTO, TTILDE_QUOTE; |
|
|
|
var const int TITEMS_REMOVED_MESSAGE, TITEMS_REMOVED_VERBOSE_MESSAGE; |
|
|
|
|
|
|
|
var const int TITEMS_ADDITION_FAILED_MESSAGE, TITEMS_REMOVAL_FAILED_MESSAGE; |
|
|
|
|
|
|
|
var const int TRESOLVED_INTO, TTILDE_QUOTE, TFAULTY_INVENTORY_IMPLEMENTATION; |
|
|
|
|
|
|
|
var const int TITEM_MISSING, TITEM_NOT_REMOVABLE, TUNKNOWN, TVISIBLE; |
|
|
|
var const int TITEM_MISSING, TITEM_NOT_REMOVABLE, TUNKNOWN, TVISIBLE; |
|
|
|
var const int TDISPLAYING_INVENTORY, THEADER_COLON, TDOT_SPACE, TCOLON_SPACE; |
|
|
|
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 TCOMMA_SPACE, TSPACE, TOUT_OF, THIDDEN_ITEMS, TDOLLAR, TYOU; |
|
|
|
var const int TYOURSELF, TTHEMSELVES; |
|
|
|
var const int TTHEMSELVES, TFAULTY_INVENTORY_IMPLEMENTATION; |
|
|
|
|
|
|
|
|
|
|
|
public static function StaticConstructor() |
|
|
|
public static function StaticConstructor() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -85,10 +82,10 @@ public static function StaticConstructor() |
|
|
|
"%%instigator%% {$TextPositive added} following weapons to" |
|
|
|
"%%instigator%% {$TextPositive added} following weapons to" |
|
|
|
@ "%%target%%: "); |
|
|
|
@ "%%target%%: "); |
|
|
|
default.templateItemsRemoved = __().text.MakeTemplate_S( |
|
|
|
default.templateItemsRemoved = __().text.MakeTemplate_S( |
|
|
|
"Weapons {$TextPositive added} to %%target%%: "); |
|
|
|
|
|
|
|
default.templateItemsAddedVerbose = __().text.MakeTemplate_S( |
|
|
|
|
|
|
|
"%%instigator%% {$TextNegative removed} following weapons from" |
|
|
|
"%%instigator%% {$TextNegative removed} following weapons from" |
|
|
|
@ "%%target%%: "); |
|
|
|
@ "%%target%%: "); |
|
|
|
|
|
|
|
default.templateItemsAddedVerbose = __().text.MakeTemplate_S( |
|
|
|
|
|
|
|
"Weapons {$TextPositive added} to %%target%%: "); |
|
|
|
default.templateItemsRemovedVerbose = __().text.MakeTemplate_S( |
|
|
|
default.templateItemsRemovedVerbose = __().text.MakeTemplate_S( |
|
|
|
"Weapons {$TextNegative removed} from %%target%%: "); |
|
|
|
"Weapons {$TextNegative removed} from %%target%%: "); |
|
|
|
default.templateAdditionFailed = __().text.MakeTemplate_S( |
|
|
|
default.templateAdditionFailed = __().text.MakeTemplate_S( |
|
|
@ -490,6 +487,52 @@ public function RemoveEquippedItems( |
|
|
|
_.memory.FreeMany(equippedItems); |
|
|
|
_.memory.FreeMany(equippedItems); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Tells `InventoryTool` which player is responsible for the changes it is |
|
|
|
|
|
|
|
* reporting. This information is used to choose the phrasing of the reported |
|
|
|
|
|
|
|
* messages. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param instigator Player that supposedly requested all the changes done by |
|
|
|
|
|
|
|
* the calller `InventoryTool`. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public final function SetupReportInstigator(EPlayer instigator) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local MutableText instigatorName, targetName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (TargetPlayerIsInvalid()) return; |
|
|
|
|
|
|
|
if (instigator == none) return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
instigatorName = ColorNickname(instigator.GetName()); |
|
|
|
|
|
|
|
if (!targetPlayer.SameAs(instigator)) { |
|
|
|
|
|
|
|
targetName = ColorNickname(targetPlayer.GetName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
targetName = T(TYOU).MutableCopy(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// For instigator |
|
|
|
|
|
|
|
default.templateItemsAdded.Reset().TextArg(T(TINSTIGATOR), instigatorName); |
|
|
|
|
|
|
|
default.templateItemsRemoved |
|
|
|
|
|
|
|
.Reset() |
|
|
|
|
|
|
|
.TextArg(T(TINSTIGATOR), instigatorName); |
|
|
|
|
|
|
|
// For everybody else |
|
|
|
|
|
|
|
default.templateAdditionFailed.Reset().TextArg(T(TTARGET), targetName); |
|
|
|
|
|
|
|
default.templateRemovalFailed.Reset().TextArg(T(TTARGET), targetName); |
|
|
|
|
|
|
|
default.templateItemsAddedVerbose.Reset().TextArg(T(TTARGET), targetName); |
|
|
|
|
|
|
|
default.templateItemsRemovedVerbose.Reset().TextArg(T(TTARGET), targetName); |
|
|
|
|
|
|
|
_.memory.Free(instigatorName); |
|
|
|
|
|
|
|
_.memory.Free(targetName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final function MutableText ColorNickname(/* take */ BaseText nickname) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (nickname == none) { |
|
|
|
|
|
|
|
return none; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return nickname |
|
|
|
|
|
|
|
.IntoMutableText() |
|
|
|
|
|
|
|
.ChangeDefaultColor(_.color.Gray); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Reports changes made to the player's inventory so far. |
|
|
|
* Reports changes made to the player's inventory so far. |
|
|
|
* |
|
|
|
* |
|
|
@ -505,79 +548,58 @@ public function RemoveEquippedItems( |
|
|
|
* be reported. |
|
|
|
* be reported. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public final function ReportChanges( |
|
|
|
public final function ReportChanges( |
|
|
|
EPlayer blamedPlayer, |
|
|
|
EPlayer instigator, |
|
|
|
ConsoleWriter writer, |
|
|
|
ConsoleWriter writer, |
|
|
|
InventoryReportTarget reportTarget) |
|
|
|
InventoryReportTarget reportTarget) |
|
|
|
{ |
|
|
|
{ |
|
|
|
local Text blamedName, targetName; |
|
|
|
if (TargetPlayerIsInvalid()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (reportTarget != IRT_Instigator) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SwapTargetNameInTemplates(instigator, reportTarget); |
|
|
|
|
|
|
|
ReportWeaponList(writer, default.templateItemsRemoved, itemsRemoved); |
|
|
|
|
|
|
|
ReportWeaponList(writer, default.templateItemsAdded, itemsAdded); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ReportWeaponList( |
|
|
|
|
|
|
|
writer, |
|
|
|
|
|
|
|
default.templateItemsRemovedVerbose, |
|
|
|
|
|
|
|
itemsRemovedPrivate); |
|
|
|
|
|
|
|
ReportWeaponList( |
|
|
|
|
|
|
|
writer, |
|
|
|
|
|
|
|
default.templateRemovalFailed, |
|
|
|
|
|
|
|
itemsRemovalFailed); |
|
|
|
|
|
|
|
ReportWeaponList( |
|
|
|
|
|
|
|
writer, |
|
|
|
|
|
|
|
default.templateItemsAddedVerbose, |
|
|
|
|
|
|
|
itemsAddedPrivate); |
|
|
|
|
|
|
|
ReportWeaponList( |
|
|
|
|
|
|
|
writer, |
|
|
|
|
|
|
|
default.templateAdditionFailed, |
|
|
|
|
|
|
|
itemsAdditionFailed); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (TargetPlayerIsInvalid()) return; |
|
|
|
private final function SwapTargetNameInTemplates( |
|
|
|
if (blamedPlayer == none) return; |
|
|
|
EPlayer instigator, |
|
|
|
|
|
|
|
InventoryReportTarget reportTarget) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local MutableText targetName; |
|
|
|
|
|
|
|
|
|
|
|
blamedName = blamedPlayer.GetName(); |
|
|
|
if (TargetPlayerIsInvalid()) { |
|
|
|
if (!targetPlayer.SameAs(blamedPlayer)) { |
|
|
|
return; |
|
|
|
targetName = targetPlayer.GetName(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
if (!targetPlayer.SameAs(instigator)) { |
|
|
|
{ |
|
|
|
targetName = ColorNickname(targetPlayer.GetName()); |
|
|
|
if (reportTarget == IRT_Instigator) { |
|
|
|
|
|
|
|
targetName = T(TYOURSELF).Copy(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (reportTarget == IRT_Target) { |
|
|
|
|
|
|
|
targetName = T(TYOU).Copy(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
targetName = T(TTHEMSELVES).Copy(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
default.templateItemsAdded |
|
|
|
else if (reportTarget == IRT_Target) { |
|
|
|
.TextArg(T(TINSTIGATOR), blamedName) |
|
|
|
targetName = T(TYOU).MutableCopy(); |
|
|
|
.TextArg(T(TTARGET), targetName); |
|
|
|
|
|
|
|
default.templateItemsRemoved |
|
|
|
|
|
|
|
.TextArg(T(TINSTIGATOR), blamedName) |
|
|
|
|
|
|
|
.TextArg(T(TTARGET), targetName); |
|
|
|
|
|
|
|
if (reportTarget == IRT_Others) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ReportWeaponList(writer, default.templateItemsAdded, itemsAdded); |
|
|
|
|
|
|
|
ReportWeaponList(writer, default.templateItemsRemoved, itemsRemoved); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else if (reportTarget == IRT_Target) |
|
|
|
else { |
|
|
|
{ |
|
|
|
targetName = T(TTHEMSELVES).MutableCopy(); |
|
|
|
ReportWeaponList(writer, default.templateItemsAdded, itemsAdded); |
|
|
|
|
|
|
|
ReportWeaponList(writer, default.templateItemsRemoved, itemsRemoved); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else if (reportTarget == IRT_Instigator) |
|
|
|
default.templateItemsAdded.TextArg(T(TTARGET), targetName); |
|
|
|
{ |
|
|
|
default.templateItemsRemoved.TextArg(T(TTARGET), targetName); |
|
|
|
default.templateItemsAddedVerbose |
|
|
|
|
|
|
|
.TextArg(T(TINSTIGATOR), blamedName) |
|
|
|
|
|
|
|
.TextArg(T(TTARGET), targetName); |
|
|
|
|
|
|
|
default.templateItemsRemovedVerbose |
|
|
|
|
|
|
|
.TextArg(T(TINSTIGATOR), blamedName) |
|
|
|
|
|
|
|
.TextArg(T(TTARGET), targetName); |
|
|
|
|
|
|
|
default.templateAdditionFailed |
|
|
|
|
|
|
|
.TextArg(T(TINSTIGATOR), blamedName) |
|
|
|
|
|
|
|
.TextArg(T(TTARGET), targetName); |
|
|
|
|
|
|
|
default.templateremovalFailed |
|
|
|
|
|
|
|
.TextArg(T(TINSTIGATOR), blamedName) |
|
|
|
|
|
|
|
.TextArg(T(TTARGET), targetName); |
|
|
|
|
|
|
|
ReportWeaponList( |
|
|
|
|
|
|
|
writer, |
|
|
|
|
|
|
|
default.templateItemsAddedVerbose, |
|
|
|
|
|
|
|
itemsAddedPrivate); |
|
|
|
|
|
|
|
ReportWeaponList( |
|
|
|
|
|
|
|
writer, |
|
|
|
|
|
|
|
default.templateItemsRemovedVerbose, |
|
|
|
|
|
|
|
itemsRemovedPrivate); |
|
|
|
|
|
|
|
ReportWeaponList( |
|
|
|
|
|
|
|
writer, |
|
|
|
|
|
|
|
default.templateAdditionFailed, |
|
|
|
|
|
|
|
itemsAdditionFailed); |
|
|
|
|
|
|
|
ReportWeaponList( |
|
|
|
|
|
|
|
writer, |
|
|
|
|
|
|
|
default.templateremovalFailed, |
|
|
|
|
|
|
|
itemsRemovalFailed); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
_.memory.Free(blamedName); |
|
|
|
|
|
|
|
_.memory.Free(targetName); |
|
|
|
_.memory.Free(targetName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -588,9 +610,10 @@ private final function ReportWeaponList( |
|
|
|
{ |
|
|
|
{ |
|
|
|
local MutableText output; |
|
|
|
local MutableText output; |
|
|
|
|
|
|
|
|
|
|
|
if (writer == none) { |
|
|
|
if (writer == none) return; |
|
|
|
return; |
|
|
|
if (builder == none) return; |
|
|
|
} |
|
|
|
if (builder.IsEmpty()) return; |
|
|
|
|
|
|
|
|
|
|
|
if (header != none) |
|
|
|
if (header != none) |
|
|
|
{ |
|
|
|
{ |
|
|
|
output = header.CollectFormattedM(); |
|
|
|
output = header.CollectFormattedM(); |
|
|
@ -598,20 +621,12 @@ private final function ReportWeaponList( |
|
|
|
_.memory.Free(output); |
|
|
|
_.memory.Free(output); |
|
|
|
output = none; |
|
|
|
output = none; |
|
|
|
} |
|
|
|
} |
|
|
|
if (builder != none) { |
|
|
|
output = builder.GetMutable(); |
|
|
|
output = builder.GetMutable(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
writer.WriteLine(output); |
|
|
|
writer.WriteLine(output); |
|
|
|
_.memory.Free(output); |
|
|
|
_.memory.Free(output); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* itemsAdded.Initialize(T(TITEMS_ADDED_MESSAGE)); |
|
|
|
// TODO: Use `ListBuilder` for the below method? |
|
|
|
itemsRemoved.Initialize(T(TITEMS_REMOVED_MESSAGE)); |
|
|
|
|
|
|
|
itemsAddedPrivate.Initialize(T(TITEMS_ADDED_VEROBSE_MESSAGE)); |
|
|
|
|
|
|
|
itemsRemovedPrivate.Initialize(T(TITEMS_REMOVED_VERBOSE_MESSAGE)); |
|
|
|
|
|
|
|
itemsAdditionFailed.Initialize(T(TITEMS_ADDITION_FAILED_MESSAGE)); |
|
|
|
|
|
|
|
itemsRemovalFailed.Initialize(T(TITEMS_REMOVAL_FAILED_MESSAGE)); */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Command that outputs summary of the player's inventory. |
|
|
|
* Command that outputs summary of the player's inventory. |
|
|
|
* |
|
|
|
* |
|
|
@ -738,56 +753,44 @@ private final function AppendAmmoInstanceInfo(MutableText builder, EAmmo ammo) |
|
|
|
|
|
|
|
|
|
|
|
defaultproperties |
|
|
|
defaultproperties |
|
|
|
{ |
|
|
|
{ |
|
|
|
// TODO remove old constants |
|
|
|
|
|
|
|
// TODO refactor `ReportChanges()` |
|
|
|
|
|
|
|
TINSTIGATOR = 0 |
|
|
|
TINSTIGATOR = 0 |
|
|
|
stringConstants(0) = "%%instigator%%" |
|
|
|
stringConstants(0) = "instigator" |
|
|
|
TTARGET = 1 |
|
|
|
TTARGET = 1 |
|
|
|
stringConstants(1) = "%%target%%" |
|
|
|
stringConstants(1) = "target" |
|
|
|
TITEMS_REMOVED_MESSAGE = 2 |
|
|
|
TRESOLVED_INTO = 2 |
|
|
|
stringConstants(2) = "%%instigator%% {$TextNegative removed} following weapons from %%target%%:" |
|
|
|
stringConstants(2) = "` resolved into `" |
|
|
|
TITEMS_REMOVED_VERBOSE_MESSAGE = 3 |
|
|
|
TTILDE_QUOTE = 3 |
|
|
|
stringConstants(3) = "Weapons {$TextNegative removed} from %%target%%:" |
|
|
|
stringConstants(3) = "`" |
|
|
|
TITEMS_ADDITION_FAILED_MESSAGE = 4 |
|
|
|
TFAULTY_INVENTORY_IMPLEMENTATION = 4 |
|
|
|
stringConstants(4) = "Weapons we've {$TextFailure failed} to add to %%target%%:" |
|
|
|
stringConstants(4) = "faulty inventory implementation" |
|
|
|
TITEMS_REMOVAL_FAILED_MESSAGE = 5 |
|
|
|
TITEM_MISSING = 5 |
|
|
|
stringConstants(5) = "Weapons we've {$TextFailure failed} to remove from %%target%%:" |
|
|
|
stringConstants(5) = "item missing" |
|
|
|
TRESOLVED_INTO = 6 |
|
|
|
TITEM_NOT_REMOVABLE = 6 |
|
|
|
stringConstants(6) = "` resolved into `" |
|
|
|
stringConstants(6) = "item not removable" |
|
|
|
TTILDE_QUOTE = 7 |
|
|
|
TUNKNOWN = 7 |
|
|
|
stringConstants(7) = "`" |
|
|
|
stringConstants(7) = "unknown" |
|
|
|
TFAULTY_INVENTORY_IMPLEMENTATION = 8 |
|
|
|
TVISIBLE = 8 |
|
|
|
stringConstants(8) = "faulty inventory implementation" |
|
|
|
stringConstants(8) = "visible" |
|
|
|
TITEM_MISSING = 9 |
|
|
|
TDISPLAYING_INVENTORY = 9 |
|
|
|
stringConstants(9) = "item missing" |
|
|
|
stringConstants(9) = "{$TextHeader Displaying inventory for player }" |
|
|
|
TITEM_NOT_REMOVABLE = 10 |
|
|
|
THEADER_COLON = 10 |
|
|
|
stringConstants(10) = "item not removable" |
|
|
|
stringConstants(10) = "{$TextHeader :}" |
|
|
|
TUNKNOWN = 11 |
|
|
|
TDOT_SPACE = 11 |
|
|
|
stringConstants(11) = "unknown" |
|
|
|
stringConstants(11) = ". " |
|
|
|
TVISIBLE = 12 |
|
|
|
TCOLON_SPACE = 12 |
|
|
|
stringConstants(12) = "visible" |
|
|
|
stringConstants(12) = ": " |
|
|
|
TDISPLAYING_INVENTORY = 13 |
|
|
|
TCOMMA_SPACE = 13 |
|
|
|
stringConstants(13) = "{$TextHeader Displaying inventory for player }" |
|
|
|
stringConstants(13) = ", " |
|
|
|
THEADER_COLON = 14 |
|
|
|
TSPACE = 14 |
|
|
|
stringConstants(14) = "{$TextHeader :}" |
|
|
|
stringConstants(14) = " " |
|
|
|
TDOT_SPACE = 15 |
|
|
|
TOUT_OF = 15 |
|
|
|
stringConstants(15) = ". " |
|
|
|
stringConstants(15) = " out of " |
|
|
|
TCOLON_SPACE = 16 |
|
|
|
THIDDEN_ITEMS = 16 |
|
|
|
stringConstants(16) = ": " |
|
|
|
stringConstants(16) = "{$TextSubHeader Hidden items:}" |
|
|
|
TCOMMA_SPACE = 17 |
|
|
|
TDOLLAR = 17 |
|
|
|
stringConstants(17) = ", " |
|
|
|
stringConstants(17) = "$" |
|
|
|
TSPACE = 18 |
|
|
|
TYOU = 18 |
|
|
|
stringConstants(18) = " " |
|
|
|
stringConstants(18) = "you" |
|
|
|
TOUT_OF = 19 |
|
|
|
TTHEMSELVES = 19 |
|
|
|
stringConstants(19) = " out of " |
|
|
|
stringConstants(19) = "themselves" |
|
|
|
THIDDEN_ITEMS = 20 |
|
|
|
|
|
|
|
stringConstants(20) = "{$TextSubHeader Hidden items:}" |
|
|
|
|
|
|
|
TDOLLAR = 21 |
|
|
|
|
|
|
|
stringConstants(21) = "$" |
|
|
|
|
|
|
|
TYOU = 22 |
|
|
|
|
|
|
|
stringConstants(22) = "you" |
|
|
|
|
|
|
|
TYOURSELF = 23 |
|
|
|
|
|
|
|
stringConstants(23) = "yourself" |
|
|
|
|
|
|
|
TTHEMSELVES = 24 |
|
|
|
|
|
|
|
stringConstants(24) = "themselves" |
|
|
|
|
|
|
|
} |
|
|
|
} |