Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

[CS:GO/CS:S] Grenade Path (Prediction)


  • Nie możesz napisać tematu
  • Zaloguj się, aby dodać odpowiedź
Brak odpowiedzi do tego tematu

#1 Adminek AMXX.PL

    Admin :)

  • Bot

Reputacja: 156
Profesjonalista

  • Postów:7 494
  • Lokalizacja:AMXX.PL
Offline

Napisano 14.01.2017 05:45

<div><font size="5"><u><b>[CS:GO/CS:S] GRENADE PATH v1.0 (Grenade Prediction)<br /></b></u></font><br />After posting 2 stupid plugins (no one downloaded :( ), I decided to look through the plugin request forum to find several private request on grenade prediction. After some research, I found that theres no public plugin for this. So I decided to take a look at all the grenade related cpp files from Source SDK 2013 on github. For those interested on how i made this you can read the comments in the source code or the spoiler below:<br /><div style="margin: 5px;">
<div class="smallfont" style="margin-bottom: 2px;">
<b>Spoiler</b> <input value="Show" style="margin: 0px; padding: 0px; width: 45px; font-size: 10px;" onclick="if(this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != 'inline')
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'inline'; this.innerText = ''; this.value = 'Hide'; }
else
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value='Show'; }" type="button">
</div>
<div class="alt2" style="border: 1px inset; padding: 6px;">
<div class="spoiler" style="display: none;"><br />Pulled grenade detection (simple):<br />OnPlayerRunCmd + check if player holding down IN_ATTACK + check if current player weapon is a type of grenade<br /><br />Grenade detonation time: retrieved from weapon_grenade.cpp<br />1.5s for hegrenade and flashbang<br />3.0s for smokegrenade decoy (i made this up myself but it accurate)<br />Detonate on contact with ground for incgrenade/molotov<br /><br />Calculation of grenade initial conditions (weapon_basesdkgrenade.cpp):<br />Initial position - offset from GetClientEyePosition<br />Throwing angle - calculated from the pitch angle of GetClientEyeAngles<br />Throwing velocity - defined in cpp file<br /><br />Building the grenade path:<br />Use For Loop + TR_TraceHullEx + TE_SetUpBeamPoints<br />For Loop runs for the whole detonation time with small increments of timestep<br />TR_TraceHullEx with hull size of 4x4x4 box check sdk_basegrenade_projectile.cpp<br />TE_SetUpBeamPoints to draw the trace<br /><br />For Loop Sequence:<br /><br />1. Calculate endpoint for the trace of this loop using kinematics (see source code, its just x = x0 + v0 * t ) taking into account of gravity. Update grenade velocity in z direction.<br /><br />2. Do a Hull Trace from Initial position to endpoint<br /><br />3. Check for collision<br />- If there is collision, overwrite endpoints with TR_GetEndPosition<br />- Calculate the new grenade velocity vector using conservation of momentum (assume perfectly elastic collision first). It just simply find the component of velocity parallel to the surface normal and reverse its sign<br />- apply inelastic coefficient (sdk_basegrenade_projectile.h)<br />- check if collision is on the ground, if yes, stop calculation for incgrenade and molotov<br /><br />4. Draw a laserbeam between initial position and endpoint<br /><br />5. Set next start point as current endpoint<br /><br />6. Repeat loop<br /><br /></div>
</div>
</div><br /><br /><b>Feature List:</b><ul><li> Tested and working for CS:GO hegrenade/smokegrenade/flashbang/incgrenade/decoy, molotov not tested yet</li>
<li> Shows a predicted path of your grenade as you hold down the attack button (mouse left button)</li>
<li> The predicted path ends at where your grenade will detonate</li>
<li> Different type of grenade will have different coloured path</li>
</ul><br /><b>CVAR list:</b><br /><div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB">sm_grenadepath&nbsp;1&nbsp;</span><span style="color: #FF8000">//&nbsp;Enable/disable&nbsp;plugin<br /></span><span style="color: #0000BB">sm_grenadepath&nbsp;25.0&nbsp;</span><span style="color: #FF8000">/*&nbsp;Number&nbsp;of&nbsp;iterations&nbsp;for&nbsp;path&nbsp;calculation<br />higher&nbsp;numbers&nbsp;=&nbsp;more&nbsp;accurate&nbsp;but&nbsp;at&nbsp;your&nbsp;performance&nbsp;expense.&nbsp;Min:&nbsp;15.0&nbsp;Max:&nbsp;45.0<br />dont&nbsp;go&nbsp;beyond&nbsp;these&nbsp;values&nbsp;else&nbsp;it&nbsp;looks&nbsp;glitchy&nbsp;due&nbsp;to&nbsp;the&nbsp;fixed&nbsp;beamlife&nbsp;of&nbsp;the&nbsp;path&nbsp;and&nbsp;the&nbsp;different&nbsp;timestep&nbsp;of&nbsp;the&nbsp;loop*/&nbsp;
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div><b>Limitations:</b><ul><li> The predicted path will treat all surface as unbreakable i.e. doesnt work when your grenade breaks some props such as windows, glass</li>
<li> If your map have moving surfaces or portals, does not work as well</li>
<li> If you used other plugins to change the detonation time of grenades, you can edit the corresponding values in the source file</li>
<li> Rarely, the grenade bounce differently since my prediction does not include angular velocity/momentum</li>
</ul><br /><b>To Do:</b><ul><li> Add CVars to customise beam color and size</li>
<li> Solve the above limitations</li>
<li> Add a video</li>
</ul><br /><b>Changelog:</b><br /><div style="margin:20px; margin-top:5px; ">
<div class="smallfont" style="margin-bottom:2px">Quote:</div>
<table cellpadding="6" cellspacing="0" border="0" width="100%">
<tr>
<td class="alt2">
<hr />

14th Jan 2017 (v1.0)<br />* Initial release.

<hr />
</td>
</tr>
</table>
</div>Note: If you found any bugs or have any request, please post a reply thanks! :)</div>


<br /> <div style="padding:6px">








<fieldset class="fieldset">
<legend>Attached Files</legend>
<table cellpadding="0" cellspacing="3" border="0">
<tr>
<td><img class="inlineimg" src="https://forums.allie.../attach/sp.gif"alt="File Type: sp" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
<td>


<a href="http://www.sourcemod...99"><strong>GetPlugin</strong></a> or
<a href="https://forums.allie...1484369092">GetSource</a> (grenadepath.sp - 9.8 KB)


</td>
</tr>
</table>
</fieldset>


</div>

Wyświetl pełny artykuł




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych