Remove weapon/set ammo to 0 script

Discussions about Coding and Scripting
Post Reply
User avatar
Metalfist
Masterful
Posts: 632
Joined: Sun Jan 03, 2010 3:54 pm
Personal rank: ^,..,^ rawr

Remove weapon/set ammo to 0 script

Post by Metalfist »

This is the idea:
-The player teleports to a room where I have a BT like room where they have to jump to the end and not use the SLV to fly. At the end they get teleported back to the beginning.

So I need a little script or something to remove the SLV weapon from the players inventory (or all weapons) OR just set their SLV ammo to 0. Another workaround solution would be fine too (like a no flying zone). So is there an existing script/workaround or someone willing to code this little thingy for me? :help:
Last edited by Metalfist on Sun May 27, 2012 10:46 am, edited 1 time in total.
Image
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Remove weapon/set ammo to 0 script?

Post by JackGriffin »

OFC, I'll hook you up girl. Mail me what you want done and the way you'd prefer it and I'll do it tonight or tomorrow.
So long, and thanks for all the fish
User avatar
Metalfist
Masterful
Posts: 632
Joined: Sun Jan 03, 2010 3:54 pm
Personal rank: ^,..,^ rawr

Re: Remove weapon script

Post by Metalfist »

Thx gopostal for coding this!

Download WeaponRemover:
WeaponRemover.zip
(52.49 KiB) Downloaded 172 times
This is a weapon remover with some effects and sound. Place it like any trigger and pawns entering it's radius will cause it to fire. They see a flash, hear an electric boom and then all their weapons are gone.
Image
User avatar
Creavion
Godlike
Posts: 4497
Joined: Sun Feb 17, 2008 7:23 pm
Personal rank: About to be non-act.
Location: Germany, Lower Saxony

Re: Remove weapon script

Post by Creavion »

Metalfist wrote:This is a weapon remover with some effects and sound. Place it like any trigger and pawns entering it's radius will cause it to fire. They see a flash, hear an electric boom and then all their weapons are gone.
Player used weapon remove. The attack was super effective!
About to be non-active
My very last UT map project: CTF-FacePalm (tropical CTF-Face remake)
Why do I leave? click here
What I want to do next: Joining an UDK team (uncertain however) and improve 3D modelling and texture editing skills
Thanks to those who visibly supported me until/at the end!
My reactivated account on indiedb.com.
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Remove weapon/set ammo to 0 script

Post by JackGriffin »

Just in case others might find this useful, here is how to specify an individual weapon(s) to be destroyed.

1) Open the weaponremover.u package in editor.
2) Subclass the weaponremover (name it whatever) and embed the new trigger in your map.
3) Edit Script on the new trigger and add this:

Code: Select all

function Touch( actor Other )
{
	local inventory Inv;
	local Weapon W;

	if( Other.IsA('Pawn') && (Other != none))
	{
	  	for(Inv=Other.Inventory; Inv!=None; Inv=Inv.Inventory)
	  	if ( Inv.IsA('Weapon'))
		{
			W = Weapon(Inv);
			W.Destroy();
			ClientFlashes();
			PlaySound(sound 'electricboom');
		}
	}
}
Now if you wanted to limit this to destroying say enforcers, you would replace the word Weapon above with Enforcer so you would have:

Code: Select all

function Touch( actor Other )
{
	local inventory Inv;
	local Enforcer W;

	if( Other.IsA('Pawn') && (Other != none))
	{
	  	for(Inv=Other.Inventory; Inv!=None; Inv=Inv.Inventory)
	  	if ( Inv.IsA('Enforcer'))
		{
			W = Enforcer(Inv);
			W.Destroy();
			ClientFlashes();
			PlaySound(sound 'electricboom');
		}
	}
}
and for multiple weapons you could subclass more triggers or redo the code like this:

Code: Select all

function Touch( actor Other )
{
	local inventory Inv;
	local SniperRifle W;
        local WarHeadLauncher M;
        local PulseGun P;

	if( Other.IsA('Pawn') && (Other != none))
	{
	  	for(Inv=Other.Inventory; Inv!=None; Inv=Inv.Inventory)
	  	if ( Inv.IsA('SniperRifle') || Inv.IsA('WarHeadLauncher') || Inv.IsA('PulseGun') )
		{
			W = SniperRifle(Inv);
			W.Destroy();
         M = WarHeadLauncher(Inv);
			M.Destroy();
         P = PulseGun(Inv);
			P.Destroy();
			ClientFlashes();
			PlaySound(sound 'electricboom');
		}
	}
}
Once you get the code in just hit the "Compile changed scripts" and you are good to go. However if you want to specify weapons that are NOT stock UT weapons it will require a lot more work because you will need to add the weapon package to EditPackages, etc. That's the main reason I scripted this to just discard everything in one simple motion.
So long, and thanks for all the fish
Post Reply