Author Topic: Adding a random WEAPON to a player?  (Read 2056 times)

Code: [Select]
function pickupCrate(%this, %obj, %col)
{
serverPlay3D(crateSound,%obj.getPosition());
%obj.delete();
        //code for adding a random weapon here
}

I need it to definately be a weapon and not the crate itself or a printer or hammer or something like that
How 2 do

make list of available weapons and chose random one
no way to do this automatically, either set up a row of bricks with weapons on them and then "read" it or create list of datablocks yourself

make list of available weapons and chose random one
no way to do this automatically, either set up a row of bricks with weapons on them and then "read" it or create list of datablocks yourself
datablockGroup
on init loop through and grab all weapon datablocks
put in array
give to player when you want

this is completely automatic.

datablockGroup
on init loop through and grab all weapon datablocks
put in array
give to player when you want

this is completely automatic.
Could you give me a tutorial on arrays and datablockGroups and init loops?

datablockGroup
on init loop through and grab all weapon datablocks
put in array
give to player when you want

this is completely automatic.

that's still going to give you stuff like the hammer and wand??

that's still going to give you stuff like the hammer and wand??

You can check for %datablock.className $= "Weapon", right?

that's still going to give you stuff like the hammer and wand??
I guess you could make a list of exclusions, and exclude things that have no uiName, and
You can check for %datablock.className $= "Weapon", right?

You can check for %datablock.className $= "Weapon", right?

You mean WeaponImage? I've seen tools with it and weapons without it.

I guess you could make a list of exclusions, and exclude things that have no uiName, and

How are you going to just magically exclude every single add-on  tool ever?

You mean WeaponImage? I've seen tools with it and weapons without it.

I meant to say category:

Code: [Select]
datablock ItemData(swordItem)
{
category = "Weapon";  // Mission editor category
//stuff
};

Every weapon that I've checked has category set to "Weapon".
« Last Edit: December 04, 2013, 01:03:59 AM by Greek2me »

You could check if the projectile can't deal damage, but that won't exclude things like the hammer. But the hammer is arguably a weapon as well as a tool because it deal damage, so I would just check if the projectile can deal damage or radius damage.

Why not just define a list of avaible weapons to be found with global vars?
Code: [Select]
$Stuff::AvaibleWeapon[0] = "sandvichGunItem";
$Stuff::AvaibleWeapon[1] = "sandvichGunItem";
$Stuff::AvaibleWeapon[2] = "sordItem";
$Stuff::AvaibleWeapon[3] = "pootisSpencerItem";
And then have a for loop cycle through the variables for a random one.

Another good way to do this is using $Stuff::AvaibleWeapons = "sandvichGunItem sodItem pootisSpencerItem"; as a variable and then use getWord().

I meant to say category:

Code: [Select]
datablock ItemData(swordItem)
{
category = "Weapon";  // Mission editor category
//stuff
};

Every weapon that I've checked has category set to "Weapon".
I'm pretty sure thats for the Wrench Dialog but yeah.

Every weapon that I've checked has category set to "Weapon".
Yeah and all the tools do too.

Why not just define a list of avaible weapons to be found with global vars?
Code: [Select]
$Stuff::AvaibleWeapon[0] = "sandvichGunItem";
$Stuff::AvaibleWeapon[1] = "sandvichGunItem";
$Stuff::AvaibleWeapon[2] = "sordItem";
$Stuff::AvaibleWeapon[3] = "pootisSpencerItem";
And then have a for loop cycle through the variables for a random one.

Another good way to do this is using $Stuff::AvaibleWeapons = "sandvichGunItem sodItem pootisSpencerItem"; as a variable and then use getWord().
hardcoding is bad for things you want dynamic

I meant to say category:

Code: [Select]
datablock ItemData(swordItem)
{
category = "Weapon";  // Mission editor category
//stuff
};

Every weapon that I've checked has category set to "Weapon".
I don't put that in my weapons

I don't put that in my weapons
well start or else they clearly wont be included in things like this.