The trouble I'm having is it seems the game uses a strange system for item ids. Instead of the value just being a simple hex number like other RE games, it reads another address contained in the item id's address to tell what the item is (this of course changes every load). I'm referencing mgr.inz.Player's item swap script from a few years ago to try to wrap my head around it.
The complete script is:
Code: Select all
[ENABLE]
{$Lua}
if syntaxcheck then return end
ResidentEvil7_basePtr = 're7.exe+081E4148'
ResidentEvil7_BagItemCount = '[['..ResidentEvil7_basePtr..']+60]+28'
ResidentEvil7_BagItemName = '[[[[[['..ResidentEvil7_basePtr..']+60]+20]+__]+28]+80]+24'
ResidentEvil7_BagItemQuantity = '[[[[['..ResidentEvil7_basePtr..']+60]+20]+__]+28]+88'
ResidentEvil7_BagItemClass = '[[[[['..ResidentEvil7_basePtr..']+60]+20]+__]+28]+80'
ResidentEvil7_BagItemClass_ptr1 = '[[[[[['..ResidentEvil7_basePtr..']+60]+20]+__]+28]+80]+0'
ResidentEvil7_BagItemClass_ptr2 = '[[[[[['..ResidentEvil7_basePtr..']+60]+20]+__]+28]+80]+18'
ResidentEvil7_Items = {'== Weapons - Melee ==',
'Bar:Crowbar',
'ChainSaw:Chain Saw',
'CircularSaw:Circular Saw',
'HandAxe:Axe',
'Knife:Knife',
'MiaKnife:Survival Knife',
'CKnife:NAH Combat Knife',
'NumaItem071:Joe Fists',
'CH9_WP000:Joe AMG-78a',
'CH9_WP006:Joe AMG-Dual',
'CH9_WP002:Joe Spirit Blade',
'CH9_WP001:Joe AMG-78',
'',
'== Weapons - Firearms ==',
'Burner:Flamethrower',
'GrenadeLauncher:Grenade Launcher',
'Handgun_Albert:Albert-01',
'Handgun_Albert_Reward:Albert-01 R',
'Handgun_G17:G17 Handgun',
'Handgun_M19:M19 Handgun',
'Handgun_MPM:MPM Handgun',
'MachineGun:P19 Machine Gun',
'Magnum:44 Mag',
'Shotgun_DB:M21 Shotgun',
'Shotgun_M37:M37 Shotgun',
'BlueBlaster:BlueBlaster',
'HyperBlaster:HyperBlaster',
'RedBlaster:RedBlaster',
'Handgun_Albert_C:NAH Albert-01 Handgun',
'Shotgun_Albert:NAH Albert-02 Shotgun',
'NumaItem072:Joe M21 Shotgun',
'',
'== Weapons - Thrown ==',
'LiquidBomb:Remote Bomb',
'Grenadebomb:NAH Frag Grenade',
'Thermatebomb:NAH Napalm Grenade',
'Stangrenadebomb:NAH Stun Grenade',
'CH9_WP004:Throwing Spear',
'CH9_WP003:Throwing Knife',
'',
'== Ammo ==',
'UnlimitedAmmo:Infinite Ammo',
'AcidBulletS:Neuro Rounds',
'BurnerBullet:Burner Fuel',
'FlameBulletS:Flame Rounds',
'HandgunBullet:Handgun Ammo',
'HandgunBulletL:Enhanced Handgun Ammo',
'MachineGunBullet:Machine Gun Ammo',
'MagnumBullet:44 Mag Ammo',
'ShotgunBullet:Shotgun Ammo',
'AlbertHandgunBullet:NAH Handgun Ammo',
'AlbertShotgunBullet:NAH Shotgun Ammo',
'AlbertHandgunBulletL:NAH RAMROD Ammo',
'',
'== Medicine ==',
'EyeDrops:Psychostimulants',
'Herb:Herb',
'RemedyL:Strong First Aid Med',
'RemedyM:First Aid Med',
'RemedyAmpoulesM:NAH Med Injector',
'RemedyAmpoulesL:NAH Strong Med Injector',
'NumaItem022:Joe Critter',
'NumaItem013:Joe First Aid Med',
'',
'== Player Upgrades ==',
'AlphaGrass:X-ray Glasses',
'BookDefence01:The Secrets Of Defense',
'BookDefence02:The Essence Of Defense',
'Depressant:Stabilizer - Faster Reload',
'Stimulant:Steroids - Increase Max Health',
'EasyBoots:Walking Shoes',
'StimulantAmpoules:NAH Steroids',
'DepressantAmpoules:NAH Stabilizer',
'BookDefenceJustGuard:NAH Easy Deflect',
'EasyBootsCh8:NAH Fast Walk',
'SiteScopeA:NAH Hammer Scope A',
'SiteScopeB:NAH Hammer Scope B',
'SiteScopeC:NAH Hammer Scope C',
'NumaItem002:Joe Infinite Weapons/Ammo',
'',
'== Coins ==',
'Coin:Antique Coin',
'GoodLuckCoinA:Defense Coin',
'GoodLuckCoinB:Attack Coin',
'GoodLuckCoinC:Instinct Coin',
'GoodLuckCoinD:GoodLuckCoinD',
'GoodLuckCoinE:GoodLuckCoinE',
'PowerUpCoin01A:Assault Coin',
'PowerUpCoin01B:Iron Defense Coin',
'KeyItem02Ch8:NAH Antique Coin',
'',
'== Crafting ==',
'Alcohol:Solid Fuel',
'AlloyClay:Chilled Chem Fluid',
'ChemicalL:Seperating Agent',
'ChemicalM:Strong Chem Fluid',
'ChemicalS:Chem Fluid',
'Flower:Supplements',
'Gunpowder:Gun Powder',
'Magnesium:Weak Acid',
'RepairKit:Gun Repair Kit',
'NumaItem004:Joe Chem Fluid',
'NumaItem009:Joe Scrap Metal',
'',
'== Documents/Books ==',
'MailMia:Email from Mia',
'MiaDriversLicense:Mia Driving License',
'ProposalBookFf:Project Proposal',
'UmbrellaFile00:NAH Briefing',
'UmbrellaFile01:NAH Umbrella Letter',
'NumaItem003:Joe Survival Manual',
'',
'== Keys ==',
'3CrestKeyA:Blue Dogs Head',
'3CrestKeyB:White Dogs Head',
'3CrestKeyC:Red Dogs Head',
'CabinKey:Captains Cabin Locker Key',
'CylinderKey:Lock Pick',
'EntranceHallKey:Ox Statuette',
'EthanCarKey:Car Key',
'FloorDoorKey:Hatch Key',
'LucasCardKey:Keycard - Blue',
'LucasCardKey2:Keycard - Red',
'MasterKey:Snake Key',
'MorgueKey:Scorpion Key',
'SpareKey:Corrosive',
'TalismanKey:Crow Key',
'WorkroomKey:Dissection Room Key',
'Ch8CageKey:NAH Cell Key',
'KeyItem05Ch8:NAH Gear',
'KeyItem03Ch8:NAH Crank',
'MineMasterKey:NAH Clown Key',
'',
'== Maps - Treasure Maps ==',
'TreasureMap01:Treasure Photo - Morgue',
'TreasureMap02:Treasure Photo - Old House',
'TreasureMap03:Treasure Photo - Master Bedroom',
'',
'== Mission Items ==',
'Battery:Battery',
'BrokenHandgun_M19:Broken Handgun',
'BrokenShotgun_DB:Broken Shotgun',
'BurnerPartsA:Burner Grip',
'BurnerPartsB:Burner Nozzle',
'ChainCutter:Bolt Cutters',
'Crank:Crank',
'DummyAxe:Toy Axe',
'EvCable:Power Cable',
'EvelynRadar1:Eveline Strange Bottle',
'EvelynRadar2:Eveline Tissue Samples (1)',
'EvelynRadar3:Eveline Tissue Samples (2)',
'EvelynRadar4:Eveline Tissue Samples (3)',
'EvOpener:Lug Wrench',
'Fuse:Fuse',
'FuseCh4:General Purpose Fuse',
'Lantern:Lantern',
'PendulumClock:Clock Pendulum',
'SerumComplete:Serum Complete',
'SerumMaterialA:D-Series Arm',
'SerumMaterialB:D-Series Head',
'SerumTypeE:E-Necrotoxin',
'SilhouettePazzlePiece:Wooden Statuette',
'SilhouettePazzlePieceOldHouse:Stone Statuette',
'Timebomb:Time bomb',
'ToyShotgun:Model Shotgun',
'NumaItem030:Partial E-Type Cure for Zoe',
'NumaItem031:Full E-Type Cure for Zoe',
'',
'== Body Parts ==',
'EthanLeg:Ethans Leg',
'HandCutOff:Ethans Hand',
'',
'== Mission Items (HappyBirthday) ==',
'Balloonbomb:Balloon',
'Candle:Candle',
'Glasses:Dirty Telescope',
'ScrewFinger:Dummy Finger',
'Quill:Quill Pen',
'Valve:Valve Handle',
'SpringCoil:Winding Key',
'',
'== Other ==',
'SaveTape:Cassette Tape (Save)',
'SupplyBoxA:Box A (2xHerb,RemedyM,RemedyL)',
'SupplyBoxOpenedA:Box A (Opened)',
'SupplyBoxB:Box B (Gunpowder,10xHandgunBullet,3xHandgunBulletL)',
'SupplyBoxOpenedB:Box B (Opened)',
'SupplyBoxC:Box C (RemedyM,7xShotgunBullet)',
'SupplyBoxOpenedC:Box C (Opened)',
'',
'== Videotapes ==',
'FoundFootage000:Derelict House Footage (1)',
'FoundFootage010:FoundFootage010',
'FoundFootage020:Derelict House Footage (2)',
'FoundFootage030:Mia',
'FoundFootage040:Happy Birthday',
'FoundFootage050:Old Videotape',
'',
'== 21 ==',
'Exchange:Exchange Card',
'Draw_4:Draw 4 Card',
'BetUp_2p:Bet Up Card',
'BetUp_2x:Bet Up + Card',
'BetDown_2:Bet Down + Card',
'SPChange_p:Transformation + Card',
'Goal_24:Goal 24 Card',
'Goal_27:Goal 27 Card',
'PerfectDraw_p:Perfect Draw + Card',
'Destroy_p:Destroy + Card',
'Destroy_pp:Destroy ++ Card',
'Replace:Replace Card',
'',
'== JBP Skills ==',
'skl001:Infinite Ammo',
'skl003:Clairvoyance',
'skl002:Health Regeneration',
'skl020:Masochist',
'skl023:Brawler',
'skl021:Vengeance',
'skl022:Narrow Escape',
'skl017:Toughness I',
'skl016:Toughness II',
'skl013:Firepower I',
'skl012:Firepower II',
'skl019:Quick Reload',
'skl018:Guard Up',
'skl005:Time Bonus a-I',
'skl004:Time Bonus a-II',
'skl007:Time Bonus b-I',
'skl006:Time Bonus B-II',
'skl011:Speed Up I',
'skl010:Speed Up II',
'skl009:Defense I',
'skl008:Defense II',
'skl015:Impact I',
'skl014:Impact II',
}
ResidentEvil7_Items_NameDescBinds = {}
form_ResidentEvil7_itemswap.lbAvailableItems.clear()
for i,v in ipairs(ResidentEvil7_Items) do
local listboxNewItem = v:gsub('(.-):','')
local itemInternalName = v:match('(.-):')
form_ResidentEvil7_itemswap.lbAvailableItems.Items.add(listboxNewItem)
if itemInternalName~=nil then
ResidentEvil7_Items_NameDescBinds[itemInternalName] = listboxNewItem
ResidentEvil7_Items_NameDescBinds[listboxNewItem] = itemInternalName
end
end
function ResidentEvil7_refreshBagItems()
--refreshing bag items
local index = form_ResidentEvil7_itemswap.lbBagItems.ItemIndex
form_ResidentEvil7_itemswap.lbBagItems.clear()
local itemCount = readInteger(ResidentEvil7_BagItemCount) or 0
for slot=1,itemCount do
local offset = string.format('%X',(slot-1)*8+0x30)
local name = readString(ResidentEvil7_BagItemName:gsub('__',offset), 128, true)
local nameEx = ResidentEvil7_Items_NameDescBinds[name] or name
form_ResidentEvil7_itemswap.lbBagItems.Items.add(nameEx)
end
if index<itemCount then
form_ResidentEvil7_itemswap.lbBagItems.ItemIndex = index
end
ResidentEvil7_ListBoxSelChange()
end
function ResidentEvil7_ListBoxSelChange()
local bagItems = form_ResidentEvil7_itemswap.lbBagItems
local availItems = form_ResidentEvil7_itemswap.lbAvailableItems
if bagItems.ItemIndex==-1 or availItems.ItemIndex==-1 then
form_ResidentEvil7_itemswap.btnSwap.Enabled=false
return
end
local selItemText = availItems.Items[availItems.ItemIndex]
if selItemText=='' or selItemText:match('==') then
form_ResidentEvil7_itemswap.btnSwap.Enabled=false
return
end
form_ResidentEvil7_itemswap.btnSwap.Enabled=true
end
function ResidentEvil7_swapSelectedItem()
local bagItems = form_ResidentEvil7_itemswap.lbBagItems
local availItems = form_ResidentEvil7_itemswap.lbAvailableItems
if bagItems.ItemIndex==-1 or availItems.ItemIndex==-1 then return end
local offset = string.format('%X',(bagItems.ItemIndex)*8+0x30)
local ptr1 = readQword((ResidentEvil7_BagItemClass_ptr1:gsub('__',offset)))
local ptr2 = readQword((ResidentEvil7_BagItemClass_ptr2:gsub('__',offset)))
local name = ResidentEvil7_Items_NameDescBinds[availItems.Items[availItems.ItemIndex]]
local input="8:"..ptr1.." 4:* 4:* 4:0 4:0 8:"..ptr2.." 4:"..(#name).." su:'"..name.."'"
local ms = createMemScan()
ms.OnlyOneResult = true
form_ResidentEvil7_itemswap.btnSwap.Caption = 'Wait'
form_ResidentEvil7_itemswap.btnSwap.Enabled=false
ms.firstScan(soExactValue, vtGrouped, rtTruncated, input, '',
'0', '7fffffffffffffff' ,'-X+W-C' ,fsmAligned ,"4",
false, false, false, false)
ms.waitTillDone()
local address = ms.Result
ms.destroy()
form_ResidentEvil7_itemswap.btnSwap.Enabled=true
if address then
writeQword(ResidentEvil7_BagItemClass:gsub('__',offset),address)
ResidentEvil7_refreshBagItems()
form_ResidentEvil7_itemswap.btnSwap.Caption = 'Succeeded'
createTimer(nil,true).OnTimer = function(t) t.destroy()
sleep(500)
form_ResidentEvil7_itemswap.btnSwap.Caption = 'Swap' end
else
form_ResidentEvil7_itemswap.btnSwap.Caption = 'Failed'
createTimer(nil,true).OnTimer = function(t) t.destroy()
sleep(500)
form_ResidentEvil7_itemswap.btnSwap.Caption = 'Swap' end
end
end
function ResidentEvil7_itemSwapShow()
ResidentEvil7_refreshBagItems()
form_ResidentEvil7_itemswap.show()
end
function ResidentEvil7_itemSwapHide()
form_ResidentEvil7_itemswap.hide()
end
function ResidentEvil7_itemSwapOnClose()
local itemswapperMR = getTableEntry('Item Swapper')
itemswapperMR.Active = false
return caNone
end
form_ResidentEvil7_itemswap.OnClose = ResidentEvil7_itemSwapOnClose
form_ResidentEvil7_itemswap.lbBagItems.OnSelectionChange = ResidentEvil7_ListBoxSelChange
form_ResidentEvil7_itemswap.lbAvailableItems.OnSelectionChange = ResidentEvil7_ListBoxSelChange
form_ResidentEvil7_itemswap.btnSwap.OnClick = ResidentEvil7_swapSelectedItem
form_ResidentEvil7_itemswap.btnRefresh.OnClick = ResidentEvil7_refreshBagItems
ResidentEvil7_itemSwapShow()
{$Asm}
[DISABLE]
{$Lua}
if syntaxcheck then return end
ResidentEvil7_itemSwapHide()
{$Asm}
Code: Select all
function ResidentEvil7_swapSelectedItem()
local bagItems = form_ResidentEvil7_itemswap.lbBagItems
local availItems = form_ResidentEvil7_itemswap.lbAvailableItems
if bagItems.ItemIndex==-1 or availItems.ItemIndex==-1 then return end
local offset = string.format('%X',(bagItems.ItemIndex)*8+0x30)
local ptr1 = readQword((ResidentEvil7_BagItemClass_ptr1:gsub('__',offset)))
local ptr2 = readQword((ResidentEvil7_BagItemClass_ptr2:gsub('__',offset)))
local name = ResidentEvil7_Items_NameDescBinds[availItems.Items[availItems.ItemIndex]]
local input="8:"..ptr1.." 4:* 4:* 4:0 4:0 8:"..ptr2.." 4:"..(#name).." su:'"..name.."'"
local ms = createMemScan()
ms.OnlyOneResult = true
form_ResidentEvil7_itemswap.btnSwap.Caption = 'Wait'
form_ResidentEvil7_itemswap.btnSwap.Enabled=false
ms.firstScan(soExactValue, vtGrouped, rtTruncated, input, '',
'0', '7fffffffffffffff' ,'-X+W-C' ,fsmAligned ,"4",
false, false, false, false)
ms.waitTillDone()
local address = ms.Result
ms.destroy()
form_ResidentEvil7_itemswap.btnSwap.Enabled=true
if address then
writeQword(ResidentEvil7_BagItemClass:gsub('__',offset),address)
ResidentEvil7_refreshBagItems()
form_ResidentEvil7_itemswap.btnSwap.Caption = 'Succeeded'
createTimer(nil,true).OnTimer = function(t) t.destroy()
sleep(500)
form_ResidentEvil7_itemswap.btnSwap.Caption = 'Swap' end
else
form_ResidentEvil7_itemswap.btnSwap.Caption = 'Failed'
createTimer(nil,true).OnTimer = function(t) t.destroy()
sleep(500)
form_ResidentEvil7_itemswap.btnSwap.Caption = 'Swap' end
end
end
Code: Select all
local input="8:"..ptr1.." 4:* 4:* 4:0 4:0 8:"..ptr2.." 4:"..(#name).." su:'"..name.."'"
8 bytes containing an address (address 1)
8 bytes of wildcards (*)
8 bytes of zeros
8 bytes containing a different address (address 2)
4 bytes of (#name) (this is the one i'm confused on because I don't understand the syntax)
su: that contains the item's dev name in a unicode string
My questions are:
1. Can someone tell me if I'm reading that line correctly?
2. What does 4:"..(#name).. mean in this instance?
3. Does anyone have a link where I can learn more about createMemScan() and how to better understand how to utilize it for my own scripts?
References:
mgr.inz.Player's item swap script:
viewtopic.php?p=99#p99
BladeZero's pointer changes for gold version:
viewtopic.php?p=75684#p75684