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 12:40 AM
 
For backstabs... You could maybe hack something with damageinfo--if the inflictor is ff_weapon_knife and the damage is more than a normal knife hit, do the thing.

Remove() and Restore() already exist. Look at base_id (need to add those to the wiki).
Reply
03-08-2010 01:24 AM
Gets tickled by FF
 
Carl, I'd put it in a sticky "to-do" dev thread to remind us of things that need to be documented on wiki. Not sure if we have one already but rather than risk forgetting
Reply
03-08-2010 05:02 PM
internet user
 
That last stuff you're asking for is basically spawning/despawning functions while keeping the entity around in memory regardless? Would something like hide or enabled be more clear
Reply
03-08-2010 05:22 PM
Banned
 
The functions already exist :Remove() and :Restore(). I missed them on the Wiki. Also, add to that list AT.kChangeTeamAutoAssign and AT.kChangeTeamRandom.
Reply
03-08-2010 06:51 PM
A Very Sound Guy!
 
Quote:
Originally Posted by Elmo
Carl, I'd put it in a sticky "to-do" dev thread to remind us of things that need to be documented on wiki. Not sure if we have one already but rather than risk forgetting
i just changed the status to "accepted" - is that ok for now? :)
Reply
03-08-2010 07:09 PM
Gets tickled by FF
 
guess that'd do lol :P - I kinda forgot the point of this thing.
Reply
03-08-2010 07:46 PM
A Very Sound Guy!
 
does anyone know if player_ondamage is called when a player is healed/repaired?
Reply
03-08-2010 07:50 PM
A Very Sound Guy!
 
also

Code:
.def("IsFrozen",			&CFFPlayer::LuaIsPlayerFrozen)
IsFrozen should already be implemented
Reply
03-08-2010 08:24 PM
Banned
 
Also, I know there's GetScore() and AddScore(), how about SubtractScore() and SetScore()?
Reply
03-08-2010 08:50 PM
A Very Sound Guy!
 
entirely possible.
Reply
03-08-2010 08:50 PM
Stuff Do-er
 
I added IsFrozen very recently. It'll be in the next patch.
Reply
03-08-2010 09:26 PM
UI Designer
Front-End Developer
 
How about you add changeMapName, so when we have long ass titles like ff_scrummage_classic_b37847583765 it doesnt get cut off :D So instead it'd be Scrummage Classic.
Reply
03-09-2010 06:19 AM
 
FuncToAll looks like a good idea.

Anything that shortens / cleans up our (TERRIBLE MESS) lua files is a good thing.
Reply
03-09-2010 06:47 AM
 
We have a couple of threads in the Lua forum. What I need is a full list of scriptable objects and their functions. I've done a lot with the old pages, some partial lists, and code that I've seen used, but it's still very incomplete. Some tutorials would be good, too.
Reply
03-09-2010 10:32 PM
 
BTW just to make everyone aware, lua callbacks cost resources. I dont know exactly how expensive they are but we need to be wary of it. If everything players ever do causes a callback then i expect lua will start to slow the game down.
Reply
Reply

Issue Tools
Subscribe to this issue

All times are GMT. The time now is 10:58 PM.


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