Official BF Editor Forums: When Are P.getdefaultvehicle(), P.getvehicle() Equal? - Official BF Editor Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

When Are P.getdefaultvehicle(), P.getvehicle() Equal?

#1 User is offline   GullyFoyle Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 17
  • Joined: 15-October 10

Posted 05 May 2012 - 12:30 AM

Full Python Source I am interested in changing: FileFront. The is the Dcon Capture the Flag game mode.

This is the behaviour I see in game:

When you approach the capturable flag in a vehicle as the driver, you do not grab the flag.
When you are a passenger, certain positions in the vehicle, such as the 2nd seat in a little bird, or 3rd seat in a vodnik, you can do a drive-by of the flag and grab it with out getting out of the vehicle.

This, I believe, is the relevant code, or code I am curious about:

def onCTFUncapTrigger (triggerId, cp, vehicle, enter, cpTeam):

	if enter:
						
		# if cpTeam == 1 and CTF.team1FlagIsTaken: return
		# elif cpTeam == 2 and CTF.team2FlagIsTaken: return
		# else: return #...uhh wtf?		
		if cpTeam == 1:
			if CTF.team1FlagIsTaken: return
		elif cpTeam == 2:
			if CTF.team2FlagIsTaken: return
		else: return #...uhh wtf?
					
		for p in vehicle.getOccupyingPlayers():
			isOk = not p.isManDown() and p.isAlive()
			if not isOk: continue
			playersTeam = p.getTeam() 

			if p.getDefaultVehicle() == p.getVehicle():
				if cpTeam == 1:
					if playersTeam == 2:
						if CTF.team2Carrier == -1 and CTF.team1FlagIsTaken == 0: 
							CTF.team1FlagIsTaken = 1
							CTF.team2Carrier = p.index
							p.score.cpCaptures += 1
							addScore(p, CTF_SCORE_STEAL, RPL)
							CTF.oppFlagHasPhys.setPosition(CTF.oppFlagHousePos)
							CTF.oppFlagUnheldRemaining = CTF_RETURN_UNHELD_FLAG_COUNT
							SendFlagEventMessage(p.getName(), 2, 1)
					elif playersTeam == 1:
						if CTF.team1Carrier == p.index:
							if not (CTF.team2FlagIsTaken == 1):
								return
							
							if not VerifyNoHack(cp, p): return 
							
							ResetFlagCpos(2)
							ShowOffObject(CTF.usFlagNoPhys)
							#print 'SCORED_____________'
							
							p.score.cpCaptures += 1
							addScore(p, CTF_SCORE_CAPTURE, RPL)
							onCTFTeamScore(1)
							SendFlagEventMessage(p.getName(), 1, 2) # name, team, event
					else:
						pass
						
				elif cpTeam == 2:
					if playersTeam == 1:
						if CTF.team1Carrier == -1 and CTF.team2FlagIsTaken == 0: 
							CTF.team2FlagIsTaken = 1
							CTF.team1Carrier = p.index
							p.score.cpCaptures += 1
							addScore(p, CTF_SCORE_STEAL, RPL)
							CTF.usFlagHasPhys.setPosition(CTF.usFlagHousePos)
							CTF.usFlagUnheldRemaining = CTF_RETURN_UNHELD_FLAG_COUNT
							SendFlagEventMessage(p.getName(), 1, 1)

					elif playersTeam == 2:
						if CTF.team2Carrier == p.index:
							if not (CTF.team1FlagIsTaken == 1):
								return
							
							if not VerifyNoHack(cp, p): return 
														
							ResetFlagCpos(1)
							ShowOffObject(CTF.oppFlagNoPhys)
							#print 'score ----'
							
							p.score.cpCaptures += 1
							addScore(p, CTF_SCORE_CAPTURE, RPL)
							onCTFTeamScore(2)
							SendFlagEventMessage(p.getName(), 2, 2) # name, team, event
					else:
						pass
				else:
					pass


I believe this code is triggered when a player comes within the defined radius of the flag (the flags are at the only uncapturable flags on the map).

Isn't the line "if p.getDefaultVehicle() == p.getVehicle()" designed to allow only players outside a vehicle to grab the flag? How would it be different depending on where you are in the vehicle?

Grabbing the flag while driving by at full speed is cheap, and my gaming group would like to see it rectified.

Thanks for any help you can offer!
0

#2 User is offline   hjid27 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 139
  • Joined: 14-September 08
  • Gender:Male
  • Location:Bergen

Posted 05 May 2012 - 11:32 AM

When you are sitting in an open seat like the 3rd seat on a vodnik, getVehicle() will return the soldier. The soldier will however be a child of the vehicle. You could try to do:

if p.getDefaultVehicle().getParent() == None:

Posted Image
0

#3 User is offline   GullyFoyle Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 17
  • Joined: 15-October 10

Posted 05 May 2012 - 02:29 PM

View Posthjid27, on 05 May 2012 - 07:32 AM, said:

When you are sitting in an open seat like the 3rd seat on a vodnik, getVehicle() will return the soldier. The soldier will however be a child of the vehicle. You could try to do:

if p.getDefaultVehicle().getParent() == None:



Thanks for your reply. I'll try it out and let you know.

** Edit **:

That worked like a charm, Thanks!

This post has been edited by GullyFoyle: 05 May 2012 - 07:12 PM

0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users