Thread: Nades Api
View Single Post
Plugin Info:     Modification:          Category:          Approver:   Arkshine (91)
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-26-2013 , 02:10   Nades Api
Reply With Quote #1

Nades Api



.: Description :.


Little Api that let's you know by forwards when a grenade is bouncing or is exploding, is smoking after the explosion, or is simply thinking because it's not time to to something else yet.
This plugin also exposes some natives to retrieve those functions indexes (internally it is pointers but we can use them as integers) that are used with pdata m_pThink and m_pUse.



.: How does the game works :.


When a grenade is shot, its m_pfnTouch function is set to BounceTouch, this function is called internally each time a nade is touching the world (sound is only played on 5 first times).

At grenade shot, m_pfnThink is set to TumbleThink for flash and hegrenade, and to SG_TumbleThink for smokegrenade, this is default think and ends when pev->dmgtime <= gpGlobals->time (and for smoke if nade is on the ground)
Then, m_pfnThink is change to Detonate, Detonate3 and SG_Detonate for respectlively flashbangs, hegrenades and smokegrenades, this is during those functions that specific grenade actions are done (flash, explosion and smoke).
After those actions it is not complitely finished, m_pfnThink is change to Smoke, Smoke3_C and SG_Smoke (same nades types order), this is function where you gonnna see little black smoke before a nade is about to die.



.: Forwards :.


Code:
// Flash forwards forward OnFlashNadenadeBounceTouch(ent, pOther); forward OnFlashNadeTumbleThink(ent); forward OnFlashNadeDetonate(ent); forward OnFlashNadeSmoke(ent); // HeGrenade forwards forward OnHeNadenadeBounceTouch(ent, pOther); forward OnHeNadeTumbleThink(ent); forward OnHeNadeDetonate(ent); forward OnHeNadeSmoke(ent); // SmokeGrenade forwards forward OnSmokeNadenadeBounceTouch(ent, pOther); forward OnSmokeNadeTumbleThink(ent); forward OnSmokeNadeDetonate(ent); forward OnSmokeNadeSmoke(ent);



.: Natives :.


Code:
// Returns TumbleThink index        // FLASH    // HE native Get_Nade_TumbleThink(); // Returns BounceTouch index        // FLASH    // HE   // SMOKE native Get_Nade_BounceTouch(); // Returns Detonate index         // FLASH native Get_Nade_Detonate(); // Returns Smoke index        // FLASH native Get_Nade_Smoke(); // Returns Detonate3 index      // HE native Get_Nade_Detonate3(); // Returns Smoke3_C index         // HE native Get_Nade_Smoke3_C(); // Returns SG_TumbleThink index  // SMOKE native Get_Nade_SG_TumbleThink(); // Returns SG_Detonate index        // SMOKE native Get_Nade_SG_Detonate(); // Returns SG_Smoke index         // SMOKE native Get_Nade_SG_Smoke();



.: Notes :.


You need those includes in order to compile plugin : https://forums.alliedmods.net/showth...01#post1712101
!! NEW !! Experimental version with C4 forwards and natives here : https://forums.alliedmods.net/showth...20#post1923720



Attached Files
File Type: sma Get Plugin or Get Source (nades_api.sma - 1265 views - 10.1 KB)
File Type: inc nades_api.inc (1.3 KB, 910 views)
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 03-31-2013 at 18:25.
ConnorMcLeod is offline