RSSy MYGO.pl Opublikowano Styczeń 14, 2017 o 04:45 RSSy Udostępnij Opublikowano Styczeń 14, 2017 o 04:45 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: Spoiler Pulled grenade detection (simple): OnPlayerRunCmd + check if player holding down IN_ATTACK + check if current player weapon is a type of grenade Grenade detonation time: retrieved from weapon_grenade.cpp 1.5s for hegrenade and flashbang 3.0s for smokegrenade decoy (i made this up myself but it accurate) Detonate on contact with ground for incgrenade/molotov Calculation of grenade initial conditions (weapon_basesdkgrenade.cpp): Initial position - offset from GetClientEyePosition Throwing angle - calculated from the pitch angle of GetClientEyeAngles Throwing velocity - defined in cpp file Building the grenade path: Use For Loop + TR_TraceHullEx + TE_SetUpBeamPoints For Loop runs for the whole detonation time with small increments of timestep TR_TraceHullEx with hull size of 4x4x4 box check sdk_basegrenade_projectile.cpp TE_SetUpBeamPoints to draw the trace For Loop Sequence: 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. 2. Do a Hull Trace from Initial position to endpoint 3. Check for collision - If there is collision, overwrite endpoints with TR_GetEndPosition - 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 - apply inelastic coefficient (sdk_basegrenade_projectile.h) - check if collision is on the ground, if yes, stop calculation for incgrenade and molotov 4. Draw a laserbeam between initial position and endpoint 5. Set next start point as current endpoint 6. Repeat loop Feature List: Tested and working for CS:GO hegrenade/smokegrenade/flashbang/incgrenade/decoy, molotov not tested yet Shows a predicted path of your grenade as you hold down the attack button (mouse left button) The predicted path ends at where your grenade will detonate Different type of grenade will have different coloured path CVAR list: PHP Code: sm_grenadepath 1 // Enable/disable plugin sm_grenadepath 25.0 // Number of iterations for path calculation //higher numbers = more accurate but at your performance expense. Min: 15.0 Max: 45.0 //dont go beyond this values else it looks glitchy due to the fixed beamlife of the path and the different timestep of the loop Limitations: The predicted path will treat all surface as unbreakable i.e. doesnt work when your grenade breaks some props such as windows, glass If your map have moving surfaces or portals, does not work as well If you used other plugins to change the detonation time of grenades, you can edit the corresponding values in the source file Rarely, the grenade bounce differently since my prediction does not include angular velocity/momentum To Do: Add CVars to customise beam color and size Solve the above limitations [B/]Changelog:[/B] Quote: 14th Jan 2017 (v1.0) * Initial release. Note: If you found any bugs or have any request, please post a reply thanks! :) Attached Files Get Plugin or Get Source (grenadepath.sp - 9.8 KB) Wyświetl pełny artykuł Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
Rekomendowane odpowiedzi
Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto
Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.
Zarejestruj nowe konto
Załóż nowe konto. To bardzo proste!
Zarejestruj sięZaloguj się
Posiadasz już konto? Zaloguj się poniżej.
Zaloguj się