Adding NEW scripts to EXISTING Lands in the CAMPAIGN

Board Necromancer

New member
Joined
Aug 20, 2010
Messages
1
So here's the Deal; I would like to implement new scripts such as FPS, Lava or what have you into the Pre Existing Black & White 2 Campaign lands.
I elaborate on this post to ensure that there are no misinterpretations or misunderstandings.

The way that I can imagine myself being capable of accomplishing the task of implementing a custom script such as FPS into the Campaign is by making the Script and then Pointing it to the proper land.

e.g.:

FPSScript.chl
Code:
define TEST_MIN_ALTITUDE = 3
define TEST_MOVE_SPEED = 1.5
//define TEST_MOVE_SPEED = 5.0
define TEST_NO_TURN_WIDTH = 0.07
define TEST_MAX_TURN_SPEED = 10
define TEST_NO_PITCH_HEIGHT = 0.125
define TEST_MAX_PITCH_SPEED = 0.125
define TEST_MAX_PITCH_AMOUNT = 1
define TEST_GRAVITY = 0.5
define TEST_JUMP_VELOCITY = 3
define TEST_WALL_HEIGHT = 2
define TEST_FIREBALL_VELOCITY = 100

// Miracle cost
define HEAL_COST = 100
define FIRE_COST = 100
define METEOR_COST = 100
define WIND_COST = 100
define WATER_COST = 100
define LIGHTNING_COST = 100

global Avatar = 1


// Kalev's First Person Shooter Script.
// - Modified by Serdan.
//
// Features:
// # Obstacle Detection.
// # Casting miracles costs mana.
// # The Avatar can be killed.
// # FPS mode can only be activated inside the player's influence.
// # Miracles have to be bought before they can be cast in FPS mode.
// # The above features can be switched on/off.
//
// Key Map:
// # Switch between FPS and God mode: T
// # Fire weapon: LMB
// # Jump: RMB and Space
// # Move: WASD and Arrows.
// # Fireball: 1
// # Lightning: 2
// # Meteor: 3
// # Wind: 4
// # Water: 5
// # Heal: E
//
// List of parameters. Variables that start with 'b' are booleans. ON: 1 / OFF: 0
// - fCooldown: Forced delay between miracles cast. If you set this to 1.0 you can hold down the fire button without lagging your PC to Hell.
// - bObstacle: Obstacle Detection.
// - bManaCost: Should the miracles require mana to be cast by the Avatar?
// - bAvatar: Should the Avatar die from wading through lava? // Can't be turned off here. Remove from code manually. Line: 297
// - bInfluence: Is influence required to turn into the Avatar?
// - bResearch: Will miracles have to be researched before they can be used by the Avatar?
begin script KalevFPS(fCooldown, bObstacle, bManaCost, bAvatar, bInfluence, bResearch)
	CurrentFocusRotation = 0
	CurrentFocusRelativeHeight = 0

	TurnAmount = 0
	TurnHotArea = 0

	CameraLoc = 0
	CameraFoc = 0

	OnGround = 0
	CurrentYVelocity = 0

	CameraAltitude = 0
	PrevCameraHeight = 0
	CameraHeight = 0

	PrevCameraLoc = 0
	NewCameraLoc = 0

	WaterHeight = 0

	// Location of exit area.
	//ExitX = 2015.31
	//ExitZ = 678.56

	// The minimum distance the player has to be from the specified exit.
	//ExitDis = 20.0

	//Weapon Variables
	Weapon = 0
	CurrentWeapon = 0
	Fire = 1
	Wind = 2
	Lightning = 3
	Meteor = 4
	Water = 5
	Heal = 6
	Shield = 7

	Mana = 0
	
	// Cooldown on miracles. Next up: A different cooldown for each miracle?
	tCooldown = create timer for 0 seconds
	//fCooldown = 1.0
start
	wait until key KB_T down
	if bInfluence == 0 or get player 0 influence at camera position > 0
	
		wait 0.2 seconds
		WaterHeight = get water height

		Avatar = create random villager of tribe TRIBE_TYPE_GREEK at camera position
		set Avatar player 0
		disable Avatar pickup
		disable Avatar can be fisted
		disable Avatar interactable

		begin cinema
			if bResearch == 0 or get research ARTEFACT_MAGIC_TYPE_FIRE_FIRE available == 2
				CurrentWeapon = Fire
				say single line "Weapon: Fire!"
			else
				CurrentWeapon = 0
			end if
			begin loop
				CameraLoc = marker at camera position

				if OnGround == 0
					CameraAltitude = get SCRIPT_OBJECT_PROPERTY_TYPE_YPOS of CameraLoc
					CameraAltitude += CurrentYVelocity
					CurrentYVelocity -= TEST_GRAVITY
				elsif key KB_SPACE down or mouse right button down
					CurrentYVelocity = TEST_JUMP_VELOCITY
					OnGround = 0
				end if

				TurnAmount = mouse percentage across
				TurnHotArea = (1 - TEST_NO_TURN_WIDTH)/2
				if TurnAmount < TurnHotArea
					CurrentFocusRotation += (1 - (TurnAmount / TurnHotArea)) * TEST_MAX_TURN_SPEED
				elsif  TurnAmount > 1 - TurnHotArea
					CurrentFocusRotation -= (1 - ((1 - TurnAmount) / TurnHotArea)) * TEST_MAX_TURN_SPEED
				end if

				TurnAmount = mouse percentage down
				TurnHotArea = (1 - TEST_NO_PITCH_HEIGHT)/2
				if TurnAmount < TurnHotArea
					CurrentFocusRelativeHeight -= (1 - (TurnAmount / TurnHotArea)) * TEST_MAX_PITCH_SPEED
				elsif  TurnAmount > 1 - TurnHotArea
					CurrentFocusRelativeHeight += (1 - ((1 - TurnAmount) / TurnHotArea)) * TEST_MAX_PITCH_SPEED
				end if
				if (CurrentFocusRelativeHeight < -1 * TEST_MAX_PITCH_AMOUNT) CurrentFocusRelativeHeight = -1 * TEST_MAX_PITCH_AMOUNT end if
				if (CurrentFocusRelativeHeight > TEST_MAX_PITCH_AMOUNT) CurrentFocusRelativeHeight = TEST_MAX_PITCH_AMOUNT end if

				PrevCameraLoc = CameraLoc
				PrevCameraHeight = CameraAltitude + land height at {CameraLoc}
				if key KB_W down or key KB_UP down
					NewCameraLoc = marker at get target from {CameraLoc} + {1,0,0} to {CameraLoc} distance TEST_MOVE_SPEED angle CurrentFocusRotation
					if bObstacle == 0 or Avatar can navigate to {NewCameraLoc}
						CameraLoc = NewCameraLoc
					end if
				elsif key KB_S down or key KB_DOWN down
					NewCameraLoc = marker at get target from {CameraLoc} + {-1,0,0} to {CameraLoc} distance TEST_MOVE_SPEED angle CurrentFocusRotation
					if bObstacle == 0 or Avatar can navigate to {NewCameraLoc}
						CameraLoc = NewCameraLoc
					end if
				end if
				if key KB_A down or key KB_LEFT down
					NewCameraLoc = marker at get target from {CameraLoc} + {0,0,1} to {CameraLoc} distance TEST_MOVE_SPEED angle CurrentFocusRotation
					if bObstacle == 0 or Avatar can navigate to {NewCameraLoc}
						CameraLoc = NewCameraLoc
					end if
				elsif key KB_D down or key KB_RIGHT down
					NewCameraLoc = marker at get target from {CameraLoc} + {0,0,-1} to {CameraLoc} distance TEST_MOVE_SPEED angle CurrentFocusRotation
					if bObstacle == 0 or Avatar can navigate to {NewCameraLoc}
						CameraLoc = NewCameraLoc
					end if
				end if
				CameraHeight = CameraAltitude + land height at {CameraLoc}
				if CameraHeight < TEST_MIN_ALTITUDE + WaterHeight
					CameraAltitude = TEST_MIN_ALTITUDE + WaterHeight - land height at {CameraLoc}
					OnGround = 1
				elsif OnGround == 0
					CameraAltitude = PrevCameraHeight - land height at {CameraLoc}
					if CameraAltitude < TEST_MIN_ALTITUDE
						CameraAltitude = TEST_MIN_ALTITUDE
						if CurrentYVelocity < 0
							OnGround = 1
						end if
					end if
				elsif land height at {CameraLoc} < WaterHeight
					CameraAltitude = TEST_MIN_ALTITUDE + WaterHeight - land height at {CameraLoc}
				elsif (land height at {CameraLoc}) - (land height at {PrevCameraLoc}) > TEST_WALL_HEIGHT
					CameraLoc = PrevCameraLoc
				end if
				SCRIPT_OBJECT_PROPERTY_TYPE_YPOS of CameraLoc = CameraAltitude

				CameraFoc = marker at get target from {CameraLoc} + {1,0,0} to {CameraLoc} distance 1 angle CurrentFocusRotation

				SCRIPT_OBJECT_PROPERTY_TYPE_YPOS of CameraFoc = get SCRIPT_OBJECT_PROPERTY_TYPE_YPOS of CameraFoc - CurrentFocusRelativeHeight

				set camera position to {CameraLoc}
				set camera focus to {CameraFoc}

				set Avatar position to {CameraLoc}
				set Avatar focus to {CameraFoc}

				// Change weapon according to key pressed.
				if key KB_1 down
					if bResearch == 0 or get research ARTEFACT_MAGIC_TYPE_FIRE_FIRE available == 2
						CurrentWeapon = Fire
						say single line "Weapon: Fire!"
					end if
				elsif key KB_2 down
					if bResearch == 0 or get research ARTEFACT_MAGIC_TYPE_WATER_STORM available == 2
						CurrentWeapon = Lightning
						say single line "Weapon: Lightning!"
					end if
				elsif key KB_3 down
					if bResearch == 0 or get research ARTEFACT_MAGIC_TYPE_EARTH_METEOR available == 2
						CurrentWeapon = Meteor
						say single line "Weapon: Meteor!"
					end if
				elsif key KB_4 down
					if bResearch == 0 or get research ARTEFACT_MAGIC_TYPE_AIR_TEMPEST available == 2
						CurrentWeapon = Wind
						say single line "Weapon: Wind!"
					end if
				elsif key KB_5 down
					if bResearch == 0 or get research ARTEFACT_MAGIC_TYPE_WATER_RAIN available == 2
						CurrentWeapon = Water
						say single line "Weapon: Water!"
					end if
				end if

				if get tCooldown time remaining <= 0
					Mana = get player 0 mana
					// Fire selected weapon
					if mouse left button down
						if CurrentWeapon == Fire
							if bManaCost == 0 or FIRE_COST <= Mana
								Weapon = make player 0 throw miracle MIRACLE_TYPE_FIRE from {CameraLoc} heading TEST_FIREBALL_VELOCITY * ({CameraFoc} - {CameraLoc})
								if bManaCost == 0
									set player 0 mana Mana-FIRE_COST
								end if
							end if
						elsif CurrentWeapon == Lightning
							if bManaCost == 0 or LIGHTNING_COST <= Mana
								Weapon = make player 0 throw miracle MIRACLE_TYPE_STORM from {CameraLoc} heading TEST_FIREBALL_VELOCITY * ({CameraFoc} - {CameraLoc})
								if bManaCost == 0
									set player 0 mana Mana-LIGHTNING_COST
								end if
							end if
						elsif CurrentWeapon == Meteor
							if bManaCost == 0 or METEOR_COST <= Mana
								Weapon = make player 0 throw miracle MIRACLE_TYPE_METEOR from {CameraLoc} heading TEST_FIREBALL_VELOCITY * ({CameraFoc} - {CameraLoc})
								if bManaCost == 0
									set player 0 mana Mana-METEOR_COST
								end if
							end if
						elsif CurrentWeapon == Wind
							if bManaCost == 0 or WIND_COST <= Mana
								Weapon = make player 0 throw miracle MIRACLE_TYPE_TORNADO from {CameraLoc} heading TEST_FIREBALL_VELOCITY * ({CameraFoc} - {CameraLoc})
								if bManaCost == 0
									set player 0 mana Mana-WIND_COST
								end if
							end if
						elsif CurrentWeapon == Water
							if bManaCost == 0 or WATER_COST <= Mana
								Weapon = make player 0 throw miracle MIRACLE_TYPE_WATER from {CameraLoc} heading TEST_FIREBALL_VELOCITY * ({CameraFoc} - {CameraLoc})
								if bManaCost == 0
									set player 0 mana Mana-WATER_COST
								end if
							end if
						end if
					end if

					if key KB_E down
						if bResearch == 0 or get research ARTEFACT_MAGIC_TYPE_LIFE_HEAL available == 2
							if bManaCost == 0 or HEAL_COST <= Mana
								Weapon = make player 0 pour miracle MIRACLE_TYPE_HEAL at {CameraLoc}
								if bManaCost == 0
									set player 0 mana Mana-HEAL_COST
								end if
							end if
						end if
					end if
					set tCooldown time to fCooldown seconds
				end if

				// Exit FPS mode when the "T" button is pressed.
				until key KB_T down or key KB_ESC down or get SCRIPT_OBJECT_PROPERTY_TYPE_HEALTH of Avatar < 0.2
				
				// To use this comment out the other exception and uncomment this one. Variables can be specified in the variable list.
				//until get distance from camera position to {ExitX,ExitZ} <= ExitDis
			end loop
		end cinema

		delete Avatar
	end if
	
	wait 0.2 seconds
	run background script KalevFPS(fCooldown, bObstacle, bManaCost, bAvatar, bInfluence, bResearch)

end script KalevFPS

I then make this point to  Land1.chl

1. How would I do this?
2. Would this method work for all of the Lands?

I am just returning to BW2 and I have never done this before, so any veterans that might be around in the dust or something... I would greatly appreciate your help.
 
I don't know why no one replied to this when it was first written but from what i've heard there is no way to mod the orginal map files but it can mod any custom map files, so if u did wanna do this you would have to implement it onto a custom map rather then one of the ones in the campaign. I hope u finished this mod or found some way to accomplish what others said could not be done, and if u did post a link a share it cause i know i would love to give it a try!
 
Back
Top