360 camera from Dungeon Adventure

Lutefisk Mafia

Inscrutable Enforcer
Joined
Jun 15, 2007
Messages
544
Location
Minnesota
And now, DA mod giblet 2: Spinny camera!

Original discussion in the DA thread can be found here:

http://forums.civfanatics.com/showpost.php?p=6929010&postcount=505

And reproduced in full below:

**************

In my DA modmod, the tall dungeon walls often made it hard to see items on the floor. To fix this, I imported a modified Afterworld style of camera freedom. I should quickly note that this mod giblet does NOT lock the player into a close-up view like AW does. (I found that really annoying).

Instead, this simple code addition to your CvEventManager.py file allows full 360 spinning of the worldview.

If you open up your CvEventManager.py file and scroll down a bit, you will come to the "def onKbdEvent" code. The code should be altered to look like this:

Code:
	def onKbdEvent(self, argsList):
		'keypress handler - return 1 if the event was consumed'

		eventType,key,mx,my,px,py = argsList
		game = gc.getGame()
		
		if (self.bAllowCheats):
			# notify debug tools of input to allow it to override the control
			argsList = (eventType,key,self.bCtrl,self.bShift,self.bAlt,mx,my,px,py,gc.getGame().isNetworkMultiPlayer())
			if ( CvDebugTools.g_CvDebugTools.notifyInput(argsList) ):
				return 0
		
		if ( eventType == self.EventKeyDown ):
			theKey=int(key)
#begin add AW camera
			if (theKey == int(InputTypes.KB_LEFT)):
				if self.bCtrl:
						CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() - 45.0)
						return 1
				elif self.bShift:
						CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() - 10.0)
						return 1
			
			if (theKey == int(InputTypes.KB_RIGHT)):
					if self.bCtrl:
							CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() + 45.0)
							return 1
					elif self.bShift:
							CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() + 10.0)
							return 1
#end add AW camera
			CvCameraControls.g_CameraControls.handleInput( theKey )
						
			if (self.bAllowCheats):
				# Shift - T (Debug - No MP)
				if (theKey == int(InputTypes.KB_T)):
					if ( self.bShift ):
						self.beginEvent(CvUtil.EventAwardTechsAndGold)
						#self.beginEvent(CvUtil.EventCameraControlPopup)
						return 1
							
				elif (theKey == int(InputTypes.KB_W)):
					if ( self.bShift and self.bCtrl):
						self.beginEvent(CvUtil.EventShowWonder)
						return 1
							
				# Shift - ] (Debug - currently mouse-overd unit, health += 10
				elif (theKey == int(InputTypes.KB_LBRACKET) and self.bShift ):
					unit = CyMap().plot(px, py).getUnit(0)
					if ( not unit.isNone() ):
						d = min( unit.maxHitPoints()-1, unit.getDamage() + 10 )
						unit.setDamage( d, PlayerTypes.NO_PLAYER )
					
				# Shift - [ (Debug - currently mouse-overd unit, health -= 10
				elif (theKey == int(InputTypes.KB_RBRACKET) and self.bShift ):
					unit = CyMap().plot(px, py).getUnit(0)
					if ( not unit.isNone() ):
						d = max( 0, unit.getDamage() - 10 )
						unit.setDamage( d, PlayerTypes.NO_PLAYER )
					
				elif (theKey == int(InputTypes.KB_F1)):
					if ( self.bShift ):
						CvScreensInterface.replayScreen.showScreen(False)
						return 1
					# don't return 1 unless you want the input consumed
				
				elif (theKey == int(InputTypes.KB_F2)):
					if ( self.bShift ):
						import CvDebugInfoScreen
						CvScreensInterface.showDebugInfoScreen()
						return 1
				
				elif (theKey == int(InputTypes.KB_F3)):
					if ( self.bShift ):
						CvScreensInterface.showDanQuayleScreen(())
						return 1
						
				elif (theKey == int(InputTypes.KB_F4)):
					if ( self.bShift ):
						CvScreensInterface.showUnVictoryScreen(())
						return 1
											
		return 0

This important bit to add in is between the "begin add AW camera" comments and the "end add AW camera" comment.

Once added, this code will allow you to spin the camera a full 360 degrees. Pressing the Control key and the left or right arrow, will spin the world 45 degrees counterclockwise (widdershins) and clockwise (deasil). Pressing the Shift key and the left or right arrow will spin 10 degrees.

In my opinion, this type of camera movement should be deafult in all Civ games, but that's just me!

An example of the python code shown above can be downloaded from here:

360 degree camera = http://www.atomicgamer.com/file.php?id=70068

Hope this is of use to you. Enjoy your newfound spinny camera freedom, and please let me know if it is working for you.
 
I really like this edition, but...
Is there anyway to make it more like other game engines by being able to hold down mouse button 3 to rotate the camera clockwise, anti-clockwise, up, down?
Basically all around in a fluid motion.
 
This is a great feature Lutefisk, it will be added in FfH 0.33.
 
@ Giddion: I believe it may be possible, but would require a lot more skill than I have. I can handle programming the game to move a certain discrete angle in response to a single keystroke. Or change the range of movement of the existing camera "swoop." But what you are talking about is a constant feedback, free camera type of movement. That would eb cool, I just don't know how to do that. Sorry! :(

@ Jabie: :lol: This code is an adapted version of the AW code! I think what you are referring to is the annoying forced "close-up" of AW. That can be changed by altering the Camera range and angles in the Globals.

@ Kael: Cool! I am gratified that something useable is coming out of this project! Thanks for the nod.
 
Top Bottom