MH No Dropped Weapon

Discussions about Coding and Scripting
Post Reply
Culprit
Novice
Posts: 9
Joined: Mon Sep 14, 2015 8:22 pm

MH No Dropped Weapon

Post by Culprit »

Hi guys, looking for some advice on how to stop killed monsters from leaving their weapon behind, after being killed. Im using Monsterhunt2gold and have tried the script below, but its not having any effect.. I had this working for players, but hope that just changing 'other' to ScriptedPawn would be enough.

There are some maps that leave many weapons behind, sometimes slowing gameplay, so I wanted to try tidying up.

class noweapdropMH expands Mutator;

function PreBeginPlay()
{
Super.PreBeginPlay();
log("Remove Monsters dropped weapon loaded!"); //Log some info for the server.
}

function ScoreKill(Pawn Killer, Pawn ScriptedPawn)
{
local Weapon w;
if (ScriptedPawn.Weapon != None) // if monster has a weapon
{
w = ScriptedPawn.Weapon;

ScriptedPawn.Weapon = None; // remove the weapon
}
// call the next mutator
if ( NextMutator != None )
NextMutator.ScoreKill(Killer, ScriptedPawn);
}

defaultproperties
{
}

Any help would be much appreciated :)
User avatar
EvilGrins
Godlike
Posts: 9668
Joined: Thu Jun 30, 2011 8:12 pm
Personal rank: God of Fudge
Location: Palo Alto, CA
Contact:

Re: MH No Dropped Weapon

Post by EvilGrins »

Coding isn't my thing, but still...

Unless I'm very much mistaken, the only monsters that have weapons that can be dropped are Skaarj Military...
Image
...as in, specifically, these guys · https://liandri.beyondunreal.com/Skaarj_Trooper

That being the case, should the code be so generally using "monster" instead of the specific classes these are?
http://unreal-games.livejournal.com/
Image
medor wrote:Replace Skaarj with EvilGrins :mrgreen:
Smilies · viewtopic.php?f=8&t=13758
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: MH No Dropped Weapon

Post by sektor2111 »

There would be a crapton of accesed nones when others than monsters are dying - because you guys are not doing any code sanity which I'm getting tired to fix asked by others. Get rid of "super.prebeginplay" stupidity. Don't you see that it's no code there ?
"if (THATCRAP != NONE && THATCRAP.Weapon != None)",
then assigning "w" for no reason - unused later nowhere. Exist a simple method for this thing but... I'm not interested, I worked my ass YEARS for a good weapon drop in order to fix monster Invisible dropped trash, and I'm not gonna work against myself right now. Call Barbie... bzzz, else I give you a hint, you can modify Gold properly right in PreventDeath (do not forget to not prevent Monster death - unless LeglessKrall will prevent running server with an infinite recursion crash...), simply destroy any inventory owned by monster killed by any entity. Why a stupid new mutator ?
I can add this as an option in MH2 which I'm doing/testing but I'm not interested to ruin my own past work.
MrLoathsome
Inhuman
Posts: 958
Joined: Wed Mar 31, 2010 9:02 pm
Personal rank: I am quite rank.
Location: MrLoathsome fell out of the world!

Re: MH No Dropped Weapon

Post by MrLoathsome »

Edit: I forget how it works I guess.

Not that it matters any.
Last edited by MrLoathsome on Sun Nov 20, 2016 3:04 am, edited 1 time in total.
blarg
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: MH No Dropped Weapon

Post by sektor2111 »

Nah, "DropWhenKilled" is another story, he was speaking about Monster.Weapon >> Pawn.Weapon which is not the same thing with "DropWhenKilled" - these are 2 different things: Skaarj can drop weapon and... some armor if me, mapper, I want that. By example monsters spawned in my map doesn't use any DropWhenKilled but they do drop weaponry at death - non-bugged weapons. DropWhenKilled is actually working similar to "content" from decorations - dropped at destroying them and nothing else.
MrLoathsome wrote: The pawns Weapon that they use NEVER actually gets dropped.
Skaarj by default drop weapon when dies. If we speak about Skaarjs from map, they do drop an invisible bugged weapon - happening all time (in servers) if you have failed old MH parties and where UTJ (called sauce-on-pizza by a "genius") was fixing nothing. All time I used Insta dropped by Skaarj in BirdBrainedResearch map, for cleaning the rest of areas. Even without to see it in HUD, it was fully operational.

I'm sorry to tell you people a small secret: I know these Skaarj types better than my pocket. The only thing miss-understood by me is timing deal: when does weapon spawn, which state, physics, etc. toward Skaarj Instigator which seems to change state or... weapon cannot do a touch that early or Skaarj is not colliding things yet, or... Once held a weapon, we can speak about P.Weapon, else LOG these if you don't believe me.

Edit:More hints. Pawn.uc - function died

Code: Select all

function Died(pawn Killer, name damageType, vector HitLocation)
{
	local pawn OtherPawn;
	local actor A;

	// mutator hook to prevent deaths
	// WARNING - don't prevent bot suicides - they suicide when really needed
	if ( Level.Game.BaseMutator.PreventDeath(self, Killer, damageType, HitLocation) )
	{
		Health = max(Health, 1); //mutator should set this higher
		return;
	}
	if ( bDeleteMe )
		return; //already destroyed
	Health = Min(0, Health);
	for ( OtherPawn=Level.PawnList; OtherPawn!=None; OtherPawn=OtherPawn.nextPawn )
		OtherPawn.Killed(Killer, self, damageType);
	if ( CarriedDecoration != None )
		DropDecoration();
	level.game.Killed(Killer, self, damageType);
	//log(class$" dying");
	if( Event != '' )
		foreach AllActors( class 'Actor', A, Event )
			A.Trigger( Self, Killer );
	Level.Game.DiscardInventory(self);
....
And then GameInfo.uc function DISCARDINVENTORY, check details:

Code: Select all

function DiscardInventory( Pawn Other )
{
	local actor dropped;
	local inventory Inv;
	local weapon weap;
	local float speed;

	if( Other.DropWhenKilled != None ) //#1
	{
		dropped = Spawn(Other.DropWhenKilled,,,Other.Location);
		Inv = Inventory(dropped);
		if ( Inv != None )
		{ 
			Inv.RespawnTime = 0.0; //don't respawn
			Inv.BecomePickup();		
		}
		if ( dropped != None )
		{
			dropped.RemoteRole = ROLE_DumbProxy;
			dropped.SetPhysics(PHYS_Falling);
			dropped.bCollideWorld = true;
			dropped.Velocity = Other.Velocity + VRand() * 280;
		}
		if ( Inv != None )
			Inv.GotoState('PickUp', 'Dropped');
	}					
	if( (Other.Weapon!=None) && (Other.Weapon.Class!=Level.Game.BaseMutator.MutatedDefaultWeapon()) //#2
		&& Other.Weapon.bCanThrow )
	{
		speed = VSize(Other.Velocity);
		weap = Other.Weapon;
		if (speed != 0)
			weap.Velocity = Normal(Other.Velocity/speed + 0.5 * VRand()) * (speed + 280);
		else {
			weap.Velocity.X = 0;
			weap.Velocity.Y = 0;
			weap.Velocity.Z = 0;
		}
		Other.TossWeapon();
		if ( weap.PickupAmmoCount == 0 )
			weap.PickupAmmoCount = 1;
	}
	Other.Weapon = None;
	Other.SelectedItem = None;	
	for( Inv=Other.Inventory; Inv!=None; Inv=Inv.Inventory )
		Inv.Destroy();
}
See BOTH #1 and #2 they are different things, else if you are well oriented you can take in account Other.Weapon.bCanThrow if you really wanna write a good code. As long as weapon is "dropable" always Pawn holder will drop it doesn't matter if Pawn is monster or me, or you, or anybody.
If memory doesn't cheat me reinventing wheel might not be recommended, we might have a mutator for not dropping weapons which can be a bit loved.
Aldebaran
Masterful
Posts: 672
Joined: Thu Jan 28, 2016 7:30 pm

Re: MH No Dropped Weapon

Post by Aldebaran »

I tested MrLoathsome's code because I need such a mutator too. The Skaarjs still drop their (actually used) weapon on death with this mutator :-(

Also it would be wise when Shockrifle and Redeemer would be excluded. As Sektor2111 mentioned it can make finishing the map easier in some case (and perhaps the mapper has intended that). But more important is in my opinion that the many useless other weapons should be removed automatically.

:help:
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: MH No Dropped Weapon

Post by sektor2111 »

You guys should take in account what I'm saying not as forum member or a guy which wants to look nice in pink color, but simply because I was arguing with Skaarj more time than you can dream about.
Pawn owns an inventory which can be pickup, weapon, anything like that, but even can be owner of a lousy actor controlling its existence and sending random directives to that A.I. pawn (bot or monster).
The fact is YOU NEED to understand that GREEN thing which I posted, simply it should not drop nothing if weapon has a behavior similar to enforcer - players in DM usually don't drop enforcer because it's a "default" which is loaded anyway, it doesn't need to be recovered. If your MH whatever ignores rules you should copy back code from DiscardInventory and set a "PreventDeath" involving monster Without to drop weapon. As a note: I'm not removing their stuff, but simply I give it a LifeSpan in purpose to not see 1 million of weapons dropped camping 2 hours on ground. Once collected one, LifeSpan is being brought to normal, these things are not dynamically tested in timers and ticks, but using normal "HandlePickupQuery" and "PreventDeath" as major keys against a high load - yes I forgot description about these - wait I did not forgot nothing, MH doesn't exist here for debates, I'm sorry, you can subscribe at Hermskii's forum for enhanced MH debates and codes tuning which is more serious toward MH because I'm not gonna ask nobody here 1000 times to set a XCGE and a MH section more useful than that one ignored UTR and the rest of forgotten cadaver sections.
User avatar
papercoffee
Godlike
Posts: 10443
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: MH No Dropped Weapon

Post by papercoffee »

sektor2111 wrote: wait I did not forgot nothing, MH doesn't exist here for debates, I'm sorry, you can subscribe at Hermskii's forum for enhanced MH debates and codes tuning which is more serious toward MH because I'm not gonna ask nobody here 1000 times to set a XCGE and a MH section more useful than that one ignored UTR and the rest of forgotten cadaver sections.
sektor, can you please calm down a little? This is not MH.org it is UT99.org ...MH is the most popular game mode nowadays (yes I know) but it's nothing special. But if you think otherwise why don't you write here viewforum.php?f=2 and explain Shade why you think MH deserves an extra section here on UT99.org. Shade is not reading every post here in the forum and he won't read your hidden rant. And you didn't contact Shade directly, or did you?

I'll contact Shade and ask him about a XCGE section because other than MH is this a global thing for UT and everyone will benefit from it.
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: MH No Dropped Weapon

Post by sektor2111 »

papercoffee wrote:sektor, can you please calm down a little? This is not MH.org it is UT99.org ...MH is the most popular game mode nowadays
But I'm calm, I'm not rotating with more than 500 Yaw and 200 Roll, there are forums with more attention to MH and tradition for MH, so I don't see a problem. Anyone which wants to learn some MH tweaking, can get info from the right place. Also UT-files has an ancient section ( old PlanetMonsterHunt - I think name is self explanatory ). Right a few days ago I've sent to a dude in private a MH2 version for testing purposes, related to this thing forum did not explode so we can keep going without sharing new MH stuff, not a big deal.
Else, if I well recall I have posted a few good months ago a MH2 version + resources, I did not see any any debate around making a mix with Gold or such, because probably was not even noticed due to forum load ( stupid useless spam posting from that time shadowing new posts with trash questions by 2 clowns suddenly affiliated to UT ) and a hard job in finding Information, so in my opinion, any MH2 doesn't worth any effort for debates. I though that after so many MH posting things a section would be automated but... never mind. I'm blue but HIGOR is green, probably XCGE doesn't deserve more attention.
Post Reply