Page 3 of 5

Re: Rotating weapon help

Posted: July 12th, 2010, 12:35 pm
by Rezil
You don't change anything in _weapon_pickup.gsc. Just follow the tutorial, you add a line of code to your main function(in this case setupWeaponForPickup("panzerschreck_mp", "xmodel/weapon_panzerschreck", 5);) and include this .gsc by using #include maps\mp\_weapon_pickup; at the very top of your maps main .gsc.

Re: Rotating weapon help

Posted: July 12th, 2010, 1:03 pm
by <LT>YosemiteSam[NL]
Thx guys it worked.... but ;
- First time you pick up the weapon you have no ammo
- Second time you get the max amount of ammo... I want it to give only 1 projectile (panzerschreck remember :wink: ).

Re: Rotating weapon help

Posted: July 12th, 2010, 1:07 pm
by Rezil
No problem, modify _weapon_pickup.gsc. Add this line under user giveweapon(weapon); :

Code: Select all

user givestartammo(weapon);
I'm not sure whether the panzerschreck has start ammo defined but this is the basic script.

Re: Rotating weapon help

Posted: July 12th, 2010, 1:26 pm
by <LT>YosemiteSam[NL]
Panzerschreck doesn't have startammo.
But I changed the panzer file into 1 missile and the max ammo aswell, now it works like a charm.
Again thx :)

Re: Rotating weapon help

Posted: July 12th, 2010, 1:33 pm
by Rezil
No prob.

Re: Rotating weapon help

Posted: July 12th, 2010, 1:35 pm
by <LT>YosemiteSam[NL]
Can I use this script for 3 different weapons, I mean I want the pick up sounds to be different ?
for the redeemer/damageamp/normal pick up I mean.

Re: Rotating weapon help

Posted: July 12th, 2010, 1:45 pm
by Rezil
I can modify the script so you have to input different sounds for picking up the weapon. Do you want the same sound for maxammo and respawning?

Code: Select all

setupWeaponForPickup(weapon_name, weapon_xmodel, soundalias, delay)
{
	precachemodel(weapon_xmodel);
	trig = getentarray("weapon_pickup_" +weapon_name,"targetname");
	org = getentarray("weapon_origin_" +weapon_name,"targetname");
	if(org.size == trig.size) //same ammount of origins and triggers, otherwise you get errors
	{
		for(i=0;i<org.size;i++)
		{
			trig[i] thread WeaponPickup(org[i], weapon_name, weapon_xmodel, soundalias, delay);
			
		}
	}
}

WeaponPickup(o, weapon, xmodel, sound, delay)
{
	while(1)
	{
		o setmodel(xmodel);
		o notsolid(); //already true, just not sure about all script_models
		self waittill("trigger", user);
		c_weap = user getcurrentweapon();
		if(user hasweapon(weapon)) 
		{ //user already has that weapon, so keep the model showing and only max out the ammo
			user givemaxammo(weapon); 
			wait 10; //to prevent unlimited ammo while staying inside the trigger
			o playsound("weapon_maxammo"); 
		}
		else 
		{
			user takeweapon(c_weap);
			user giveweapon(weapon);
			user switchtoweapon(weapon);
			o playsound(sound);
			
			o hide();
			self maps\mp\_utility::TriggerOff();
			
			if(isdefined(delay))
			{
				wait delay;
			}
			
			self maps\mp\_utility::TriggerOn();
			o playsound("weapon_respawned");
			o show();
		}
	}
}

Re: Rotating weapon help

Posted: July 12th, 2010, 2:09 pm
by <LT>YosemiteSam[NL]
Maxammo and spawn are all the same.
But I'm at a loss :?
how does this work, putting the sound here plays the same sound for all weapons .. right ?

Code: Select all

user takeweapon(c_weap);
         user giveweapon(weapon);
         user switchtoweapon(weapon);
         o playsound(sound);

Re: Rotating weapon help

Posted: July 12th, 2010, 2:15 pm
by Rezil
No, you add multiple setupWeaponForPickup in your main script for multiple weapons. You have to add multiple triggers and origins for multiple weapons as well. For example if you wanted a luger and an m1garand respawning, you would create a trigger and script_model for the luger and a different trigger and script_model for the garand. Then you just add multiple setupWeaponForPickup in your main script. You don't modify _weapon_pickup.gsc. I did that for your convenience. :P

Re: Rotating weapon help

Posted: July 12th, 2010, 2:20 pm
by <LT>YosemiteSam[NL]
:) Ok I 'll give it a go.....doing so many things at the same time at the moment :?

Re: Rotating weapon help

Posted: July 12th, 2010, 3:09 pm
by <LT>YosemiteSam[NL]
Got it all working, still 10 weapons or so to go :?
But when I pick up the ammo the sound doesn't play (the normal pickup ammo sound I mean)
Any ideas ?

Re: Rotating weapon help

Posted: July 12th, 2010, 3:22 pm
by Rezil
That's because everything is scripted. You have to make sounds for picking up, picking up ammo and respawning the weapon(or at least make the soundaliases).

Re: Rotating weapon help

Posted: July 12th, 2010, 4:15 pm
by <LT>YosemiteSam[NL]
Aha ok. I'll try that.

I made 3 weapons respawn and picked up by a trigger multiple but 1 of em (panzeschreck) doesn't work, I get this error;

Oh yeah, is it also possible to let players carry more then 2 weapons ( 15 for instance) ?

Re: Rotating weapon help

Posted: July 12th, 2010, 4:22 pm
by Rezil
Precache the weapon first, then try again.

Re: Rotating weapon help

Posted: July 12th, 2010, 7:17 pm
by <LT>YosemiteSam[NL]
My main code is like this now ;

Code: Select all

#include maps\mp\_weapon_pickup;
main()
{

maps\mp\_load::main();
ambientPlay("ambient_mp_deck16");
maps\mp\bounce_jump::main();
maps\mp\teleport::main();
maps\mp\poison::main();
maps\mp\elevators::main();
//maps\mp\redeemer_rotate::main();

game["allies"] = "british";
game["axis"] = "german";
game["british_soldiertype"] = "airborne";
game["british_soldiervariation"] = "normal";
game["german_soldiertype"] = "fallschirmjagergrey";
game["german_soldiervariation"] = "normal";
game["attackers"] = "allies";
game["defenders"] = "axis";

setcvar ("g_gravity", 800);
setcvar ("g_speed" , 300);
setcvar ("jump_height" ,55);
setcvar ("bg_fallDamageMinHeight", 100000); 
setcvar ("bg_fallDamageMaxHeight", 200000);
setcvar ("scr_dm_timelimit" , "6");
level thread precache();
setupWeaponForPickup("bren_mp", "xmodel/weapon_bren","weap_pickup", 30);
setupWeaponForPickup("panzerschreck_mp", "xmodel/weapon_panzerschreck","weap_pickup", 10);
setupWeaponForPickup("m1garand_mp", "xmodel/weapon_m1garand","weap_pickup", 10);
}
precache()
{
precachemodel("xmodel/weapon_panzerschreck");
}
but still I get the error, did I precache right ?