2 Flag CTF: Republic Commando rules (Help Needed)

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

2 Flag CTF: Republic Commando rules (Help Needed)

Post by Ace_Azzameen_5 »

I enjoy playing the CTF mode in republic commando, and I believe that its because of a few simple game rule changes:

The Differences
v/ = easily do-able in SWBF2
-You can't capture the enemy flag if your flag has been takenv/
-Flag bearers can't use their primary weapon (or pick up secondaries)
-Flag returns aren't timer based, walking through a flag auto returns it.
-The flag can be dropped and retrieved
-No AI unitsv/
-Random spawn.v/

At least the first two of these things can be achieved for SWBF 2 with the mission LUA script.

However, what I really think would help CTF would be the first RepCom Dynamic: taking the enemy flag prevents them from capturing yours. This would give players with no idea where their flag has gotten to a way to help their team, and I think it would help with large games.

Instead of writing an essay on why the game is more fun that way, I'll just summarize that has to do with eliminating some of the noob-fest aspects and respawn time problems.

Also, it's easy to implement, I'ma try it now.
(Neutralizing the Capture Region on Flag Pick up-unless this causes a crash like hangar regions seem too.... :x

In summary,
meh.
Last edited by Ace_Azzameen_5 on Mon May 21, 2007 4:06 pm, edited 1 time in total.
User avatar
EraOfDesann
Jedi Admin
Jedi Admin
Posts: 2170
Joined: Mon May 30, 2005 5:22 pm
Location: North Texas
Contact:

Post by EraOfDesann »

Sounds good! SWBF2 CTF is so-so and isn't quite as fun as it is in Jedi Outcast or Jedi Academy so this should be a nice change. It'd be neat if there were more CTF-oriented maps out there. Hm... maybe I... Nah!
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Post by Ace_Azzameen_5 »

Got region disabling to work. I finally grasped what the DOCs were saying in regards to the correct syntax.

*EDIT*

Paste this into a CTF mission LUA (and make adjustments if necessary) to enable the first RecCom rule,
No Capturing the flag if yours has been taken:

Code: Select all

--The New Rule-Your flag must be at home base in order for you to capture.
--Region Deactivation
OnFlagPickUp(
function(post)
DeactivateRegion ("team1_capture") 
"flag1"   
end  
)

OnFlagPickUp(
function(post)
DeactivateRegion ("team2_capture") 
"flag2"   
end  
)
--Region Reactivation
OnFlagReturn(
function(post)
ActivateRegion ("team1_capture")
"flag1"
end
)

OnFlagReturn(
function(post)
ActivateRegion ("team2_capture")
"flag2"
end
)

OnFlagCapture(
function(post)
ActivateRegion ("team1_capture")
"flag1"
end
)

OnFlagCapture(
function(post)
ActivateRegion ("team2_capture")
"flag2"
end
)
Simple enough. Now to see if I can get some of the other stuff working, and I might make the capture region object thingy "change colours" when capturing is enabled and disabled. (Really I'll be deleting one object and adding another. No such thing as live texture change AFAIK)

*EDIT* I think I might have one of the flags backwards or the context/filter isn't working right or something.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: 2 Flag CTF: Republic Commando rules?

Post by [RDH]Zerted »

Ace_Azzameen_5 wrote:You can't capture the enemy flag if your flag has been taken
Thats great. I wish the game was made that way.

Want to you mean by random spawn? A random location or a random respawn time? The worst thing about the official CTF maps is that one side can normally, easily spawn camp the other.

All your ideas can be done in SWBF2.
-_-
Gametoast Staff
Gametoast Staff
Posts: 2678
Joined: Sat May 07, 2005 1:22 pm

RE: Re: 2 Flag CTF: Republic Commando rules?

Post by -_- »

Random spawn is easy. You just need to make the spawn paths all over the 1 side of the map for each team.
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Post by Ace_Azzameen_5 »

Hence the green v/ mark.

Also, I don't know why, but that code, specifically, the first 2 events, will sometimes make it so that the your flag needs to be taken and returned before you can capture it. I had captured 2 flags, had my flag taken and returned a couple times (Can't tell wether it had been taken AFTER my last capture or not-probably important to know) and I couldn't capture the enemy flag until they stole the flag and I returned it.

Can someone help me play Spot the Logic Error?
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Post by Ace_Azzameen_5 »

Ok, After some code changes to give messages in game about disabling messages, I found out the problem as shown in the video below.

I also fixed the code from disabling regions every time a flag is picked up, and now it only happens when a flag is picked up after being returned.

Code: Select all

--The New Rule-Your flag must be at home base in order for you to capture.
--Region Deactivation
OnFlagPickUp(
function(post)
if returned1 ~= 1 then
returned1 = 0
DeactivateRegion ("team1_capture")
ShowMessageText("level.rcf.ctf.repcapturedisabled", REP)
ShowMessageText("level.rcf.ctf.repcapturedisabled", CIS)
"flag1"
end
end 
)

OnFlagPickUp(
function(post)
if returned2 ~= 1 then
returned2 = 0
DeactivateRegion ("team2_capture")
ShowMessageText("level.rcf.ctf.ciscapturedisabled", REP)
ShowMessageText("level.rcf.ctf.ciscapturedisabled", CIS)
"flag2"
end 
end
)
--Region Reactivation
OnFlagReturn(
function(post)
returned1 = 1
ActivateRegion ("team1_capture")
ShowMessageText("level.rcf.ctf.repcaptureenabled", REP)
ShowMessageText("level.rcf.ctf.repcaptureenabled", CIS)
"flag1"
end
)

OnFlagReturn(
function(post)
returned2 = 1
ActivateRegion ("team2_capture")
ShowMessageText("level.rcf.ctf.ciscaptureenabled", REP)
ShowMessageText("level.rcf.ctf.ciscaptureenabled", CIS)
"flag2"
end
)

OnFlagCapture(
function(post)
returned1 = 1
ActivateRegion ("team1_capture")
ShowMessageText("level.rcf.ctf.repcaptureenabled", REP)
ShowMessageText("level.rcf.ctf.repcaptureenabled", CIS)
"flag1"
end
)

OnFlagCapture(
function(post)
returned2 = 1
ActivateRegion ("team2_capture")
ShowMessageText("level.rcf.ctf.ciscaptureenabled", REP)
ShowMessageText("level.rcf.ctf.ciscaptureenabled", CIS)
"flag2"
end
) 
Please excuse the framerate. (I was multitasking)

Image

My hypothesis is that SWBF is being stupid and not distinguishing between flag1 and Flag2. Maybe the event line should look like "OnFlagPickUpFlag" or maybe team or something. Help?
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Post by [RDH]Zerted »

I didn't really debug your code, but if returned# is only 1 or 0 why are you setting it to 0 when it already is?
Code: if returned# ~= 1 then returned# = 0
Reads: if returned# is not equal to 1 then returned# = 0

I wrote and tested a method/function that you could stick into any map to enable your rule. It also scales to any amount of teams. Intrestingly, I don't think you need to re-enable the region (but I left that section in anyway). When the flag gets reset, I think the capture region reactivates. I didn't look into why this happens (maybe the AI goal code does it?).

This table contains the capture regions. The first value is team 1's capture region. The second value is team 2's capture region. The thrid value would be team 3's capture region... Node: team 0 is not supported, but can be if you need it. Generally, this code would be in ScriptPostLoad(). In the example, the rule will not be enforced on team 3.

Code: Select all

	--table holds the capture regions for each team following the rule
	--use nil to skip that team from following the rule	
	local regions = {
		"team1_capture",
		"team2_capture",
		nil,
		"team4_capture_region",
	}
	
	--enable the rule
	cantCaptureIfOwnFlagTaken( regions )
This is the method that enables the rule. You can put it in the Lua outside of any other method.

Code: Select all

--Rule by Ace_Azzameen_5: "You can't capture the enemy flag if your flag has been taken"        
function cantCaptureIfOwnFlagTaken( captureRegions )

	--rule pointless if there are no know capture regions
	if captureRegions == nil then return end
	
		
	--when a team's flag is taken, prevent that team from being able to score
	OnFlagPickUp(
		function( flag, carrierObj )
			--output for debugging			
			print("cantCaptureIfOwnFlagTaken(): OnFlagPickup()")

			--get the team whose flag has been taken	
			if flag == nil then return end
			local team = GetObjectTeam( flag )
			
			--get the team's capture region
			local region = captureRegions[team]
			if region == nil then return end
			
			--disable the team's capture region so it cannot score
			DeactivateRegion( region )

			--output for debugging			
			print("cantCaptureIfOwnFlagTaken(): OnFlagPickUp(): Team = " .. team .. ", Region = " .. region .. ", Action = Disabled")
		end
	)
	
	--when a team's flag is returned, allow that team to score
	OnFlagReset(
		function( flag, carrierObj )
			--output for debugging			
			print("cantCaptureIfOwnFlagTaken(): OnFlagReset()")

			--get the team whose flag has been returned
			if flag == nil then return end
			local team = GetObjectTeam( flag )
		
			--get the team's capture region
			local region = captureRegions[team]
			if region == nil then return end
		
			--enable the team's capture region so it can score
			ActivateRegion( region )

			--output for debugging			
			print("cantCaptureIfOwnFlagTaken(): OnFlagReset(): Team = " .. team .. ", Region = " .. region .. ", Action = Enabled")
		end
	)

	--output for debugging
	print("cantCaptureIfOwnFlagTaken(): Rule now in effect")
end
Something else to point out, OnFlagReturn() is never used in any official Lua script. The docs say its for when a friendly unit returns it's own flag. In CTF, you normally can't pickup your own flag. If you want when the flag gets reset after being dropped or carried too long use OnFlagReset(), which isn't in the docs but is used in the scripts.
Can you really make it so a carrier player can press a button and drop the flag without dieing, then pick it up again? Or was I not being specific enough?
I assumed you meant when a player died, he dropped the flag and another could pick it up (which is what normally happens, so its possible). The way you want it might not work too well. If you drop a flag, it drops right where you are. You'd pick it right back up. An example of this might be like in space CTF when you fly into a hanger while holding the flag. You may be able to change a unit properity to prevent the unit from picking up flags, then force that unit to drop the flag.

In order to determine when a player wants to drop the flag, he would have to trigger an event callback, such as OnCharacterDispenseControllable(), meaning he needs to be given a drop flag weapon when picking up the flag.

I'm thinkign to drop a flag, you kill the flag object then respawn it at the unit's location (works like the teleporter).
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Post by Ace_Azzameen_5 »

Yeah, I'm thinking the whole problem was the event. Thanks.

Also, it might be cool to kill the units pickup ability for a a couple of milliseconds so that would work. But I have no idea how to get a button wired to drop the flag....wait, Unless their an FireWeapon or similar event-that would kill too rules with one function
1. No shooting with the flag
2. Flag drop-able.

If you or anyone else has the spare time to try it (or the desire) then go ahead. I'm more focused on my java (eww, gridbag Gui!) based SWBF2 lua editor.

Maybe I'll post a help thread for that in a while.

again, thanks for the help .
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Post by [RDH]Zerted »

With OnFlagPickup(), you can change the player's weapons with the SetProperty() functions. The FireWeapon event would be OnCharacterDispenseControllable(). Just make sure to give the controllable object an extremely short lifespan (less than 1 second).

Yuck, gridbag layout. I never took the time to learn that one. As far as I know, it doesn't resize well and it creates unreadable code. Lookup spring layout. It works well. If you don't care about the window not resizing, just use absolute positions.
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Post by Ace_Azzameen_5 »

Learning JAVA (my first true code language, really) has helped me understand some of the code blocks that left me nuts before.

I would have never realized that the above code was a function method (lua equivalen) and that the reason why the word region was where I though a reigion name should be spacified-its a variable that gets filled. I used to think the Diet Dr. Pepper doc's were saying "Region name here".

Its finally starting to make sense. TY for the help again, NRN ATM.

*EDIT*
I got your code working, but as with mine, there this glitch were if the enemy is in their capture region with your flag when their flag resets, they have to exit and reenter the region or drop the flag and pick it up again to score.

Any creative ways to fix this, without physically pushing units out with ZE animations and blocking the area with objects?
Post Reply