Code: Select all
aaa.RandomContents();
Code: Select all
let wep=(class<hdweapon>)(invclasses[thisitem]);
HDGearcrate.wad
Code: Select all
extend class HDGearCrate{
void RandomContents(){
if(hd_debug)A_Log("\n* Backpack: *");
for(int i=0;i<5;i++){
int thisitem=random(1,invclasses.size())-1;
let wep=(class<hdweapon>)(invclasses[thisitem]);
let pkup=(class<hdpickup>)(invclasses[thisitem]);
let mag=(class<hdmagammo>)(pkup);
int howmany=0;
if(wep){
let iii=inventory(spawn(wep,pos,ALLOW_REPLACE));
if(hdweapongiver(iii))itemtobackpack(hdweapongiver(iii).actualweapon);
else if(hdpickupgiver(iii))itemtobackpack(hdpickupgiver(iii).actualitem);
else itemtobackpack(iii);
}else if(mag){
howmany=min(
random(1,random(1,20)),
getdefaultbytype(mag).maxamount,
HDCONST_BPMAX/(
max(1.,getdefaultbytype(mag).roundbulk)
*max(1.,getdefaultbytype(mag).magbulk)
*5.
)
);
for(int j=0;j<howmany;j++){
inventory iii=inventory(spawn(mag,pos,ALLOW_REPLACE));
if(iii){
itemtobackpack(iii);
if(iii)iii.destroy();
}
}
}else if(pkup){
let iii=spawn(pkup,pos,ALLOW_REPLACE);
if(iii){
iii.destroy();
howmany=min(
random(1,getdefaultbytype(pkup).bmultipickup?random(1,80):random(1,random(1,20))),
getdefaultbytype(pkup).maxamount,
HDCONST_BPMAX/(max(1.,getdefaultbytype(pkup).bulk)*5.)
);
if(
getdefaultbytype(pkup).refid==""
){
howmany=random(-2,howmany);
}
amounts[thisitem]=""..howmany;
if(amounts[thisitem].toint()<1)amounts[thisitem]="";
}
}
if(hd_debug)A_Log(invclasses[thisitem].." "..howmany);
}
weaponbulk();
updatemessage(index);
}
}
Code: Select all
class WildGearCrate:IdleDummy {
//$Category "Items/Hideous Destructor/Gear"
//$Title "Backpack (Random Spawn)"
//$Sprite "GRCRA0"
override void postbeginplay(){
super.postbeginplay();
let aaa=HDBackpack(spawn("HDGearCrate",pos,ALLOW_REPLACE));
aaa.RandomContents();
destroy();
}
}
Code: Select all
extend class HDBackpack{
void RandomContents(){
if(hd_debug)A_Log("\n* Backpack: *");
for(int i=0;i<5;i++){
int thisitem=random(1,invclasses.size())-1;
let wep=(class<hdweapon>)(invclasses[thisitem]);
let pkup=(class<hdpickup>)(invclasses[thisitem]);
let mag=(class<hdmagammo>)(pkup);
int howmany=0;
if(wep){
let iii=inventory(spawn(wep,pos,ALLOW_REPLACE));
if(hdweapongiver(iii))itemtobackpack(hdweapongiver(iii).actualweapon);
else if(hdpickupgiver(iii))itemtobackpack(hdpickupgiver(iii).actualitem);
else itemtobackpack(iii);
}else if(mag){
howmany=min(
random(1,random(1,20)),
getdefaultbytype(mag).maxamount,
HDCONST_BPMAX/(
max(1.,getdefaultbytype(mag).roundbulk)
*max(1.,getdefaultbytype(mag).magbulk)
*5.
)
);
for(int j=0;j<howmany;j++){
inventory iii=inventory(spawn(mag,pos,ALLOW_REPLACE));
if(iii){
itemtobackpack(iii);
if(iii)iii.destroy();
}
}
}else if(pkup){
let iii=spawn(pkup,pos,ALLOW_REPLACE);
if(iii){
iii.destroy();
howmany=min(
random(1,getdefaultbytype(pkup).bmultipickup?random(1,80):random(1,random(1,20))),
getdefaultbytype(pkup).maxamount,
HDCONST_BPMAX/(max(1.,getdefaultbytype(pkup).bulk)*5.)
);
if(
getdefaultbytype(pkup).refid==""
){
howmany=random(-2,howmany);
}
amounts[thisitem]=""..howmany;
if(amounts[thisitem].toint()<1)amounts[thisitem]="";
}
}
if(hd_debug)A_Log(invclasses[thisitem].." "..howmany);
}
weaponbulk();
updatemessage(index);
}