Announcement

Collapse
No announcement yet.

Re: REQUEST: Blood Trails Mutator & More!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Re: REQUEST: Blood Trails Mutator & More!

    ***ATTENTION***
    Blood Mod v2.0 *SHOULD* network properly, but because I have no one to test with, I cannot verify this! If you can help me test, I would and I'm sure everyone else would greatly appreciate it.

    PM me for contacts or join the #gneu channel on irc.quakenet.org

    ***UPDATE***
    Blood Mod v2.0

    Code:
     BloodMod v2.0
    =============================================================================
     -Players now lose health when they bleed... the more they bleed,
      the more they lose health.  They eventually stop losing health...
      (you can't die from blood loss)
    
     -Players now slow down as they lose health... at around 4 health, they are
      pretty much frozen
    =============================================================================
    
     BloodMod v1.0
    =============================================================================
     This mutator drops blood from wounded players allowing other players
     to track them.  This version will progressively drop more and more blood
     dependent upon the player's health.
    =============================================================================


    I have completed a basic version of the blood trails mutator as requested here:
    http://utforums.epicgames.com/showth...ht=blood+trail

    http://www.mikewhitfield.org/videos/bloodmoddivx.avi



    Here's the code:

    BloodMod.uc
    Code:
    //=============================================================================
    // BloodMod
    //
    //This mutator drops blood from wounded players allowing other players
    //to track them.  This version will progressively drop more and more blood
    //dependent upon the player's health.  Every time blood is spilled, the
    //bleeding player will lose health.  As requested, players speed will also
    //slow as they lose more and more health.
    //
    // Contact : whitfieldemail@gmail.com
    // Website : www.gneu.org (by affiliation, not by ownership)
    // License : Content is available under Creative Commons Attribution-ShareAlike
    //			 3.0 License.
    //=============================================================================
    Class BloodMod extends UTMutator Config( BloodMod );
    
    struct PlayerInfo
    {
    	var Info_BloodMod info;
    	var UTPlayerController pc;
    };
    
    var array<PlayerInfo> playerInfoArray;
    var float minInterval;
    var float maxInterval;
    
    var float minBloodLifespan;
    var float maxBloodLifespan;
    
    var int maxHealthLoss;
    
    //validate input, save config
    function InitMutator( string Options, out string ErrorMessage )
    {
    	 //validate input
    
    	 SaveConfig();
    
    	 Super.InitMutator(Options, ErrorMessage);
    }
    
    
    //remove the player controller from our array
    function NotifyLogout( Controller player )
    {
    	local int i;
    
    	if( UTPlayerController( player ) != None )
    		i = playerInfoArray.Find( 'pc', UTPlayerController( player ) );
    	else
    		i = -1;
    
    	if ( i > -1 )
    		playerInfoArray.Remove( i, 1 );
    
    	Super.NotifyLogout( player );
    }
    
    //store player controllers in a local array
    //create PlayerInfo object and set properties
    function NotifyLogin( Controller player )
    {
    	local PlayerInfo newPlayerInfo;
    
    	if( UTPlayerController( player ) != None )
    	{
    		newPlayerInfo.pc = UTPlayerController( player );
    		newPlayerInfo.info = Spawn( class'Info_BloodMod', player );
    		playerInfoArray.AddItem( newPlayerInfo );
    	}
    
    	Super.NotifyLogin( player );
    }
    
    
    //this method is going to grab variables
    //that are only located on the pawn.
    //because the player is not spawned at the
    //time NotifyLogin is called, we must delay
    //our storage of pawn variables.  chyea. :)
    function initializePlayer( PlayerInfo player )
    {
    	player.info.initGroundSpeed = player.pc.Pawn.default.GroundSpeed;
    	player.info.initAirSpeed = player.pc.Pawn.default.AirSpeed;
    	player.info.ini****erSpeed = player.pc.Pawn.default.WaterSpeed;
    
    	player.info.initialized = true;
    }
    
    //does lastTick exceed the tickInterval?
    //tickInterval will be determined by the
    //playerHealth... if the condition is met,
    //bleed will be called on the player
    function bool shouldBleed( PlayerInfo player )
    {
    	local float playerHealth;
    
       	playerHealth = float( player.pc.Pawn.Health ) / float( player.pc.Pawn.HealthMax );
    
    	if ( player.info.lastBleed < ( ( maxInterval - minInterval ) * playerHealth + minInterval ) )
    		return false;
    	else
    		return true;
    }
    
    
    //paints the blood decal and
    //takes health from the player.
    simulated function bleed( PlayerInfo player )
    {
    	local float playerHealth;
    	local float bloodLifespan;
    
    	//taken from UTCheatManager.uc
    	local MaterialInstance MIC_Decal;
    	local Actor TraceActor;
    	local vector out_HitLocation;
    	local vector out_HitNormal;
    	local vector TraceDest;
    	local vector TraceStart;
    	local vector TraceExtent;
    	local TraceHitInfo HitInfo;
    
       	playerHealth = float( player.pc.Pawn.Health ) / float( player.pc.Pawn.HealthMax );
    	bloodLifespan = ( ( maxBloodLifespan - minBloodLifespan ) - ( ( maxBloodLifespan - minBloodLifespan ) * playerHealth ) ) + minBloodLifespan;
    
        	player.info.lastBleed = 0.0;
    
    	//the following code was taken from UTCheatManager.LeaveADecal
    
    	// these should be randomized
    	TraceStart = player.pc.Pawn.Location + ( Vect(0,0,15));
    	TraceDest =  player.pc.Pawn.Location - ( Vect(0,0,100));
    
    	TraceActor = Trace( out_HitLocation, out_HitNormal, TraceDest, TraceStart, false, TraceExtent, HitInfo, TRACEFLAG_PhysicsVolumes );
    
    	if( TraceActor != None )
    	{
    		MIC_Decal = new(Outer) class'MaterialInstanceTimeVarying';
    		MIC_Decal.SetParent( MaterialInstanceTimeVarying'CH_Gibs.Decals.BloodSplatter' );
    
    		WorldInfo.MyDecalManager.SpawnDecal(MIC_Decal, out_HitLocation, rotator(-out_HitNormal), 200, 200, 10, false,, HitInfo.HitComponent, true, false, HitInfo.BoneName, HitInfo.Item, HitInfo.LevelIndex);
    
    		MaterialInstanceTimeVarying(MIC_Decal).SetScalarStartTime( 'DissolveAmount',  bloodLifespan );
    		MaterialInstanceTimeVarying(MIC_Decal).SetScalarStartTime( 'BloodAlpha',  0.85f );
    		MIC_Decal.SetScalarParameterValue( 'DissolveAmount',  bloodLifespan );
    		MIC_Decal.SetScalarParameterValue( 'BloodAlpha',  0.85f );
    	}
    
    	//take health from the player... they have just bled!
    	if ( player.pc.Pawn.Health > maxHealthLoss )
    		player.pc.Pawn.Health -= ( 1.0f - playerHealth ) * maxHealthLoss;
    }
    
    function updateSpeeds( PlayerInfo player )
    {
    	local float playerHealth;
    
       	playerHealth = float( player.pc.Pawn.Health ) / float( player.pc.Pawn.HealthMax );
    
    	//set speed of the player
    	//this is based on player health
    	//and the initial speeds supplied by the player
    	player.pc.Pawn.GroundSpeed = playerHealth * player.info.initGroundSpeed;
    	player.pc.Pawn.AirSpeed = playerHealth * player.info.initAirSpeed;
    	player.pc.Pawn.WaterSpeed = playerHealth * player.info.ini****erSpeed;
    }
    
    function resetSpeeds( PlayerInfo player )
    {
    	//reset speed of the player
    	//this is based on the initial
    	//speeds supplied by the player
    	player.pc.Pawn.GroundSpeed = player.info.initGroundSpeed;
    	player.pc.Pawn.AirSpeed = player.info.initAirSpeed;
    	player.pc.Pawn.WaterSpeed = player.info.ini****erSpeed;
    
    }
    
    //on tick, drop blood from players
    //that are hurt; players will bleed
    //different amounts according to
    //their health
    event Tick( float DeltaTime )
    {
    	local PlayerInfo player;
    
    	foreach playerInfoArray( player )
    	{
    
    		/*
    		`Log( "*************Blood Mod*************",, 'BloodMod' );
    		`Log( "*player.info.lastBleed: " @ player.info.lastBleed,, 'BloodMod' );
    		`Log( "*player.info.initialized: " @ player.info.initialized,, 'BloodMod' );
    		`Log( "*player.info.initGroundSpeed: " @ player.info.initGroundSpeed,, 'BloodMod' );
    		`Log( "*player.info.initAirSpeed: " @ player.info.initAirSpeed,, 'BloodMod' );
    		`Log( "*player.info.ini****erSpeed: " @ player.info.ini****erSpeed,, 'BloodMod' );
    		`Log( "***********************************",, 'BloodMod' );
    		*/
    
    		if ( player.pc.Pawn != None )
    		{
    			if ( !player.info.initialized )
    			{
    				/*
    				`Log( "*************Blood Mod*************",, 'BloodMod' );
    				`Log( "*PLAYER INITIALIZED",, 'BloodMod' );
    				`Log( "***********************************",, 'BloodMod' );
    				*/
    
    				initializePlayer( player );
    			}
    
    			if ( player.pc.Pawn.Health < player.pc.Pawn.HealthMax )
    			{
    				player.info.lastBleed += DeltaTime;
    
    				updateSpeeds( player );
    
    				/*
    				`Log( "*************Blood Mod*************",, 'BloodMod' );
    				`Log( "*player.info.initGroundSpeed: " @ player.info.initGroundSpeed,, 'BloodMod' );
    				`Log( "***********************************",, 'BloodMod' );
    				*/
    
    				if ( shouldBleed( player ) )
    					bleed( player );
    			}
    			else
    			{
    				/*
    				`Log( "*************Blood Mod*************",, 'BloodMod' );
    				`Log( "*player.pc.Pawn.GroundSpeed: " @ player.pc.Pawn.GroundSpeed,, 'BloodMod' );
    				`Log( "***********************************",, 'BloodMod' );
    				*/
    				resetSpeeds( player );
    			}
    		}
    
    		/*
    		`Log( "*************Blood Mod*************",, 'BloodMod' );
    		`Log( "*player.info.lastBleed: " @ player.info.lastBleed,, 'BloodMod' );
    		`Log( "*player.info.initialized: " @ player.info.initialized,, 'BloodMod' );
    		`Log( "*player.info.initGroundSpeed: " @ player.info.initGroundSpeed,, 'BloodMod' );
    		`Log( "*player.info.initAirSpeed: " @ player.info.initAirSpeed,, 'BloodMod' );
    		`Log( "*player.info.ini****erSpeed: " @ player.info.ini****erSpeed,, 'BloodMod' );
    		`Log( "***********************************",, 'BloodMod' );
    		*/
    	}
    }
    
    // Set Default Properties
    defaultproperties
    {
    	minInterval=0.2
    	maxInterval=2.0
    	minBloodLifespan=5.0f
    	maxBloodLifespan=16.0f
    
    	maxHealthLoss=4
    }
    Info_BloodMod.uc
    Code:
    //=============================================================================
    // BloodMod
    //
    //This mutator drops blood from wounded players allowing other players
    //to track them.  This version will progressively drop more and more blood
    //dependent upon the player's health.  Every time blood is spilled, the
    //bleeding player will lose health.  As requested, players speed will also
    //slow as they lose more and more health.
    //
    // Contact : whitfieldemail@gmail.com
    // Website : www.gneu.org (by affiliation, not by ownership)
    // License : Content is available under Creative Commons Attribution-ShareAlike
    //			 3.0 License.
    //=============================================================================
    
    Class Info_BloodMod Extends ReplicationInfo DependsOn( BloodMod );
    
    //used for initializing
    //variables on the pawn
    var bool initialized;
    
    //timestamp for our last bleed...
    //base the next bleed on this timestamp
    var float lastBleed;
    
    //SPEED! it decreases as you lose
    //health... we need to store initial
    //values in order to restore them
    //upon the pawns death. we also need
    //them to base our speed penalty on.
    var float initGroundSpeed;
    var float initAirSpeed;
    var float ini****erSpeed;
    
    Replication
    {
        if( bNetDirty && ( Role == ROLE_Authority ) )
        	initialized, lastBleed, initGroundSpeed, initAirSpeed, ini****erSpeed;
    }
    
    defaultproperties
    {
    	RemoteRole = ROLE_SimulatedProxy
    	bAlwaysRelevant = True
    	bOnlyRelevantToOwner = True
    	lastBleed=0.0f
    	initialized=false
    	initGroundSpeed=0.0f
    	initAirSpeed=0.0f
    	ini****erSpeed=0.0f
    }
    Download from http://www.mikewhitfield.org/unreal/BloodModv2.0.zip

    Have a nice day.

    #2
    Wow that's was pro XD,, maby you can make my request: http://utforums.epicgames.com/showthread.php?t=600939

    It doesn't sound that hard but i can't make it... maby you can? thanks

    Comment


      #3
      Unfortunately, I don't think replacing the camera class is possible with a mutator (assuming the camera class controls view overlays such as post-process shaders). I will definitely toy with motion blur at some point, likely coding some sort of shell-shock effect for the mod I'm working on.

      Sorry I couldn't be more help.

      Cheers,
      Mike Whitfield

      www.gneu.org
      www.mikewhitfield.org

      Comment


        #4
        I would download it but the link doesn't work.

        Comment


          #5
          Fix the download and I will put it on my server immediately.

          Comment


            #6
            download link didnt wroking for me

            could you fix please ?

            Comment


              #7
              Fixed. Sorry about that. I think the file names are case sensitive.

              Comment


                #8
                yay got it !

                Originally posted by whitfield View Post
                Fixed. Sorry about that. I think the file names are case sensitive.
                thanks !

                Comment


                  #9
                  Thanks for fixing the link. I've been looking forward to this mutator (or something similar). As far as ideas what about this from the thread you referenced:

                  "B.) Blood color should be based on race. Please make the stupid droids bleed oil and the aliens some sort of green. It might be nice to have a color toggel to make the blood trails match team colors.

                  Wounded Dog

                  A.) When you shot someone they should have trouble escaping. I'd like to see various levels of intensity. Make movement speed and weapon fire rate decrease as you take more damage. Also, since you're dripping blood lets throw in health degeration. Might be easiest to base this on a percentage of your total health. A toggel to select which negative effects you wish to use would be a plus. Something like the "Massacure," only it takes affect based on your % of lost health and is a negative rather than positive.

                  B.) Where you're hit should determine what negative affects you suffer. I'd say leg shoots should cause the movement speed decrease, arms shots should cause your fire rate to drop and torso shots could trigger the health degeneration. Hehehe... Is there any way to make head shots cause a concussion and disorient your view for X # of seconds (like motion blur)?"

                  Comment


                    #10
                    Here's what I'm thinking.

                    I am gonna leave blood mod as it is. Changing blood color and whatnot is probably the only thing I would do and that's secondary. The reason it is secondary is that I am working on a previously planned Self-Destruct mod which allows you to... self-destruct. Specifically, here:

                    Code:
                    //=============================================================================
                    // Self-Destruct Mutator
                    //
                    //The self-destruct mutator takes an existing button (Currently jump) and
                    //tests it until it is hit 3 times in a given time interval.  Rockets will
                    //surround the player.  Once the rockets have hit the player, his body will
                    //gib and a huge hemisphere explosion will erupt from the location of death.
                    //
                    // Contact : whitfieldemail@gmail.com
                    // Website : www.gneu.org (by affiliation, not by ownership)
                    // License : Content is available under Creative Commons Attribution-ShareAlike
                    //			 3.0 License.
                    //=============================================================================
                    So... the big idea is to combine a bunch of small mutators together and make something I'd probably call, 'Whitfield Mode' or something just as cool lol.

                    Comment


                      #11
                      Sounds interesting ... thanks for the quick response.

                      Comment


                        #12
                        can't wait for you to finalize this, really looking forward to using this in duels

                        Comment


                          #13
                          Yea... I apologize if I came off as all haughty before in saying blood mod will stay at it is. I asked for feedback and I definitely shot it down.

                          I definitely need to create the UI sliders. No doubt there.

                          The blood colors are reasonable - they just wouldn't be a high priority. Health degeneration and speed degeneration would be really cool now that I think about it. OOO... and what if you could have finishing moves...?! What if you could watch as your opponent slows down to a stop and then crouches on one knee. OOO... and what if his health stopped regenerating at that point and you could do finishing moves?!!!

                          Oh wowzers. Code time.

                          mike whitfield

                          www.mikewhitfield.org
                          www.gneu.org

                          P.S. I didn't forget the hitboxes... I just frankly think they may be quite hard to code. I'm not sure. Let's put it this way - I'm afraid.

                          Comment


                            #14
                            Are players losing health as they bleed out?

                            Comment


                              #15
                              Not currently Bob. I think I am going to implement that quite soon.

                              Comment

                              Working...
                              X