Module dpmod: Change committed

havoc at icculus.org havoc at icculus.org
Sun Jul 27 02:19:27 EDT 2003


Commiter   : havoc
CVSROOT    : /cvs/cvsroot/twilight
Module     : dpmod
Commit time: 2003-07-27 06:19:27 UTC

Log message:

fixed empty backpack bug (by reverting to using items for ammo) and made monsters convert their quake inventory to inventory when spawning (just incase anyone put an ammo count in the monster entity)

Modified files:
     qc/inventory.qc qc/m_monsters.qc

------=MIME.8ec980287f76c18b87f85a4e728a3438
Content-Type: text/plain; name="dpmod.20030727.061927.havoc.diff"
Content-Disposition: attachment; filename="dpmod.20030727.061927.havoc.diff"
Content-Transfer-Encoding: 8bit

Index: dpmod/qc/inventory.qc
diff -u dpmod/qc/inventory.qc:1.2 dpmod/qc/inventory.qc:1.3
--- dpmod/qc/inventory.qc:1.2	Sat Jul 12 06:02:55 2003
+++ dpmod/qc/inventory.qc	Sun Jul 27 02:19:17 2003
@@ -17,6 +17,7 @@
 
 float(entity character) Inventory_GetBulk;
 float(entity character) Inventory_GetBulkLimit;
+
 entity(entity character, entity item) Inventory_GetNextItem;
 entity(entity character, string name) Inventory_ItemByName;
 void(entity character, entity item) Inventory_AttachItem;
@@ -26,14 +27,18 @@
 void(entity character, entity item) Inventory_PickupItem;
 float(entity character, string name, float itemcount) Inventory_DropByName;
 float(entity character, string name, float itemcount) Inventory_DestroyByName;
+
 float(entity character, entity absorbcharacter) Inventory_AbsorbInventory;
 float(entity character, string name) Inventory_Quantity;
 float(entity character, string name, float adjust) Inventory_AdjustQuantity;
 float(entity character, string name, float n) Inventory_SetQuantity;
+
+/*
 entity(entity character, string name, float chooseempty) Inventory_ItemWithMostCapacity;
 entity(entity character, string name, float choosefull) Inventory_ItemWithLeastCapacity;
 entity(entity character, string name, float choosefull) Inventory_ItemWithMostQuantity;
 entity(entity character, string name, float chooseempty) Inventory_ItemWithLeastQuantity;
+*/
 
 void(entity character) updateammodisplay;
 
@@ -462,6 +467,7 @@
 {
 	local float c;
 	local entity item;
+
 	c = 0;
 	item = Inventory_GetNextItem(character, world);
 	while (item)
@@ -483,6 +489,7 @@
 {
 	local float c;
 	local entity item;
+
 	c = 0;
 	item = Inventory_GetNextItem(absorbcharacter, world);
 	while (item)
@@ -503,85 +510,59 @@
 {
 	local float c;
 	local entity item;
-	if (name == "shells")
-		return character.ammo_shells;
-	else if (name == "nails")
-		return character.ammo_nails;
-	else if (name == "rockets")
-		return character.ammo_rockets;
-	else if (name == "cells")
-		return character.ammo_cells;
-	else if (name == "xshells")
-		return character.ammo_xshells;
-	else
+	c = 0;
+	item = character.inventory_next;
+	if (item == world)
+		item = character.inventory_next = character.inventory_prev = character;
+	while (item != character)
 	{
-		c = 0;
-		item = character.inventory_next;
-		if (item == world)
-			item = character.inventory_next = character.inventory_prev = character;
-		while (item != character)
-		{
-			if (item.netname == name)
-				c = c + item.count;
-			item = item.inventory_next;
-		}
-		return c;
+		if (item.netname == name)
+			c = c + item.count;
+		item = item.inventory_next;
 	}
+	return c;
 };
 
 float(entity character, string name, float adjust) Inventory_AdjustQuantity =
 {
 	local entity item, aitemclass;
 	local float c, total;
-	if (name == "shells")
-		return character.ammo_shells = bound(0, character.ammo_shells + adjust, AMMOMAX_SHELLS);
-	else if (name == "nails")
-		return character.ammo_nails = bound(0, character.ammo_nails + adjust, AMMOMAX_NAILS);
-	else if (name == "rockets")
-		return character.ammo_rockets = bound(0, character.ammo_rockets + adjust, AMMOMAX_ROCKETS);
-	else if (name == "cells")
-		return character.ammo_cells = bound(0, character.ammo_cells + adjust, AMMOMAX_CELLS);
-	else if (name == "xshells")
-		return character.ammo_xshells = bound(0, character.ammo_xshells + adjust, AMMOMAX_XSHELLS);
-	else
-	{
-		c = 0;
-		total = adjust;
-		item = Inventory_GetNextItem(character, world);
-		while (item && adjust != 0)
+	c = 0;
+	total = adjust;
+	item = Inventory_GetNextItem(character, world);
+	while (item && adjust != 0)
+	{
+		if (item.itemclass.netname == name)
 		{
-			if (item.itemclass.netname == name)
+			c = c + 1;
+			adjust = adjust - Item_AdjustQuantity(item, adjust);
+			if (item.count == 0)
 			{
-				c = c + 1;
-				adjust = adjust - Item_AdjustQuantity(item, adjust);
-				if (item.count == 0)
-				{
-					Item_Destroy(item);
-					item = world;
-					c = 0;
-				}
+				Item_Destroy(item);
+				item = world;
+				c = 0;
 			}
-			item = Inventory_GetNextItem(character, item);
 		}
-		// some may remain, check if we can spawn an item to hold it
-		if (adjust > 0)
-		{
-			aitemclass = ItemClass_FindByName(name);
-			//eprint(aitemclass);
-			if (c < aitemclass.count2)
-			if (aitemclass.bulkbase + aitemclass.bulkpercount * adjust <= character.bulklimit - Inventory_GetBulk(character))
-			{
-				// create item and add it to inventory
-				item = Item_Create(aitemclass);
-				item.count = adjust;
-				adjust = 0;
-				//eprint(item);
-				Inventory_AttachItem(character, item);
-			}
+		item = Inventory_GetNextItem(character, item);
+	}
+	// some may remain, check if we can spawn an item to hold it
+	if (adjust > 0)
+	{
+		aitemclass = ItemClass_FindByName(name);
+		//eprint(aitemclass);
+		if (c < aitemclass.count2)
+		if (aitemclass.bulkbase + aitemclass.bulkpercount * adjust <= character.bulklimit - Inventory_GetBulk(character))
+		{
+			// create item and add it to inventory
+			item = Item_Create(aitemclass);
+			item.count = adjust;
+			adjust = 0;
+			//eprint(item);
+			Inventory_AttachItem(character, item);
 		}
-		total = total - adjust;
-		return total;
 	}
+	total = total - adjust;
+	return total;
 };
 
 float(entity character, string name, float n) Inventory_SetQuantity =
@@ -590,6 +571,7 @@
 	return Inventory_AdjustQuantity(character, name, n);
 }
 
+/*
 entity(entity character, string name, float chooseempty) Inventory_ItemWithMostCapacity =
 {
 	local entity item, best;
@@ -693,6 +675,7 @@
 	}
 	return best;
 };
+*/
 
 /*
 float(entity character, string name, float n) Inventory_AdjustQuantityAllByName =
@@ -773,6 +756,24 @@
 /*
 };
 */
+
+void(entity character) Inventory_ConvertFromQuakeInventory =
+{
+	if (character.ammo_shells > 0)
+		Inventory_AdjustQuantity(character, "shells", character.ammo_shells);
+	character.ammo_shells = 0;
+	if (character.ammo_nails > 0)
+		Inventory_AdjustQuantity(character, "nails", character.ammo_nails);
+	character.ammo_nails = 0;
+	if (character.ammo_rockets > 0)
+		Inventory_AdjustQuantity(character, "rockets", character.ammo_rockets);
+	character.ammo_rockets = 0;
+	if (character.ammo_cells > 0)
+		Inventory_AdjustQuantity(character, "cells", character.ammo_cells);
+	character.ammo_cells = 0;
+	// TODO: convert .items
+	// TODO: convert .armorvalue/.armortype
+};
 
 void(entity character) updateammodisplay =
 {
Index: dpmod/qc/m_monsters.qc
diff -u dpmod/qc/m_monsters.qc:1.2 dpmod/qc/m_monsters.qc:1.3
--- dpmod/qc/m_monsters.qc:1.2	Thu Feb 20 03:52:35 2003
+++ dpmod/qc/m_monsters.qc	Sun Jul 27 02:19:17 2003
@@ -206,6 +206,7 @@
 
 void() walkmonster_start =
 {
+	Inventory_ConvertFromQuakeInventory(self);
 	self.candrown = 1; // this is turned off by some monsters like zombies
 	// delay drop to floor to make sure all doors have been spawned
 	// spread think times so they don't all happen at same time
@@ -297,6 +298,7 @@
 
 void() flymonster_start =
 {
+	Inventory_ConvertFromQuakeInventory(self);
 	self.candrown = 1;
 	// spread think times so they don't all happen at same time
 	self.nextthink = time + random()*0.5 + 0.1;
@@ -384,6 +386,7 @@
 
 void() swimmonster_start =
 {
+	Inventory_ConvertFromQuakeInventory(self);
 	// spread think times so they don't all happen at same time
 	self.candrown = 0;
 	self.nextthink = time + random()*0.5 + 0.1;


More information about the twilight-commits mailing list