List of L4D2 Script Functions/AddThinkToEnt

From Valve Developer Community
Jump to: navigation, search

Turns a function of an entity's script into a think function, which is a function that constantly reruns again and again. By default, think functions attempt to run every 0.1 seconds, though think functions can reconfigure its rethink rate by simplying returning a number. There can only be one think function for each entity at a time, so you can't chain think functions; You can however passnullas an argument under funcname to stop this entity from thinking.

See this sub-section of the Entity Scripts page to know more about think functions.

Parameters

void AddThinkToEnt(CBaseEntity entity,string funcname)

Type Name Description
CBaseEntity entity Target entity to be applied a think function.
string funcname Given the string, find the function of the exact same name (no brackets allowed!). Passnullto remove it.

Code Samples

Fastest Rethink Rate

L4D2ScriptFunctions AddThinkToEnt-FastestRethinkRate.png

When ran, an info_target will be spawned with a think function that automatically uses the fastest possible rethink rate (that's capped). The think function uses ClientPrint() and fills the chatbox about how long the game has been running. When it has sent the messages 30 times, the entity will then delete itself, thus halting the think function.

Since <Left 4 Dead 2> runs on 30 ticks by default, think functions can never run faster than 0.03333... seconds. See this sub-section of the Entity Scripts page to know more about think functions.



Survivor Health Decay

Look at Rochelle, Ellis and Coach's health.

This script applies a slow think function onto all players, which will then slowly decay their normal health, and turn it into temporary health. It also implements a buffer system, a period where health decay attempts will not be allowed.