Show weapons

This commit is contained in:
Wizzard 2025-03-10 13:09:01 -04:00
parent 7bdc3fbaa3
commit 067fff4ef8
5 changed files with 132 additions and 10 deletions

@ -19,12 +19,15 @@ pub struct PlayerData {
is_scoped: bool,
#[serde(rename = "playerName")]
player_name: String
player_name: String,
#[serde(rename = "weaponId")]
weapon_id: i16,
}
impl PlayerData {
pub fn new(pos: Vec3, yaw: f32, player_type: PlayerType, has_bomb: bool, has_awp: bool, is_scoped: bool, player_name: String) -> PlayerData {
PlayerData { pos, yaw, player_type, has_bomb, has_awp, is_scoped, player_name }
pub fn new(pos: Vec3, yaw: f32, player_type: PlayerType, has_bomb: bool, has_awp: bool, is_scoped: bool, player_name: String, weapon_id: i16) -> PlayerData {
PlayerData { pos, yaw, player_type, has_bomb, has_awp, is_scoped, player_name, weapon_id }
}
}

@ -126,14 +126,14 @@ impl DmaCtx {
let team = TeamID::from_i32(team);
let has_awp = {
let (has_awp, weapon_id) = {
let clipping_weapon: Address = clipping_weapon.into();
let items_def_idx_addr = clipping_weapon + cs2dumper::client::C_EconEntity::m_AttributeManager
+ cs2dumper::client::C_AttributeContainer::m_Item + cs2dumper::client::C_EconItemView::m_iItemDefinitionIndex;
let items_def_idx: i16 = self.process.read(items_def_idx_addr)?;
items_def_idx == 9
(items_def_idx == 9, items_def_idx)
};
Ok(BatchedPlayerData {
@ -144,6 +144,7 @@ impl DmaCtx {
has_awp,
is_scoped: is_scoped != 0,
player_name,
weapon_id,
})
}
@ -270,4 +271,5 @@ pub struct BatchedPlayerData {
pub has_awp: bool,
pub is_scoped: bool,
pub player_name: String,
pub weapon_id: i16,
}

@ -166,7 +166,8 @@ pub async fn run(radar_data: ArcRwlockRadarData, connector: Connector, pcileech_
has_bomb,
local_data.has_awp,
local_data.is_scoped,
local_data.player_name
local_data.player_name,
local_data.weapon_id
)
)
);
@ -204,7 +205,8 @@ pub async fn run(radar_data: ArcRwlockRadarData, connector: Connector, pcileech_
has_bomb,
player_data.has_awp,
player_data.is_scoped,
player_data.player_name
player_data.player_name,
player_data.weapon_id
)
)
);

@ -22,6 +22,10 @@
<input type="checkbox" onclick="toggleNames()" id="namesCheck" name="names"/>
<label for="namesCheck">Player Names</label>
</div>
<div>
<input type="checkbox" onclick="toggleGuns()" id="gunsCheck" name="guns"/>
<label for="gunsCheck">Weapons</label>
</div>
</div>
</div>
<canvas id="canvas"></canvas>

@ -10,6 +10,7 @@ shouldZoom = false
drawStats = true
drawNames = true
drawGuns = true
// Common
canvas = null
@ -30,6 +31,52 @@ zoomSet = false
safetyBound = 50
boundingRect = null
// Weapon IDs
const weaponIdMap = {
1: "DEAGLE",
2: "DUALIES",
3: "FIVE-SEVEN",
4: "GLOCK",
7: "AK-47",
8: "AUG",
9: "AWP",
10: "FAMAS",
11: "G3SG1",
13: "GALIL",
14: "M249",
16: "M4A4",
17: "MAC-10",
19: "P90",
23: "MP5",
24: "UMP",
25: "XM1014",
26: "BIZON",
27: "MAG-7",
28: "NEGEV",
29: "SAWED-OFF",
30: "TEC-9",
31: "ZEUS",
32: "P2000",
33: "MP7",
34: "MP9",
35: "NOVA",
36: "P250",
38: "SCAR-20",
39: "SG 553",
40: "SCOUT",
60: "M4A1-S",
61: "USP-S",
63: "CZ75",
64: "REVOLVER",
43: "FLASH",
44: "HE",
45: "SMOKE",
46: "MOLOTOV",
47: "DECOY",
48: "INCENDIARY",
49: "C4",
0: "KNIFE"
};
// networking
websocket = null
if (location.protocol == 'https:') {
@ -123,6 +170,7 @@ function drawPlayerName(pos, playerName, playerType, hasAwp, hasBomb) {
textSize = 12;
}
// Always position at the top
const textY = pos.y + 20;
let displayName = playerName;
@ -135,9 +183,6 @@ function drawPlayerName(pos, playerName, playerType, hasAwp, hasBomb) {
ctx.fillStyle = enemyColor;
}
if (hasAwp) {
displayName += " [AWP]";
}
if (hasBomb) {
displayName += " [C4]";
}
@ -153,6 +198,49 @@ function drawPlayerName(pos, playerName, playerType, hasAwp, hasBomb) {
ctx.fillText(displayName, pos.x, textY);
}
function getWeaponName(weaponId) {
if (weaponIdMap[weaponId]) {
return weaponIdMap[weaponId];
}
if (weaponId >= 500) {
return "KNIFE";
}
return "WEAPON";
}
function drawPlayerWeapon(pos, playerType, weaponId) {
if (!map) return;
if (zoomSet) {
pos = boundingCoordinates(mapCoordinates(pos), boundingRect);
textSize = boundingScale(10, boundingRect);
} else {
pos = mapCoordinates(pos);
textSize = 10;
}
const textY = pos.y + (drawNames ? 35 : 20);
let weaponName = getWeaponName(weaponId);
if (weaponId === 9) {
ctx.fillStyle = "orange";
} else {
ctx.fillStyle = textColor;
}
ctx.font = `${textSize}px Arial`;
ctx.textAlign = "center";
ctx.textBaseline = "top";
ctx.lineWidth = 2;
ctx.strokeStyle = "black";
ctx.strokeText(`[${weaponName}]`, pos.x, textY);
ctx.fillText(`[${weaponName}]`, pos.x, textY);
}
function render() {
if (update) {
fillCanvas()
@ -219,6 +307,24 @@ function render() {
data.Player.isScoped
);
if (drawNames && !data.Player.isDormant) {
drawPlayerName(
data.Player.pos,
data.Player.playerName,
data.Player.playerType,
data.Player.hasAwp,
data.Player.hasBomb
);
}
if (drawGuns && !data.Player.isDormant) {
drawPlayerWeapon(
data.Player.pos,
data.Player.playerType,
data.Player.weaponId
);
}
if (drawNames && data.Player.playerName) {
drawPlayerName(data.Player.pos, data.Player.playerName, data.Player.playerType);
}
@ -569,6 +675,7 @@ addEventListener("DOMContentLoaded", (e) => {
document.getElementById("zoomCheck").checked = false;
document.getElementById("statsCheck").checked = true;
document.getElementById("namesCheck").checked = true;
document.getElementById("gunsCheck").checked = true;
canvas = document.getElementById('canvas');
canvas.width = 1024;
@ -590,4 +697,8 @@ function toggleStats() {
function toggleNames() {
drawNames = !drawNames
}
function toggleGuns() {
drawGuns = !drawGuns
}