Thread: [TF2] Cloak API
View Single Post
Author Message
Zabaniya
Junior Member
Join Date: Oct 2020
Location: Fyrestone
Old 09-25-2021 , 16:12   [TF2] Cloak API
Reply With Quote #1

Cloak API

Have you ever wanted to mess with watches, whether for a new custom effect or just detect it? You've come to the right place.

This is an API that provides hooks for developers to use to detect and/or change the behaviours of watches.

It has an SDKHook-like system and it automatically unhooks when a player disconnects, so you won't have to.

Three Main Hooks

- OnActivateInvisibilityWatch: Based on
Code:
CTFWeaponInvis::ActivateInvisibilityWatch()
It gets called whenever a player activates or deactivates the watch.

- OnCleanupInvisibilityWatch: Based on
Code:
CTFWeaponInvis::CleanupInvisibilityWatch()
This function gets called when the player has changed loadouts or has done something else that causes it to clean up any side effects of the watch. It doesn't get called when a player dies for some reason, so I decided to make it call the forward myself. You've got an argument that tells you whether or not it was called because the player died, in case you don't want that behaviour.

- OnUpdateCloakMeter: Based on
Code:
CTFPlayerShared::UpdateCloakMeter()
It gets called every tick to manage the player's cloak drain & regen.

Examples

Here is an example of a plugin that utilizes the API.

https://github.com/tsuza/attr_speed_bonus_during_cloak


Download

Github Repository

Last edited by Zabaniya; 02-04-2024 at 17:42.
Zabaniya is offline