Simba Code:
type TRSNPC = record
Name, OverheadText : String;
Actions : TStringArray;
ID, Index, Level, CurrentHP, MaxHP, Animation, Interacting, Orientation, Plane : Integer;
InCombat : boolean;
Tile, TileWalkQueue : TRSTile;
end;
TRSNPCArray = array of TRSNPC;
function R_GetRSNPCActions(NPC_Comp:Integer):TStringArray;
var i, j, actionCount, _string : integer;
begin
ActionCount := SmartGetFieldArraySize(SmartCurrentTarget, NPC_Comp, NPCComposite_getActions, 0);
for i:=0 to ActionCount do begin
_string := SmartGetFieldArrayObject(SmartCurrentTarget, NPC_Comp, NPCComposite_getActions, i);
if(_string <= 0)then
continue;
inc(j);
SetLength(Result, j);
result[j-1] := trim(R_GetJavaString(_string, 512));
SmartFreeObject(SmartCurrentTarget, _string);
end;
end;
function R_GetAllRSNPCs: TRSNPCArray;
var
i, j, NPCCount, Ref, Def, NPCName, Overhead, x, y, LoopCycle : Integer;
begin
NPCCount := SmartGetFieldArraySize(SmartCurrentTarget, 0, Client_getLocalNPCs, 0);
for i:=0 to NPCCount-1 do begin
Ref := SmartGetFieldArrayObject(SmartCurrentTarget, 0, Client_getLocalNPCs, i);
if (Ref <= 0) then
Continue;
Def := SmartGetFieldObject(SmartCurrentTarget, Ref, NPC_getComposite);
Inc(j);
SetLength(Result, j);
NPCName := SmartGetFieldObject(SmartCurrentTarget, Def, NPCComposite_getName);
Overhead := SmartGetFieldObject(SmartCurrentTarget, Ref, Character_getOverheadText);
x := SmartGetFieldInt(SmartCurrentTarget, 0, Client_getBaseX)*Client_getBaseX_Multiplier;
y := SmartGetFieldInt(SmartCurrentTarget, 0, Client_getBaseY)*Client_getBaseY_Multiplier;
LoopCycle := SmartGetFieldInt(SmartCurrentTarget, 0, Client_getGameCycle)*Client_getGameCycle_Multiplier;
with Result[j-1] do begin
Actions := R_GetRSNPCActions(Def);
Plane := SmartGetFieldInt(SmartCurrentTarget, 0, Client_getPlane)*Client_getPlane_Multiplier; //uses client's plane it was found on...
Interacting := SmartGetFieldInt(SmartCurrentTarget, Ref, Character_getInteractingIndex)*Character_getInteractingIndex_Multiplier;
Orientation := Round(FixD(180 + (SmartGetFieldInt(SmartCurrentTarget, Ref, Character_getOrientation)*Character_getOrientation_Multiplier*45)/2048));
CurrentHP := SmartGetFieldInt(SmartCurrentTarget, Ref, Character_getHealth)*Character_getHealth_Multiplier;
MaxHP := SmartGetFieldInt(SmartCurrentTarget, Ref, Character_getMaxHealth)*Character_getMaxHealth_Multiplier;
Level := SmartGetFieldInt(SmartCurrentTarget, Def, NPCComposite_getLevel) * NPCComposite_getLevel_Multiplier;;
InCombat := (SmartGetFieldInt(SmartCurrentTarget, Ref, Character_getCycle) * Character_getCycle_Multiplier) > LoopCycle;
Tile := Point(x + (SmartGetFieldInt(SmartCurrentTarget, Ref, Character_getX) * Character_getX_Multiplier) div 128, y + (SmartGetFieldInt(SmartCurrentTarget, Ref, Character_getY) * Character_getY_Multiplier) div 128);
TileWalkQueue := Point(SmartGetFieldInt(SmartCurrentTarget, Ref, Character_getQueueX), SmartGetFieldInt(SmartCurrentTarget, Ref, Character_getQueueY));
Index := i;
Name := trim(R_GetJavaString(NPCName, 512));
OverheadText := trim(R_GetJavaString(Overhead, 512));
Animation:= SmartGetFieldInt(SmartCurrentTarget, Ref, Character_getAnimation) * Character_getAnimation_Multiplier;
ID := SmartGetFieldInt(SmartCurrentTarget, Def, NPCComposite_getID) * NPCComposite_getID_Multiplier;
end;
SmartFreeObject(SmartCurrentTarget, NPCName);
SmartFreeObject(SmartCurrentTarget, Ref);
SmartFreeObject(SmartCurrentTarget, Def);
SmartFreeObject(SmartCurrentTarget, Overhead);
end;
end;
Simba Code:
function R_GetRSEquipItemAtSlot(_Slot:integer):TRSEquipItem;
var
_Equipment, _Inventory, _InventorySlot, _ItemID, _ItemQuantity, j{, _Name}: Integer;
_items : TRSEquipItemArray;
begin
GameTab(tab_Equip);
_Equipment := R_GetWidgetChildRef(387, _Slot);//_slot can be between 6 and 16
for _InventorySlot := 0 to 2 do begin
_Inventory := SmartGetFieldArrayObject(SmartCurrentTarget, _Equipment, Widget_getChildren, _InventorySlot);
_ItemID := SmartGetFieldInt(SmartCurrentTarget, _Inventory, Widget_getItemID)*Widget_getItemID_Multiplier;
inc(j);
SetLength(_items, j);
_ItemQuantity := SmartGetFieldInt(SmartCurrentTarget, _Inventory, Widget_getItemStack)*Widget_getItemStack_Multiplier;
//_Name := SmartGetFieldArrayObject(SmartCurrentTarget, _Inventory, Widget_getName, _InventorySlot);
with _items[j-1] do begin
ID := _ItemID;
StackSize := _ItemQuantity;
Slot := _Slot;
//Name := Trim(R_GetJavaString(_Name, 512));
//Actions := R_GetRSInvItemActions(_Inventory, _InventorySlot);
end;
//SmartFreeObject(SmartCurrentTarget, _Name);
end;
SmartFreeObject(SmartCurrentTarget, _Inventory);
result := Null_RSEquipItem;
for j:=0 to high(_items) do begin
if (_items[j].ID > 0)then begin
result := _items[j];
end;
end;
end;
Code is really half-assed right now, but its a start.