| 1 | /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ |
| 2 | /* If you are missing that file, acquire a complete release at teeworlds.com. */ |
| 3 | |
| 4 | #include "players.h" |
| 5 | |
| 6 | #include <base/color.h> |
| 7 | #include <base/math.h> |
| 8 | |
| 9 | #include <engine/client/enums.h> |
| 10 | #include <engine/demo.h> |
| 11 | #include <engine/graphics.h> |
| 12 | #include <engine/shared/config.h> |
| 13 | |
| 14 | #include <generated/client_data.h> |
| 15 | #include <generated/client_data7.h> |
| 16 | #include <generated/protocol.h> |
| 17 | |
| 18 | #include <game/client/animstate.h> |
| 19 | #include <game/client/components/controls.h> |
| 20 | #include <game/client/components/effects.h> |
| 21 | #include <game/client/components/flow.h> |
| 22 | #include <game/client/components/skins.h> |
| 23 | #include <game/client/components/sounds.h> |
| 24 | #include <game/client/gameclient.h> |
| 25 | #include <game/gamecore.h> |
| 26 | #include <game/mapitems.h> |
| 27 | |
| 28 | static float CalculateHandAngle(vec2 Dir, float AngleOffset) |
| 29 | { |
| 30 | const float Angle = angle(a: Dir); |
| 31 | if(Dir.x < 0.0f) |
| 32 | { |
| 33 | return Angle - AngleOffset; |
| 34 | } |
| 35 | else |
| 36 | { |
| 37 | return Angle + AngleOffset; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | static vec2 CalculateHandPosition(vec2 CenterPos, vec2 Dir, vec2 PostRotOffset) |
| 42 | { |
| 43 | vec2 DirY = vec2(-Dir.y, Dir.x); |
| 44 | if(Dir.x < 0.0f) |
| 45 | { |
| 46 | DirY = -DirY; |
| 47 | } |
| 48 | return CenterPos + Dir + Dir * PostRotOffset.x + DirY * PostRotOffset.y; |
| 49 | } |
| 50 | |
| 51 | void CPlayers::RenderHand(const CTeeRenderInfo *pInfo, vec2 CenterPos, vec2 Dir, float AngleOffset, vec2 PostRotOffset, float Alpha) |
| 52 | { |
| 53 | const vec2 HandPos = CalculateHandPosition(CenterPos, Dir, PostRotOffset); |
| 54 | const float HandAngle = CalculateHandAngle(Dir, AngleOffset); |
| 55 | if(pInfo->m_aSixup[g_Config.m_ClDummy].PartTexture(Part: protocol7::SKINPART_HANDS).IsValid()) |
| 56 | { |
| 57 | RenderHand7(pInfo, HandPos, HandAngle, Alpha); |
| 58 | } |
| 59 | else |
| 60 | { |
| 61 | RenderHand6(pInfo, HandPos, HandAngle, Alpha); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | void CPlayers::RenderHand7(const CTeeRenderInfo *pInfo, vec2 HandPos, float HandAngle, float Alpha) |
| 66 | { |
| 67 | // in-game hand size is 15 when tee size is 64 |
| 68 | const float BaseSize = 15.0f * (pInfo->m_Size / 64.0f); |
| 69 | IGraphics::CQuadItem QuadOutline(HandPos.x, HandPos.y, 2 * BaseSize, 2 * BaseSize); |
| 70 | IGraphics::CQuadItem QuadHand = QuadOutline; |
| 71 | |
| 72 | Graphics()->TextureSet(Texture: pInfo->m_aSixup[g_Config.m_ClDummy].PartTexture(Part: protocol7::SKINPART_HANDS)); |
| 73 | Graphics()->QuadsBegin(); |
| 74 | Graphics()->SetColor(pInfo->m_aSixup[g_Config.m_ClDummy].m_aColors[protocol7::SKINPART_HANDS].WithAlpha(alpha: Alpha)); |
| 75 | Graphics()->QuadsSetRotation(Angle: HandAngle); |
| 76 | Graphics()->SelectSprite7(Id: client_data7::SPRITE_TEE_HAND_OUTLINE); |
| 77 | Graphics()->QuadsDraw(pArray: &QuadOutline, Num: 1); |
| 78 | Graphics()->SelectSprite7(Id: client_data7::SPRITE_TEE_HAND); |
| 79 | Graphics()->QuadsDraw(pArray: &QuadHand, Num: 1); |
| 80 | Graphics()->QuadsEnd(); |
| 81 | } |
| 82 | |
| 83 | void CPlayers::RenderHand6(const CTeeRenderInfo *pInfo, vec2 HandPos, float HandAngle, float Alpha) |
| 84 | { |
| 85 | const CSkin::CSkinTextures *pSkinTextures = pInfo->m_CustomColoredSkin ? &pInfo->m_ColorableRenderSkin : &pInfo->m_OriginalRenderSkin; |
| 86 | |
| 87 | Graphics()->SetColor(pInfo->m_ColorBody.WithAlpha(alpha: Alpha)); |
| 88 | Graphics()->QuadsSetRotation(Angle: HandAngle); |
| 89 | Graphics()->TextureSet(Texture: pSkinTextures->m_HandsOutline); |
| 90 | Graphics()->RenderQuadContainerAsSprite(ContainerIndex: m_WeaponEmoteQuadContainerIndex, QuadOffset: NUM_WEAPONS * 2, X: HandPos.x, Y: HandPos.y); |
| 91 | Graphics()->TextureSet(Texture: pSkinTextures->m_Hands); |
| 92 | Graphics()->RenderQuadContainerAsSprite(ContainerIndex: m_WeaponEmoteQuadContainerIndex, QuadOffset: NUM_WEAPONS * 2 + 1, X: HandPos.x, Y: HandPos.y); |
| 93 | } |
| 94 | |
| 95 | float CPlayers::GetPlayerTargetAngle( |
| 96 | const CNetObj_Character *pPrevChar, |
| 97 | const CNetObj_Character *pPlayerChar, |
| 98 | int ClientId, |
| 99 | float Intra) |
| 100 | { |
| 101 | if(GameClient()->m_Snap.m_LocalClientId == ClientId && !GameClient()->m_Snap.m_SpecInfo.m_Active && Client()->State() != IClient::STATE_DEMOPLAYBACK) |
| 102 | { |
| 103 | // calculate what would be sent to the server from our current input |
| 104 | vec2 Direction = normalize(v: vec2((int)GameClient()->m_Controls.m_aMousePos[g_Config.m_ClDummy].x, (int)GameClient()->m_Controls.m_aMousePos[g_Config.m_ClDummy].y)); |
| 105 | |
| 106 | // fix direction if mouse is exactly in the center |
| 107 | if(Direction == vec2(0.0f, 0.0f)) |
| 108 | Direction = vec2(1.0f, 0.0f); |
| 109 | |
| 110 | return angle(a: Direction); |
| 111 | } |
| 112 | |
| 113 | // using unpredicted angle when rendering other players in-game |
| 114 | if(ClientId >= 0) |
| 115 | Intra = Client()->IntraGameTick(Conn: g_Config.m_ClDummy); |
| 116 | |
| 117 | if(ClientId >= 0 && GameClient()->m_Snap.m_aCharacters[ClientId].m_HasExtendedDisplayInfo) |
| 118 | { |
| 119 | const CNetObj_DDNetCharacter *pExtendedData = &GameClient()->m_Snap.m_aCharacters[ClientId].m_ExtendedData; |
| 120 | const CNetObj_DDNetCharacter *pPrevExtendedData = GameClient()->m_Snap.m_aCharacters[ClientId].m_pPrevExtendedData; |
| 121 | if(pPrevExtendedData) |
| 122 | { |
| 123 | float MixX = mix(a: (float)pPrevExtendedData->m_TargetX, b: (float)pExtendedData->m_TargetX, amount: Intra); |
| 124 | float MixY = mix(a: (float)pPrevExtendedData->m_TargetY, b: (float)pExtendedData->m_TargetY, amount: Intra); |
| 125 | return angle(a: vec2(MixX, MixY)); |
| 126 | } |
| 127 | else |
| 128 | { |
| 129 | return angle(a: vec2(pExtendedData->m_TargetX, pExtendedData->m_TargetY)); |
| 130 | } |
| 131 | } |
| 132 | else |
| 133 | { |
| 134 | // If the player moves their weapon through top, then change |
| 135 | // the end angle by 2*Pi, so that the mix function will use the |
| 136 | // short path and not the long one. |
| 137 | if(pPlayerChar->m_Angle > (256.0f * pi) && pPrevChar->m_Angle < 0) |
| 138 | { |
| 139 | return mix(a: (float)pPrevChar->m_Angle, b: (float)(pPlayerChar->m_Angle - 256.0f * 2 * pi), amount: Intra) / 256.0f; |
| 140 | } |
| 141 | else if(pPlayerChar->m_Angle < 0 && pPrevChar->m_Angle > (256.0f * pi)) |
| 142 | { |
| 143 | return mix(a: (float)pPrevChar->m_Angle, b: (float)(pPlayerChar->m_Angle + 256.0f * 2 * pi), amount: Intra) / 256.0f; |
| 144 | } |
| 145 | else |
| 146 | { |
| 147 | return mix(a: (float)pPrevChar->m_Angle, b: (float)pPlayerChar->m_Angle, amount: Intra) / 256.0f; |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | void CPlayers::RenderHookCollLine( |
| 153 | const CNetObj_Character *pPrevChar, |
| 154 | const CNetObj_Character *pPlayerChar, |
| 155 | int ClientId) |
| 156 | { |
| 157 | CNetObj_Character Prev; |
| 158 | CNetObj_Character Player; |
| 159 | Prev = *pPrevChar; |
| 160 | Player = *pPlayerChar; |
| 161 | |
| 162 | dbg_assert(in_range(ClientId, MAX_CLIENTS - 1), "invalid client id (%d)" , ClientId); |
| 163 | |
| 164 | bool Local = GameClient()->m_Snap.m_LocalClientId == ClientId; |
| 165 | |
| 166 | float Intra = GameClient()->m_aClients[ClientId].m_IsPredicted ? Client()->PredIntraGameTick(Conn: g_Config.m_ClDummy) : Client()->IntraGameTick(Conn: g_Config.m_ClDummy); |
| 167 | float Angle = GetPlayerTargetAngle(pPrevChar: &Prev, pPlayerChar: &Player, ClientId, Intra); |
| 168 | |
| 169 | vec2 Direction = direction(angle: Angle); |
| 170 | vec2 Position = GameClient()->m_aClients[ClientId].m_RenderPos; |
| 171 | |
| 172 | bool Aim = (Player.m_PlayerFlags & PLAYERFLAG_AIM); |
| 173 | if(!Client()->ServerCapAnyPlayerFlag()) |
| 174 | { |
| 175 | for(int i = 0; i < NUM_DUMMIES; i++) |
| 176 | { |
| 177 | if(ClientId == GameClient()->m_aLocalIds[i]) |
| 178 | { |
| 179 | Aim = GameClient()->m_Controls.m_aShowHookColl[i]; |
| 180 | break; |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | #if defined(CONF_VIDEORECORDER) |
| 186 | if(IVideo::Current() && !g_Config.m_ClVideoShowHookCollOther && !Local) |
| 187 | return; |
| 188 | #endif |
| 189 | |
| 190 | bool AlwaysRenderHookColl = GameClient()->m_GameInfo.m_AllowHookColl && (Local ? g_Config.m_ClShowHookCollOwn : g_Config.m_ClShowHookCollOther) == 2; |
| 191 | bool RenderHookCollPlayer = Aim && (Local ? g_Config.m_ClShowHookCollOwn : g_Config.m_ClShowHookCollOther) > 0; |
| 192 | if(Local && GameClient()->m_GameInfo.m_AllowHookColl && Client()->State() != IClient::STATE_DEMOPLAYBACK) |
| 193 | RenderHookCollPlayer = GameClient()->m_Controls.m_aShowHookColl[g_Config.m_ClDummy] && g_Config.m_ClShowHookCollOwn > 0; |
| 194 | if(!AlwaysRenderHookColl && !RenderHookCollPlayer) |
| 195 | return; |
| 196 | |
| 197 | static constexpr float HOOK_START_DISTANCE = CCharacterCore::PhysicalSize() * 1.5f; |
| 198 | float HookLength = (float)GameClient()->m_aClients[ClientId].m_Predicted.m_Tuning.m_HookLength; |
| 199 | float HookFireSpeed = (float)GameClient()->m_aClients[ClientId].m_Predicted.m_Tuning.m_HookFireSpeed; |
| 200 | |
| 201 | // janky physics |
| 202 | if(HookLength < HOOK_START_DISTANCE || HookFireSpeed <= 0.0f) |
| 203 | return; |
| 204 | |
| 205 | vec2 QuantizedDirection = Direction; |
| 206 | vec2 StartOffset = Direction * HOOK_START_DISTANCE; |
| 207 | vec2 BasePos = Position; |
| 208 | vec2 LineStartPos = BasePos + StartOffset; |
| 209 | vec2 SegmentStartPos = LineStartPos; |
| 210 | |
| 211 | ColorRGBA HookCollColor = color_cast<ColorRGBA>(hsl: ColorHSLA(g_Config.m_ClHookCollColorNoColl)); |
| 212 | std::vector<IGraphics::CLineItem> vLineSegments; |
| 213 | |
| 214 | const int MaxHookTicks = 5 * Client()->GameTickSpeed(); // calculating above 5 seconds is very expensive and unlikely to happen |
| 215 | |
| 216 | auto AddHookPlayerSegment = [&](const vec2 &StartPos, const vec2 &EndPos, const vec2 &HookablePlayerPosition, const vec2 &HitPos) { |
| 217 | HookCollColor = color_cast<ColorRGBA>(hsl: ColorHSLA(g_Config.m_ClHookCollColorTeeColl)); |
| 218 | |
| 219 | // stop hookline at player circle so it looks better |
| 220 | vec2 aIntersections[2]; |
| 221 | int NumIntersections = intersect_line_circle(LineStart: StartPos, LineEnd: EndPos, CircleCenter: HookablePlayerPosition, Radius: CCharacterCore::PhysicalSize() * 1.45f / 2.0f, aIntersections); |
| 222 | if(NumIntersections == 2) |
| 223 | { |
| 224 | if(distance(a: Position, b: aIntersections[0]) < distance(a: Position, b: aIntersections[1])) |
| 225 | vLineSegments.emplace_back(args: StartPos, args&: aIntersections[0]); |
| 226 | else |
| 227 | vLineSegments.emplace_back(args: StartPos, args&: aIntersections[1]); |
| 228 | } |
| 229 | else if(NumIntersections == 1) |
| 230 | vLineSegments.emplace_back(args: StartPos, args&: aIntersections[0]); |
| 231 | else |
| 232 | vLineSegments.emplace_back(args: StartPos, args: HitPos); |
| 233 | }; |
| 234 | |
| 235 | // simulate the hook into the future |
| 236 | int HookTick; |
| 237 | bool HookEnteredTelehook = false; |
| 238 | for(HookTick = 0; HookTick < MaxHookTicks; ++HookTick) |
| 239 | { |
| 240 | int Tele; |
| 241 | vec2 HitPos, IntersectedPlayerPosition; |
| 242 | vec2 SegmentEndPos = SegmentStartPos + QuantizedDirection * HookFireSpeed; |
| 243 | |
| 244 | // check if a hook would enter retracting state in this tick |
| 245 | if(distance(a: BasePos, b: SegmentEndPos) > HookLength) |
| 246 | { |
| 247 | // check if the retracting hook hits a player |
| 248 | if(!HookEnteredTelehook) |
| 249 | { |
| 250 | vec2 RetractingHookEndPos = BasePos + normalize(v: SegmentEndPos - BasePos) * HookLength; |
| 251 | if(GameClient()->IntersectCharacter(HookPos: SegmentStartPos, NewPos: RetractingHookEndPos, NewPos2&: HitPos, OwnId: ClientId, pPlayerPosition: &IntersectedPlayerPosition) != -1) |
| 252 | { |
| 253 | AddHookPlayerSegment(LineStartPos, SegmentEndPos, IntersectedPlayerPosition, HitPos); |
| 254 | break; |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | // the line is too long here, and the hook retracts, use old position |
| 259 | vLineSegments.emplace_back(args&: LineStartPos, args&: SegmentStartPos); |
| 260 | break; |
| 261 | } |
| 262 | |
| 263 | // check for map collisions |
| 264 | int Hit = Collision()->IntersectLineTeleHook(Pos0: SegmentStartPos, Pos1: SegmentEndPos, pOutCollision: &HitPos, pOutBeforeCollision: nullptr, pTeleNr: &Tele); |
| 265 | |
| 266 | // check if we intersect a player |
| 267 | if(GameClient()->IntersectCharacter(HookPos: SegmentStartPos, NewPos: HitPos, NewPos2&: SegmentEndPos, OwnId: ClientId, pPlayerPosition: &IntersectedPlayerPosition) != -1) |
| 268 | { |
| 269 | AddHookPlayerSegment(LineStartPos, HitPos, IntersectedPlayerPosition, SegmentEndPos); |
| 270 | break; |
| 271 | } |
| 272 | |
| 273 | // we hit nothing, continue calculating segments |
| 274 | if(!Hit) |
| 275 | { |
| 276 | SegmentStartPos = SegmentEndPos; |
| 277 | SegmentStartPos.x = round_to_int(f: SegmentStartPos.x); |
| 278 | SegmentStartPos.y = round_to_int(f: SegmentStartPos.y); |
| 279 | |
| 280 | // direction is always the same after the first tick quantization |
| 281 | if(HookTick == 0) |
| 282 | { |
| 283 | QuantizedDirection.x = round_to_int(f: QuantizedDirection.x * 256.0f) / 256.0f; |
| 284 | QuantizedDirection.y = round_to_int(f: QuantizedDirection.y * 256.0f) / 256.0f; |
| 285 | } |
| 286 | continue; |
| 287 | } |
| 288 | |
| 289 | // we hit a solid / hook stopper |
| 290 | if(Hit != TILE_TELEINHOOK) |
| 291 | { |
| 292 | if(Hit != TILE_NOHOOK) |
| 293 | HookCollColor = color_cast<ColorRGBA>(hsl: ColorHSLA(g_Config.m_ClHookCollColorHookableColl)); |
| 294 | vLineSegments.emplace_back(args&: LineStartPos, args&: HitPos); |
| 295 | break; |
| 296 | } |
| 297 | |
| 298 | // we are hitting TILE_TELEINHOOK |
| 299 | vLineSegments.emplace_back(args&: LineStartPos, args&: HitPos); |
| 300 | HookEnteredTelehook = true; |
| 301 | |
| 302 | // check tele outs |
| 303 | const std::vector<vec2> &vTeleOuts = Collision()->TeleOuts(Number: Tele - 1); |
| 304 | if(vTeleOuts.empty()) |
| 305 | { |
| 306 | // the hook gets stuck, this is a feature or a bug |
| 307 | HookCollColor = color_cast<ColorRGBA>(hsl: ColorHSLA(g_Config.m_ClHookCollColorHookableColl)); |
| 308 | break; |
| 309 | } |
| 310 | else if(vTeleOuts.size() > 1) |
| 311 | { |
| 312 | // we don't know which teleout the hook takes, just invert the color |
| 313 | HookCollColor = color_invert(col: color_cast<ColorRGBA>(hsl: ColorHSLA(g_Config.m_ClHookCollColorTeeColl))); |
| 314 | break; |
| 315 | } |
| 316 | |
| 317 | // go through one teleout, update positions and continue |
| 318 | BasePos = vTeleOuts[0]; |
| 319 | LineStartPos = BasePos; // make the line start in the teleporter to prevent a gap |
| 320 | SegmentStartPos = BasePos + Direction * HOOK_START_DISTANCE; |
| 321 | SegmentStartPos.x = round_to_int(f: SegmentStartPos.x); |
| 322 | SegmentStartPos.y = round_to_int(f: SegmentStartPos.y); |
| 323 | |
| 324 | // direction is always the same after the first tick quantization |
| 325 | if(HookTick == 0) |
| 326 | { |
| 327 | QuantizedDirection.x = round_to_int(f: QuantizedDirection.x * 256.0f) / 256.0f; |
| 328 | QuantizedDirection.y = round_to_int(f: QuantizedDirection.y * 256.0f) / 256.0f; |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | // The hook line is too expensive to calculate and didn't hit anything before, just set a straight line |
| 333 | if(HookTick >= MaxHookTicks && vLineSegments.empty()) |
| 334 | { |
| 335 | // we simply don't know if we hit anything or not |
| 336 | HookCollColor = color_invert(col: color_cast<ColorRGBA>(hsl: ColorHSLA(g_Config.m_ClHookCollColorTeeColl))); |
| 337 | vLineSegments.emplace_back(args&: LineStartPos, args: BasePos + QuantizedDirection * HookLength); |
| 338 | } |
| 339 | |
| 340 | // add a line from the player to the start position to prevent a visual gap |
| 341 | vLineSegments.emplace_back(args&: Position, args: Position + StartOffset); |
| 342 | |
| 343 | if(AlwaysRenderHookColl && RenderHookCollPlayer) |
| 344 | { |
| 345 | // invert the hook coll colors when using cl_show_hook_coll_always and +showhookcoll is pressed |
| 346 | HookCollColor = color_invert(col: HookCollColor); |
| 347 | } |
| 348 | |
| 349 | // Render hook coll line |
| 350 | const int HookCollSize = Local ? g_Config.m_ClHookCollSize : g_Config.m_ClHookCollSizeOther; |
| 351 | |
| 352 | float Alpha = GameClient()->IsOtherTeam(ClientId) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f; |
| 353 | Alpha *= (float)g_Config.m_ClHookCollAlpha / 100; |
| 354 | if(Alpha <= 0.0f) |
| 355 | return; |
| 356 | |
| 357 | Graphics()->TextureClear(); |
| 358 | if(HookCollSize > 0) |
| 359 | { |
| 360 | std::vector<IGraphics::CFreeformItem> vLineQuadSegments; |
| 361 | vLineQuadSegments.reserve(n: vLineSegments.size()); |
| 362 | |
| 363 | float LineWidth = 0.5f + (float)(HookCollSize - 1) * 0.25f; |
| 364 | const vec2 PerpToAngle = normalize(v: vec2(Direction.y, -Direction.x)) * GameClient()->m_Camera.m_Zoom; |
| 365 | |
| 366 | for(const auto &LineSegment : vLineSegments) |
| 367 | { |
| 368 | vec2 DrawInitPos(LineSegment.m_X0, LineSegment.m_Y0); |
| 369 | vec2 DrawFinishPos(LineSegment.m_X1, LineSegment.m_Y1); |
| 370 | vec2 Pos0 = DrawFinishPos + PerpToAngle * -LineWidth; |
| 371 | vec2 Pos1 = DrawFinishPos + PerpToAngle * LineWidth; |
| 372 | vec2 Pos2 = DrawInitPos + PerpToAngle * -LineWidth; |
| 373 | vec2 Pos3 = DrawInitPos + PerpToAngle * LineWidth; |
| 374 | vLineQuadSegments.emplace_back(args&: Pos0.x, args&: Pos0.y, args&: Pos1.x, args&: Pos1.y, args&: Pos2.x, args&: Pos2.y, args&: Pos3.x, args&: Pos3.y); |
| 375 | } |
| 376 | Graphics()->QuadsBegin(); |
| 377 | Graphics()->SetColor(HookCollColor.WithAlpha(alpha: Alpha)); |
| 378 | Graphics()->QuadsDrawFreeform(pArray: vLineQuadSegments.data(), Num: vLineQuadSegments.size()); |
| 379 | Graphics()->QuadsEnd(); |
| 380 | } |
| 381 | else |
| 382 | { |
| 383 | Graphics()->LinesBegin(); |
| 384 | Graphics()->SetColor(HookCollColor.WithAlpha(alpha: Alpha)); |
| 385 | Graphics()->LinesDraw(pArray: vLineSegments.data(), Num: vLineSegments.size()); |
| 386 | Graphics()->LinesEnd(); |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | void CPlayers::RenderHook( |
| 391 | const CNetObj_Character *pPrevChar, |
| 392 | const CNetObj_Character *pPlayerChar, |
| 393 | const CTeeRenderInfo *pRenderInfo, |
| 394 | int ClientId, |
| 395 | float Intra) |
| 396 | { |
| 397 | if(pPrevChar->m_HookState <= 0 || pPlayerChar->m_HookState <= 0) |
| 398 | return; |
| 399 | |
| 400 | CNetObj_Character Prev; |
| 401 | CNetObj_Character Player; |
| 402 | Prev = *pPrevChar; |
| 403 | Player = *pPlayerChar; |
| 404 | |
| 405 | CTeeRenderInfo RenderInfo = *pRenderInfo; |
| 406 | |
| 407 | // don't render hooks to not active character cores |
| 408 | if(pPlayerChar->m_HookedPlayer != -1 && !GameClient()->m_Snap.m_aCharacters[pPlayerChar->m_HookedPlayer].m_Active) |
| 409 | return; |
| 410 | |
| 411 | if(ClientId >= 0) |
| 412 | Intra = GameClient()->m_aClients[ClientId].m_IsPredicted ? Client()->PredIntraGameTick(Conn: g_Config.m_ClDummy) : Client()->IntraGameTick(Conn: g_Config.m_ClDummy); |
| 413 | |
| 414 | bool OtherTeam = GameClient()->IsOtherTeam(ClientId); |
| 415 | float Alpha = (OtherTeam || ClientId < 0) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f; |
| 416 | if(ClientId == -2) // ghost |
| 417 | Alpha = g_Config.m_ClRaceGhostAlpha / 100.0f; |
| 418 | |
| 419 | RenderInfo.m_Size = 64.0f; |
| 420 | |
| 421 | vec2 Position; |
| 422 | if(in_range(a: ClientId, upper: MAX_CLIENTS - 1)) |
| 423 | Position = GameClient()->m_aClients[ClientId].m_RenderPos; |
| 424 | else |
| 425 | Position = mix(a: vec2(Prev.m_X, Prev.m_Y), b: vec2(Player.m_X, Player.m_Y), amount: Intra); |
| 426 | |
| 427 | // draw hook |
| 428 | Graphics()->SetColor(r: 1.0f, g: 1.0f, b: 1.0f, a: 1.0f); |
| 429 | if(ClientId < 0) |
| 430 | Graphics()->SetColor(r: 1.0f, g: 1.0f, b: 1.0f, a: 0.5f); |
| 431 | |
| 432 | vec2 Pos = Position; |
| 433 | vec2 HookPos; |
| 434 | |
| 435 | if(in_range(a: pPlayerChar->m_HookedPlayer, upper: MAX_CLIENTS - 1)) |
| 436 | HookPos = GameClient()->m_aClients[pPlayerChar->m_HookedPlayer].m_RenderPos; |
| 437 | else |
| 438 | HookPos = mix(a: vec2(Prev.m_HookX, Prev.m_HookY), b: vec2(Player.m_HookX, Player.m_HookY), amount: Intra); |
| 439 | |
| 440 | float d = distance(a: Pos, b: HookPos); |
| 441 | vec2 Dir = normalize(v: Pos - HookPos); |
| 442 | |
| 443 | Graphics()->TextureSet(Texture: GameClient()->m_GameSkin.m_SpriteHookHead); |
| 444 | Graphics()->QuadsSetRotation(Angle: angle(a: Dir) + pi); |
| 445 | // render head |
| 446 | int QuadOffset = NUM_WEAPONS * 2 + 2; |
| 447 | Graphics()->SetColor(r: 1.0f, g: 1.0f, b: 1.0f, a: Alpha); |
| 448 | Graphics()->RenderQuadContainerAsSprite(ContainerIndex: m_WeaponEmoteQuadContainerIndex, QuadOffset, X: HookPos.x, Y: HookPos.y); |
| 449 | |
| 450 | // render chain |
| 451 | ++QuadOffset; |
| 452 | static IGraphics::SRenderSpriteInfo s_aHookChainRenderInfo[1024]; |
| 453 | int HookChainCount = 0; |
| 454 | for(float f = 24; f < d && HookChainCount < 1024; f += 24, ++HookChainCount) |
| 455 | { |
| 456 | vec2 p = HookPos + Dir * f; |
| 457 | s_aHookChainRenderInfo[HookChainCount].m_Pos[0] = p.x; |
| 458 | s_aHookChainRenderInfo[HookChainCount].m_Pos[1] = p.y; |
| 459 | s_aHookChainRenderInfo[HookChainCount].m_Scale = 1; |
| 460 | s_aHookChainRenderInfo[HookChainCount].m_Rotation = angle(a: Dir) + pi; |
| 461 | } |
| 462 | Graphics()->TextureSet(Texture: GameClient()->m_GameSkin.m_SpriteHookChain); |
| 463 | Graphics()->RenderQuadContainerAsSpriteMultiple(ContainerIndex: m_WeaponEmoteQuadContainerIndex, QuadOffset, DrawCount: HookChainCount, pRenderInfo: s_aHookChainRenderInfo); |
| 464 | |
| 465 | Graphics()->QuadsSetRotation(Angle: 0); |
| 466 | Graphics()->SetColor(r: 1.0f, g: 1.0f, b: 1.0f, a: 1.0f); |
| 467 | |
| 468 | RenderHand(pInfo: &RenderInfo, CenterPos: Position, Dir: normalize(v: HookPos - Pos), AngleOffset: -pi / 2, PostRotOffset: vec2(20, 0), Alpha); |
| 469 | } |
| 470 | |
| 471 | void CPlayers::RenderPlayer( |
| 472 | const CNetObj_Character *pPrevChar, |
| 473 | const CNetObj_Character *pPlayerChar, |
| 474 | const CTeeRenderInfo *pRenderInfo, |
| 475 | int ClientId, |
| 476 | float Intra) |
| 477 | { |
| 478 | CNetObj_Character Prev; |
| 479 | CNetObj_Character Player; |
| 480 | Prev = *pPrevChar; |
| 481 | Player = *pPlayerChar; |
| 482 | |
| 483 | CTeeRenderInfo RenderInfo = *pRenderInfo; |
| 484 | |
| 485 | bool Local = GameClient()->m_Snap.m_LocalClientId == ClientId; |
| 486 | bool OtherTeam = GameClient()->IsOtherTeam(ClientId); |
| 487 | float Alpha = (OtherTeam || ClientId < 0) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f; |
| 488 | if(ClientId == -2) // ghost |
| 489 | Alpha = g_Config.m_ClRaceGhostAlpha / 100.0f; |
| 490 | // TODO: snd_game_volume_others |
| 491 | const float Volume = 1.0f; |
| 492 | |
| 493 | // set size |
| 494 | RenderInfo.m_Size = 64.0f; |
| 495 | |
| 496 | if(ClientId >= 0) |
| 497 | Intra = GameClient()->m_aClients[ClientId].m_IsPredicted ? Client()->PredIntraGameTick(Conn: g_Config.m_ClDummy) : Client()->IntraGameTick(Conn: g_Config.m_ClDummy); |
| 498 | |
| 499 | static float s_LastGameTickTime = Client()->GameTickTime(Conn: g_Config.m_ClDummy); |
| 500 | static float s_LastPredIntraTick = Client()->PredIntraGameTick(Conn: g_Config.m_ClDummy); |
| 501 | if(GameClient()->m_Snap.m_pGameInfoObj && !(GameClient()->m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED)) |
| 502 | { |
| 503 | s_LastGameTickTime = Client()->GameTickTime(Conn: g_Config.m_ClDummy); |
| 504 | s_LastPredIntraTick = Client()->PredIntraGameTick(Conn: g_Config.m_ClDummy); |
| 505 | } |
| 506 | |
| 507 | bool PredictLocalWeapons = false; |
| 508 | float AttackTime = (Client()->PrevGameTick(Conn: g_Config.m_ClDummy) - Player.m_AttackTick) / (float)Client()->GameTickSpeed() + Client()->GameTickTime(Conn: g_Config.m_ClDummy); |
| 509 | float LastAttackTime = (Client()->PrevGameTick(Conn: g_Config.m_ClDummy) - Player.m_AttackTick) / (float)Client()->GameTickSpeed() + s_LastGameTickTime; |
| 510 | if(ClientId >= 0 && GameClient()->m_aClients[ClientId].m_IsPredictedLocal && GameClient()->AntiPingGunfire()) |
| 511 | { |
| 512 | PredictLocalWeapons = true; |
| 513 | AttackTime = (Client()->PredIntraGameTick(Conn: g_Config.m_ClDummy) + (Client()->PredGameTick(Conn: g_Config.m_ClDummy) - 1 - Player.m_AttackTick)) / (float)Client()->GameTickSpeed(); |
| 514 | LastAttackTime = (s_LastPredIntraTick + (Client()->PredGameTick(Conn: g_Config.m_ClDummy) - 1 - Player.m_AttackTick)) / (float)Client()->GameTickSpeed(); |
| 515 | } |
| 516 | float AttackTicksPassed = AttackTime * (float)Client()->GameTickSpeed(); |
| 517 | |
| 518 | float Angle = GetPlayerTargetAngle(pPrevChar: &Prev, pPlayerChar: &Player, ClientId, Intra); |
| 519 | |
| 520 | vec2 Direction = direction(angle: Angle); |
| 521 | vec2 Position; |
| 522 | if(in_range(a: ClientId, upper: MAX_CLIENTS - 1)) |
| 523 | Position = GameClient()->m_aClients[ClientId].m_RenderPos; |
| 524 | else |
| 525 | Position = mix(a: vec2(Prev.m_X, Prev.m_Y), b: vec2(Player.m_X, Player.m_Y), amount: Intra); |
| 526 | vec2 Vel = mix(a: vec2(Prev.m_VelX / 256.0f, Prev.m_VelY / 256.0f), b: vec2(Player.m_VelX / 256.0f, Player.m_VelY / 256.0f), amount: Intra); |
| 527 | |
| 528 | GameClient()->m_Flow.Add(Pos: Position, Vel: Vel * 100.0f, Size: 10.0f); |
| 529 | |
| 530 | RenderInfo.m_GotAirJump = Player.m_Jumped & 2 ? false : true; |
| 531 | |
| 532 | RenderInfo.m_FeetFlipped = false; |
| 533 | |
| 534 | bool Stationary = Player.m_VelX <= 1 && Player.m_VelX >= -1; |
| 535 | bool InAir = !Collision()->CheckPoint(x: Player.m_X, y: Player.m_Y + 16); |
| 536 | bool Running = Player.m_VelX >= 5000 || Player.m_VelX <= -5000; |
| 537 | bool WantOtherDir = (Player.m_Direction == -1 && Vel.x > 0) || (Player.m_Direction == 1 && Vel.x < 0); |
| 538 | bool Inactive = ClientId >= 0 && (GameClient()->m_aClients[ClientId].m_Afk || GameClient()->m_aClients[ClientId].m_Paused); |
| 539 | |
| 540 | // evaluate animation |
| 541 | float WalkTime = std::fmod(x: Position.x, y: 100.0f) / 100.0f; |
| 542 | float RunTime = std::fmod(x: Position.x, y: 200.0f) / 200.0f; |
| 543 | |
| 544 | // Don't do a moon walk outside the left border |
| 545 | if(WalkTime < 0.0f) |
| 546 | WalkTime += 1.0f; |
| 547 | if(RunTime < 0.0f) |
| 548 | RunTime += 1.0f; |
| 549 | |
| 550 | CAnimState State; |
| 551 | State.Set(pAnim: &g_pData->m_aAnimations[ANIM_BASE], Time: 0.0f); |
| 552 | |
| 553 | if(InAir) |
| 554 | State.Add(pAnim: &g_pData->m_aAnimations[ANIM_INAIR], Time: 0.0f, Amount: 1.0f); // TODO: some sort of time here |
| 555 | else if(Stationary) |
| 556 | { |
| 557 | if(Inactive) |
| 558 | { |
| 559 | State.Add(pAnim: Direction.x < 0.0f ? &g_pData->m_aAnimations[ANIM_SIT_LEFT] : &g_pData->m_aAnimations[ANIM_SIT_RIGHT], Time: 0.0f, Amount: 1.0f); // TODO: some sort of time here |
| 560 | RenderInfo.m_FeetFlipped = true; |
| 561 | } |
| 562 | else |
| 563 | State.Add(pAnim: &g_pData->m_aAnimations[ANIM_IDLE], Time: 0.0f, Amount: 1.0f); // TODO: some sort of time here |
| 564 | } |
| 565 | else if(!WantOtherDir) |
| 566 | { |
| 567 | if(Running) |
| 568 | State.Add(pAnim: Player.m_VelX < 0 ? &g_pData->m_aAnimations[ANIM_RUN_LEFT] : &g_pData->m_aAnimations[ANIM_RUN_RIGHT], Time: RunTime, Amount: 1.0f); |
| 569 | else |
| 570 | State.Add(pAnim: &g_pData->m_aAnimations[ANIM_WALK], Time: WalkTime, Amount: 1.0f); |
| 571 | } |
| 572 | |
| 573 | if(Player.m_Weapon == WEAPON_HAMMER) |
| 574 | State.Add(pAnim: &g_pData->m_aAnimations[ANIM_HAMMER_SWING], Time: std::clamp(val: LastAttackTime * 5.0f, lo: 0.0f, hi: 1.0f), Amount: 1.0f); |
| 575 | if(Player.m_Weapon == WEAPON_NINJA) |
| 576 | State.Add(pAnim: &g_pData->m_aAnimations[ANIM_NINJA_SWING], Time: std::clamp(val: LastAttackTime * 2.0f, lo: 0.0f, hi: 1.0f), Amount: 1.0f); |
| 577 | |
| 578 | // do skidding |
| 579 | if(!InAir && WantOtherDir && length(a: Vel * 50) > 500.0f) |
| 580 | GameClient()->m_Effects.SkidTrail(Pos: Position, Vel, Direction: Player.m_Direction, Alpha, Volume); |
| 581 | |
| 582 | // draw gun |
| 583 | if(Player.m_Weapon >= 0) |
| 584 | { |
| 585 | if(!(RenderInfo.m_TeeRenderFlags & TEE_NO_WEAPON)) |
| 586 | { |
| 587 | Graphics()->SetColor(r: 1.0f, g: 1.0f, b: 1.0f, a: Alpha); |
| 588 | |
| 589 | // normal weapons |
| 590 | int CurrentWeapon = std::clamp(val: Player.m_Weapon, lo: 0, hi: NUM_WEAPONS - 1); |
| 591 | Graphics()->TextureSet(Texture: GameClient()->m_GameSkin.m_aSpriteWeapons[CurrentWeapon]); |
| 592 | int QuadOffset = CurrentWeapon * 2 + (Direction.x < 0.0f ? 1 : 0); |
| 593 | |
| 594 | float Recoil = 0.0f; |
| 595 | vec2 WeaponPosition; |
| 596 | bool IsSit = Inactive && !InAir && Stationary; |
| 597 | |
| 598 | if(Player.m_Weapon == WEAPON_HAMMER) |
| 599 | { |
| 600 | // static position for hammer |
| 601 | WeaponPosition = Position + vec2(State.GetAttach()->m_X, State.GetAttach()->m_Y); |
| 602 | WeaponPosition.y += g_pData->m_Weapons.m_aId[CurrentWeapon].m_Offsety; |
| 603 | if(Direction.x < 0.0f) |
| 604 | WeaponPosition.x -= g_pData->m_Weapons.m_aId[CurrentWeapon].m_Offsetx; |
| 605 | if(IsSit) |
| 606 | WeaponPosition.y += 3.0f; |
| 607 | |
| 608 | // if active and attack is under way, bash stuffs |
| 609 | if(!Inactive || LastAttackTime < GameClient()->m_aClients[ClientId].m_Predicted.m_Tuning.GetWeaponFireDelay(Weapon: Player.m_Weapon)) |
| 610 | { |
| 611 | if(Direction.x < 0) |
| 612 | Graphics()->QuadsSetRotation(Angle: -pi / 2.0f - State.GetAttach()->m_Angle * pi * 2.0f); |
| 613 | else |
| 614 | Graphics()->QuadsSetRotation(Angle: -pi / 2.0f + State.GetAttach()->m_Angle * pi * 2.0f); |
| 615 | } |
| 616 | else |
| 617 | Graphics()->QuadsSetRotation(Angle: Direction.x < 0.0f ? 100.0f : 500.0f); |
| 618 | |
| 619 | Graphics()->RenderQuadContainerAsSprite(ContainerIndex: m_WeaponEmoteQuadContainerIndex, QuadOffset, X: WeaponPosition.x, Y: WeaponPosition.y); |
| 620 | } |
| 621 | else if(Player.m_Weapon == WEAPON_NINJA) |
| 622 | { |
| 623 | WeaponPosition = Position; |
| 624 | WeaponPosition.y += g_pData->m_Weapons.m_aId[CurrentWeapon].m_Offsety; |
| 625 | if(IsSit) |
| 626 | WeaponPosition.y += 3.0f; |
| 627 | |
| 628 | if(Direction.x < 0.0f) |
| 629 | { |
| 630 | Graphics()->QuadsSetRotation(Angle: -pi / 2 - State.GetAttach()->m_Angle * pi * 2.0f); |
| 631 | WeaponPosition.x -= g_pData->m_Weapons.m_aId[CurrentWeapon].m_Offsetx; |
| 632 | GameClient()->m_Effects.PowerupShine(Pos: WeaponPosition + vec2(32.0f, 0.0f), Size: vec2(32.0f, 12.0f), Alpha); |
| 633 | } |
| 634 | else |
| 635 | { |
| 636 | Graphics()->QuadsSetRotation(Angle: -pi / 2 + State.GetAttach()->m_Angle * pi * 2.0f); |
| 637 | GameClient()->m_Effects.PowerupShine(Pos: WeaponPosition - vec2(32.0f, 0.0f), Size: vec2(32.0f, 12.0f), Alpha); |
| 638 | } |
| 639 | Graphics()->RenderQuadContainerAsSprite(ContainerIndex: m_WeaponEmoteQuadContainerIndex, QuadOffset, X: WeaponPosition.x, Y: WeaponPosition.y); |
| 640 | |
| 641 | // HADOKEN |
| 642 | if(AttackTime <= 1.0f / 6.0f && g_pData->m_Weapons.m_aId[CurrentWeapon].m_NumSpriteMuzzles) |
| 643 | { |
| 644 | int IteX = rand() % g_pData->m_Weapons.m_aId[CurrentWeapon].m_NumSpriteMuzzles; |
| 645 | static int s_LastIteX = IteX; |
| 646 | if(Client()->State() == IClient::STATE_DEMOPLAYBACK) |
| 647 | { |
| 648 | const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo(); |
| 649 | if(pInfo->m_Paused) |
| 650 | IteX = s_LastIteX; |
| 651 | else |
| 652 | s_LastIteX = IteX; |
| 653 | } |
| 654 | else |
| 655 | { |
| 656 | if(GameClient()->m_Snap.m_pGameInfoObj && GameClient()->m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED) |
| 657 | IteX = s_LastIteX; |
| 658 | else |
| 659 | s_LastIteX = IteX; |
| 660 | } |
| 661 | if(g_pData->m_Weapons.m_aId[CurrentWeapon].m_aSpriteMuzzles[IteX]) |
| 662 | { |
| 663 | vec2 HadokenDirection; |
| 664 | if(PredictLocalWeapons || ClientId < 0) |
| 665 | HadokenDirection = vec2(pPlayerChar->m_X, pPlayerChar->m_Y) - vec2(pPrevChar->m_X, pPrevChar->m_Y); |
| 666 | else |
| 667 | HadokenDirection = vec2(GameClient()->m_Snap.m_aCharacters[ClientId].m_Cur.m_X, GameClient()->m_Snap.m_aCharacters[ClientId].m_Cur.m_Y) - vec2(GameClient()->m_Snap.m_aCharacters[ClientId].m_Prev.m_X, GameClient()->m_Snap.m_aCharacters[ClientId].m_Prev.m_Y); |
| 668 | float HadokenAngle = 0.0f; |
| 669 | if(absolute(a: HadokenDirection.x) > 0.0001f || absolute(a: HadokenDirection.y) > 0.0001f) |
| 670 | { |
| 671 | HadokenDirection = normalize(v: HadokenDirection); |
| 672 | HadokenAngle = angle(a: HadokenDirection); |
| 673 | } |
| 674 | else |
| 675 | { |
| 676 | HadokenDirection = vec2(1.0f, 0.0f); |
| 677 | } |
| 678 | Graphics()->QuadsSetRotation(Angle: HadokenAngle); |
| 679 | QuadOffset = IteX * 2; |
| 680 | WeaponPosition = Position; |
| 681 | float OffsetX = g_pData->m_Weapons.m_aId[CurrentWeapon].m_Muzzleoffsetx; |
| 682 | WeaponPosition -= HadokenDirection * OffsetX; |
| 683 | Graphics()->TextureSet(Texture: GameClient()->m_GameSkin.m_aaSpriteWeaponsMuzzles[CurrentWeapon][IteX]); |
| 684 | Graphics()->RenderQuadContainerAsSprite(ContainerIndex: m_aWeaponSpriteMuzzleQuadContainerIndex[CurrentWeapon], QuadOffset, X: WeaponPosition.x, Y: WeaponPosition.y); |
| 685 | } |
| 686 | } |
| 687 | } |
| 688 | else |
| 689 | { |
| 690 | // TODO: should be an animation |
| 691 | Recoil = 0.0f; |
| 692 | float a = AttackTicksPassed / 5.0f; |
| 693 | if(a < 1.0f) |
| 694 | Recoil = std::sin(x: a * pi); |
| 695 | WeaponPosition = Position + Direction * g_pData->m_Weapons.m_aId[CurrentWeapon].m_Offsetx - Direction * Recoil * 10.0f; |
| 696 | WeaponPosition.y += g_pData->m_Weapons.m_aId[CurrentWeapon].m_Offsety; |
| 697 | if(IsSit) |
| 698 | WeaponPosition.y += 3.0f; |
| 699 | if(Player.m_Weapon == WEAPON_GUN && g_Config.m_ClOldGunPosition) |
| 700 | WeaponPosition.y -= 8.0f; |
| 701 | Graphics()->QuadsSetRotation(Angle: State.GetAttach()->m_Angle * pi * 2.0f + Angle); |
| 702 | Graphics()->RenderQuadContainerAsSprite(ContainerIndex: m_WeaponEmoteQuadContainerIndex, QuadOffset, X: WeaponPosition.x, Y: WeaponPosition.y); |
| 703 | } |
| 704 | |
| 705 | if(Player.m_Weapon == WEAPON_GUN || Player.m_Weapon == WEAPON_SHOTGUN) |
| 706 | { |
| 707 | // check if we're firing stuff |
| 708 | if(g_pData->m_Weapons.m_aId[CurrentWeapon].m_NumSpriteMuzzles) // prev.attackticks) |
| 709 | { |
| 710 | float AlphaMuzzle = 0.0f; |
| 711 | if(AttackTicksPassed < g_pData->m_Weapons.m_aId[CurrentWeapon].m_Muzzleduration + 3.0f) |
| 712 | { |
| 713 | float t = AttackTicksPassed / g_pData->m_Weapons.m_aId[CurrentWeapon].m_Muzzleduration; |
| 714 | AlphaMuzzle = mix(a: 2.0f, b: 0.0f, amount: minimum(a: 1.0f, b: maximum(a: 0.0f, b: t))); |
| 715 | } |
| 716 | |
| 717 | int IteX = rand() % g_pData->m_Weapons.m_aId[CurrentWeapon].m_NumSpriteMuzzles; |
| 718 | static int s_LastIteX = IteX; |
| 719 | if(Client()->State() == IClient::STATE_DEMOPLAYBACK) |
| 720 | { |
| 721 | const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo(); |
| 722 | if(pInfo->m_Paused) |
| 723 | IteX = s_LastIteX; |
| 724 | else |
| 725 | s_LastIteX = IteX; |
| 726 | } |
| 727 | else |
| 728 | { |
| 729 | if(GameClient()->m_Snap.m_pGameInfoObj && GameClient()->m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED) |
| 730 | IteX = s_LastIteX; |
| 731 | else |
| 732 | s_LastIteX = IteX; |
| 733 | } |
| 734 | if(AlphaMuzzle > 0.0f && g_pData->m_Weapons.m_aId[CurrentWeapon].m_aSpriteMuzzles[IteX]) |
| 735 | { |
| 736 | float OffsetY = -g_pData->m_Weapons.m_aId[CurrentWeapon].m_Muzzleoffsety; |
| 737 | QuadOffset = IteX * 2 + (Direction.x < 0.0f ? 1 : 0); |
| 738 | if(Direction.x < 0.0f) |
| 739 | OffsetY = -OffsetY; |
| 740 | |
| 741 | vec2 DirectionY(-Direction.y, Direction.x); |
| 742 | vec2 MuzzlePos = WeaponPosition + Direction * g_pData->m_Weapons.m_aId[CurrentWeapon].m_Muzzleoffsetx + DirectionY * OffsetY; |
| 743 | Graphics()->TextureSet(Texture: GameClient()->m_GameSkin.m_aaSpriteWeaponsMuzzles[CurrentWeapon][IteX]); |
| 744 | Graphics()->RenderQuadContainerAsSprite(ContainerIndex: m_aWeaponSpriteMuzzleQuadContainerIndex[CurrentWeapon], QuadOffset, X: MuzzlePos.x, Y: MuzzlePos.y); |
| 745 | } |
| 746 | } |
| 747 | } |
| 748 | Graphics()->SetColor(r: 1.0f, g: 1.0f, b: 1.0f, a: 1.0f); |
| 749 | Graphics()->QuadsSetRotation(Angle: 0.0f); |
| 750 | |
| 751 | switch(Player.m_Weapon) |
| 752 | { |
| 753 | case WEAPON_GUN: RenderHand(pInfo: &RenderInfo, CenterPos: WeaponPosition, Dir: Direction, AngleOffset: -3.0f * pi / 4.0f, PostRotOffset: vec2(-15.0f, 4.0f), Alpha); break; |
| 754 | case WEAPON_SHOTGUN: RenderHand(pInfo: &RenderInfo, CenterPos: WeaponPosition, Dir: Direction, AngleOffset: -pi / 2.0f, PostRotOffset: vec2(-5.0f, 4.0f), Alpha); break; |
| 755 | case WEAPON_GRENADE: RenderHand(pInfo: &RenderInfo, CenterPos: WeaponPosition, Dir: Direction, AngleOffset: -pi / 2.0f, PostRotOffset: vec2(-4.0f, 7.0f), Alpha); break; |
| 756 | } |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | // render the "shadow" tee |
| 761 | if(Local && ((g_Config.m_Debug && g_Config.m_ClUnpredictedShadow >= 0) || g_Config.m_ClUnpredictedShadow == 1)) |
| 762 | { |
| 763 | vec2 ShadowPosition = Position; |
| 764 | if(ClientId >= 0) |
| 765 | ShadowPosition = mix( |
| 766 | a: vec2(GameClient()->m_Snap.m_aCharacters[ClientId].m_Prev.m_X, GameClient()->m_Snap.m_aCharacters[ClientId].m_Prev.m_Y), |
| 767 | b: vec2(GameClient()->m_Snap.m_aCharacters[ClientId].m_Cur.m_X, GameClient()->m_Snap.m_aCharacters[ClientId].m_Cur.m_Y), |
| 768 | amount: Client()->IntraGameTick(Conn: g_Config.m_ClDummy)); |
| 769 | |
| 770 | RenderTools()->RenderTee(pAnim: &State, pInfo: &RenderInfo, Emote: Player.m_Emote, Dir: Direction, Pos: ShadowPosition, Alpha: 0.5f); // render ghost |
| 771 | } |
| 772 | |
| 773 | RenderTools()->RenderTee(pAnim: &State, pInfo: &RenderInfo, Emote: Player.m_Emote, Dir: Direction, Pos: Position, Alpha); |
| 774 | |
| 775 | float TeeAnimScale, TeeBaseSize; |
| 776 | CRenderTools::GetRenderTeeAnimScaleAndBaseSize(pInfo: &RenderInfo, AnimScale&: TeeAnimScale, BaseSize&: TeeBaseSize); |
| 777 | vec2 BodyPos = Position + vec2(State.GetBody()->m_X, State.GetBody()->m_Y) * TeeAnimScale; |
| 778 | if(RenderInfo.m_TeeRenderFlags & TEE_EFFECT_FROZEN) |
| 779 | { |
| 780 | GameClient()->m_Effects.FreezingFlakes(Pos: BodyPos, Size: vec2(32, 32), Alpha); |
| 781 | } |
| 782 | if(RenderInfo.m_TeeRenderFlags & TEE_EFFECT_SPARKLE) |
| 783 | { |
| 784 | GameClient()->m_Effects.SparkleTrail(Pos: BodyPos, Alpha); |
| 785 | } |
| 786 | |
| 787 | if(ClientId < 0) |
| 788 | return; |
| 789 | |
| 790 | int QuadOffsetToEmoticon = NUM_WEAPONS * 2 + 2 + 2; |
| 791 | if((Player.m_PlayerFlags & PLAYERFLAG_CHATTING) && !GameClient()->m_aClients[ClientId].m_Afk) |
| 792 | { |
| 793 | int CurEmoticon = (SPRITE_DOTDOT - SPRITE_OOP); |
| 794 | Graphics()->TextureSet(Texture: GameClient()->m_EmoticonsSkin.m_aSpriteEmoticons[CurEmoticon]); |
| 795 | int QuadOffset = QuadOffsetToEmoticon + CurEmoticon; |
| 796 | Graphics()->SetColor(r: 1.0f, g: 1.0f, b: 1.0f, a: Alpha); |
| 797 | Graphics()->RenderQuadContainerAsSprite(ContainerIndex: m_WeaponEmoteQuadContainerIndex, QuadOffset, X: Position.x + 24.f, Y: Position.y - 40.f); |
| 798 | |
| 799 | Graphics()->SetColor(r: 1.0f, g: 1.0f, b: 1.0f, a: 1.0f); |
| 800 | Graphics()->QuadsSetRotation(Angle: 0); |
| 801 | } |
| 802 | |
| 803 | if(g_Config.m_ClAfkEmote && GameClient()->m_aClients[ClientId].m_Afk && ClientId != GameClient()->m_aLocalIds[!g_Config.m_ClDummy]) |
| 804 | { |
| 805 | int CurEmoticon = (SPRITE_ZZZ - SPRITE_OOP); |
| 806 | Graphics()->TextureSet(Texture: GameClient()->m_EmoticonsSkin.m_aSpriteEmoticons[CurEmoticon]); |
| 807 | int QuadOffset = QuadOffsetToEmoticon + CurEmoticon; |
| 808 | Graphics()->SetColor(r: 1.0f, g: 1.0f, b: 1.0f, a: Alpha); |
| 809 | Graphics()->RenderQuadContainerAsSprite(ContainerIndex: m_WeaponEmoteQuadContainerIndex, QuadOffset, X: Position.x + 24.f, Y: Position.y - 40.f); |
| 810 | |
| 811 | Graphics()->SetColor(r: 1.0f, g: 1.0f, b: 1.0f, a: 1.0f); |
| 812 | Graphics()->QuadsSetRotation(Angle: 0); |
| 813 | } |
| 814 | |
| 815 | if(g_Config.m_ClShowEmotes && !GameClient()->m_aClients[ClientId].m_EmoticonIgnore && GameClient()->m_aClients[ClientId].m_EmoticonStartTick != -1) |
| 816 | { |
| 817 | float SinceStart = (Client()->GameTick(Conn: g_Config.m_ClDummy) - GameClient()->m_aClients[ClientId].m_EmoticonStartTick) + (Client()->IntraGameTickSincePrev(Conn: g_Config.m_ClDummy) - GameClient()->m_aClients[ClientId].m_EmoticonStartFraction); |
| 818 | float FromEnd = (2 * Client()->GameTickSpeed()) - SinceStart; |
| 819 | |
| 820 | if(0 <= SinceStart && FromEnd > 0) |
| 821 | { |
| 822 | float a = 1; |
| 823 | |
| 824 | if(FromEnd < Client()->GameTickSpeed() / 5) |
| 825 | a = FromEnd / (Client()->GameTickSpeed() / 5.0f); |
| 826 | |
| 827 | float h = 1; |
| 828 | if(SinceStart < Client()->GameTickSpeed() / 10) |
| 829 | h = SinceStart / (Client()->GameTickSpeed() / 10.0f); |
| 830 | |
| 831 | float Wiggle = 0; |
| 832 | if(SinceStart < Client()->GameTickSpeed() / 5) |
| 833 | Wiggle = SinceStart / (Client()->GameTickSpeed() / 5.0f); |
| 834 | |
| 835 | float WiggleAngle = std::sin(x: 5 * Wiggle); |
| 836 | |
| 837 | Graphics()->QuadsSetRotation(Angle: pi / 6 * WiggleAngle); |
| 838 | |
| 839 | Graphics()->SetColor(r: 1.0f, g: 1.0f, b: 1.0f, a: a * Alpha); |
| 840 | // client_datas::emoticon is an offset from the first emoticon |
| 841 | int QuadOffset = QuadOffsetToEmoticon + GameClient()->m_aClients[ClientId].m_Emoticon; |
| 842 | Graphics()->TextureSet(Texture: GameClient()->m_EmoticonsSkin.m_aSpriteEmoticons[GameClient()->m_aClients[ClientId].m_Emoticon]); |
| 843 | Graphics()->RenderQuadContainerAsSprite(ContainerIndex: m_WeaponEmoteQuadContainerIndex, QuadOffset, X: Position.x, Y: Position.y - 23.f - 32.f * h, ScaleX: 1.f, ScaleY: (64.f * h) / 64.f); |
| 844 | |
| 845 | Graphics()->SetColor(r: 1.0f, g: 1.0f, b: 1.0f, a: 1.0f); |
| 846 | Graphics()->QuadsSetRotation(Angle: 0); |
| 847 | } |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | inline bool CPlayers::IsPlayerInfoAvailable(int ClientId) const |
| 852 | { |
| 853 | return GameClient()->m_Snap.m_aCharacters[ClientId].m_Active && |
| 854 | GameClient()->m_Snap.m_apPrevPlayerInfos[ClientId] != nullptr && |
| 855 | GameClient()->m_Snap.m_apPlayerInfos[ClientId] != nullptr; |
| 856 | } |
| 857 | |
| 858 | void CPlayers::OnRender() |
| 859 | { |
| 860 | if(Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK) |
| 861 | return; |
| 862 | |
| 863 | // update render info for ninja |
| 864 | CTeeRenderInfo aRenderInfo[MAX_CLIENTS]; |
| 865 | const bool IsTeamPlay = GameClient()->IsTeamPlay(); |
| 866 | for(int i = 0; i < MAX_CLIENTS; ++i) |
| 867 | { |
| 868 | aRenderInfo[i] = GameClient()->m_aClients[i].m_RenderInfo; |
| 869 | aRenderInfo[i].m_TeeRenderFlags = 0; |
| 870 | |
| 871 | // predict freeze skin only for local players |
| 872 | bool Frozen = false; |
| 873 | if(i == GameClient()->m_aLocalIds[0] || i == GameClient()->m_aLocalIds[1]) |
| 874 | { |
| 875 | if(GameClient()->m_aClients[i].m_Predicted.m_FreezeEnd != 0) |
| 876 | aRenderInfo[i].m_TeeRenderFlags |= TEE_EFFECT_FROZEN | TEE_NO_WEAPON; |
| 877 | if(GameClient()->m_aClients[i].m_Predicted.m_LiveFrozen) |
| 878 | aRenderInfo[i].m_TeeRenderFlags |= TEE_EFFECT_FROZEN; |
| 879 | if(GameClient()->m_aClients[i].m_Predicted.m_Invincible) |
| 880 | aRenderInfo[i].m_TeeRenderFlags |= TEE_EFFECT_SPARKLE; |
| 881 | |
| 882 | Frozen = GameClient()->m_aClients[i].m_Predicted.m_FreezeEnd != 0; |
| 883 | } |
| 884 | else |
| 885 | { |
| 886 | if(GameClient()->m_aClients[i].m_FreezeEnd != 0) |
| 887 | aRenderInfo[i].m_TeeRenderFlags |= TEE_EFFECT_FROZEN | TEE_NO_WEAPON; |
| 888 | if(GameClient()->m_aClients[i].m_LiveFrozen) |
| 889 | aRenderInfo[i].m_TeeRenderFlags |= TEE_EFFECT_FROZEN; |
| 890 | if(GameClient()->m_aClients[i].m_Invincible) |
| 891 | aRenderInfo[i].m_TeeRenderFlags |= TEE_EFFECT_SPARKLE; |
| 892 | |
| 893 | Frozen = GameClient()->m_Snap.m_aCharacters[i].m_HasExtendedData && GameClient()->m_Snap.m_aCharacters[i].m_ExtendedData.m_FreezeEnd != 0; |
| 894 | } |
| 895 | |
| 896 | if((GameClient()->m_aClients[i].m_RenderCur.m_Weapon == WEAPON_NINJA || (Frozen && !GameClient()->m_GameInfo.m_NoSkinChangeForFrozen)) && g_Config.m_ClShowNinja) |
| 897 | { |
| 898 | // change the skin for the player to the ninja |
| 899 | aRenderInfo[i].m_aSixup[g_Config.m_ClDummy].Reset(); |
| 900 | aRenderInfo[i].ApplySkin(TeeRenderInfo: NinjaTeeRenderInfo()->TeeRenderInfo()); |
| 901 | aRenderInfo[i].m_CustomColoredSkin = IsTeamPlay; |
| 902 | if(!IsTeamPlay) |
| 903 | { |
| 904 | aRenderInfo[i].m_ColorBody = ColorRGBA(1, 1, 1); |
| 905 | aRenderInfo[i].m_ColorFeet = ColorRGBA(1, 1, 1); |
| 906 | } |
| 907 | } |
| 908 | } |
| 909 | |
| 910 | // get screen edges to avoid rendering offscreen |
| 911 | float ScreenX0, ScreenY0, ScreenX1, ScreenY1; |
| 912 | Graphics()->GetScreen(pTopLeftX: &ScreenX0, pTopLeftY: &ScreenY0, pBottomRightX: &ScreenX1, pBottomRightY: &ScreenY1); |
| 913 | // expand the edges to prevent popping in/out onscreen |
| 914 | // |
| 915 | // it is assumed that the tee, all its weapons, and emotes fit into a 200x200 box centered on the tee |
| 916 | // this may need to be changed or calculated differently in the future |
| 917 | float BorderBuffer = 100; |
| 918 | ScreenX0 -= BorderBuffer; |
| 919 | ScreenX1 += BorderBuffer; |
| 920 | ScreenY0 -= BorderBuffer; |
| 921 | ScreenY1 += BorderBuffer; |
| 922 | |
| 923 | // render everyone else's hook, then our own |
| 924 | const int LocalClientId = GameClient()->m_Snap.m_LocalClientId; |
| 925 | for(int ClientId = 0; ClientId < MAX_CLIENTS; ClientId++) |
| 926 | { |
| 927 | if(ClientId == LocalClientId || !IsPlayerInfoAvailable(ClientId)) |
| 928 | { |
| 929 | continue; |
| 930 | } |
| 931 | RenderHook(pPrevChar: &GameClient()->m_aClients[ClientId].m_RenderPrev, pPlayerChar: &GameClient()->m_aClients[ClientId].m_RenderCur, pRenderInfo: &aRenderInfo[ClientId], ClientId); |
| 932 | } |
| 933 | if(LocalClientId != -1 && IsPlayerInfoAvailable(ClientId: LocalClientId)) |
| 934 | { |
| 935 | const CGameClient::CClientData *pLocalClientData = &GameClient()->m_aClients[LocalClientId]; |
| 936 | RenderHook(pPrevChar: &pLocalClientData->m_RenderPrev, pPlayerChar: &pLocalClientData->m_RenderCur, pRenderInfo: &aRenderInfo[LocalClientId], ClientId: LocalClientId); |
| 937 | } |
| 938 | |
| 939 | // render spectating players |
| 940 | for(const auto &Client : GameClient()->m_aClients) |
| 941 | { |
| 942 | if(!Client.m_SpecCharPresent) |
| 943 | { |
| 944 | continue; |
| 945 | } |
| 946 | |
| 947 | const int ClientId = Client.ClientId(); |
| 948 | float Alpha = (GameClient()->IsOtherTeam(ClientId) || ClientId < 0) ? g_Config.m_ClShowOthersAlpha / 100.f : 1.f; |
| 949 | if(ClientId == -2) // ghost |
| 950 | { |
| 951 | Alpha = g_Config.m_ClRaceGhostAlpha / 100.f; |
| 952 | } |
| 953 | RenderTools()->RenderTee(pAnim: CAnimState::GetIdle(), pInfo: &SpectatorTeeRenderInfo()->TeeRenderInfo(), Emote: EMOTE_BLINK, Dir: vec2(1, 0), Pos: Client.m_SpecChar, Alpha); |
| 954 | } |
| 955 | |
| 956 | // render everyone else's tee, then either our own or the tee we are spectating. |
| 957 | const int RenderLastId = (GameClient()->m_Snap.m_SpecInfo.m_SpectatorId != SPEC_FREEVIEW && GameClient()->m_Snap.m_SpecInfo.m_Active) ? GameClient()->m_Snap.m_SpecInfo.m_SpectatorId : LocalClientId; |
| 958 | |
| 959 | for(int ClientId = 0; ClientId < MAX_CLIENTS; ClientId++) |
| 960 | { |
| 961 | if(ClientId == RenderLastId || !IsPlayerInfoAvailable(ClientId)) |
| 962 | { |
| 963 | continue; |
| 964 | } |
| 965 | |
| 966 | RenderHookCollLine(pPrevChar: &GameClient()->m_aClients[ClientId].m_RenderPrev, pPlayerChar: &GameClient()->m_aClients[ClientId].m_RenderCur, ClientId); |
| 967 | |
| 968 | if(!in_range(a: GameClient()->m_aClients[ClientId].m_RenderPos.x, lower: ScreenX0, upper: ScreenX1) || !in_range(a: GameClient()->m_aClients[ClientId].m_RenderPos.y, lower: ScreenY0, upper: ScreenY1)) |
| 969 | { |
| 970 | continue; |
| 971 | } |
| 972 | RenderPlayer(pPrevChar: &GameClient()->m_aClients[ClientId].m_RenderPrev, pPlayerChar: &GameClient()->m_aClients[ClientId].m_RenderCur, pRenderInfo: &aRenderInfo[ClientId], ClientId); |
| 973 | } |
| 974 | if(RenderLastId != -1 && IsPlayerInfoAvailable(ClientId: RenderLastId)) |
| 975 | { |
| 976 | const CGameClient::CClientData *pClientData = &GameClient()->m_aClients[RenderLastId]; |
| 977 | RenderHookCollLine(pPrevChar: &pClientData->m_RenderPrev, pPlayerChar: &pClientData->m_RenderCur, ClientId: RenderLastId); |
| 978 | RenderPlayer(pPrevChar: &pClientData->m_RenderPrev, pPlayerChar: &pClientData->m_RenderCur, pRenderInfo: &aRenderInfo[RenderLastId], ClientId: RenderLastId); |
| 979 | } |
| 980 | } |
| 981 | |
| 982 | void CPlayers::CreateNinjaTeeRenderInfo() |
| 983 | { |
| 984 | CTeeRenderInfo NinjaTeeRenderInfo; |
| 985 | NinjaTeeRenderInfo.m_Size = 64.0f; |
| 986 | CSkinDescriptor NinjaSkinDescriptor; |
| 987 | NinjaSkinDescriptor.m_Flags |= CSkinDescriptor::FLAG_SIX; |
| 988 | str_copy(dst&: NinjaSkinDescriptor.m_aSkinName, src: "x_ninja" ); |
| 989 | m_pNinjaTeeRenderInfo = GameClient()->CreateManagedTeeRenderInfo(TeeRenderInfo: NinjaTeeRenderInfo, SkinDescriptor: NinjaSkinDescriptor); |
| 990 | } |
| 991 | |
| 992 | void CPlayers::CreateSpectatorTeeRenderInfo() |
| 993 | { |
| 994 | CTeeRenderInfo SpectatorTeeRenderInfo; |
| 995 | SpectatorTeeRenderInfo.m_Size = 64.0f; |
| 996 | CSkinDescriptor SpectatorSkinDescriptor; |
| 997 | SpectatorSkinDescriptor.m_Flags |= CSkinDescriptor::FLAG_SIX; |
| 998 | str_copy(dst&: SpectatorSkinDescriptor.m_aSkinName, src: "x_spec" ); |
| 999 | m_pSpectatorTeeRenderInfo = GameClient()->CreateManagedTeeRenderInfo(TeeRenderInfo: SpectatorTeeRenderInfo, SkinDescriptor: SpectatorSkinDescriptor); |
| 1000 | } |
| 1001 | |
| 1002 | void CPlayers::OnInit() |
| 1003 | { |
| 1004 | m_WeaponEmoteQuadContainerIndex = Graphics()->CreateQuadContainer(AutomaticUpload: false); |
| 1005 | |
| 1006 | Graphics()->SetColor(r: 1.f, g: 1.f, b: 1.f, a: 1.f); |
| 1007 | |
| 1008 | for(int i = 0; i < NUM_WEAPONS; ++i) |
| 1009 | { |
| 1010 | float ScaleX, ScaleY; |
| 1011 | Graphics()->GetSpriteScale(pSprite: g_pData->m_Weapons.m_aId[i].m_pSpriteBody, ScaleX, ScaleY); |
| 1012 | Graphics()->QuadsSetSubset(TopLeftU: 0, TopLeftV: 0, BottomRightU: 1, BottomRightV: 1); |
| 1013 | Graphics()->QuadContainerAddSprite(QuadContainerIndex: m_WeaponEmoteQuadContainerIndex, Width: g_pData->m_Weapons.m_aId[i].m_VisualSize * ScaleX, Height: g_pData->m_Weapons.m_aId[i].m_VisualSize * ScaleY); |
| 1014 | Graphics()->QuadsSetSubset(TopLeftU: 0, TopLeftV: 1, BottomRightU: 1, BottomRightV: 0); |
| 1015 | Graphics()->QuadContainerAddSprite(QuadContainerIndex: m_WeaponEmoteQuadContainerIndex, Width: g_pData->m_Weapons.m_aId[i].m_VisualSize * ScaleX, Height: g_pData->m_Weapons.m_aId[i].m_VisualSize * ScaleY); |
| 1016 | } |
| 1017 | float ScaleX, ScaleY; |
| 1018 | |
| 1019 | // at the end the hand |
| 1020 | Graphics()->QuadsSetSubset(TopLeftU: 0, TopLeftV: 0, BottomRightU: 1, BottomRightV: 1); |
| 1021 | Graphics()->QuadContainerAddSprite(QuadContainerIndex: m_WeaponEmoteQuadContainerIndex, Size: 20.f); |
| 1022 | Graphics()->QuadsSetSubset(TopLeftU: 0, TopLeftV: 0, BottomRightU: 1, BottomRightV: 1); |
| 1023 | Graphics()->QuadContainerAddSprite(QuadContainerIndex: m_WeaponEmoteQuadContainerIndex, Size: 20.f); |
| 1024 | |
| 1025 | Graphics()->QuadsSetSubset(TopLeftU: 0, TopLeftV: 0, BottomRightU: 1, BottomRightV: 1); |
| 1026 | Graphics()->QuadContainerAddSprite(QuadContainerIndex: m_WeaponEmoteQuadContainerIndex, X: -12.f, Y: -8.f, Width: 24.f, Height: 16.f); |
| 1027 | Graphics()->QuadsSetSubset(TopLeftU: 0, TopLeftV: 0, BottomRightU: 1, BottomRightV: 1); |
| 1028 | Graphics()->QuadContainerAddSprite(QuadContainerIndex: m_WeaponEmoteQuadContainerIndex, X: -12.f, Y: -8.f, Width: 24.f, Height: 16.f); |
| 1029 | |
| 1030 | for(int i = 0; i < NUM_EMOTICONS; ++i) |
| 1031 | { |
| 1032 | Graphics()->QuadsSetSubset(TopLeftU: 0, TopLeftV: 0, BottomRightU: 1, BottomRightV: 1); |
| 1033 | Graphics()->QuadContainerAddSprite(QuadContainerIndex: m_WeaponEmoteQuadContainerIndex, Size: 64.f); |
| 1034 | } |
| 1035 | Graphics()->QuadContainerUpload(ContainerIndex: m_WeaponEmoteQuadContainerIndex); |
| 1036 | |
| 1037 | for(int i = 0; i < NUM_WEAPONS; ++i) |
| 1038 | { |
| 1039 | m_aWeaponSpriteMuzzleQuadContainerIndex[i] = Graphics()->CreateQuadContainer(AutomaticUpload: false); |
| 1040 | for(int n = 0; n < g_pData->m_Weapons.m_aId[i].m_NumSpriteMuzzles; ++n) |
| 1041 | { |
| 1042 | if(g_pData->m_Weapons.m_aId[i].m_aSpriteMuzzles[n]) |
| 1043 | { |
| 1044 | if(i == WEAPON_GUN || i == WEAPON_SHOTGUN) |
| 1045 | { |
| 1046 | // TODO: hardcoded for now to get the same particle size as before |
| 1047 | Graphics()->GetSpriteScaleImpl(Width: 96, Height: 64, ScaleX, ScaleY); |
| 1048 | } |
| 1049 | else |
| 1050 | Graphics()->GetSpriteScale(pSprite: g_pData->m_Weapons.m_aId[i].m_aSpriteMuzzles[n], ScaleX, ScaleY); |
| 1051 | } |
| 1052 | |
| 1053 | float SWidth = (g_pData->m_Weapons.m_aId[i].m_VisualSize * ScaleX) * (4.0f / 3.0f); |
| 1054 | float SHeight = g_pData->m_Weapons.m_aId[i].m_VisualSize * ScaleY; |
| 1055 | |
| 1056 | Graphics()->QuadsSetSubset(TopLeftU: 0, TopLeftV: 0, BottomRightU: 1, BottomRightV: 1); |
| 1057 | if(WEAPON_NINJA == i) |
| 1058 | Graphics()->QuadContainerAddSprite(QuadContainerIndex: m_aWeaponSpriteMuzzleQuadContainerIndex[i], Width: 160.f * ScaleX, Height: 160.f * ScaleY); |
| 1059 | else |
| 1060 | Graphics()->QuadContainerAddSprite(QuadContainerIndex: m_aWeaponSpriteMuzzleQuadContainerIndex[i], Width: SWidth, Height: SHeight); |
| 1061 | |
| 1062 | Graphics()->QuadsSetSubset(TopLeftU: 0, TopLeftV: 1, BottomRightU: 1, BottomRightV: 0); |
| 1063 | if(WEAPON_NINJA == i) |
| 1064 | Graphics()->QuadContainerAddSprite(QuadContainerIndex: m_aWeaponSpriteMuzzleQuadContainerIndex[i], Width: 160.f * ScaleX, Height: 160.f * ScaleY); |
| 1065 | else |
| 1066 | Graphics()->QuadContainerAddSprite(QuadContainerIndex: m_aWeaponSpriteMuzzleQuadContainerIndex[i], Width: SWidth, Height: SHeight); |
| 1067 | } |
| 1068 | Graphics()->QuadContainerUpload(ContainerIndex: m_aWeaponSpriteMuzzleQuadContainerIndex[i]); |
| 1069 | } |
| 1070 | |
| 1071 | Graphics()->QuadsSetSubset(TopLeftU: 0.f, TopLeftV: 0.f, BottomRightU: 1.f, BottomRightV: 1.f); |
| 1072 | Graphics()->QuadsSetRotation(Angle: 0.f); |
| 1073 | |
| 1074 | CreateNinjaTeeRenderInfo(); |
| 1075 | CreateSpectatorTeeRenderInfo(); |
| 1076 | } |
| 1077 | |