# HG changeset patch
# User Maikel de Vries
# Date 1292346153 -3600
# Node ID 24cfa426748412741132606649203d4ba2d0bb2f
# Parent  6cfb432a6e388bba4a22db06a5120e8d5a0aef4a
Physical: Rescale MaxEnergy in C4Script.
The transformations occur in Set/GetMaxEnergy, these need to be changed if the engine implementation changes.

diff -r 6cfb432a6e38 -r 24cfa4267484 planet/BackToTheRocks.c4f/Hideout.c4s/LifeGem.c4d/Script.c
--- a/planet/BackToTheRocks.c4f/Hideout.c4s/LifeGem.c4d/Script.c	Mon Dec 13 23:22:15 2010 +0100
+++ b/planet/BackToTheRocks.c4f/Hideout.c4s/LifeGem.c4d/Script.c	Tue Dec 14 18:02:33 2010 +0100
@@ -32,7 +32,7 @@
 
 func FxGemHealingTimer(target, effect_number, effect_time)
 {
-	if(target->GetEnergy() >= target.MaxEnergy/1000)
+	if(target->GetEnergy() >= target->GetMaxEnergy())
 	{
 		if(effect_time < 36) return 0;
 		return -1;
diff -r 6cfb432a6e38 -r 24cfa4267484 planet/Objects.c4d/Goals.c4d/KingOfTheHill.c4d/KingOfTheHillLocation.c4d/Script.c
--- a/planet/Objects.c4d/Goals.c4d/KingOfTheHill.c4d/KingOfTheHillLocation.c4d/Script.c	Mon Dec 13 23:22:15 2010 +0100
+++ b/planet/Objects.c4d/Goals.c4d/KingOfTheHill.c4d/KingOfTheHillLocation.c4d/Script.c	Tue Dec 14 18:02:33 2010 +0100
@@ -124,7 +124,7 @@
 	++timer;
 	if(king)
 	{
-		var percent=(king->GetEnergy()  * 100) / (king.MaxEnergy / 1000);
+		var percent=(king->GetEnergy() * 100) / (king->GetMaxEnergy());
 		var red=255; if(percent > 50) red=(255*(100-2*(percent-50))) / 100;
 		var green=255; if(percent < 50) green=(255*(2*percent)) / 100;
 		color=RGB(red/2, green/2, 0);
diff -r 6cfb432a6e38 -r 24cfa4267484 planet/Objects.c4d/HUD.c4d/Elements.c4d/CrewSelector.c4d/Script.c
--- a/planet/Objects.c4d/HUD.c4d/Elements.c4d/CrewSelector.c4d/Script.c	Mon Dec 13 23:22:15 2010 +0100
+++ b/planet/Objects.c4d/HUD.c4d/Elements.c4d/CrewSelector.c4d/Script.c	Tue Dec 14 18:02:33 2010 +0100
@@ -184,10 +184,10 @@
 public func UpdateHealthBar()
 {
 	if(!crew) return;
-	var phys = crew.MaxEnergy;
+	var phys = crew->GetMaxEnergy();
 	var promille;
 	if(phys == 0) promille = 0;
-	else promille = 1000 * crew->GetEnergy() / (phys / 1000);
+	else promille = 1000 * crew->GetEnergy() / phys;
 
 	energypos = -GetDefWidth()/2*(1000-promille)/1000;
 
@@ -198,7 +198,7 @@
 public func UpdateBreathBar()
 {
 	if(!crew) return;
-	var phys = crew.MaxBreath;
+	var phys = crew->GetMaxBreath();
 	var promille;
 	if(phys == 0) promille = 0;
 	else promille = 1000 * crew->GetBreath() / phys;
diff -r 6cfb432a6e38 -r 24cfa4267484 planet/Objects.c4d/Libraries.c4d/Base.c4d/Script.c
--- a/planet/Objects.c4d/Libraries.c4d/Base.c4d/Script.c	Mon Dec 13 23:22:15 2010 +0100
+++ b/planet/Objects.c4d/Libraries.c4d/Base.c4d/Script.c	Tue Dec 14 18:02:33 2010 +0100
@@ -121,7 +121,7 @@
 	if(CanHeal() && GetHeal())
 		for(pObj in FindObjects(Find_Container(this), Find_OCF(OCF_CrewMember), Find_Allied(GetOwner())))
 		{
-			if(pObj->GetEnergy() < pObj.MaxEnergy/1000 && !GetEffect("IntBaseHeal", pObj))
+			if(pObj->GetEnergy() < pObj->GetMaxEnergy() && !GetEffect("IntBaseHeal", pObj))
 				AddEffect("IntBaseHeal", pObj, 1, 1, this);
 		}
 	// Can this base extinguish? Then look for something on fire
@@ -151,7 +151,7 @@
 	// The clonk has left the base? Stop!
 	if(pClonk->Contained() != this) return -1;
 	// Full energy? Stop too.
-	if(pClonk->GetEnergy() >= pClonk.MaxEnergy/1000) return -1;
+	if(pClonk->GetEnergy() >= pClonk->GetMaxEnergy()) return -1;
 
 	// No energy left? Buy some
 	if(!iEnergy)
diff -r 6cfb432a6e38 -r 24cfa4267484 planet/Objects.c4d/Structures.c4d/SteamEngine.c4d/Script.c
--- a/planet/Objects.c4d/Structures.c4d/SteamEngine.c4d/Script.c	Mon Dec 13 23:22:15 2010 +0100
+++ b/planet/Objects.c4d/Structures.c4d/SteamEngine.c4d/Script.c	Tue Dec 14 18:02:33 2010 +0100
@@ -85,5 +85,4 @@
 },
 };
 local Name = "$Name$";
-local MaxEnergy = 100000;
 
diff -r 6cfb432a6e38 -r 24cfa4267484 planet/System.c4g/Helpers.c
--- a/planet/System.c4g/Helpers.c	Mon Dec 13 23:22:15 2010 +0100
+++ b/planet/System.c4g/Helpers.c	Tue Dec 14 18:02:33 2010 +0100
@@ -110,6 +110,7 @@
 {
 	if (!this)
 		return;
+	value *= 1000;
 	var old_maxeng = this.MaxEnergy;
 	this.MaxEnergy = value;
 	// Make sure current energy does not exceed maximum and implicit callback.
@@ -122,7 +123,7 @@
 {
 	if (!this)
 		return;
-	return this.MaxEnergy;
+	return this.MaxEnergy / 1000;
 }
 
 // Sets the MaxBreath value of an object and does the necessary callbacks.
diff -r 6cfb432a6e38 -r 24cfa4267484 planet/Tutorial.c4f/Tutorial04.c4s/EnergyBar.c4d/Script.c
--- a/planet/Tutorial.c4f/Tutorial04.c4s/EnergyBar.c4d/Script.c	Mon Dec 13 23:22:15 2010 +0100
+++ b/planet/Tutorial.c4f/Tutorial04.c4s/EnergyBar.c4d/Script.c	Tue Dec 14 18:02:33 2010 +0100
@@ -35,12 +35,12 @@
 	var energy = target->GetEnergy();
 	if (!energy)
 		return RemoveObject();
-	var phys = target.MaxEnergy;
+	var phys = target->GetMaxEnergy();
 	var promille;
 	if (phys == 0) 
 		promille = 0;
 	else 
-		promille = 1000 * energy / (phys / 1000);
+		promille = 1000 * energy / phys;
 	SetBarProgress(promille, 0);	
 	return;
 }
diff -r 6cfb432a6e38 -r 24cfa4267484 planet/Tutorial.c4f/Tutorial04.c4s/Script.c
--- a/planet/Tutorial.c4f/Tutorial04.c4s/Script.c	Mon Dec 13 23:22:15 2010 +0100
+++ b/planet/Tutorial.c4f/Tutorial04.c4s/Script.c	Tue Dec 14 18:02:33 2010 +0100
@@ -37,7 +37,7 @@
 	
 	// Second section: Weak opponent with javelins.
 	var spearman1 = CreateObject(Clonk, 1050, 560, NO_OWNER);
-	spearman1->SetMaxEnergy(40000);
+	spearman1->SetMaxEnergy(40);
 	spearman1->CreateContents(Javelin);
 	spearman1->AI_GuardArea(800, 400, 400, 250);
 	AddEffect("IntContentRemoval", spearman1, 100, 0);
@@ -50,14 +50,14 @@
 	// Third section: Two opponents in a tower.
 	// Lower part: a weak spearman.
 	var spearman2 = CreateObject(Clonk, 1753, 410, NO_OWNER);
-	spearman2->SetMaxEnergy(40000);
+	spearman2->SetMaxEnergy(40);
 	spearman2->CreateContents(Javelin);
 	spearman2->AI_GuardArea(1350, 200, 500, 400);
 	AddEffect("IntContentRemoval", spearman2, 100, 0);
 	CreateObject(EnergyBar)->SetTarget(spearman2);
 	// Upper part: a normal bowman.
 	var bowman = CreateObject(Clonk, 1732, 330, NO_OWNER);
-	bowman->SetMaxEnergy(45000);
+	bowman->SetMaxEnergy(45);
 	bowman->CreateContents(Bow)->CreateContents(Arrow);
 	bowman->AI_GuardArea(1350, 200, 500, 400);
 	AddEffect("IntContentRemoval", bowman, 100, 0);
@@ -69,7 +69,7 @@
 	
 	// Fourth section: Opponent with sword and shield.
 	var swordman = CreateObject(Clonk, 2250, 330, NO_OWNER);
-	swordman->SetMaxEnergy(60000);
+	swordman->SetMaxEnergy(60);
 	swordman->CreateContents(Shield);
 	swordman->CreateContents(Sword);
 	swordman->AI_GuardArea(2050, 300, 300, 100);
