Fortress Forever

Go Back   Fortress Forever > Projects > Fortress Forever > Feature

Some LUA stuff Issue Tools
issueid=272 03-07-2010 03:32 PM
Banned
Some LUA stuff

I don't see them on the wiki page, so I'm going to suggest them here. They might be in the standards, but I don't know them, so lolololol here we go:

player_onrepair(player, inflictor)
This is called whenever the player has his armor repaired by a friendly Engineer.

player_onheal(player, inflictor)
This is called whenever the player is healed by a friendly Medic.

player_onfriendlyfire(player, damageinfo)
This should be called whenever the player is hit by friendly fire. Note, this should only be called when FF is off and the attacker ATTEMPTS to friendly fire. I would like to be able to make effects relative to weapons. I'm not sure _ondamage(*) gets called when friendlies shoot each other, so meh. You could rename this to avoid confusion.

Code:
function player_onfriendlyfire(player, damageinfo)
	local inflictor = damageinfo:GetInflictor():GetClassName()
	if(inflictor == 'ff_weapon_spanner' and player:IsFrozen()) then
		BroadCastMessageToPlayer(player, "The Holy Wrench has unfrozen you.")
		player:freeze(false)
	end
	return event_allowed
end
player_onbackstab(player, inflictor)
This is called whenever the player gets backstabbed.

player_ondecloak(player)
This is called whenever a player gets decloaked by an enemy Spy or Scout

player:IsFrozen()
This returns true or false. Simple to do, no need for collections unless iterating through entire teams or something. Do it now. See the example above if you don't have an imagination.

FuncToAll({ CF.k* }, function)
Sure, we could use collections, but if Lua did the work for us, that'd be nice:

Code:
FuncToAll({ CF.kPlayers, CF.kTeamBlue, CF.kPlayerSniper }, Message2Snipers(player))

function Message2Snipers(player)
	BroadCastMessageToPlayer(player, "Stop playing Sniper, you nub.")
	player:RemoveAllWeapons()
end
COMPARE:

Code:
function Message2Snipers(player)
	c = Collection()
	c:GetByFilter({CF.kPlayers, CF.kTeamBlue, CF.kSnipers})
	for temp in c.items do
		local player = CastToPlayer(temp)
		if(player) then
			BroadCastMessageToPlayer(player, "Stop playing Sniper, you nub!")
			player:RemoveAllWeapons()
		end
	end
end
Alright, it's not that bad. The first just feels more intuitive.

RegenerateEntities()
I'm not sure how I would go about refreshing entities on maps (all at once and without using Respawn(), so I am going to suggest this as well. The function should cycle through the array and refresh all entities of that name on the map.

Code:
function BagsBagsBags()
	BroadCastMessage("YOU CAN HAZ BAGZ")
	RegenerateEntities({'grenadebag1', 'grenadebag2'})
end
Of course, this shouldn't/wouldn't work if the entities are deleted, which is my problem. So, I guess we would need a new function for info_ff_script entities?

info_ff_script:Remove()
Removes the entity from the map, but doesn't delete it. Allows that entity to get brought back (in its initial condition) using RegenerateEntities()

That's all I can think of right now.
Issue Details
Issue Type Feature
Project Fortress Forever
Category LUA (Map Scripting)
Status Accepted
Priority 7 - Med/Low
Suggested Version Undefined
Implemented Version (none)
Votes for this feature 1
Votes against this feature 0
Assigned Users (none)
Tags (none)

03-08-2010 06:50 PM
Issue Changed by mervaka
  • Status changed from Suggested to Accepted
Reply

All times are GMT. The time now is 08:32 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.