Left 4 Dead 2
Left 4 Dead 2 is a single-player and multiplayer co-operative survival horror FPS game.
VSLib Developer Guide - Damage, Update, Chat Hooks
6,807
InterceptChat() Hooks
Sometimes, you just want plain 'ol Valve InterceptChat(). You can access this by typing the following:
// str is the original string, and srcEnt is the CBaseEntity object that spoke
function MyInterceptChat ( str, srcEnt )
{
	...
}

// Add the intercept chat hook
EasyLogic.AddInterceptChat ( MyInterceptChat );

// And here's how you remove the hook if needed
EasyLogic.RemoveInterceptChat ( MyInterceptChat );
Using this approach, you can have as many InterceptChat functions as you want...
AllowTakeDamage() Hooks
Creating the Hooks

The process for damage hooking is pretty simple. Just create a function somewhere with the following template:
function EasyLogic::OnTakeDamage::YourFunctionName ( damageTable )
{
	... your code AllowTakeDamage code ...
}
You can have as many as you want. Just be sure to change the function name each time.


Filtering by Classname

There's also a handy feature to filter damage notifications by classname. For example, to only receive damage notifications on players and prop_physics:
// For dynamic props
function EasyLogic::OnDamage::prop_physics ( victim, attacker, damageDone, damageTable )
{
	... your code for prop_physics damage calculation ...
}


// For players
function EasyLogic::OnDamage::player ( victim, attacker, damageDone, damageTable )
{
	... your code for player damage calculation ...
}
You can define as many different classnames as you want, mix and match with the previous OnTakeDamage hooks, and whatnot. Hopefully that made sense.
Update() Hooks
Same process. Just create a function somewhere with the following template:
function EasyLogic::Update::YourFunctionName ( )
{
	... your Update code ...
}
You can have as many as you want. Just be sure to change the function name each time.
I found this article helpful
I did not find this article helpful
What people are saying...
You must be logged in to post a comment.
There are no comments yet for this guide.