XIIIMP
Class XIIIMPPlayerPawn

source: C:\XIII\XIIIMP\Classes\XIIIMPPlayerPawn.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Pawn
         |
         +--XIII.XIIIPawn
            |
            +--XIII.XIIIPlayerPawn
               |
               +--XIIIMP.XIIIMPPlayerPawn
Direct Known Subclasses:BotPlayer, HeavySoldierPlayer, HunterPlayer, MercenaryPlayer, SniperPlayer, SoldierPlayer

class XIIIMPPlayerPawn
extends XIII.XIIIPlayerPawn

//============================================================================= // XIIIPlayerPawn. //=============================================================================
Variables
 byte CodeMesh
           Used for sounds
 bool HasTheDuck
           Should be used for games w/ classes (bombing)
 int MarioBonusID
           Should be used for games w/ classes (bombing)
 int MarioBonusLAN
           Should be used for games w/ classes (bombing)
 string SkinMP[2]
           Team 0/1 (Red/Blue) skins
 eSubClass SubClass
           Should be used for games w/ classes (bombing)
 float SuperDamageFactor
           Should be used for games w/ classes (bombing)
 int SuperDamageNumber
           Should be used for games w/ classes (bombing)
 bool bMarioInvisibility
           Should be used for games w/ classes (bombing)

States
Dying

Function Summary
 
simulated
ClientChangeSkin(int NewSkinId)
     
//_____________________________________________________________________________
// not real client function but this called on the server will update SkinID wich is native-replicated
 void DropMyWeapon()
     
//_____________________________________________________________________________
// Not Simulated, Server call only


State Dying Function Summary



Source Code


00001	//=============================================================================
00002	// XIIIPlayerPawn.
00003	//=============================================================================
00004	class XIIIMPPlayerPawn extends XIIIPlayerPawn;
00005	
00006	#exec OBJ LOAD FILE=Onomatopees.uax PACKAGE=Onomatopees
00007	
00008	var string SkinMP[2];       // Team 0/1 (Red/Blue) skins
00009	var byte CodeMesh;          // Used for sounds
00010	enum eSubClass
00011	{
00012	  SC_Sniper,
00013	  SC_Soldier,
00014	  SC_Mercenary,
00015	  SC_HeavySoldier,
00016	  SC_Hunter,
00017	};
00018	var eSubClass SubClass;     // Should be used for games w/ classes (bombing)
00019	/*
00020	// Classes should be : + Additional equipment (9mm infinite ammo is basis)
00021	Sniper :        · sniper rifle · mini gun · 2 flasbangs
00022	Soldier :       · AssaultRifle · 1 AssaultRifke grenad · FGrenad · Flasbang
00023	Mercenary :     · Kalash · MiniGun · 2 FGrenad
00024	Heavy soldier : · M60 · Grenad
00025	Hunter :        · ShotGun · 3 Grenads · 1 FlashBang
00026	*/
00027	
00028	var float SuperDamageFactor;
00029	var int MarioBonusID;
00030	var int SuperDamageNumber;
00031	var bool bMarioInvisibility;
00032	var bool HasTheDuck;
00033	var int MarioBonusLAN;
00034	
00035	
00036	//__________________________________________________________________
00037	replication
00038	{
00039	    reliable if( Role==ROLE_Authority )
00040	        MarioBonusLAN;
00041	}
00042	
00043	//_____________________________________________________________________________
00044	// event called on skinID change by replication
00045	simulated event ChangeSkin()
00046	{
00047	//    Log("SKIN"@self@"ChangeSkin new Id="$SkinID);
00048	    ClientChangeSkin(SkinID);
00049	}
00050	
00051	//_____________________________________________________________________________
00052	// not real client function but this called on the server will update SkinID wich is native-replicated
00053	simulated function ClientChangeSkin( int NewSkinId )
00054	{
00055	    local int i, NbSkins;
00056	    local mesh MeshSkin;
00057	
00058	    if ( PlayerReplicationInfo != none )
00059	      Log("SKIN"@self@"ClientChangeSkin new Id="$SkinID@"SkinName='"$PlayerReplicationInfo.SkinCodeName$"'");
00060	    else
00061	      Log("SKIN"@self@"ClientChangeSkin new Id="$SkinID@" NO PRI");
00062	
00063	    if ( (PlayerReplicationInfo != none) && (PlayerReplicationInfo.SkinCodeName != "") )
00064	    { // Assign new skin
00065	      NbSkins = class'MeshSkinList'.default.MeshSkinListInfo.Length;
00066	      i = class'MeshSkinList'.Static.StaticFindSkinIndex(PlayerReplicationInfo.SkinCodeName);
00067	      if ( i <= NbSkins )
00068	      {
00069	        Log(" Found SKIN "$i$" - "$class'MeshSkinList'.default.MeshSkinListInfo[i].SkinReadableName@"("$class'MeshSkinList'.default.MeshSkinListInfo[i].SkinCode$"|"$class'MeshSkinList'.default.MeshSkinListInfo[i].SkinName$")");
00070	        MeshSkin = mesh(DynamicLoadObject(class'MeshSkinList'.default.MeshSkinListInfo[i].SkinName, class'Mesh'));
00071	        if ( MeshSkin != none )
00072	        {
00073	          Mesh = MeshSkin;
00074	          SkinMP[0] = class'MeshSkinList'.default.MeshSkinListInfo[i].SkinRed;
00075	          SkinMP[1] = class'MeshSkinList'.default.MeshSkinListInfo[i].SkinBlue;
00076	          CodeMesh = class'MeshSkinList'.default.MeshSkinListInfo[i].CodeMesh;
00077	          bInitializeAnimation = false;
00078	        }
00079	      }
00080	      else
00081	        Log(" SKIN code"@PlayerReplicationInfo.SkinCodeName@"NOT found, Use default/Previous");
00082	    }
00083	    // Assign new color
00084	    SkinID = NewSkinId;
00085	    if ( (NewSkinId < 2) && (NewSkinId > -1) )
00086	      skins[0] = texture(DynamicLoadObject(SkinMP[NewSkinId], class'texture'));
00087	    else
00088	      Skins[0] = none;
00089	}
00090	
00091	//_____________________________________________________________________________
00092	function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, class<DamageType> damageType)
00093	{
00094	    if (XIIIMPPlayerController(controller) != none && XIIIMPPlayerController(controller).bImmortal)
00095	      return;
00096	
00097	    if( damageType != class'DTFell')
00098	    {
00099	        if( damageType == class'XIII.DTSniped')
00100	            Damage *= 2.0;
00101	
00102	      if( XIIIMPPlayerPawn(instigatedBy) != none )
00103	        Damage *= XIIIMPPlayerPawn(instigatedBy).SuperDamageFactor;
00104	    }
00105	    Damage *= 0.6;
00106	    super.TakeDamage(Damage, instigatedBy, hitlocation, momentum, damageType);
00107	}
00108	
00109	//_____________________________________________________________________________
00110	// Not Simulated, Server call only
00111	function DropMyWeapon()
00112	{
00113	    local inventory Inv, InvD;
00114	    local weapon MyTossedWeapon;
00115	    local MPBomb TheBomb;
00116	
00117	//    LOG("DROPWEAPON"@Weapon);
00118	    // bombing mode code
00119	    TheBomb = MPBomb(FindInventoryType(class'MPBomb'));
00120	    if ( TheBomb != none )
00121	    {
00122	/*
00123	      if ( Level.NetMode == NM_Client )
00124	        TheBomb.ServerResetPickupSource();
00125	      else
00126	        TheBomb.PickupSource.GotoState('DelayBeforePickable');
00127	*/
00128	      TheBomb.Destroy();
00129	    }
00130	
00131	    if ( Weapon != none )
00132	    {
00133	      if( MPBomb(Weapon) == none )
00134	      {
00135	          if ( (BerettaMulti(Weapon) == none) && Weapon.HasAmmo() ) // no need to check for bomb because already destroyed
00136	          {
00137	            MyTossedWeapon = Weapon;
00138	            Weapon.bTossedOut = true;
00139	            TossWeapon(Vector(Rotation) * 500 + vect(0,0,220));
00140	          }
00141	      }
00142	    }
00143	
00144	/* // ELR Will be done at pawn destruction.
00145	    inv = Inventory;
00146	    while ( Inv != none )
00147	//    for( Inv=Inventory; Inv!=None; Inv=Inv.Inventory )
00148	    { // destroy anything left in inventory after dropping weapon & bomb
00149	//      LOG("  > DESTROY"@Inv@"BECAUSE DEAD");
00150	      InvD = Inv;
00151	      Inv = Inv.Inventory;
00152	      InvD.Destroy();
00153	    }
00154	*/
00155	}
00156	
00157	//_____________________________________________________________________________
00158	simulated function PlayTakeHit(vector HitLoc, int Damage, class<DamageType> damageType)
00159	{
00160	    if ( (Level.NetMode == NM_Client) || (Level.NetMode == NM_ListenServer) )
00161	    { // only for on-line, not against bots
00162	//      Log("MPANIM PlayTakeHit for "$self);
00163	      PlaySndPNJOno(pnjono'Onomatopees.hPNJHurt',CodeMesh,0);
00164	    }
00165	    Super.PlayTakeHit(HitLoc, Damage, DamageType);
00166	}
00167	
00168	//_____________________________________________________________________________
00169	simulated function PlayDyingAnim(class<DamageType> DamageType, vector HitLoc)
00170	{
00171	//    Log("ANIM PlayDyingAnim for"@self@"Weapon="@Weapon@"NetMode="$Level.NetMode@"Local ?"@IsLocallyControlled());
00172	    if ( Weapon != none )
00173	    {
00174	      Weapon.instigator = self;
00175	      Weapon.NotifyOwnerKilled(none);
00176	    }
00177	    // ELR On clients, must reset these because bug if we pick it up again
00178	    if ( (Level.NetMode == NM_Client) /*&& IsLocallyControlled()*/ && (Weapon != none) )
00179	    { // ELR IsLocallycontrolled don't work anymore, reason : no more controller when PlayDyingAnim is called.
00180	      // solution : remove IsLocallycontrolled test, if have weapon then must be locally controlled.
00181	//      LOG("REINITWEAPON"@Weapon);
00182	      Weapon.Instigator = none;
00183	      Weapon.SetOwner(none);
00184	      Weapon.SetBase(none);
00185	      Weapon.StopAnimating();
00186	      Weapon.GotoState('');
00187	      Weapon.bRendered = false;
00188	      Weapon.bHidden = true;
00189	      Weapon.RefreshDisplaying();
00190	      Weapon.DetachFromPawn(self);
00191	      DeleteInventory(Weapon);
00192	    }
00193	    else
00194	      DropMyWeapon(); // on Server call only
00195	
00196	    super.PlayDyingAnim(DamageType, HitLoc);
00197	    PlaySndDeathOno(deathono'Onomatopees.hPNJDeath1',CodeMesh,0);
00198	}
00199	
00200	//_____________________________________________________________________________
00201	simulated function ClientDying(class<DamageType> DamageType, vector HitLocation)
00202	{
00203	//  Log("ClientDying Weapon="$Weapon);
00204	  if ( Weapon != none )
00205	    Weapon.NotifyOwnerKilled(none);
00206		if ( Controller != None )
00207			Controller.ClientDying(DamageType, HitLocation);
00208	}
00209	
00210	//_____________________________________________________________________________
00211	state Dying
00212	{
00213	    simulated event BeginState()
00214	    {
00215	//      Log("Dying BeginState");
00216	      MarioBonusLAN = 0;
00217	      if( ( PlayerController(Controller) != none ) && ( XIIIMPHud(PlayerController(Controller).MyHUD) != none ) )
00218	      {
00219	        XIIIMPHud(PlayerController(Controller).MyHUD).MarioBonus=0;
00220	        XIIIMPHud(PlayerController(Controller).MyHUD).FragCount=0;
00221	      }
00222	      if ( bTearOff && (Level.NetMode == NM_DedicatedServer) )
00223	        LifeSpan = 1.0;
00224	      SetTimer2(10.0, false); // leave enough time to see in bombing mode while waiting for respawn
00225	
00226	      SetPhysics(PHYS_Falling);
00227	      bInvulnerableBody = true;
00228	      if ( Controller != none )
00229	        Controller.PawnDied();
00230	    }
00231	
00232	    simulated event Timer2()
00233	    {
00234	      local XIIIGameReplicationInfo XGRI;
00235	
00236	      foreach allactors(class'XIIIGameReplicationInfo', XGRI)
00237	        break;
00238	//      Log("Dying Timer");
00239	      if ( XGRI.iGameState == 2 )
00240	        Destroy(); // only destroy while playing game, not when game ended
00241	      else
00242	        SetTimer2(3.0, false);
00243	    }
00244	    simulated event Timer()
00245	    {
00246	      Global.Timer();
00247	    }
00248	}
00249	
00250	
00251	
00252	defaultproperties
00253	{
00254	     SuperDamageFactor=1.000000
00255	     GroundSpeed=567.000000
00256	     Health=250
00257	     hHitSound=Sound'XIIIsound.Impacts__ImpFlesh.ImpFlesh__hPlayImpFlesh'
00258	     HeadShotFactor=5.000000
00259	     bIgnoreVignetteAlpha=False
00260	     bHasRollOff=True
00261	     bHasPosition=True
00262	}

End Source Code