diff --git a/planet/Defense.ocf/FightForGidl.ocs/CustomAI.ocd/Script.c b/planet/Defense.ocf/FightForGidl.ocs/CustomAI.ocd/Script.c index 9c2433ae1..6143d8e2e 100644 --- a/planet/Defense.ocf/FightForGidl.ocs/CustomAI.ocd/Script.c +++ b/planet/Defense.ocf/FightForGidl.ocs/CustomAI.ocd/Script.c @@ -202,9 +202,8 @@ func LaunchEnemy(proplist enemy, int xmin, int xrange, int y) obj.JumpSpeed = obj.JumpSpeed * enemy.Speed / 100; obj.FlySpeed = obj.FlySpeed * enemy.Speed / 100; } - obj.MaxContentsCount = CustomAI.Clonk_MaxContentsCount; + obj.MaxContentsCount = 1; obj->MakeInvincibleToFriendlyFire(); - obj.MaxContentsCountVal = 1; // Reward for killing enemy obj.Bounty = enemy.Bounty; // Vehicles @@ -267,6 +266,4 @@ func LaunchEnemy(proplist enemy, int xmin, int xrange, int y) // global func ForceVal2Array(v) { if (GetType(v) != C4V_Array) return [v]; else return v; } -// forward max contents count to property -func Clonk_MaxContentsCount() { return this.MaxContentsCountVal; } diff --git a/planet/Defense.ocf/FightForGidl.ocs/Script.c b/planet/Defense.ocf/FightForGidl.ocs/Script.c index 45118eb22..f1c9020bc 100644 --- a/planet/Defense.ocf/FightForGidl.ocs/Script.c +++ b/planet/Defense.ocf/FightForGidl.ocs/Script.c @@ -103,8 +103,7 @@ func JoinPlayer(plr, prev_clonk) clonk->DoEnergy(1000); clonk->MakeInvincibleToFriendlyFire(); // contents - clonk.MaxContentsCount = CustomAI.Clonk_MaxContentsCount; - clonk.MaxContentsCountVal = 1; + clonk.MaxContentsCount = 1; if (prev_clonk) TransferInventory(prev_clonk, clonk); if (!clonk->ContentsCount()) { diff --git a/planet/Defense.ocf/Windmill.ocs/CustomAI.ocd/Script.c b/planet/Defense.ocf/Windmill.ocs/CustomAI.ocd/Script.c index fe31d5980..3a5f25f93 100644 --- a/planet/Defense.ocf/Windmill.ocs/CustomAI.ocd/Script.c +++ b/planet/Defense.ocf/Windmill.ocs/CustomAI.ocd/Script.c @@ -479,9 +479,8 @@ func LaunchEnemy(proplist enemy, int xmin, int xrange, int ymin, yrange) obj.JumpSpeed = obj.JumpSpeed * enemy.Speed / 100; obj.FlySpeed = obj.FlySpeed * enemy.Speed / 100; } - obj.MaxContentsCount = CustomAI.Clonk_MaxContentsCount; + obj.MaxContentsCount = 2; obj->MakeInvincibleToFriendlyFire(); - obj.MaxContentsCountVal = 2; // Reward for killing enemy obj.Bounty = enemy.Bounty; // Vehicles @@ -552,6 +551,3 @@ func LaunchEnemy(proplist enemy, int xmin, int xrange, int ymin, yrange) g_spawned_enemies[GetLength(g_spawned_enemies)] = obj; return obj; } - -// forward max contents count to property -func Clonk_MaxContentsCount() { return this.MaxContentsCountVal; } \ No newline at end of file diff --git a/planet/Defense.ocf/Windmill.ocs/Script.c b/planet/Defense.ocf/Windmill.ocs/Script.c index ebc07d965..c8fc562b6 100644 --- a/planet/Defense.ocf/Windmill.ocs/Script.c +++ b/planet/Defense.ocf/Windmill.ocs/Script.c @@ -101,8 +101,7 @@ func JoinPlayer(plr, prev_clonk) clonk->DoEnergy(1000); clonk->MakeInvincibleToFriendlyFire(); // contents - clonk.MaxContentsCount = CustomAI.Clonk_MaxContentsCount; - clonk.MaxContentsCountVal = 1; + clonk.MaxContentsCount = 1; if (prev_clonk) TransferInventory(prev_clonk, clonk); if (!clonk->ContentsCount()) { diff --git a/planet/Experimental.ocf/CableLorrys.ocs/CableCars.ocd/Vehicles.ocd/Lorry.ocd/Script.c b/planet/Experimental.ocf/CableLorrys.ocs/CableCars.ocd/Vehicles.ocd/Lorry.ocd/Script.c index 214d21ee0..8c10008c7 100644 --- a/planet/Experimental.ocf/CableLorrys.ocs/CableCars.ocd/Vehicles.ocd/Lorry.ocd/Script.c +++ b/planet/Experimental.ocf/CableLorrys.ocs/CableCars.ocd/Vehicles.ocd/Lorry.ocd/Script.c @@ -51,14 +51,11 @@ protected func ContactRight() /*-- Contents --*/ -private func MaxContentsCount() -{ - return 50; -} +local MaxContentsCount = 50; protected func RejectCollect(id object_id, object obj) { - if (ContentsCount() < this->MaxContentsCount()) + if (ContentsCount() < MaxContentsCount) { Sound("Objects::Clonk"); return false; diff --git a/planet/Objects.ocd/HUD.ocd/Controller.ocd/ControllerInventoryBar.ocd/Script.c b/planet/Objects.ocd/HUD.ocd/Controller.ocd/ControllerInventoryBar.ocd/Script.c index f88514b93..badaac14d 100644 --- a/planet/Objects.ocd/HUD.ocd/Controller.ocd/ControllerInventoryBar.ocd/Script.c +++ b/planet/Objects.ocd/HUD.ocd/Controller.ocd/ControllerInventoryBar.ocd/Script.c @@ -238,7 +238,7 @@ private func UpdateInventory() // Sets the inventory size to the currently selected clonk private func UpdateInventoryButtons(object clonk) { - var max_contents_count = clonk->~MaxContentsCount(); + var max_contents_count = clonk.MaxContentsCount; var old_count = GetLength(inventory_slots); diff --git a/planet/Objects.ocd/Items.ocd/Tools.ocd/Crate.ocd/Script.c b/planet/Objects.ocd/Items.ocd/Tools.ocd/Crate.ocd/Script.c index 6b0ed7246..4f021052d 100644 --- a/planet/Objects.ocd/Items.ocd/Tools.ocd/Crate.ocd/Script.c +++ b/planet/Objects.ocd/Items.ocd/Tools.ocd/Crate.ocd/Script.c @@ -29,14 +29,11 @@ protected func Construction() /*-- Contents --*/ -private func MaxContentsCount() -{ - return 5; -} +local MaxContentsCount = 5; protected func RejectCollect(id def, object obj) { - if (ContentsCount() >= MaxContentsCount()) + if (ContentsCount() >= MaxContentsCount) return true; if (obj->~IsCarryHeavy()) return true; diff --git a/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/Script.c b/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/Script.c index f4007722e..07379cf19 100644 --- a/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/Script.c +++ b/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/Script.c @@ -30,7 +30,7 @@ protected func Construction() effect.oldcount = count; } -protected func MaxContentsCount() { return 12; } +local MaxContentsCount = 12; public func GetPowderCount() { diff --git a/planet/Objects.ocd/Libraries.ocd/ClonkControl.ocd/Script.c b/planet/Objects.ocd/Libraries.ocd/ClonkControl.ocd/Script.c index f783b0a74..7548dd809 100644 --- a/planet/Objects.ocd/Libraries.ocd/ClonkControl.ocd/Script.c +++ b/planet/Objects.ocd/Libraries.ocd/ClonkControl.ocd/Script.c @@ -64,8 +64,8 @@ static const ELEVATOR_CALL_DISTANCE = 30; /* Item limit */ -public func MaxContentsCount() { return 5; } // Size of the clonks inventory -public func HandObjects() { return 1; } // Amount of hands to select items +local MaxContentsCount = 5; // Size of the clonks inventory +local HandObjects = 1; // Amount of hands to select items public func NoStackedContentMenu() { return true; } // Contents-Menu shall display each object in a seperate slot diff --git a/planet/Objects.ocd/Libraries.ocd/ClonkInventoryControl.ocd/Script.c b/planet/Objects.ocd/Libraries.ocd/ClonkInventoryControl.ocd/Script.c index ab6475113..c78b6fa53 100644 --- a/planet/Objects.ocd/Libraries.ocd/ClonkInventoryControl.ocd/Script.c +++ b/planet/Objects.ocd/Libraries.ocd/ClonkInventoryControl.ocd/Script.c @@ -55,7 +55,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re if (ctrl == CON_QuickSwitch) { // but ignore quickswitch if we have more than 1 hand-slot - if(this->HandObjects() > 1) + if(this.HandObjects > 1) return inherited(plr, ctrl, x, y, strength, repeat, release, ...);; // select last slot @@ -144,8 +144,8 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re if (inventory_shift) { - var current = (this->GetHandItemPos(0) + inventory_shift) % this->MaxContentsCount(); - if (current < 0) current = this->MaxContentsCount() + current; + var current = (this->GetHandItemPos(0) + inventory_shift) % this.MaxContentsCount; + if (current < 0) current = this.MaxContentsCount + current; this->SetHandItemPos(0, current); return true; } @@ -193,7 +193,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re // only the last-pressed key is taken into consideration. // if 2 hotkeys are held, the earlier one is being treated as released - if (hot > 0 && hot <= this->MaxContentsCount()) + if (hot > 0 && hot <= this.MaxContentsCount) { SetHandItemPos(0, hot-1); return true; diff --git a/planet/Objects.ocd/Libraries.ocd/Inventory.ocd/Script.c b/planet/Objects.ocd/Libraries.ocd/Inventory.ocd/Script.c index b757ef4bd..00f3e6a08 100644 --- a/planet/Objects.ocd/Libraries.ocd/Inventory.ocd/Script.c +++ b/planet/Objects.ocd/Libraries.ocd/Inventory.ocd/Script.c @@ -7,10 +7,10 @@ The inventory management: The objects in the inventory are saved (parallel to Contents()) in the array 'inventory'. They are accessed via GetItem(i) and GetItemPos(obj). - Other functions are MaxContentsCount() (defines the maximum number of + Other properties are MaxContentsCount (defines the maximum number of contents) - Furthermore the clonk has a defined amount of "hands", defined by HandObjects(). + Furthermore the clonk has a defined amount of "hands", defined by local HandObjects. The array 'use_objects' is a mapping of "hands" onto the inventory-slots. The functions GetHandItem(i) returns the object in the "i"th hand. @@ -23,8 +23,8 @@ /* Item limit */ -public func MaxContentsCount() { return 10; } // Size of the inventory -public func HandObjects() { return 1; } // Amount of hands to select items +local MaxContentsCount = 10; // Size of the inventory +local HandObjects = 1; // Amount of hands to select items func Construction() { @@ -35,7 +35,7 @@ func Construction() this.inventory.hand_objects = []; this.inventory.force_collection = false; - for(var i=0; i < HandObjects(); i++) + for(var i=0; i < HandObjects; i++) this.inventory.hand_objects[i] = i; return _inherited(...); } @@ -85,7 +85,7 @@ public func GetHandItem(int i) public func SetHandItemPos(int hand, int inv) { // indices are in range? - if(hand >= HandObjects() || inv >= MaxContentsCount()) + if(hand >= HandObjects || inv >= MaxContentsCount) return nil; if(hand < 0 || inv < 0) return nil; // no slot change? @@ -214,8 +214,8 @@ public func GetItemPos(object item) public func Switch2Items(int one, int two) { // no valid inventory index: cancel - if (!Inside(one,0,MaxContentsCount()-1)) return; - if (!Inside(two,0,MaxContentsCount()-1)) return; + if (!Inside(one,0,MaxContentsCount-1)) return; + if (!Inside(two,0,MaxContentsCount-1)) return; // switch them around var temp = this.inventory.objects[one]; @@ -279,7 +279,7 @@ public func Collect(object item, bool ignoreOCF, int pos, bool force) return success; } // fail if the specified slot is full - if (GetItem(pos) == nil && pos >= 0 && pos < MaxContentsCount()) + if (GetItem(pos) == nil && pos >= 0 && pos < MaxContentsCount) { if (item) { @@ -319,7 +319,7 @@ protected func Collection2(object obj) var i; // sort into selected hands if empty - for(i = 0; i < HandObjects(); i++) + for(i = 0; i < HandObjects; i++) if(!GetHandItem(i)) { sel = GetHandItemPos(i); @@ -331,7 +331,7 @@ protected func Collection2(object obj) // otherwise, first empty slot if(!success) { - for(var i = 0; i < MaxContentsCount(); ++i) + for(var i = 0; i < MaxContentsCount; ++i) { if (!GetItem(i)) { @@ -464,7 +464,7 @@ protected func RejectCollect(id objid, object obj) // Can't carry bucket material with bare hands. if (obj->~IsBucketMaterial()) return true; // check max contents - if (ContentsCount() >= MaxContentsCount()) return true; + if (ContentsCount() >= MaxContentsCount) return true; return _inherited(objid,obj,...); } diff --git a/planet/Objects.ocd/Structures.ocd/Chest.ocd/Script.c b/planet/Objects.ocd/Structures.ocd/Chest.ocd/Script.c index 9148e326d..9f6e24416 100644 --- a/planet/Objects.ocd/Structures.ocd/Chest.ocd/Script.c +++ b/planet/Objects.ocd/Structures.ocd/Chest.ocd/Script.c @@ -23,14 +23,11 @@ protected func Construction() public func IsContainer() { return true; } -private func MaxContentsCount() -{ - return 50; -} +local MaxContentsCount = 50; protected func RejectCollect() { - if (ContentsCount() >= this->MaxContentsCount()) + if (ContentsCount() >= MaxContentsCount) return true; return false; } diff --git a/planet/Objects.ocd/Vehicles.ocd/Lorry.ocd/Script.c b/planet/Objects.ocd/Vehicles.ocd/Lorry.ocd/Script.c index b2967510c..1f149867f 100644 --- a/planet/Objects.ocd/Vehicles.ocd/Lorry.ocd/Script.c +++ b/planet/Objects.ocd/Vehicles.ocd/Lorry.ocd/Script.c @@ -136,10 +136,7 @@ public func FxBlockCollectionByLorryTimer() { return FX_Execute_Kill; } /*-- Contents --*/ -private func MaxContentsCount() -{ - return 50; -} +local MaxContentsCount = 50; protected func RejectCollect(id object_id, object obj) { @@ -148,7 +145,7 @@ protected func RejectCollect(id object_id, object obj) return true; // Objects can still be collected. - if (ContentsCount() < this->MaxContentsCount()) + if (ContentsCount() < MaxContentsCount) { Sound("Objects::Clonk"); return false; diff --git a/planet/Parkour.ocf/Boomrace.ocs/System.ocg/Clonk.c b/planet/Parkour.ocf/Boomrace.ocs/System.ocg/Clonk.c index d06298055..315f62a66 100644 --- a/planet/Parkour.ocf/Boomrace.ocs/System.ocg/Clonk.c +++ b/planet/Parkour.ocf/Boomrace.ocs/System.ocg/Clonk.c @@ -9,10 +9,7 @@ protected func RejectCollect(id objid, object obj) return _inherited(objid, obj); } -public func MaxContentsCount() -{ - return 0; -} +local MaxContentsCount = 0; public func ObjectControl(int plr, int ctrl) { diff --git a/planet/Parkour.ocf/Boomshire.ocs/System.ocg/Clonk.c b/planet/Parkour.ocf/Boomshire.ocs/System.ocg/Clonk.c index c1d108aba..723aee53d 100644 --- a/planet/Parkour.ocf/Boomshire.ocs/System.ocg/Clonk.c +++ b/planet/Parkour.ocf/Boomshire.ocs/System.ocg/Clonk.c @@ -9,15 +9,8 @@ protected func RejectCollect(id objid, object obj) } // Only one inventory slot. -public func MaxContentsCount() -{ - return 1; -} - -public func HandObjects() -{ - return 1; -} +local MaxContentsCount = 1; +local HandObjects = 1; // Lose all items on death. func StartDead() diff --git a/planet/System.ocg/Library_Inventory.c b/planet/System.ocg/Library_Inventory.c index 8d4a175ff..23c200e73 100644 --- a/planet/System.ocg/Library_Inventory.c +++ b/planet/System.ocg/Library_Inventory.c @@ -5,7 +5,7 @@ // overload function for objects with Inventory.ocd global func ShiftContents(bool shift_back, id target_id) { - if (this && (this->~HandObjects() > 0)) + if (this && (this.HandObjects > 0)) { // special handling for only one hand: just move the hand to next item // always move hand 0 @@ -13,7 +13,7 @@ global func ShiftContents(bool shift_back, id target_id) // move to target ID? if(target_id) { - for(var pos = 0; pos < this->MaxContentsCount(); ++pos) + for(var pos = 0; pos < this.MaxContentsCount; ++pos) { var obj = this.inventory.objects[pos]; if(!obj) continue; @@ -29,11 +29,11 @@ global func ShiftContents(bool shift_back, id target_id) var move_dir = 1; if(shift_back) move_dir = -1; var current_pos = this->GetHandItemPos(0); - for(var i = this->MaxContentsCount(); i > 0; --i) + for(var i = this.MaxContentsCount; i > 0; --i) { current_pos += move_dir; - if(current_pos < 0) current_pos = this->MaxContentsCount() + current_pos; - else current_pos = current_pos % this->MaxContentsCount(); + if(current_pos < 0) current_pos = this.MaxContentsCount + current_pos; + else current_pos = current_pos % this.MaxContentsCount; // is there an object at the slot? if(!this.inventory.objects[current_pos]) continue; diff --git a/planet/Worlds.ocf/Krakatoa.ocs/System.ocg/Airplane.c b/planet/Worlds.ocf/Krakatoa.ocs/System.ocg/Airplane.c index 351671cae..e5cd11e0b 100644 --- a/planet/Worlds.ocf/Krakatoa.ocs/System.ocg/Airplane.c +++ b/planet/Worlds.ocf/Krakatoa.ocs/System.ocg/Airplane.c @@ -5,15 +5,12 @@ public func IsContainer() { return true; } -private func MaxContentsCount() -{ - return 25; -} +local MaxContentsCount = 25; protected func RejectCollect(id object_id, object obj) { // Objects can collected if gold bar and not above max contents count. - if (ContentsCount() < MaxContentsCount() && object_id == GoldBar) + if (ContentsCount() < MaxContentsCount && object_id == GoldBar) return false; return true; }