PT_NONE = -1; PT_PLAYER = 1; PT_MONSTER = 2; PT_NPC = 4; PT_NODE = 4; CObject = class( function (self, ptr) self.Address = ptr; self.Name = ""; self.Id = 0; self.Type = PT_NONE; self.X = 0.0; self.Y = 0.0; self.Z = 0.0; self.TargetPtr = 0; self.HP = 1000; self.MaxHP = 1000; self.Class1 = CLASS_NONE; self.Level = 1; self.attackableFlag = 0 self.InParty = false self.Mounted = false self.TargetIcon = false self.Attackable = false self.Aggressive = false if( self.Address ~= 0 and self.Address ~= nil ) then self:update(); end end ); function CObject:update() local proc = getProc(); local tmp; --local results = memoryReadBatch(proc,self.Address,"20_Ii12_fff") local results = memoryReadBatch(proc,self.Address,"20_Ii12_fff580_I80_i4_i40_ii128_I") --[[ pawnId_offset = 0x14, 20_ I pawnType_offset = 0x18, i pawnX_offset = 0x28, 12_ f pawnY_offset = 0x2C, f pawnZ_offset = 0x30, f pawnTargetPtr_offset = 0x278, 580_ I pawnHP_offset = 0x2CC, 80_ i pawnMaxHP_offset = 0x2D4, 4_ i pawnClass1_offset = 0x300, 40_ i pawnLevel_offset = 0x304, i pawnAttackable_offset = 0x388, 128_ I ]] self.Id = results[1] self.Type = results[2] if 1 > self.Id or self.Id > 999999 then -- invalid object self.Id = 0 self.Type = -1 self.Name = "" return; end self.X = results[3] self.Y = results[4] self.Z = results[5] if results[6] ~= 0 then self.TargetPtr = results[6] end self.HP = results[7] self.MaxHP = results[8] self.Class1 = results[9] self.Level = results[10] self.attackableFlag = results[11] if attackableFlag then self.Mounted = bitAnd(attackableFlag, 0x10000000) --=== Does icon appear when you click pawn ===-- if bitAnd(attackableFlag,0x10) then self.TargetIcon = true else self.TargetIcon = false end --=== InParty indicator ===-- if bitAnd(attackableFlag,0x80000000) then self.InParty = true else self.InParty = false end if( self.Type == PT_MONSTER ) then if( bitAnd(attackableFlag, ATTACKABLE_MASK_MONSTER) and bitAnd(attackableFlag, ATTACKABLE_MASK_CLICKABLE) ) then self.Attackable = true; else self.Attackable = false; end if( bitAnd(attackableFlag, AGGRESSIVE_MASK_MONSTER) ) then self.Aggressive = true; else self.Aggressive = false; end else self.Attackable = false; end end if self.Type == PT_NONE then return end -- shouldn't be needed. if self.Name == "" then if self.Type ~= PT_PLAYER then self.Name = GetIdName(self.Id) else showWarnings(false); local namePtr = memoryReadRepeat("uint", proc, self.Address + addresses.pawnName_offset); --0x294 if( namePtr == nil or namePtr == 0 ) then tmp = nil; else tmp = memoryReadString(proc, namePtr); end showWarnings(true); -- Re-enable warnings after reading -- UTF8 -> ASCII translation not for player names -- because that would need the whole table and there we normaly -- don't need it, we don't print player names in the MM window or so if( tmp == nil ) then self.Name = ""; else if( bot.ClientLanguage == "RU" ) then self.Name = utf82oem_russian(tmp); else self.Name = utf8ToAscii_umlauts(tmp); -- only convert umlauts end end end end --[[ if self.Name == "" then -- Disable memory warnings for name reading only showWarnings(false); local namePtr = memoryReadRepeat("uint", proc, self.Address + addresses.pawnName_offset); --0x294 if( namePtr == nil or namePtr == 0 ) then tmp = nil; else tmp = memoryReadString(proc, namePtr); end showWarnings(true); -- Re-enable warnings after reading -- UTF8 -> ASCII translation not for player names -- because that would need the whole table and there we normaly -- don't need it, we don't print player names in the MM window or so if( tmp == nil ) then self.Name = ""; else if( bot.ClientLanguage == "RU" ) then self.Name = utf82oem_russian(tmp); else self.Name = utf8ToAscii_umlauts(tmp); -- only convert umlauts end end end ]] if( self.Address == nil ) then error("Error reading memory in CObject:update()"); end end