Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.00 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////////////////////////////////////////NEW//////////////////////////////////////////////////////////////////////////////////////////////
  2.  
  3. ////////////////////////////////////// Traces //////////////////////////////////////
  4. void CAutowall::TraceLine(const SSDK::Vector& vecAbsStart, const SSDK::Vector& vecAbsEnd, unsigned int mask, CBaseEntity* ignore, SSDK::Trace_t* ptr)
  5. {
  6. SSDK::Ray_t ray;
  7. ray.Init(vecAbsStart, vecAbsEnd);
  8. SSDK::CTraceFilter filter;
  9. filter.pSkip = ignore;
  10.  
  11. SSDK::I::EngineTrace()->TraceRay(ray, mask, &filter, ptr);
  12. }
  13.  
  14. void CAutowall::ClipTraceToPlayers(SSDK::Vector& absStart, SSDK::Vector absEnd, unsigned int mask, SSDK::ITraceFilter* filter, SSDK::Trace_t* tr)
  15. {
  16. //TODO: Un-ASM this
  17. #ifdef _WIN32
  18. _asm
  19. {
  20. mov eax, filter
  21. lea ecx, tr
  22. push ecx
  23. push eax
  24. push mask
  25. lea edx, absEnd
  26. lea ecx, absStart
  27. call UTIL_ClipTraceToPlayers
  28. add esp, 0xC
  29. }
  30. #else
  31. UTIL_ClipTraceToPlayers(absStart, absEnd, mask, filter, tr, 60.f, 0.f);
  32. #endif
  33. }
  34.  
  35. ////////////////////////////////////// Legacy Functions //////////////////////////////////////
  36. void CAutowall::GetBulletTypeParameters(float& maxRange, float& maxDistance, char* bulletType, bool sv_penetration_type)
  37. {
  38. if (sv_penetration_type)
  39. {
  40. maxRange = 35.0;
  41. maxDistance = 3000.0;
  42. }
  43. else
  44. {
  45. //Play tribune to framerate. Thanks, stringcompare
  46. //Regardless I doubt anyone will use the old penetration system anyway; so it won't matter much.
  47. if (!strcmp(bulletType, PROTSTR1("BULLET_PLAYER_338MAG")))
  48. {
  49. maxRange = 45.0;
  50. maxDistance = 8000.0;
  51. }
  52. if (!strcmp(bulletType, PROTSTR1("BULLET_PLAYER_762MM")))
  53. {
  54. maxRange = 39.0;
  55. maxDistance = 5000.0;
  56. }
  57. if (!strcmp(bulletType, PROTSTR1("BULLET_PLAYER_556MM")) || !strcmp(bulletType, PROTSTR1("BULLET_PLAYER_556MM_SMALL")) || !strcmp(bulletType, PROTSTR1("BULLET_PLAYER_556MM_BOX")))
  58. {
  59. maxRange = 35.0;
  60. maxDistance = 4000.0;
  61. }
  62. if (!strcmp(bulletType, PROTSTR1("BULLET_PLAYER_57MM")))
  63. {
  64. maxRange = 30.0;
  65. maxDistance = 2000.0;
  66. }
  67. if (!strcmp(bulletType, PROTSTR1("BULLET_PLAYER_50AE")))
  68. {
  69. maxRange = 30.0;
  70. maxDistance = 1000.0;
  71. }
  72. if (!strcmp(bulletType, PROTSTR1("BULLET_PLAYER_357SIG")) || !strcmp(bulletType, PROTSTR1("BULLET_PLAYER_357SIG_SMALL")) || !strcmp(bulletType, PROTSTR1("BULLET_PLAYER_357SIG_P250")) || !strcmp(bulletType, PROTSTR1("BULLET_PLAYER_357SIG_MIN")))
  73. {
  74. maxRange = 25.0;
  75. maxDistance = 800.0;
  76. }
  77. if (!strcmp(bulletType, PROTSTR1("BULLET_PLAYER_9MM")))
  78. {
  79. maxRange = 21.0;
  80. maxDistance = 800.0;
  81. }
  82. if (!strcmp(bulletType, PROTSTR1("BULLET_PLAYER_45ACP")))
  83. {
  84. maxRange = 15.0;
  85. maxDistance = 500.0;
  86. }
  87. if (!strcmp(bulletType, PROTSTR1("BULLET_PLAYER_BUCKSHOT")))
  88. {
  89. maxRange = 0.0;
  90. maxDistance = 0.0;
  91. }
  92. }
  93. }
  94.  
  95. ////////////////////////////////////// Misc Functions //////////////////////////////////////
  96. bool CAutowall::IsBreakableEntity(IClientEntity* entity)
  97. {
  98. if (!entity || entity->EntIndex() == 0)
  99. return false;
  100.  
  101. //m_takeDamage isn't properly set when using the signature.
  102. //Back it up, set it to true, then restore.
  103. int takeDamageBackup = ((C_BaseEntity*)entity)->m_takeDamage();
  104.  
  105. ClientClass *pClass = entity->GetClientClass();
  106.  
  107. // ' '' ' ' '
  108. // 01234567890123456 012345678
  109. //Check against CBreakableSurface and CBaseDoor
  110.  
  111. //Windows etc. are CBrekableSurface
  112. //Large garage door in Office is CBaseDoor and it get's reported as a breakable when it is not one
  113. //This is seperate from "CPropDoorRotating", which is a normal door.
  114. //Normally you would also check for "CFuncBrush" but it was acting oddly so I removed it. It's below if interested.
  115. //((clientClass->m_pNetworkName[1]) != 'F' || (clientClass->m_pNetworkName[4]) != 'c' || (clientClass->m_pNetworkName[5]) != 'B' || (clientClass->m_pNetworkName[9]) != 'h')
  116.  
  117. if ((pClass->m_pNetworkName[1] == 'B' && pClass->m_pNetworkName[9] == 'e' && pClass->m_pNetworkName[10] == 'S' && pClass->m_pNetworkName[16] == 'e')
  118. || (pClass->m_pNetworkName[1] != 'B' || pClass->m_pNetworkName[5] != 'D'))
  119. ((C_BaseEntity*)entity)->m_takeDamage() = DAMAGE_YES;
  120.  
  121. bool breakable = ::IsBreakableEntity(entity);
  122. ((C_BaseEntity*)entity)->m_takeDamage() = takeDamageBackup;
  123.  
  124. return breakable;
  125. }
  126.  
  127. void CAutowall::ScaleDamage(SSDK::Trace_t &enterTrace, CCSWeaponInfo *weaponData, float& currentDamage)
  128. {
  129. //Cred. to N0xius for reversing this.
  130. //TODO: _xAE^; look into reversing this yourself sometime
  131.  
  132. bool hasHeavyArmor = ((C_BasePlayer*)enterTrace.m_pEnt)->m_bHasHeavyArmor();
  133. int armorValue = ((C_BasePlayer*)enterTrace.m_pEnt)->m_ArmorValue();
  134. HitGroups hitGroup = enterTrace.hitgroup;
  135.  
  136. //Fuck making a new function, lambda beste. ~ Does the person have armor on for the hitbox checked?
  137. auto IsArmored = [&enterTrace]()->bool
  138. {
  139. C_BasePlayer* targetEntity = (C_BasePlayer*)enterTrace.m_pEnt;
  140. switch (enterTrace.hitgroup)
  141. {
  142. case HitGroups::HITGROUP_HEAD:
  143. return !!(C_BasePlayer*)targetEntity->m_bHasHelmet(); //Fuck compiler errors - force-convert it to a bool via (!!)
  144. case HitGroups::HITGROUP_GENERIC:
  145. case HitGroups::HITGROUP_CHEST:
  146. case HitGroups::HITGROUP_STOMACH:
  147. case HitGroups::HITGROUP_LEFTARM:
  148. case HitGroups::HITGROUP_RIGHTARM:
  149. return true;
  150. default:
  151. return false;
  152. }
  153. };
  154.  
  155. switch (hitGroup)
  156. {
  157. case HitGroups::HITGROUP_HEAD:
  158. currentDamage *= hasHeavyArmor ? 2.f : 4.f; //Heavy Armor does 1/2 damage
  159. break;
  160. case HitGroups::HITGROUP_STOMACH:
  161. currentDamage *= 1.25f;
  162. break;
  163. case HitGroups::HITGROUP_LEFTLEG:
  164. case HitGroups::HITGROUP_RIGHTLEG:
  165. currentDamage *= 0.75f;
  166. break;
  167. default:
  168. break;
  169. }
  170.  
  171. if (armorValue > 0 && IsArmored())
  172. {
  173. float bonusValue = 1.f, armorBonusRatio = 0.5f, armorRatio = weaponData->flArmorRatio() / 2.f;
  174.  
  175. //Damage gets modified for heavy armor users
  176. if (hasHeavyArmor)
  177. {
  178. armorBonusRatio = 0.33f;
  179. armorRatio *= 0.5f;
  180. bonusValue = 0.33f;
  181. }
  182.  
  183. auto NewDamage = currentDamage * armorRatio;
  184.  
  185. if (hasHeavyArmor)
  186. NewDamage *= 0.85f;
  187.  
  188. if (((currentDamage - (currentDamage * armorRatio)) * (bonusValue * armorBonusRatio)) > armorValue)
  189. NewDamage = currentDamage - (armorValue / armorBonusRatio);
  190.  
  191. currentDamage = NewDamage;
  192. }
  193. }
  194.  
  195. ////////////////////////////////////// Main Autowall Functions //////////////////////////////////////
  196. bool CAutowall::TraceToExit(SSDK::Trace_t& enterTrace, SSDK::Trace_t& exitTrace, SSDK::Vector startPosition, SSDK::Vector direction)
  197. {
  198. /*
  199. Masks used:
  200. MASK_SHOT_HULL = 0x600400B
  201. CONTENTS_HITBOX = 0x40000000
  202. MASK_SHOT_HULL | CONTENTS_HITBOX = 0x4600400B
  203. */
  204.  
  205. SSDK::Vector start, end;
  206. float maxDistance = 90.f, rayExtension = 4.f, currentDistance = 0;
  207. int firstContents = 0;
  208.  
  209. while (currentDistance <= maxDistance)
  210. {
  211. //Add extra distance to our ray
  212. currentDistance += rayExtension;
  213.  
  214. //Multiply the direction vector to the distance so we go outwards, add our position to it.
  215. start = startPosition + direction * currentDistance;
  216.  
  217. if (!firstContents)
  218. firstContents = g_EngineTrace->GetPointContents(start, MASK_SHOT_HULL | CONTENTS_HITBOX, nullptr); /*0x4600400B*/
  219. int pointContents = g_EngineTrace->GetPointContents(start, MASK_SHOT_HULL | CONTENTS_HITBOX, nullptr);
  220.  
  221. if (!(pointContents & MASK_SHOT_HULL) || pointContents & CONTENTS_HITBOX && pointContents != firstContents) /*0x600400B, *0x40000000*/
  222. {
  223. //Let's setup our end position by deducting the direction by the extra added distance
  224. end = start - (direction * rayExtension);
  225.  
  226. //Let's cast a ray from our start pos to the end pos
  227. TraceLine(start, end, MASK_SHOT_HULL | CONTENTS_HITBOX, nullptr, &exitTrace);
  228.  
  229. //Let's check if a hitbox is in-front of our enemy and if they are behind of a solid wall
  230. if (exitTrace.startsolid && exitTrace.surface.flags & SURF_HITBOX)
  231. {
  232. TraceLine(start, startPosition, MASK_SHOT_HULL, exitTrace.m_pEnt, &exitTrace);
  233.  
  234. if (exitTrace.DidHit() && !exitTrace.startsolid)
  235. {
  236. start = exitTrace.endpos;
  237. return true;
  238. }
  239.  
  240. continue;
  241. }
  242.  
  243. //Can we hit? Is the wall solid?
  244. if (exitTrace.DidHit() && !exitTrace.startsolid)
  245. {
  246.  
  247. //Is the wall a breakable? If so, let's shoot through it.
  248. if (Autowall::IsBreakableEntity(enterTrace.m_pEnt) && Autowall::IsBreakableEntity(exitTrace.m_pEnt))
  249. return true;
  250.  
  251. if (enterTrace.surface.flags & SURF_NODRAW || !(exitTrace.surface.flags & SURF_NODRAW) && (exitTrace.plane.normal.Dot(direction) <= 1.f))
  252. {
  253. float multAmount = exitTrace.fraction * 4.f;
  254. start -= direction * multAmount;
  255. return true;
  256. }
  257.  
  258. continue;
  259. }
  260.  
  261. if (!exitTrace.DidHit() || exitTrace.startsolid)
  262. {
  263. if (enterTrace.DidHitNonWorldEntity() && Autowall::IsBreakableEntity(enterTrace.m_pEnt))
  264. {
  265. exitTrace = enterTrace;
  266. exitTrace.endpos = start + direction;
  267. return true;
  268. }
  269.  
  270. continue;
  271. }
  272. }
  273. }
  274. return false;
  275. }
  276.  
  277. bool CAutowall::HandleBulletPenetration(CCSWeaponInfo* weaponData, SSDK::Trace_t& enterTrace, SSDK::Vector& eyePosition, SSDK::Vector direction, int& possibleHitsRemaining, float& currentDamage, float penetrationPower, bool sv_penetration_type, float ff_damage_reduction_bullets, float ff_damage_bullet_penetration)
  278. {
  279. //Because there's been issues regarding this- putting this here.
  280. if (&currentDamage == nullptr)
  281. throw std::invalid_argument("currentDamage is null!");
  282.  
  283. SafeLocalPlayer() false;
  284. SSDK::Trace_t exitTrace;
  285. C_BaseEntity* pEnemy = (C_BasePlayer*)enterTrace.m_pEnt;
  286. surfacedata_t *enterSurfaceData = g_PhysSurface->GetSurfaceData(enterTrace.surface.surfaceProps);
  287. int enterMaterial = enterSurfaceData->game.material;
  288.  
  289. float enterSurfPenetrationModifier = enterSurfaceData->game.flPenetrationModifier;
  290. float enterDamageModifier = enterSurfaceData->game.flDamageModifier;
  291. float thickness, modifier, lostDamage, finalDamageModifier, combinedPenetrationModifier;
  292. bool isSolidSurf = ((enterTrace.contents >> 3) & CONTENTS_SOLID);
  293. bool isLightSurf = ((enterTrace.surface.flags >> 7) & SURF_LIGHT);
  294.  
  295. if (possibleHitsRemaining <= 0
  296. //Test for "DE_CACHE/DE_CACHE_TELA_03" as the entering surface and "CS_ITALY/CR_MISCWOOD2B" as the exiting surface.
  297. //Fixes a wall in de_cache which seems to be broken in some way. Although bullet penetration is not recorded to go through this wall
  298. //Decals can be seen of bullets within the glass behind of the enemy. Hacky method, but works.
  299. //You might want to have a check for this to only be activated on de_cache.
  300. || (enterTrace.surface.name == (const char*)0x2227c261 && exitTrace.surface.name == (const char*)0x2227c868)
  301. || (!possibleHitsRemaining && !isLightSurf && !isSolidSurf && enterMaterial != CHAR_TEX_GRATE && enterMaterial != CHAR_TEX_GLASS)
  302. || weaponData->flPenetration() <= 0.f
  303. || !TraceToExit(enterTrace, exitTrace, enterTrace.endpos, direction)
  304. && !(g_EngineTrace->GetPointContents(enterTrace.endpos, MASK_SHOT_HULL, nullptr) & MASK_SHOT_HULL))
  305. return false;
  306.  
  307. surfacedata_t *exitSurfaceData = g_PhysSurface->GetSurfaceData(exitTrace.surface.surfaceProps);
  308. int exitMaterial = exitSurfaceData->game.material;
  309. float exitSurfPenetrationModifier = exitSurfaceData->game.flPenetrationModifier;
  310. float exitDamageModifier = exitSurfaceData->game.flDamageModifier;
  311.  
  312. //Are we using the newer penetration system?
  313. if (sv_penetration_type)
  314. {
  315. if (enterMaterial == CHAR_TEX_GRATE || enterMaterial == CHAR_TEX_GLASS)
  316. {
  317. combinedPenetrationModifier = 3.f;
  318. finalDamageModifier = 0.05f;
  319. }
  320. else if (isSolidSurf || isLightSurf)
  321. {
  322. combinedPenetrationModifier = 1.f;
  323. finalDamageModifier = 0.16f;
  324. }
  325. else if (enterMaterial == CHAR_TEX_FLESH && (localPlayer->m_iTeamNum() == pEnemy->m_iTeamNum() && ff_damage_reduction_bullets == 0.f)) //TODO: Team check config
  326. {
  327. //Look's like you aren't shooting through your teammate today
  328. if (ff_damage_bullet_penetration == 0.f)
  329. return false;
  330.  
  331. //Let's shoot through teammates and get kicked for teamdmg! Whatever, atleast we did damage to the enemy. I call that a win.
  332. combinedPenetrationModifier = ff_damage_bullet_penetration;
  333. finalDamageModifier = 0.16f;
  334. }
  335. else
  336. {
  337. combinedPenetrationModifier = (enterSurfPenetrationModifier + exitSurfPenetrationModifier) / 2.f;
  338. finalDamageModifier = 0.16f;
  339. }
  340.  
  341. //Do our materials line up?
  342. if (enterMaterial == exitMaterial)
  343. {
  344. if (exitMaterial == CHAR_TEX_CARDBOARD || exitMaterial == CHAR_TEX_WOOD)
  345. combinedPenetrationModifier = 3.f;
  346. else if (exitMaterial == CHAR_TEX_PLASTIC)
  347. combinedPenetrationModifier = 2.f;
  348. }
  349.  
  350. //Calculate thickness of the wall by getting the length of the range of the trace and squaring
  351. thickness = (exitTrace.endpos - enterTrace.endpos).LengthSqr();
  352. modifier = fmaxf(1.f / combinedPenetrationModifier, 0.f);
  353.  
  354. //This calculates how much damage we've lost depending on thickness of the wall, our penetration, damage, and the modifiers set earlier
  355. lostDamage = fmaxf(
  356. ((modifier * thickness) / 24.f)
  357. + ((currentDamage * finalDamageModifier)
  358. + (fmaxf(3.75f / penetrationPower, 0.f) * 3.f * modifier)), 0.f);
  359.  
  360. //Did we loose too much damage?
  361. if (lostDamage > currentDamage)
  362. return false;
  363.  
  364. //We can't use any of the damage that we've lost
  365. if (lostDamage > 0.f)
  366. currentDamage -= lostDamage;
  367.  
  368. //Do we still have enough damage to deal?
  369. if (currentDamage < 1.f)
  370. return false;
  371.  
  372. eyePosition = exitTrace.endpos;
  373. --possibleHitsRemaining;
  374.  
  375. return true;
  376. }
  377. else //Legacy penetration system
  378. {
  379. combinedPenetrationModifier = 1.f;
  380.  
  381. if (isSolidSurf || isLightSurf)
  382. finalDamageModifier = 0.99f; //Good meme :^)
  383. else
  384. {
  385. finalDamageModifier = fminf(enterDamageModifier, exitDamageModifier);
  386. combinedPenetrationModifier = fminf(enterSurfPenetrationModifier, exitSurfPenetrationModifier);
  387. }
  388.  
  389. if (enterMaterial == exitMaterial && (exitMaterial == CHAR_TEX_METAL || exitMaterial == CHAR_TEX_WOOD))
  390. combinedPenetrationModifier += combinedPenetrationModifier;
  391.  
  392. thickness = (exitTrace.endpos - enterTrace.endpos).LengthSqr();
  393.  
  394. if (sqrt(thickness) <= combinedPenetrationModifier * penetrationPower)
  395. {
  396. currentDamage *= finalDamageModifier;
  397. eyePosition = exitTrace.endpos;
  398. --possibleHitsRemaining;
  399.  
  400. return true;
  401. }
  402.  
  403. return false;
  404. }
  405. }
  406.  
  407. bool CAutowall::FireBullet(C_BaseCombatWeapon* pWeapon, SSDK::Vector& direction, float& currentDamage)
  408. {
  409. if (!pWeapon)
  410. return false;
  411.  
  412. SafeLocalPlayer() false;
  413. bool sv_penetration_type;
  414. // Current bullet travel Power to penetrate Distance to penetrate Range Player bullet reduction convars Amount to extend ray by
  415. float currentDistance = 0.f, penetrationPower, penetrationDistance, maxRange, ff_damage_reduction_bullets, ff_damage_bullet_penetration, rayExtension = 40.f;
  416. SSDK::Vector eyePosition = localPlayer->GetEyePos();
  417.  
  418. //For being superiour when the server owners think your autowall isn't well reversed. Imagine a meme HvH server with the old penetration system- pff
  419. static ConVar* penetrationSystem = g_CVar->FindVar(PROTSTR1("sv_penetration_type"));
  420. static ConVar* damageReductionBullets = g_CVar->FindVar(PROTSTR1("ff_damage_reduction_bullets"));
  421. static ConVar* damageBulletPenetration = g_CVar->FindVar(PROTSTR1("ff_damage_bullet_penetration"));
  422.  
  423. sv_penetration_type = penetrationSystem->GetBool();
  424. ff_damage_reduction_bullets = damageReductionBullets->GetFloat();
  425. ff_damage_bullet_penetration = damageBulletPenetration->GetFloat();
  426.  
  427. CCSWeaponInfo* weaponData = pWeapon->GetCSWeaponData();
  428. SSDK::Trace_t enterTrace;
  429.  
  430. //We should be skipping localplayer when casting a ray to players.
  431. CTraceFilter filter;
  432. filter.pSkip = localPlayer;
  433.  
  434. if (!weaponData)
  435. return false;
  436.  
  437. maxRange = weaponData->flRange();
  438.  
  439. GetBulletTypeParameters(penetrationPower, penetrationDistance, weaponData->bulletType(), sv_penetration_type);
  440.  
  441. if (sv_penetration_type)
  442. penetrationPower = weaponData->flPenetration();
  443.  
  444. //This gets set in FX_Firebullets to 4 as a pass-through value.
  445. //CS:GO has a maximum of 4 surfaces a bullet can pass-through before it 100% stops.
  446. //Excerpt from Valve: https://steamcommunity.com/sharedfiles/filedetails/?id=275573090
  447. //"The total number of surfaces any bullet can penetrate in a single flight is capped at 4." -CS:GO Official
  448. int possibleHitsRemaining = 4;
  449.  
  450. //Set our current damage to what our gun's initial damage reports it will do
  451. currentDamage = weaponData->iDamage();
  452.  
  453. //If our damage is greater than (or equal to) 1, and we can shoot, let's shoot.
  454. while (possibleHitsRemaining > 0 && currentDamage >= 1.f)
  455. {
  456. //Calculate max bullet range
  457. maxRange -= currentDistance;
  458.  
  459. //Create endpoint of bullet
  460. SSDK::Vector end = eyePosition + direction * maxRange;
  461.  
  462. TraceLine(eyePosition, end, MASK_SHOT_HULL | CONTENTS_HITBOX, localPlayer, &enterTrace);
  463. Autowall::ClipTraceToPlayers(eyePosition, end + direction * rayExtension, MASK_SHOT_HULL | CONTENTS_HITBOX, &filter, &enterTrace);
  464.  
  465. //We have to do this *after* tracing to the player.
  466. surfacedata_t *enterSurfaceData = g_PhysSurface->GetSurfaceData(enterTrace.surface.surfaceProps);
  467. float enterSurfPenetrationModifier = enterSurfaceData->game.flPenetrationModifier;
  468. int enterMaterial = enterSurfaceData->game.material;
  469.  
  470. //"Fraction == 1" means that we didn't hit anything. We don't want that- so let's break on it.
  471. if (enterTrace.fraction == 1.f)
  472. break;
  473.  
  474. //calculate the damage based on the distance the bullet traveled.
  475. currentDistance += enterTrace.fraction * maxRange;
  476.  
  477. //Let's make our damage drops off the further away the bullet is.
  478. currentDamage *= pow(weaponData->flRangeModifier(), (currentDistance / 500.f));
  479.  
  480. //Sanity checking / Can we actually shoot through?
  481. if (currentDistance > penetrationDistance && weaponData->flPenetration() > 0.f || enterSurfPenetrationModifier < 0.1f)
  482. break;
  483.  
  484. //This looks gay as fuck if we put it into 1 long line of code.
  485. bool canDoDamage = (enterTrace.hitgroup != HitGroups::HITGROUP_GEAR && enterTrace.hitgroup != HitGroups::HITGROUP_GENERIC);
  486. bool isPlayer = ((enterTrace.m_pEnt)->GetClientClass()->m_ClassID == ClassId_CCSPlayer);
  487. bool isEnemy = (((C_BasePlayer*)localPlayer)->m_iTeamNum() != ((C_BasePlayer*)enterTrace.m_pEnt)->m_iTeamNum());
  488. bool onTeam = (((C_BasePlayer*)enterTrace.m_pEnt)->m_iTeamNum() == (int32_t)TeamNumbers::TEAM_CT || ((C_BasePlayer*)enterTrace.m_pEnt)->m_iTeamNum() == (int32_t)TeamNumbers::TEAM_T);
  489.  
  490. //TODO: Team check config
  491. if ((canDoDamage && isPlayer && isEnemy) && onTeam)
  492. {
  493. ScaleDamage(enterTrace, weaponData, currentDamage);
  494. return true;
  495. }
  496.  
  497. //Calling HandleBulletPenetration here reduces our penetrationCounter, and if it returns true, we can't shoot through it.
  498. if (!HandleBulletPenetration(weaponData, enterTrace, eyePosition, direction, possibleHitsRemaining, currentDamage, penetrationPower, sv_penetration_type, ff_damage_reduction_bullets, ff_damage_bullet_penetration))
  499. break;
  500. }
  501. return false;
  502. }
  503.  
  504. ////////////////////////////////////// Usage Calls //////////////////////////////////////
  505. float CAutowall::CanHit(SSDK::Vector &vecEyePos, SSDK::Vector &point)
  506. {
  507. SafeLocalPlayer() - 1.f; //If localplayer isn't avaliable, just return as "too thick"
  508. SSDK::Vector angles, direction;
  509. SSDK::Vector tmp = point - localPlayer->GetEyePos();
  510. float currentDamage = 0;
  511.  
  512. Math::VectorAngles(tmp, angles);
  513. Math::AngleVectors(angles, &direction);
  514. direction.NormalizeInPlace();
  515.  
  516. if (FireBullet(localPlayer->m_hActiveWeapon(), direction, currentDamage))
  517. return currentDamage;
  518. return -1; //That wall is just a bit too thick buddy
  519. }
  520.  
  521. //////////////////////////////////////////////////////////////////////////////////////////////
  522. // Wow I took way too long on autowall.
  523. // Special Thanks to the following (No order intended)
  524. // Killerra
  525. // Flaw
  526. // Zbe
  527. // Heep
  528. // Polak (indirectly; IsBreakable Fix)
  529. // Esoterik (Autowall UC Post)
  530. // N0xius (ScaleDamage)
  531. // Requiii
  532. // drew1ind#8957 (Scaling for ConVar)
  533. // The non-autistic slice of CS:GO-UC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement