New feature: random items allow spawn not themselves, but an item from a brad selection

- specify random items in RandomItems.xml
- when the game creates a random item, it searches all vialbe items according to random item class and picks one randomly
- this allows mappers to place items in maps that are more independent of the xml-set used, however the random items themselves msut be the same in map&mod
- can also be used to broaden the enemy gun/item choices selection
- for more reference, see http://www.bears-pit.com/board/ubbthreads.php/topics/310793.html#Post310793

FIX: sector curfew value was interpreted wrong

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5594 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2012-09-30 21:59:47 +00:00
parent 84c86d96ad
commit ff157fd96b
13 changed files with 577 additions and 9 deletions
+8 -1
View File
@@ -5,6 +5,7 @@
#include "GameSettings.h"
#include "screenids.h"
#include "Action Items.h" // added by Flugente for the ACTION_ITEM_BLOW_UP value
#include "Random.h" // added by Flugente
int BODYPOSFINAL = GUNSLINGPOCKPOS;//RESET in initInventory
@@ -1326,6 +1327,11 @@ OBJECTTYPE& OBJECTTYPE::operator=(const OLD_OBJECTTYPE_101& src)
this->usItem = NONE;
}
// Flugente: random items
UINT16 newitemfromrandom = 0;
if ( GetItemFromRandomItem(src.usItem, &newitemfromrandom) )
this->usItem = newitemfromrandom;
//and now the big change, the union
//copy the old data, making sure not to write over, since the old size is actually 9 bytes
if (ubNumberOfObjects == 1) {
@@ -1341,7 +1347,8 @@ OBJECTTYPE& OBJECTTYPE::operator=(const OLD_OBJECTTYPE_101& src)
(*this)[0]->data.gun.bGunAmmoStatus = 0;
(*this)[0]->data.gun.ubGunState = 0;
//Lastly, convert values from the old format to the new based on the type of object
switch(Item[src.usItem].usItemClass)
switch(Item[this->usItem].usItemClass)
{
case IC_MONEY:
(*this)[0]->data.money.uiMoneyAmount = src.ugYucky.uiMoneyAmount;