Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //credits to s0beit on UC
- //Updated for engine drawing
- typedef struct
- {
- float x;
- float y;
- float w;
- float h;
- }RadarGlobals_t;
- RadarGlobals_t; rGlobals;
- bool IsInSpace(int x, int y)
- {
- return ((x >= rGlobals.x && y >= rGlobals.y) && (x <= (rGlobals.x + rGlobals.w) && y <= (rGlobals.y + rGlobals.h)));
- }
- bool CalculatePoint(Vector3 vec, int *nx, int *ny, float flRange)
- {
- float fy = cg->ViewAngle.y / 180 * 3.141;
- float fc = cos(fy);
- float fs = sin(fy);
- float dx = vec[0] - pRefdef->vOrigin[0];
- float dy = vec[1] - pRefdef->vOrigin[1];
- float px = dy * (-fc) + (dx * fs);
- float py = dx * (-fc) - (dy * fs);
- int irrx = (rGlobals.x + (rGlobals.w / 2)) + int(px / flRange);
- int irry = (rGlobals.y + (rGlobals.h / 2)) + int(py / flRange);
- if (IsInSpace(irrx, irry) == false)
- return false;
- *nx = irrx;
- *ny = irry;
- return true;
- }
- //Put inside your loop
- if (bRadar)
- {
- //Radar coordinates
- rGlobals.x = 1240;
- rGlobals.y = 60;
- rGlobals.w = 300;
- rGlobals.h = 300;
- if (pRefdef == NULL)
- return;
- entity_t *pLocalEntity = cg_entities[cg->ClientNumber];
- if (cg_entities == NULL)
- return;
- clientinfo_t *pLocalInfo = clientInfo[cg->ClientNumber];
- if (clientInfo == NULL)
- return;
- entity_t *pEntity = cg_entities[i];
- if (pEntity == NULL)
- continue;
- clientinfo_t *pEntityInfo = clientInfo[i];
- if (pEntityInfo == NULL)
- continue;
- if (pEntity->iAlive == false)
- continue;
- if (pLocalEntity->clientNum == pEntity->clientNum)
- continue;
- int cx = 0, cy = 0;
- if (CalculatePoint(pEntity->vOrigin, &cx, &cy, 20.0f)) {
- cx -= 3;
- cy -= 3;
- CG_DrawRotatedPicPhysical(0x10FB780, cx - 8, cy - 8, 20, 20, (cg->ViewAngle.y - clientInfo[i]->vAngles.y), flColor, Material_RegisterHandle("compassping_player", 3));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement