Difference between revisions of "Category:Damageinfo functions"

From Fortress Forever Wiki
Jump to navigationJump to search
(New page: Damageinfo is an object that's passed along whenever a player is damaged or dies. By intercepting this object, you can detect events in the game, or change the outcome of those events. Dam...)
 
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
Damageinfo is an object that's passed along whenever a player is damaged or dies. By intercepting this object, you can detect events in the game, or change the outcome of those events. Damageinfo can be accessed from within the callbacks [[Lua:player_ondamage|player_ondamage]] and [[Lua:player_onkilled|player_onkilled]].
+
{{Infobox manual/Header}}
 +
{{Infobox_mapping}}
 +
Damageinfo is an object that's passed along whenever a player is damaged or dies. By intercepting this object, you can detect events in the game, or change the outcome of those events. Damageinfo can be accessed from within the callbacks [[Lua:player_ondamage|player_ondamage]], [[Lua:buildable_ondamage|buildable_ondamage]] and [[Lua:player_killed|player_killed]].
  
 
===Usage===
 
===Usage===
Line 21: Line 23:
 
attacker_is_buildable = true
 
attacker_is_buildable = true
 
end
 
end
if attacker_is_buildable ~= true and weapon ~= "ff_weapon_sniperrifle" and weapon ~= "ff_weapon_crowbar" and weapon ~= "ff_projectile_dart" and weapon ~= "ff_weapon_knife" then
+
if attacker_is_buildable ~= true and weapon ~= "ff_weapon_sniperrifle" and
 +
weapon ~= "ff_weapon_crowbar" and weapon ~= "ff_projectile_dart" and weapon ~= "ff_weapon_knife" then
 
damageinfo:ScaleDamage(0)
 
damageinfo:ScaleDamage(0)
 
else
 
else
Line 41: Line 44:
  
 
===Functions===
 
===Functions===
TODO: list parameters, return types, and descriptions
+
{| border="1" cellspacing="2" cellpadding="5"
GetAttacker  
+
! Command !! Description
GetInflictor
+
|-
GetDamage  
+
|entity GetAttacker() || Returns the entity that did damage. May be a player or buildable.
GetDamageForce  
+
|-
GetDamagePosition  
+
|GetInflictor() || Returns the object that caused the damage. May be a weapon, projectile, or grenade.
GetDamageType
+
|-
GetAmmoType
+
|GetDamage() || Returns the current damage being dealt.
ScaleDamage
+
|-
SetDamage
+
|Vector GetDamageForce() || Returns the push force being dealt as a vector.
 +
|-
 +
|GetDamagePosition() || REturns the position of the damage event as a vector?
 +
|-
 +
|GetDamageType()
 +
|-
 +
|GetAmmoType()
 +
|-
 +
|ScaleDamage(float) || Multiply the damage done by this number.
 +
|-
 +
|SetDamage(float) || Do this amount of damage
 +
|-
 +
|SetDamageForce( Vector(0,0,0) ) || Sets a new force vector to push the player that is being damaged.
 +
|}
  
 
[[Category:Lua]]
 
[[Category:Lua]]
 
[[Category:Lua_Commands]]
 
[[Category:Lua_Commands]]
 +
{{Infobox manual/Footer}}

Latest revision as of 20:57, 10 November 2014


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

Damageinfo is an object that's passed along whenever a player is damaged or dies. By intercepting this object, you can detect events in the game, or change the outcome of those events. Damageinfo can be accessed from within the callbacks player_ondamage, buildable_ondamage and player_killed.

Usage

CTakeDamageInfo: function(parameters)

Example

function player_ondamage( player, damageinfo )

	-- if no damageinfo do nothing
	if not damageinfo then return end

	local attacker = damageinfo:GetAttacker()
	local inflictor = damageinfo:GetInflictor()

	-- hunted has body armor on and only takes damage from certain things
	if player:GetTeamId() == Team.kBlue then
		local weapon = damageinfo:GetInflictor():GetClassName()
		local attacker_is_buildable = false

		if IsSentrygun(attacker) or IsDispenser(attacker) or IsSentrygun(inflictor) or IsDispenser(inflictor) then
			attacker_is_buildable = true
		end
		if attacker_is_buildable ~= true and weapon ~= "ff_weapon_sniperrifle" and
 weapon ~= "ff_weapon_crowbar" and weapon ~= "ff_projectile_dart" and weapon ~= "ff_weapon_knife" then
			damageinfo:ScaleDamage(0)
		else
		end

	-- hunted also has quad damage
	else
		if IsPlayer( attacker ) then
			attacker = CastToPlayer( attacker )
			if attacker:GetTeamId() == Team.kBlue and player:GetTeamId() ~= HUNTED_ALLIES_TEAM then
				damageinfo:ScaleDamage(4)
				attacker:AddFortPoints( POINTS_PER_HUNTED_ATTACK * 10, "Hunted Attack" )
				ConsoleToAll( "The Hunted, " .. attacker:GetName() .. ", dealt quad damage to" .. player:GetName() .. "!" )
			end
		end
	end
end

Functions

Command Description
entity GetAttacker() Returns the entity that did damage. May be a player or buildable.
GetInflictor() Returns the object that caused the damage. May be a weapon, projectile, or grenade.
GetDamage() Returns the current damage being dealt.
Vector GetDamageForce() Returns the push force being dealt as a vector.
GetDamagePosition() REturns the position of the damage event as a vector?
GetDamageType()
GetAmmoType()
ScaleDamage(float) Multiply the damage done by this number.
SetDamage(float) Do this amount of damage
SetDamageForce( Vector(0,0,0) ) Sets a new force vector to push the player that is being damaged.

This category currently contains no pages or media.