require "freem_vpw2" --emu.console("freem's virtual pro wrestling 2 lua script thing\n") wgui.resize(960,480) local guiInfo = wgui.info() local function SetDataFont(bold) freemLib.SetFont("ProggySquareTTSZ",12,"black","white",bold and "b" or "") end local function SetOuterDataFont() freemLib.SetFont("ProggySquareTTSZ",12,"white","black") end local dataMemo = { CurScreen = nil, MatchType = 0, Arena = 0, WrestlerID4 = { P1 = 0, P2 = 0, P3 = 0, P4 = 0 }, SpiritValues = { P1 = 0, P2 = 0, P3 = 0, P4 = 0 }, IntroControl = nil } local dataPositions = { TopLeft = { WrestlerID4 = { X=66, Y=8 }, SpiritMeter = { X=200, Y=24 }, SpiritCounter = { X=212, Y=36 }, BroadAction = { X=4, Y=34 }, PlayerPos = { X=66, Y=52 }, NameAlign = "l", NameOffset = 36, }, TopRight = { WrestlerID4 = { X=542, Y=8 }, SpiritMeter = { X=388, Y=24 }, SpiritCounter = { X=400, Y=36 }, BroadAction = { X=576, Y=34 }, PlayerPos = { X=408, Y=52 }, NameAlign = "r", NameOffset = -324, }, BotLeft = { WrestlerID4 = { X=66, Y=382 }, SpiritMeter = { X=200, Y=396 }, SpiritCounter = { X=212, Y=408 }, BroadAction = { X=4, Y=406 }, PlayerPos = { X=66, Y=426 }, NameAlign = "l", NameOffset = 36, }, BotRight = { WrestlerID4 = { X=542, Y=382 }, SpiritMeter = { X=388, Y=396 }, SpiritCounter = { X=400, Y=408 }, BroadAction = { X=576, Y=406 }, PlayerPos = { X=408, Y=426 }, NameAlign = "r", NameOffset = -324, }, } local function PlayerDataPosition(playerNum) --[[ if dataMemo.CurScreen == nil then dataMemo.CurScreen = memory.readbyte(ramLocations.CurrentScreen) end --]] if dataMemo.MatchType == 0 or dataMemo.MatchType == 4 then -- singles/elimination if playerNum == 1 then return dataPositions.BotLeft elseif playerNum == 2 then return dataPositions.BotRight else return nil end elseif dataMemo.MatchType == 1 then -- tag if playerNum == 1 then return dataPositions.TopLeft elseif playerNum == 2 then return dataPositions.BotLeft elseif playerNum == 3 then return dataPositions.TopRight elseif playerNum == 4 then return dataPositions.BotRight end elseif dataMemo.MatchType == 2 then -- 3way if playerNum == 1 then return dataPositions.TopLeft elseif playerNum == 2 then return dataPositions.BotLeft elseif playerNum == 3 then return dataPositions.TopRight else return nil end elseif dataMemo.MatchType == 3 then -- battle royal if playerNum == 1 then return dataPositions.TopLeft elseif playerNum == 2 then return dataPositions.BotLeft elseif playerNum == 3 then return dataPositions.TopRight elseif playerNum == 4 then return dataPositions.BotRight end end end local function CurScreenText() SetOuterDataFont() dataMemo.CurScreen = memory.readbyte(ramLocations.CurrentScreen) dataMemo.MatchType = memory.readbyte(ramLocations.MatchType) dataMemo.Arena = memory.readbyte(ramLocations.CurrentArena) local screenHex = string.format("0x%02X",dataMemo.CurScreen) wgui.text(650,10,"screen: "..ScreenToName(dataMemo.CurScreen).." (".. screenHex ..")") wgui.text(650,20,"matchtype: "..MatchTypeString(dataMemo.MatchType)) wgui.text(650,30,"current arena: "..ArenaString(dataMemo.Arena)) --wgui.drawtext("current screen: "..tostring(a),{l = 650, t = 10, w = 200, h = 480},"l") end local function WrestlerIDText() SetDataFont(true) dataMemo.WrestlerID4.P1 = memory.readword(playerMap.P1.WrestlerID4) dataMemo.WrestlerID4.P2 = memory.readword(playerMap.P2.WrestlerID4) dataMemo.WrestlerID4.P3 = memory.readword(playerMap.P3.WrestlerID4) dataMemo.WrestlerID4.P4 = memory.readword(playerMap.P4.WrestlerID4) local p1ID = string.format("%04X",dataMemo.WrestlerID4.P1) local p1Pos = PlayerDataPosition(1).WrestlerID4 wgui.text(p1Pos.X,p1Pos.Y,p1ID) wgui.drawtext(GetWrestlerNameFromID4(dataMemo.WrestlerID4.P1),{l=(p1Pos.X)+PlayerDataPosition(1).NameOffset,t=p1Pos.Y,w=320,h=12},PlayerDataPosition(1).NameAlign) local p2ID = string.format("%04X",dataMemo.WrestlerID4.P2) local p2Pos = PlayerDataPosition(2).WrestlerID4 wgui.text(p2Pos.X,p2Pos.Y,p2ID) wgui.drawtext(GetWrestlerNameFromID4(dataMemo.WrestlerID4.P2),{l=(p2Pos.X)+PlayerDataPosition(2).NameOffset,t=p2Pos.Y,w=320,h=12},PlayerDataPosition(2).NameAlign) if dataMemo.MatchType ~= 0 and dataMemo.MatchType ~= 4 then local p3ID = string.format("%04X",dataMemo.WrestlerID4.P3) local p3Pos = PlayerDataPosition(3).WrestlerID4 wgui.text(p3Pos.X,p3Pos.Y,p3ID) wgui.drawtext(GetWrestlerNameFromID4(dataMemo.WrestlerID4.P3),{l=(p3Pos.X)+PlayerDataPosition(3).NameOffset,t=p3Pos.Y,w=320,h=12},PlayerDataPosition(3).NameAlign) end if dataMemo.MatchType == 1 or dataMemo.MatchType == 3 then local p4ID = string.format("%04X",dataMemo.WrestlerID4.P4) local p4Pos = PlayerDataPosition(4).WrestlerID4 wgui.text(p4Pos.X,p4Pos.Y,p4ID) wgui.drawtext(GetWrestlerNameFromID4(dataMemo.WrestlerID4.P4),{l=(p4Pos.X)+PlayerDataPosition(4).NameOffset,t=p4Pos.Y,w=320,h=12},PlayerDataPosition(4).NameAlign) end SetDataFont(false) end local function SpiritText() SetDataFont() dataMemo.SpiritValues.P1 = memory.readbyte(playerMap.P1.SpiritMeter) dataMemo.SpiritValues.P2 = memory.readbyte(playerMap.P2.SpiritMeter) dataMemo.SpiritValues.P3 = memory.readbyte(playerMap.P3.SpiritMeter) dataMemo.SpiritValues.P4 = memory.readbyte(playerMap.P4.SpiritMeter) local p1Pos = PlayerDataPosition(1) wgui.text(p1Pos.SpiritMeter.X,p1Pos.SpiritMeter.Y,tostring(dataMemo.SpiritValues.P1).."/100") local specialTypeP1 = memory.readbyte(playerMap.P1.SpecialType) if specialTypeP1 == 4 or specialTypeP1 == 0x0C then wgui.setcolor(specialTypeP1 == 0xC and "yellow" or "white") wgui.text(p1Pos.SpiritCounter.X,p1Pos.SpiritCounter.Y,tostring(memory.readword(playerMap.P1.SpiritCounter))) end local p2Pos = PlayerDataPosition(2) wgui.text(p2Pos.SpiritMeter.X,p2Pos.SpiritMeter.Y,tostring(dataMemo.SpiritValues.P2).."/100") local specialTypeP2 = memory.readbyte(playerMap.P2.SpecialType) if specialTypeP2 == 4 or specialTypeP2 == 0x0C then wgui.setcolor(specialTypeP2 == 0xC and "yellow" or "white") wgui.text(p2Pos.SpiritCounter.X,p2Pos.SpiritCounter.Y,tostring(memory.readword(playerMap.P2.SpiritCounter))) end if dataMemo.MatchType ~= 0 and dataMemo.MatchType ~= 4 then local p3Pos = PlayerDataPosition(3) wgui.text(p3Pos.SpiritMeter.X,p3Pos.SpiritMeter.Y,tostring(dataMemo.SpiritValues.P3).."/100") local specialTypeP3 = memory.readbyte(playerMap.P3.SpecialType) if specialTypeP3 == 4 or specialTypeP3 == 0x0C then wgui.setcolor(specialTypeP3 == 0xC and "yellow" or "white") wgui.text(p3Pos.SpiritCounter.X,p3Pos.SpiritCounter.Y,tostring(memory.readword(playerMap.P3.SpiritCounter))) end end if dataMemo.MatchType == 1 or dataMemo.MatchType == 3 then local p4Pos = PlayerDataPosition(4) wgui.text(p4Pos.SpiritMeter.X,p4Pos.SpiritMeter.Y,tostring(dataMemo.SpiritValues.P4).."/100") local specialTypeP4 = memory.readbyte(playerMap.P4.SpecialType) if specialTypeP4 == 4 or specialTypeP4 == 0x0C then wgui.setcolor(specialTypeP4 == 0xC and "yellow" or "white") wgui.text(p4Pos.SpiritCounter.X,p4Pos.SpiritCounter.Y,tostring(memory.readword(playerMap.P4.SpiritCounter))) end end end -- this handles broad action, animation local function WrestlerStatus1() SetDataFont() local actionP1 = memory.readword(playerMap.P1.BroadAction) local animP1 = memory.readword(playerMap.P1.CurrentAnim) local p1Pos = PlayerDataPosition(1) wgui.text(p1Pos.BroadAction.X,p1Pos.BroadAction.Y,string.format("act:0x%02X",actionP1)) wgui.text(p1Pos.BroadAction.X,p1Pos.BroadAction.Y-12,string.format("ani:0x%04X",animP1)) local actionP2 = memory.readword(playerMap.P2.BroadAction) local animP2 = memory.readword(playerMap.P2.CurrentAnim) local p2Pos = PlayerDataPosition(2) wgui.text(p2Pos.BroadAction.X,p2Pos.BroadAction.Y,string.format("act:0x%02X",actionP2)) wgui.text(p2Pos.BroadAction.X,p2Pos.BroadAction.Y-12,string.format("ani:0x%04X",animP2)) if dataMemo.MatchType ~= 0 and dataMemo.MatchType ~= 4 then local actionP3 = memory.readword(playerMap.P3.BroadAction) local animP3 = memory.readword(playerMap.P3.CurrentAnim) local p3Pos = PlayerDataPosition(3) wgui.text(p3Pos.BroadAction.X,p3Pos.BroadAction.Y,string.format("act:0x%02X",actionP3)) wgui.text(p3Pos.BroadAction.X,p3Pos.BroadAction.Y-12,string.format("ani:0x%03X",animP3)) end if dataMemo.MatchType == 1 or dataMemo.MatchType == 3 then local actionP4 = memory.readword(playerMap.P4.BroadAction) local animP4 = memory.readword(playerMap.P4.CurrentAnim) local p4Pos = PlayerDataPosition(4) wgui.text(p4Pos.BroadAction.X,p4Pos.BroadAction.Y,string.format("act:0x%02X",actionP4)) wgui.text(p4Pos.BroadAction.X,p4Pos.BroadAction.Y-12,string.format("ani:0x%04X",animP4)) end end local function PositionText() SetDataFont() local p1Pos = PlayerDataPosition(1) local p1Values = { X = memory.readfloat(playerMap.P1.Position.X), Y = memory.readfloat(playerMap.P1.Position.Y), Z = memory.readfloat(playerMap.P1.Position.Z), } local p1LocString = string.format("X:%f\tZ:%f\tY:%i",p1Values.X,p1Values.Z,p1Values.Y) wgui.text(p1Pos.PlayerPos.X,p1Pos.PlayerPos.Y,p1LocString) local p2Pos = PlayerDataPosition(2) local p2Values = { X = memory.readfloat(playerMap.P2.Position.X), Y = memory.readfloat(playerMap.P2.Position.Y), Z = memory.readfloat(playerMap.P2.Position.Z), } local p2LocString = string.format("X:%f\tZ:%f\tY:%i",p2Values.X,p2Values.Z,p2Values.Y) wgui.text(p2Pos.PlayerPos.X,p2Pos.PlayerPos.Y,p2LocString) if dataMemo.MatchType ~= 0 and dataMemo.MatchType ~= 4 then local p3Pos = PlayerDataPosition(3) local p3Values = { X = memory.readfloat(playerMap.P3.Position.X), Y = memory.readfloat(playerMap.P3.Position.Y), Z = memory.readfloat(playerMap.P3.Position.Z), } local p3LocString = string.format("X:%f\tZ:%f\tY:%i",p3Values.X,p3Values.Z,p3Values.Y) wgui.text(p3Pos.PlayerPos.X,p3Pos.PlayerPos.Y,p3LocString) end if dataMemo.MatchType == 1 or dataMemo.MatchType == 3 then local p4Pos = PlayerDataPosition(4) local p4Values = { X = memory.readfloat(playerMap.P4.Position.X), Y = memory.readfloat(playerMap.P4.Position.Y), Z = memory.readfloat(playerMap.P4.Position.Z), } local p4LocString = string.format("X:%f\tZ:%f\tY:%i",p4Values.X,p4Values.Z,p4Values.Y) wgui.text(p4Pos.PlayerPos.X,p4Pos.PlayerPos.Y,p4LocString) end end local function WrestlerIntro() dataMemo.IntroControl = memory.readbyte(ramLocations.IntroControl) if dataMemo.IntroControl ~= 0 then SetOuterDataFont() wgui.text(650,41,"IntroControl: "..tostring(dataMemo.IntroControl)) local temp = memory.readword(ramLocations.LockerRoomCounter) if dataMemo.IntroControl == 3 or dataMemo.IntroControl == 8 or dataMemo.IntroControl == 0x0D or dataMemo.IntroControl == 0x12 then wgui.text(650,52,"LockerRoomTime: "..string.format("0x%04X",temp)) end end end local function EditModeWrestlerData() SetDataFont(true) -- xxx: it's not consistent. --local curWrestlerID4 = memory.readword(0x11911A) local curWrestlerID4 = memory.readword(ramLocations.EditMode.CurID4) local wresName = GetWrestlerNameFromID4(curWrestlerID4) if wresName ~= nil then local outString = string.format("%04X:%s",curWrestlerID4,wresName) wgui.text(166,42,outString) end SetDataFont(false) if memory.readbyte(ramLocations.IntroControl) == 0x51 then local anim = memory.readword(ramLocations.EditMode.CurAnim) local frame = memory.readword(ramLocations.EditMode.AnimFrame) wgui.text(72,116,string.format("anim:0x%04X frame:0x%04X",anim,frame)) end end local EditModeScreens = { 0x18, 0x19, 0x1A, -- name is stored in a different location on some of these screens: 0x1B, 0x1C, 0x1D } local function IsEditMode(curScreen) for _,v in pairs(EditModeScreens) do if v == curScreen then return true end end return false end local function WldFbBattleRoyalHack() local gameplayVal = memory.readword(0x1310C0) if gameplayVal == 0x3462 then memory.writeword(0x1310C2,0x0000) end -- camera blocks local cam = memory.readword(0x153754) if cam == 0x4316 then memory.writeword(0x153762,0x0000) memory.writeword(0x153766,0x0000) memory.writeword(0x15376A,0x0000) memory.writeword(0x15376E,0x0000) end end -- DataLoop handles everything. local function DataLoop() freemLib.Console() -- off-screen: CurScreenText() -- this needs to be called up here to if dataMemo.CurScreen == 0x21 then WrestlerIntro() end -- during edit mode if IsEditMode(dataMemo.CurScreen) then EditModeWrestlerData() end -- during match: if dataMemo.CurScreen == 0x21 and dataMemo.IntroControl == 0 then WrestlerIDText() SpiritText() WrestlerStatus1() --PositionText() if memory.readbyte(ramLocations.MatchType) == 3 then WldFbBattleRoyalHack() end end -- warning: this happens a lot. it also only works in interpreter modes. end gui.register(DataLoop)