Fortress Forever

Go Back   Fortress Forever > Editing > Mapping > Lua

Reply
 
Thread Tools Display Modes
Old 09-27-2007, 04:38 AM   #1
Mulchman MM
Retired FF Staff
 
Mulchman MM's Avatar
 
Join Date: Dec 2004
Location: Lacey, WA
Posts Rated Helpful 0 Times
Send a message via ICQ to Mulchman MM Send a message via AIM to Mulchman MM Send a message via MSN to Mulchman MM Send a message via Yahoo to Mulchman MM Send a message via Skype™ to Mulchman MM
Lua Callbacks

Okay, I started documenting the callbacks but got tired of it very quickly. This is sort of a high level programmer type overview as that's the quickest way I could do this. This documents a lot but not all of the callbacks the game makes into Lua. I started writing it as a .doc for a PM so that's why the format is like I'm talking to someone specifically or something.

Quote:
Okay, Lua callbacks.

In quotations is the callback name (and case). Next is whether the function is global or is invoked on an existing object. If invoked on an object then the word “entity” is available to the Lua script as the actual object the script is being called on – so you could do stuff like “IsPlayer(entity)” even if there’s no mention of entity in the function already. If it’s a global function then “entity” is nil. Next are any arguments – the forward slash should be treated as an “or”, and commas will be used to designate multiple arguments. Next is the return value – “none” indicates no return value is needed. Finally, there’s a short description of when it’s used or something.

“startup” – global – () – none – called during ff_restartround. I think it should be called during map startup as well but I didn’t check

“validspawn” – info_ff_teamspawn – (CFFPlayer *) – true / false – called on a spawn point and returns true/false for whether the player can spawn at the spawn point

“validtarget” – ff_miniturret – (CBaseEntity *) – true / false – called on a turret to see if the player / sg / dispenser it is targeting is a valid target or not [cast appropriately]

“deploydelay” – ff_miniturret – (CBaseEntity *) – float – called on a turret to get the delay until it should deploy [the parameter could be a player / sg / dispenser but is sent as a CBaseEntity * and would need to be cast appropriately before anything was done to it)

“onownercloak” – CBaseEntity * [ie. info_ff_script] - (CFFPlayer *) – none – called on each info_ff_script the player ‘owns’ (is carrying) so that the entity can be notified the player is cloaking and do something about it (get dropped perhaps)

“spawn” – trigger_ff_clip – () – none – called when a trigger_ff_clip gets spawned

“player_killed” – global – (CFFPlayer *, CTakeDamageInfo *) – none – called when a player is killed. On /kill no CTakeDamageInfo is passed along . On changing class this is also called with no CTakeDamageInfo. On changing team this is also called with no CTakeDamageInfo.

Okay, I’m already tired of doing this. I’m just going to jump to player specific stuff…

“player_onkill” – global – (CFFPlayer *) – true / false – called to see whether the player can /kill themselves or not

“player_spawn” – global – (CFFPlayer *) – none – called when a player is spawning

“player_switchteam” – global – (CFFPlayer *, current team number [int], proposed team number [int]) – true / false – called when a player tries to switch team

“flaginfo” – global – (CFFPlayer *) – none – called when a player hits their flaginfo key

“dropitemcmd” – CBaseEntity * [ie. info_ff_script] – (CFFPlayer *) – none – called on each item the player ‘owns’ when the player hits their drop items button

“player_onthrowgren1 / 2” – global – (CFFPlayer *, prime time [float]) – true / false – called when trying to release a grenade

“player_ondamage” – global – (CFFPlayer *, CTakeDamageInfo *) – none – called when a player takes damage. The CTakeDamageInfo can be modified by Lua.

And I’m kind of done for the moment. There’s a ton of the Lua effect ones that need to be documented. Most of these allow you to change or deny the effect, change the duration of the effect [with -1 being infinite], and change the icon duration [like the status icon (again with -1 being infinite)]. Most of these take player being effected and then a CBaseEntity * of the entity/player doing the effecting.

These events start with “onplayer%s” and fill %s with:

“fire”, “conc”, “gas”, “infect”, “radiotag”, “headshot”, “legshot”, “tranq”, “caltrop”, “acspinup”, “sniperrifle”, speedlua1”, “speedlua2”, up to “speedlua10” (so you could have up 10 speed effects Lua controlled).

Duration is initially set to 0, icon duration is initially set to 0, and speed is initially set to 0. If any of the events don’t use these they’ll always stay 0 otherwise they’ll be filled in with the default values for you to modify and return back to the game.

These variables are “%s_duration”, “%s_iconduration”, “%s_speed” where %s are the events listed above (like “fire”, “conc”, etc).

So, in Lua you’d have something like:

Code:
-- player_entity is guy getting conc’d
-- effector_entity is the one doing the conc’ing
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
Hopefully some of this helps.
__________________
Head of the Orca Revolution (TM)

Last edited by Mulchman MM; 09-27-2007 at 04:44 AM.
Mulchman MM is offline   Reply With Quote


Old 09-27-2007, 11:05 PM   #2
AltPluzF4
Newb
 
AltPluzF4's Avatar
 
Join Date: Sep 2007
Posts Rated Helpful 0 Times
Send a message via ICQ to AltPluzF4 Send a message via AIM to AltPluzF4 Send a message via MSN to AltPluzF4 Send a message via Yahoo to AltPluzF4
Great! But, are there any functions for player joining and leaving the server?
Those would be very useful!

Thanks.
AltPluzF4 is offline   Reply With Quote


Old 09-27-2007, 11:18 PM   #3
DeviusCreed
 
Join Date: Mar 2007
Posts Rated Helpful 0 Times
I am attempting to remove the radiotag for usage in snipermaps but with little success. according to this post the following should work, correct? But it doesn't.

function player_onradiotag(player_entity, effector_entity)
return EVENT_DISALLOWED
end

I also tried using the following to shorten to almost nothing but still doesn't do anything.

function player_onradiotag(player_entity, effector_entity)

radiotag_duration = 1
radiotag_iconduration = 1
return EVENT_ALLOWED

end
DeviusCreed is offline   Reply With Quote


Old 09-27-2007, 11:36 PM   #4
AltPluzF4
Newb
 
AltPluzF4's Avatar
 
Join Date: Sep 2007
Posts Rated Helpful 0 Times
Send a message via ICQ to AltPluzF4 Send a message via AIM to AltPluzF4 Send a message via MSN to AltPluzF4 Send a message via Yahoo to AltPluzF4
Yeah, the player_ongas doesn't work either. I believe some of those that Mulch posted are from the developers build, so expect their use in the first patch.
AltPluzF4 is offline   Reply With Quote


Old 09-28-2007, 12:39 AM   #5
Mulchman MM
Retired FF Staff
 
Mulchman MM's Avatar
 
Join Date: Dec 2004
Location: Lacey, WA
Posts Rated Helpful 0 Times
Send a message via ICQ to Mulchman MM Send a message via AIM to Mulchman MM Send a message via MSN to Mulchman MM Send a message via Yahoo to Mulchman MM Send a message via Skype™ to Mulchman MM
Some of the effect ones might not work as I don't remember if I actually finished that stuff when working on it waaaaaay back. I know onconc works. :P
__________________
Head of the Orca Revolution (TM)
Mulchman MM is offline   Reply With Quote


Old 09-28-2007, 12:53 AM   #6
mervaka
A Very Sound Guy!
Fortress Forever Staff
 
mervaka's Avatar
 
Join Date: May 2005
Location: UK
Posts Rated Helpful 15 Times
Quote:
Originally Posted by DeviusCreed
I am attempting to remove the radiotag for usage in snipermaps but with little success. according to this post the following should work, correct? But it doesn't.

function player_onradiotag(player_entity, effector_entity)
return EVENT_DISALLOWED
end

I also tried using the following to shorten to almost nothing but still doesn't do anything.

function player_onradiotag(player_entity, effector_entity)

radiotag_duration = 1
radiotag_iconduration = 1
return EVENT_ALLOWED

end
are the snipermaps that close? radiotag shouldnt work at sniping distances anyway.
__________________
Support FF:
mervaka is offline   Reply With Quote


Old 09-28-2007, 01:18 AM   #7
DeviusCreed
 
Join Date: Mar 2007
Posts Rated Helpful 0 Times
the zoom feels way too underpowered so many of us involved with the slv3 were disappointed. I ported a bunch of maps from tfc over and made a few custom ones to get the league going. To accommodate for the loss in zoom power from tfc to FF I adjusted the maps to be more suitable for our class. Many of them have outer yards which the radiotag becomes an issue. the laser is a bit of a hinderance but makes things interesting sometimes. Is there any other way of removing the radiotag other than the way i attempted??

www.slv3.com in case you were wondering what i was referring to.
DeviusCreed is offline   Reply With Quote


Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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