AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [L4D2] Offset to get duration of the "insect_swarm" entity (https://forums.alliedmods.net/showthread.php?t=332313)

cravenge 05-05-2021 09:12

[L4D2] Offset to get duration of the "insect_swarm" entity
 
As the title says, I want to know how long the spit puddles last before they fade away. I've seen that in l4d2_uniform_spit's source code:
PHP Code:

// I transitioned it to new syntax on my end
float GetPuddleLifetime(int entity)
{
    return 
ITimer_GetElapsedTime(view_as<IntervalTimer>(GetEntityAddress(entity) + view_as<Address>(2968)));


I've tried figuring out how to find that offset but I came to a dead end so I took a look at the game's binaries and found CInsectSwarm::GetFlameLifetime.

Is the function mentioned above perhaps similar to the code by any chance? If so, I'm gonna call that one through SDKTools instead.

BHaType 05-05-2021 21:31

Re: [L4D2] Offset to get duration of the "insect_swarm" entity
 
Quote:

Originally Posted by cravenge (Post 2746007)
As the title says, I want to know how long the spit puddles last before they fade away. I've seen that in l4d2_uniform_spit's source code:
PHP Code:

// I transitioned it to new syntax on my end
float GetPuddleLifetime(int entity)
{
    return 
ITimer_GetElapsedTime(view_as<IntervalTimer>(GetEntityAddress(entity) + view_as<Address>(2968)));


I've tried figuring out how to find that offset but I came to a dead end so I took a look at the game's binaries and found CInsectSwarm::GetFlameLifetime.

Is the function mentioned above perhaps similar to the code by any chance? If so, I'm gonna call that one through SDKTools instead.

CInsectSwarm inherits from the CInferno class that stores the creation timestamp

Elapsed time = GetGameTime() - stored timestamp
Remaining time before insect_swarm will be killed = CInsectSwarm::GetFlameLifetime() - Elapsed time

You can also calculate the time manually without using offsets

Below are two ways to get the remaining time
Spoiler

cravenge 05-06-2021 13:26

Re: [L4D2] Offset to get duration of the "insect_swarm" entity
 
Quote:

Originally Posted by BHaType (Post 2746067)
CInsectSwarm inherits from the CInferno class that stores the creation timestamp

Elapsed time = GetGameTime() - stored timestamp
Remaining time before insect_swarm will be killed = CInsectSwarm::GetFlameLifetime() - Elapsed time

You can also calculate the time manually without using offsets

Below are two ways to get the remaining time
Spoiler

This is just what I needed. Thank you so much!


All times are GMT -4. The time now is 17:46.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.