02-02-2009, 06:14 PM | #1 |
Join Date: Feb 2009
Gametype: Capture the Flag Posts Rated Helpful 0 Times
|
Flag Specific Trigger
Hi, I've been helping a friend with a map for a couple of days now. We are trying to go about the flag security in a new and somewhat unique way. However I need certain outputs to take place on whether the flag is in its respawn position or not. So I was thinking making a trigger that is activated by the set team flag. I have messed with the lua a bit but dont have much knowledge on it. I got it to a point where the flag can trigger it however a player had to be present in the trigger also. I would like it to be able to trigger with just the flag in it. If anyone could help me figure this out I would appreciate it. Thanks.
|
|
02-02-2009, 06:22 PM | #2 |
Stuff Do-er
Lua Team
Wiki Team Fortress Forever Staff |
Not possible at the moment, but it is high on the lua-priority list.
__________________
#FF.Pickup ¤ Fortress-Forever pickups My Non-official Maps Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic Beta FF_Myth - FF_Redlight_Greenlight Sick of the people on the internet, always moanin'. They just moan. - Karl Pilkington |
|
02-02-2009, 07:02 PM | #3 |
Join Date: Feb 2009
Gametype: Capture the Flag Posts Rated Helpful 0 Times
|
Thanks, how about a script that would constantly check the flag origin and compare it to the location where its suppose to respawn.
|
|
02-02-2009, 10:54 PM | #4 |
Stuff Do-er
Lua Team
Wiki Team Fortress Forever Staff |
Well, you can definitely check to see if it's off its origin. In base_ctf, the flag info_ff_script definitions have a status property that starts at 0 and changes to 1/2 after it gets touched initially. Detecting if it's within a certain trigger, though, is impossible.
You may be able to hack a crazy workaround using GetOrigin(), but I'd just wait until we get a real implementation of this.
__________________
#FF.Pickup ¤ Fortress-Forever pickups My Non-official Maps Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic Beta FF_Myth - FF_Redlight_Greenlight Sick of the people on the internet, always moanin'. They just moan. - Karl Pilkington |
|
02-03-2009, 03:05 AM | #5 |
Join Date: Feb 2009
Gametype: Capture the Flag Posts Rated Helpful 0 Times
|
Would you have any kind of time frame for this feature. Also could you explain to me how the GetOrigin() works just in case I choose to be crazy as you put it.
Last edited by Entigren; 02-03-2009 at 03:23 AM. |
|
02-03-2009, 05:09 AM | #6 | |
Stuff Do-er
Lua Team
Wiki Team Fortress Forever Staff |
Hopefully soon, though nothing definite. It's been on our to-do list forever.
Quote:
Code:
local flag = GetInfoScriptByName( "flag_name" ) local pos = flag:GetOrigin() Code:
pos.x pos.y pos.z
__________________
#FF.Pickup ¤ Fortress-Forever pickups My Non-official Maps Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic Beta FF_Myth - FF_Redlight_Greenlight Sick of the people on the internet, always moanin'. They just moan. - Karl Pilkington |
|
|
02-03-2009, 03:33 PM | #7 |
Join Date: Feb 2009
Gametype: Capture the Flag Posts Rated Helpful 0 Times
|
Thanks for the help squeek. However, I guess I just don't understand enough about the lua to get this to work. What I am trying to do is mainly use that getorigin to compare the position of the flag at any given moment to where the flag spawns at. If the flag is there I would like a switch to become usable, and if it is not obviously make the switch unusable. Since I didn't know how to tell the switch to lock or unlock through the lua I tried just changing it to only work for a team that isn't in that map (kGreen or kYellow). However as much as I try I can not get this to work.
Here is my lua code to do this. If any one could take a look and tell me what I am doing wrong. I am sure there are a lot of mistakes to it. So don't hold back on ripping it apart. Code:
button_common = func_button:new({ team = Team.kUnassigned }) function button_common:allowed( allowed_entity ) if IsPlayer( allowed_entity ) then local player = CastToPlayer( allowed_entity ) if player:GetTeamId() == self.team then return EVENT_ALLOWED end end return EVENT_DISALLOWED end -- TODO this doesn't work function button_common:onfailuse( use_entity ) if IsPlayer( use_entity ) then local player = CastToPlayer( use_entity ) BroadCastMessageToPlayer( player, "#FF_NOTALLOWEDBUTTON" ) end end AddSchedule("CheckFlag", 1, getflagorigin) function getflagorigin() local flag = GetInfoScriptByName( "red_flag") local pos = flag:GetOrigin() if pos.x == 319 then if pos.y == -297 then if pos.z == 237 then red_button_lower = button_common:new({ team = Team.kBlue }) else red_button_lower = button_common:new({ team = Team.kGreen }) end else red_button_lower = button_common:new({ team = Team.kGreen }) end else red_button_lower = button_common:new({ team = Team.kGreen }) end end |
|
02-03-2009, 04:07 PM | #8 |
D&A Member
Wiki Team Fortress Forever Staff Join Date: Apr 2007
Posts Rated Helpful 31 Times
|
This doesn't make sense. It's extremely unlikely that a flag will land exactly where it spawns, unless you will cause it to return there. In that case, just use a variable to keep track of whether the flag has been returned or whather it has been picked up (the default CTF flags already do this).
But if for some reason you need to do it this way, I would have the origin check function return a boolean (true/false), and call it from within the :allowed() function. And instead of checking for an exact coordinate, test for a max/min range of x, y, and z. Otherwise it would almost never return true. |
|
02-03-2009, 04:14 PM | #9 |
Join Date: Feb 2009
Gametype: Capture the Flag Posts Rated Helpful 0 Times
|
The flag returned or picked up would work perfectly. How would I go about telling it to check this. I am new to lua and it was just a shot in the dark. Thanks.
|
|
02-03-2009, 06:07 PM | #10 |
[ gr. Cloud ]
Join Date: Sep 2007
Posts Rated Helpful 0 Times
|
In the base_teamplay.lua, where the base_flag is defined, it seems to have a check for the status of the flag pertaining (i.e., if it's 'home', picked up, or dropped):
Code:
----------------------------------------------------------------------------- -- Flag -- status: 0 = home, 1 = carried, 2 = dropped ----------------------------------------------------------------------------- baseflag = info_ff_script:new({ name = "base flag", team = 0, model = "models/flag/flag.mdl", tosssound = "Flag.Toss", modelskin = 1, dropnotouchtime = 2, capnotouchtime = 2, botgoaltype = Bot.kFlag, status = 0, hudicon = "", hudx = 5, hudy = 114, hudalign = 1, hudstatusiconalign = 2, hudstatusicon = "", hudstatusiconx = 0, hudstatusicony = 0, hudstatusiconw = 50, hudstatusiconh = 50, allowdrop = true, touchflags = {AllowFlags.kOnlyPlayers,AllowFlags.kBlue, AllowFlags.kRed, AllowFlags.kYellow, AllowFlags.kGreen} }) |
|
02-03-2009, 08:21 PM | #11 |
Stuff Do-er
Lua Team
Wiki Team Fortress Forever Staff |
Code:
flag_button_common = func_button:new({ team = Team.kUnassigned, flagname = "default_flag_name" }) function flag_button_common:allowed( allowed_entity ) if IsPlayer( allowed_entity ) then local player = CastToPlayer( allowed_entity ) -- if player is on the correct team if player:GetTeamId() == self.team then -- if flag is at its spawn point if _G[self.flagname].status == 0 then return EVENT_ALLOWED end end end return EVENT_DISALLOWED end -- if not allowed function flag_button_common:onfailuse( use_entity ) if IsPlayer( use_entity ) then local player = CastToPlayer( use_entity ) BroadCastMessageToPlayer( player, "#FF_NOTALLOWEDBUTTON" ) end end red_flag_button = flag_button_common:new({ team = Team.kRed, flagname = "flag_name" }) blue_flag_button = flag_button_common:new({ team = Team.kBlue, flagname = "flag_name" })
__________________
#FF.Pickup ¤ Fortress-Forever pickups My Non-official Maps Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic Beta FF_Myth - FF_Redlight_Greenlight Sick of the people on the internet, always moanin'. They just moan. - Karl Pilkington |
|
02-04-2009, 01:17 AM | #12 |
Join Date: Feb 2009
Gametype: Capture the Flag Posts Rated Helpful 0 Times
|
Squeek, you rock its working great so far. Thanks to you and crazycarl my friend can now move on with his map.
|
|
02-04-2009, 03:12 AM | #13 |
Join Date: Feb 2009
Gametype: Capture the Flag Posts Rated Helpful 0 Times
|
One last question and I promise I'm done for now. Is it possible to parent something through the lua.
|
|
02-04-2009, 03:34 AM | #14 | |
Stuff Do-er
Lua Team
Wiki Team Fortress Forever Staff |
Quote:
Code:
OutputEvent( "entity_name", "SetParent", "parent_entity" )
__________________
#FF.Pickup ¤ Fortress-Forever pickups My Non-official Maps Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic Beta FF_Myth - FF_Redlight_Greenlight Sick of the people on the internet, always moanin'. They just moan. - Karl Pilkington |
|
|
02-04-2009, 03:36 AM | #15 |
Join Date: Feb 2009
Gametype: Capture the Flag Posts Rated Helpful 0 Times
|
Thanks again squeek, I actually just figured it out and was about to edit my question.
|
|
Tags |
flag, lua, trigger |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|