Merge branch 'val-u-add' into 'master'

Val-U-Add Plugin

See merge request 2009scape/rt4-client!11
This commit is contained in:
Ceikry 2023-08-20 01:18:43 +00:00
commit a0b7eebe78
2 changed files with 44 additions and 10 deletions

View file

@ -26,7 +26,7 @@ public final class Inv extends Node {
public int[] objectIds = new int[]{-1}; public int[] objectIds = new int[]{-1};
@OriginalMember(owner = "client!qe", name = "u", descriptor = "[I") @OriginalMember(owner = "client!qe", name = "u", descriptor = "[I")
public int[] anIntArray422 = new int[]{0}; public int[] objectStackSizes = new int[]{0};
@OriginalMember(owner = "client!ba", name = "a", descriptor = "(IB)I") @OriginalMember(owner = "client!ba", name = "a", descriptor = "(IB)I")
public static int getFreeSpace(@OriginalArg(0) int arg0) { public static int getFreeSpace(@OriginalArg(0) int arg0) {
@ -60,7 +60,7 @@ public final class Inv extends Node {
@Pc(68) IntNode local68 = (IntNode) local56.params.get(arg2); @Pc(68) IntNode local68 = (IntNode) local56.params.get(arg2);
if (local68 != null) { if (local68 != null) {
if (arg0) { if (arg0) {
local27 += local19.anIntArray422[local29] * local68.value; local27 += local19.objectStackSizes[local29] * local68.value;
} else { } else {
local27 += local68.value; local27 += local68.value;
} }
@ -80,9 +80,9 @@ public final class Inv extends Node {
return 0; return 0;
} else { } else {
@Pc(25) int local25 = 0; @Pc(25) int local25 = 0;
for (@Pc(27) int local27 = 0; local27 < local8.anIntArray422.length; local27++) { for (@Pc(27) int local27 = 0; local27 < local8.objectStackSizes.length; local27++) {
if (arg1 == local8.objectIds[local27]) { if (arg1 == local8.objectIds[local27]) {
local25 += local8.anIntArray422[local27]; local25 += local8.objectStackSizes[local27];
} }
} }
return local25; return local25;
@ -94,8 +94,8 @@ public final class Inv extends Node {
@Pc(10) Inv local10 = (Inv) objectContainerCache.get(arg0); @Pc(10) Inv local10 = (Inv) objectContainerCache.get(arg0);
if (local10 == null) { if (local10 == null) {
return 0; return 0;
} else if (arg1 >= 0 && arg1 < local10.anIntArray422.length) { } else if (arg1 >= 0 && arg1 < local10.objectStackSizes.length) {
return local10.anIntArray422[arg1]; return local10.objectStackSizes[arg1];
} else { } else {
return 0; return 0;
} }
@ -139,17 +139,17 @@ public final class Inv extends Node {
@Pc(46) int local46; @Pc(46) int local46;
for (local46 = 0; local46 < local12.objectIds.length; local46++) { for (local46 = 0; local46 < local12.objectIds.length; local46++) {
local39[local46] = local12.objectIds[local46]; local39[local46] = local12.objectIds[local46];
local44[local46] = local12.anIntArray422[local46]; local44[local46] = local12.objectStackSizes[local46];
} }
for (local46 = local12.objectIds.length; local46 < arg1; local46++) { for (local46 = local12.objectIds.length; local46 < arg1; local46++) {
local39[local46] = -1; local39[local46] = -1;
local44[local46] = 0; local44[local46] = 0;
} }
local12.objectIds = local39; local12.objectIds = local39;
local12.anIntArray422 = local44; local12.objectStackSizes = local44;
} }
local12.objectIds[arg1] = arg0; local12.objectIds[arg1] = arg0;
local12.anIntArray422[arg1] = arg2; local12.objectStackSizes[arg1] = arg2;
} }
@OriginalMember(owner = "client!pf", name = "a", descriptor = "(IIZIII)Lclient!qf;") @OriginalMember(owner = "client!pf", name = "a", descriptor = "(IIZIII)Lclient!qf;")
@ -277,7 +277,7 @@ public final class Inv extends Node {
if (local8 != null) { if (local8 != null) {
for (@Pc(24) int local24 = 0; local24 < local8.objectIds.length; local24++) { for (@Pc(24) int local24 = 0; local24 < local8.objectIds.length; local24++) {
local8.objectIds[local24] = -1; local8.objectIds[local24] = -1;
local8.anIntArray422[local24] = 0; local8.objectStackSizes[local24] = 0;
} }
} }
} }

View file

@ -0,0 +1,34 @@
package ValUAdd
import plugin.Plugin
import plugin.annotations.PluginMeta
import plugin.api.API.SendMessage
import rt4.Inv
import rt4.ObjTypeList
import kotlin.math.round
@PluginMeta (
author = "bushtail",
description = "Quickly tally the value of your inventory with a command.",
version = 1.0
)
class plugin : Plugin() {
override fun ProcessCommand(commandStr: String, args: Array<out String>?) {
when(commandStr.toLowerCase()) {
"::valuadd" -> {
var value = 0
val inventory = Inv.objectContainerCache.get(93) as Inv
for(i in 0 until inventory.objectIds.size) {
if(inventory.objectIds[i] != -1) {
val obj = ObjTypeList.get(inventory.objectIds[i])
val stackSize = inventory.objectStackSizes[i]
val itemBaseCost = round(obj.cost * 0.6).toInt()
val itemStackCost = itemBaseCost * stackSize
value += itemStackCost
}
}
SendMessage("Total HA value of inventory: $value GP")
}
}
}
}