Difference between revisions of "Lua:Effect-triggered callbacks"

From Fortress Forever Wiki
Jump to navigationJump to search
(New page: These callbacks are triggered whenever a player is afflicted with a Status Effect. Returning false will prevent the effect from occurring. ===Inputs=== *playe...)
 
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
{{Infobox_mapping}}
 
These callbacks are triggered whenever a player is afflicted with a [[:Category:Status Effects|Status Effect]]. Returning false will prevent the effect from occurring.
 
These callbacks are triggered whenever a player is afflicted with a [[:Category:Status Effects|Status Effect]]. Returning false will prevent the effect from occurring.
  
Line 91: Line 92:
 
</pre>
 
</pre>
  
[[Category:Lua Callbacks]]
+
[[Category:Lua Callbacks]][[Category:Global Callbacks]]
 
{{Infobox manual/Footer}}
 
{{Infobox manual/Footer}}

Latest revision as of 20:11, 28 June 2009

Mapping for FF
The Basics

Setting up Hammer
Getting Started With Lua
Releasing a map

FF-specific Entities

Lua location system

Map Templates
FF Lua Documentation

Entity Typing
Entity Collections

Commands
Callbacks

These callbacks are triggered whenever a player is afflicted with a Status Effect. Returning false will prevent the effect from occurring.

Inputs

  • player_entity(CBaseEntity) The entity that got the effect.
  • effector_entity(CBaseEntity) The entity that caused the effect.

Variables

The following variables are set in the global lua namespace before the function is called. Changing these variables will alter the duration or severity of the effect. Ignoring them will leave them at default values. Setting a duration to -1 will cause it to last forever.

LUA Command Description
player_onconc( player, inflictor ) triggers when a player is conced.

conc_duration -- duration of conc

conc_iconduration -- duration of conced icon on HUD

player_ontranq( player, inflictor ) triggers when a player is tranq'd.

tranq_duration -- duration of tranq.

tranq_speed -- speed of tranq'd player.

player_ongas( player, inflictor ) triggers when a player is gassed.

gas_duration

gas_iconduration

player_oninfect( player, inflictor ) triggers when a player is infected.

infection_duration

infect_iconduration

player_onradiotag( player, inflictor ) triggers when a player is tagged by a sniper.

radiotag_duration radiotag_iconduration

player_onheadshot( player, inflictor ) triggers when a player is head-shot.
player_onlegshot( player, inflictor ) triggers when a player is leg-shot.

legshot_duration

legshot_iconduration

legshot_speed

player_oncaltrop( player, inflictor ) Obsolete.

caltrop_duration

caltrop_iconduration

caltrop_speed

player_onacspinup( player, inflictor ) triggers when a player revs up an autocannon.

acspinup_duration

acspinup_speed

player_onsniperrifle( player, inflictor ) triggers when a player charges a sniperrifle.

sniperrifle_speed

player_onspeedluaX( player, inflictor ) these are for various speed settings, like CZ2's flags. Replace X with a number 1 to 10.

speedlua_speed

Examples


function player_onconc(player_entity, effector_entity)
	-- make conc effect last 20 seconds
	conc_duration = 20
	-- make conc status icon last 1 second
	conc_iconduration = 1

	return EVENT_ALLOWED
	-- or you can just return “true” to let the conc happen. If you return false no conc effect happens
end
-- player_entity is guy getting conc’d
-- effector_entity is the one doing the conc’ing
function player_onconc(player_entity, effector_entity)
	--effector_entity is a CBaseEntity type, we need to verify that it's a player before we do anything with it
	if isPlayer(effector_entity) then
		local concer = CastToPlayer(effector_entity)
		--Award some fortress points for concing somebody.
		concer:AddFortPoints(5, "Conc-Tagging a player")
	end
	--Don't actually concuss the other guy
	return false
end