1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

player invulnerable

Discussion in 'Ask a Coder' started by Ghost3021, Mar 4, 2005.

  1. Ghost3021

    Ghost3021 Registered Hobbit

    Joined:
    Nov 21, 2004
    Messages:
    586
    Likes Received:
    0
    -[ut99]-player invulnerable

    ok im making a single player mod and the player is a skaarj trooper. yay! :D
    ok, i want to set it up so that when the player presses a key(on keyboard/mouse/joystick wichever they pics) the players model plays the shldup anim and loops shldhold until they let go. while shielded, no damage can be taken. a bar on hud will measure energy for shield, will normaly go down slowly but jumps if damage is taken, and will slowly recharge. the player cant fire while invulnerable. how the heck do i do this? i already got my player class, and it spawns with the model/health and such, but i dont know how to do the above. her'es what i have:(a lot taken from SkaarjPlayer)
    Code:
    //========================================================
    // SkaarjOpPlayer.
    //========================================================
    class SkaarjOpPlayer expands UnrealIPlayer;
    var bool bshielded;
    
    	
    
    
    simulated function WalkStep()
    {
    	local sound step;
    	local float decision;
    	
    	if ( Role < ROLE_Authority )
    		return;
    	if ( FootRegion.Zone.bWaterZone )
    	{
    		PlaySound(sound 'LSplash', SLOT_Interact, 1, false, 1000.0, 1.0);
    		return;
    	}
    
    	PlaySound(Footstep1, SLOT_Interact, 0.1, false, 800.0, 1.0);
    }
    
    simulated function RunStep()
    {
    	local sound step;
    	local float decision;
    
    	if ( Role < ROLE_Authority )
    		return;
    	if ( FootRegion.Zone.bWaterZone )
    	{
    		PlaySound(sound 'LSplash', SLOT_Interact, 1, false, 1000.0, 1.0);
    		return;
    	}
    
    	PlaySound(Footstep1, SLOT_Interact, 0.7, false, 800.0, 1.0);
    }
    
    //-----------------------------------------------------------------------------
    // Animation functions
    
    function PlayDodge(eDodgeDir DodgeMove)
    {
    	Velocity.Z = 210;
    	if ( DodgeMove == DODGE_Left )
    		PlayAnim('LeftDodge', 1.35, 0.06);
    	else if ( DodgeMove == DODGE_Right )
    		PlayAnim('RightDodge', 1.35, 0.06);
    	else if ( DodgeMove == DODGE_Forward )
    		PlayAnim('Lunge', 1.2, 0.06);
    	else
    		PlayDuck();
    }
    		
    function PlayTurning()
    {
    	BaseEyeHeight = Default.BaseEyeHeight;
    	PlayAnim('Turn', 0.3, 0.3);
    }
    
    function TweenToWalking(float tweentime)
    {
    	BaseEyeHeight = Default.BaseEyeHeight;
    	if (Weapon == None)
    		TweenAnim('Walk', tweentime);
    	else if ( Weapon.bPointing || (CarriedDecoration != None) ) 
    		TweenAnim('WalkFire', tweentime);
    	else
    		TweenAnim('Walk', tweentime);
    }
    
    function TweenToRunning(float tweentime)
    {
    	BaseEyeHeight = Default.BaseEyeHeight;
    	if (bIsWalking)
    		TweenToWalking(0.1);
    	else if (Weapon == None)
    		PlayAnim('Jog', 1, tweentime);
    	else if ( Weapon.bPointing ) 
    		PlayAnim('JogFire', 1, tweentime);
    	else
    		PlayAnim('Jog', 1, tweentime);
    }
    
    function PlayWalking()
    {
    	BaseEyeHeight = Default.BaseEyeHeight;
    	if (Weapon == None)
    		LoopAnim('Walk',1.1);
    	else if ( Weapon.bPointing || (CarriedDecoration != None) ) 
    		LoopAnim('WalkFire',1.1);
    	else
    		LoopAnim('Walk',1.1);
    }
    
    function PlayRunning()
    {
    	BaseEyeHeight = Default.BaseEyeHeight;
    	if (Weapon == None)
    		LoopAnim('Jog',1.1);
    	else if ( Weapon.bPointing ) 
    		LoopAnim('JogFire',1.1);
    	else
    		LoopAnim('Jog',1.1);
    }
    
    function PlayRising()
    {
    	BaseEyeHeight = 0.4 * Default.BaseEyeHeight;
    	PlayAnim('Getup', 0.7, 0.1);
    }
    
    function PlayFeignDeath()
    {
    	BaseEyeHeight = 0;
    	PlayAnim('Death2',0.7);
    }
    
    function PlayDying(name DamageType, vector HitLoc)
    {
    	local vector X,Y,Z, HitVec, HitVec2D;
    	local float dotp;
    
    	BaseEyeHeight = Default.BaseEyeHeight;
    	PlayDyingSound();
    			
    	if ( FRand() < 0.15 )
    	{
    		PlayAnim('Death',0.7,0.1);
    		return;
    	}
    
    	// check for big hit
    	if ( (Velocity.Z > 250) && (FRand() < 0.7) )
    	{
    		PlayAnim('Death2', 0.7, 0.1);
    		return;
    	}
    
    	// check for head hit
    	if ( (DamageType == 'Decapitated') || (HitLoc.Z - Location.Z > 0.6 * CollisionHeight) )
    	{
    		DamageType = 'Decapitated';
    		PlayAnim('Death', 0.7, 0.1);
    		return;
    	}
    
    	
    	if ( FRand() < 0.15)
    	{
    		PlayAnim('Death3', 0.7, 0.1);
    		return;
    	}
    
    	GetAxes(Rotation,X,Y,Z);
    	X.Z = 0;
    	HitVec = Normal(HitLoc - Location);
    	HitVec2D= HitVec;
    	HitVec2D.Z = 0;
    	dotp = HitVec2D dot X;
    	
    	if (Abs(dotp) > 0.71) //then hit in front or back
    		PlayAnim('Death3', 0.7, 0.1);
    	else
    	{
    		dotp = HitVec dot Y;
    		if (dotp > 0.0)
    			PlayAnim('Death', 0.7, 0.1);
    		else
    			PlayAnim('Death4', 0.7, 0.1);
    	}
    }
    
    //FIXME - add death first frames as alternate takehit anims!!!
    
    function PlayGutHit(float tweentime)
    {
    	if ( AnimSequence == 'GutHit' )
    	{
    		if (FRand() < 0.5)
    			TweenAnim('LeftHit', tweentime);
    		else
    			TweenAnim('RightHit', tweentime);
    	}
    	else
    		TweenAnim('GutHit', tweentime);
    }
    
    function PlayHeadHit(float tweentime)
    {
    	if ( AnimSequence == 'HeadHit' )
    		TweenAnim('GutHit', tweentime);
    	else
    		TweenAnim('HeadHit', tweentime);
    }
    
    function PlayLeftHit(float tweentime)
    {
    	if ( AnimSequence == 'LeftHit' )
    		TweenAnim('GutHit', tweentime);
    	else
    		TweenAnim('LeftHit', tweentime);
    }
    
    function PlayRightHit(float tweentime)
    {
    	if ( AnimSequence == 'RightHit' )
    		TweenAnim('GutHit', tweentime);
    	else
    		TweenAnim('RightHit', tweentime);
    }
    	
    function PlayLanded(float impactVel)
    	{	
    		impactVel = impactVel/JumpZ;
    		impactVel = 0.1 * impactVel * impactVel;
    		BaseEyeHeight = Default.BaseEyeHeight;
    
    		if ( Role == ROLE_Authority )
    		{
    			if ( impactVel > 0.17 )
    				PlaySound(LandGrunt, SLOT_Talk, FMin(5, 5 * impactVel),false,1200,FRand()*0.4+0.8);
    			if ( !FootRegion.Zone.bWaterZone && (impactVel > 0.01) )
    				PlaySound(Land, SLOT_Interact, FClamp(4.5 * impactVel,0.5,6), false, 1000, 1.0);
    		}
    If (bShielded == True)
    	TweenAnim('ShldLand',0.12);
    
    		if ( (GetAnimGroup(AnimSequence) == 'Dodge') && IsAnimating() )
    			return;
    		if ( (impactVel > 0.06) || (GetAnimGroup(AnimSequence) == 'Jumping') )
    			TweenAnim('Land', 0.12);
    		else if ( !IsAnimating() )
    		{
    			if ( GetAnimGroup(AnimSequence) == 'TakeHit' )
    				AnimEnd();
    			else
    				TweenAnim('Land', 0.12);
    		}
    	}
    	
    function PlayInAir()
    {
    	BaseEyeHeight =  Default.BaseEyeHeight;
    	TweenAnim('InAir', 0.4);
    	if (bshielded == true)
    	loopanim('holdshield');
    }
    
    function PlayDuck()
    {
    	BaseEyeHeight = 0;
    	TweenAnim('Duck', 0.25);
    		
    }
    
    function PlayCrawling()
    {
    	BaseEyeHeight = 0;
    	LoopAnim('DuckWalk');
    	if (bshielded == true)
    	loopanim('shldland');
    }
    
    function TweenToWaiting(float tweentime)
    {
    	if( IsInState('PlayerSwimming') || Physics==PHYS_Swimming )
    	{
    		BaseEyeHeight = 0.7 * Default.BaseEyeHeight;
    		TweenAnim('Swim', tweentime);
    	}
    	else
    	{
    		BaseEyeHeight = Default.BaseEyeHeight;
    		TweenAnim('Firing', tweentime);
    	}
    }
    	
    function PlayWaiting()
    {
    	local name newAnim;
    
    	if( IsInState('PlayerSwimming') || (Physics==PHYS_Swimming) )
    	{
    		BaseEyeHeight = 0.7 * Default.BaseEyeHeight;
    		LoopAnim('Swim');
    	}
    	else
    	{	
    		BaseEyeHeight = Default.BaseEyeHeight;
    		if ( (Weapon != None) && Weapon.bPointing )
    			TweenAnim('Firing', 0.3);
    		else
    		{
    			if ( FRand() < 0.2 )
    				newAnim = 'Breath';
    			else
    				newAnim = 'Breath2';
    			
    			if ( AnimSequence == newAnim )
    				LoopAnim(newAnim, 0.3 + 0.7 * FRand());
    			else
    				PlayAnim(newAnim, 0.3 + 0.7 * FRand(), 0.25);
    		}
    	}
    }	
    
    function PlayFiring()
    {
    	// switch animation sequence mid-stream if needed
    	if (AnimSequence == 'Jog')
    		AnimSequence = 'JogFire';
    	else if (AnimSequence == 'Walk')
    		AnimSequence = 'WalkFire';
    	else if ( AnimSequence == 'InAir' )
    		TweenAnim('JogFire', 0.03);
    	else if ( (GetAnimGroup(AnimSequence) != 'Attack')
    			&& (GetAnimGroup(AnimSequence) != 'MovingAttack') 
    			&& (GetAnimGroup(AnimSequence) != 'Dodge')
    			&& (AnimSequence != 'Swim') )
    		TweenAnim('Firing', 0.02);
    }
    Function StartShield()
    {
    TweenAnim('shldup', 0.12);
    }
    Function Shield()
    {
    BaseEyeHeight = 0.65 * Default.BaseEyeHeight;
    LoopAnim('HoldShield');
    }
    Function EndShield()
    {
    TweenAnim('shlddown', 0.12);
    }
    function PlayWeaponSwitch(Weapon NewWeapon)
    {
    }
    
    function PlaySwimming()
    {
    	BaseEyeHeight = 0.7 * Default.BaseEyeHeight;
    	LoopAnim('Swim');
    }
    
    function TweenToSwimming(float tweentime)
    {
    	BaseEyeHeight = 0.7 * Default.BaseEyeHeight;
    	TweenAnim('Swim',tweentime);
    }
    
    function SwimAnimUpdate(bool bNotForward)
    {
    	if ( !bAnimTransition && (GetAnimGroup(AnimSequence) != 'Gesture') && (AnimSequence != 'Swim') )
    		TweenToSwimming(0.1);
    }
    
    
    
    plz help me! ive only scripted for about 6months, with great help from wod's tuts and others... i'd give the lucky peoples who helped me credit in the mod! plz? :(

    i would also like the player to bleed when they lose to much heath. :)
     
    Last edited: Mar 7, 2005
  2. Ghost3021

    Ghost3021 Registered Hobbit

    Joined:
    Nov 21, 2004
    Messages:
    586
    Likes Received:
    0
    ok, anyone know waht im doing wrong?
     

Share This Page