## XIIIMP
Class TheDuck

source: C:\XIII\XIIIMP\Classes\TheDuck.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Pawn
             |
             +--XIIIMP.TheDuck

Direct Known Subclasses:TheCatchableDuck

class TheDuck
extends Engine.Pawn

    //
    //-----------------------------------------------------------

Variables
`int` | `FullDamage`
`OldLoopAnimID,` | `LoopAnimID`
`byte` | `Oldsoundcounter0,Oldsoundcounter1,Oldsoundcounter2,Oldsoundcounter3,Oldsoundcounter4`
`byte` | `soundcounter0,soundcounter1,soundcounter2,soundcounter3,soundcounter4`

Function Summary
`simulated` | `ApplyLoopAnimation(int ID)`
    //__________________________________________________________________
`void` | `ChangeLoopAnimation(int ID)`
    //__________________________________________________________________
`simulated` | `PlaySoundOfTheDeath()`
    //__________________________________________________________________
`simulated` | `PostBeginPlay()`
    //__________________________________________________________________

Source Code

    00001	//
    00002	//-----------------------------------------------------------
    00003	class TheDuck extends Pawn native;
    00004
    00005	#exec OBJ LOAD FILE=XIIISound.uax PACKAGE=XIIISound
    00006
    00007	var int FullDamage;
    00008	var int OldLoopAnimID, LoopAnimID;
    00009	var byte soundcounter0,soundcounter1,soundcounter2,soundcounter3,soundcounter4;
    00010	var byte Oldsoundcounter0,Oldsoundcounter1,Oldsoundcounter2,Oldsoundcounter3,Oldsoundcounter4;
    00011
    00012	//__________________________________________________________________
    00013
    00014	replication
    00015	{
    00016	    reliable if( Role==ROLE_Authority )
    00017	        LoopAnimID, FullDamage, soundcounter0 ,soundcounter1 ,soundcounter2 ,soundcounter3 ,soundcounter4 ;
    00018	}
    00019
    00020	//__________________________________________________________________
    00021
    00022	event Attach( Actor Other )
    00023	{
    00024	    if( Pawn(Other ) != none )
    00025	    {
    00026	        log("[ HUNT ] Detachage De Cadavre");
    00027	        Other.SetBase( none );
    00028	    }
    00029	}
    00030
    00031	//__________________________________________________________________
    00032
    00033	simulated function PostBeginPlay()
    00034	{
    00035	    SetBoneScale(32,3,'X Head');
    00036	//    SetBoneScale(31,0.66,'X Pelvis');
    00037	    super.PostBeginPlay();
    00038	}
    00039
    00040	//__________________________________________________________________
    00041
    00042	simulated event LaunchSound()
    00043	{
    00044	    PlaySoundOfTheDeath();
    00045	}
    00046
    00047	//__________________________________________________________________
    00048
    00049	simulated function PlaySoundOfTheDeath()
    00050	{
    00051	    if( soundcounter0 != Oldsoundcounter0 )
    00052	    {
    00053	        Oldsoundcounter0 = soundcounter0;
    00054	        PlaySound(Sound'XIIIsound.Multi__SFXMulti.SFXMulti__hHuntKilled');
    00055	    }
    00056
    00057	    if( soundcounter1 != Oldsoundcounter1 )
    00058	    {
    00059	        Oldsoundcounter1 = soundcounter1;
    00060	        PlaySound( Sound'XIIIsound.Multi__SFXMulti.SFXMulti__hHuntPafed' );
    00061	    }
    00062
    00063	    if( soundcounter2 != Oldsoundcounter2 )
    00064	    {
    00065	        Oldsoundcounter2 = soundcounter2;
    00066	        playsound(Sound'XIIIsound.Multi__SFXMulti.SFXMulti__hHuntKill');
    00067	    }
    00068
    00069	    if( soundcounter3 != Oldsoundcounter3 )
    00070	    {
    00071	        Oldsoundcounter3 = soundcounter3;
    00072	        PlaySound(Sound'XIIIsound.Multi__SFXMulti.SFXMulti__hHuntLoop');
    00073	    }
    00074
    00075	    if( soundcounter4 != Oldsoundcounter4 )
    00076	    {
    00077	        Oldsoundcounter4 = soundcounter4;
    00078	        PlaySound(Sound'XIIIsound.Multi__SFXMulti.SFXMulti__hHuntStopLoop');
    00079	    }
    00080	}
    00081
    00082	//__________________________________________________________________
    00083
    00084	function ChangeLoopAnimation( int ID )
    00085	{
    00086	    LoopAnimID = ID;
    00087	    ApplyLoopAnimation( ID );
    00088	}
    00089
    00090	//__________________________________________________________________
    00091
    00092	simulated event SetLoopAnimation( int ID )
    00093	{
    00094	    ApplyLoopAnimation( ID );
    00095	}
    00096
    00097	//__________________________________________________________________
    00098
    00099	simulated function ApplyLoopAnimation( int ID )
    00100	{
    00101	    local float fScale3D;
    00102	    local vector vScale3D;
    00103
    00104	    fScale3D = 0.8- FullDamage*0.02;
    00105
    00106	    vScale3D.X=fScale3D;
    00107	    vScale3D.Y=fScale3D;
    00108	    vScale3D.Z=fScale3D;
    00109
    00110	    SetDrawScale3D( vScale3D );
    00111	    SetCollisionSize(20,78*fScale3D);
    00112	    //SetBoneScale(32,1+FullDamage*0.1,'X Head');
    00113
    00114	    switch( ID )
    00115	    {
    00116	        case 0: LoopAnim('affole') ; break;
    00117	        case 1: LoopAnim('run') ; break;
    00118	        case 2: LoopAnim('walk') ; break;
    00119	        case 3: LoopAnim('AttenteGrenade') ; break;
    00120	        case 4: LoopAnim('MigBoxeProvoc') ; break;
    00121	    }
    00122	}
    00123
    00124	//_____________________________________________________________________________
    00125
    00126	function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation,vector momentum, class<DamageType> damageType)
    00127	{
    00128	    local int TmpDamage;
    00129
    00130	    if( damageType == class'XIII.DTShotGunned' )
    00131	        Damage *= 2;
    00132
    00133	    TmpDamage = Max(1,Damage/25);
    00134	    instigatedBy.Controller.PlayerReplicationInfo.Score += TmpDamage;
    00135	    FullDamage += TmpDamage;
    00136
    00137	    if( FullDamage > 30 )
    00138	    {
    00139	        Spawn(class'BlastDuck',,, Location);
    00140	        Spawn(class'XIIIMPDeathExplosionEmitter',,, Location);
    00141
    00142	        if( instigatedBy != none )
    00143	        {
    00144	            instigatedBy.Controller.PlayerReplicationInfo.Score += 30;
    00145	            BroadcastLocalizedMessage( class'XIIIMPDuckMessage', -2, instigatedBy.Controller.PlayerReplicationInfo);
    00146	        }
    00147
    00148	        FullDamage = 0;
    00149
    00150	        // ----------- Lauch Sound for the Death ---------------------
    00151	        // 0 :PlaySound(Sound'XIIIsound.Multi__SFXMulti.SFXMulti__hHuntKilled');
    00152	        soundcounter0++;
    00153	        if( soundcounter0 == 255 )
    00154	            soundcounter0 =0;
    00155	        PlaySoundOfTheDeath();
    00156	        // ------------------------------------------------------------
    00157
    00158	        Controller.GotoState('ReInitWithTeleport');
    00159	    }
    00160	    else
    00161	    {
    00162	        XIIIMPDuckController(controller).Damaged(instigatedBy);
    00163	        Spawn(class'BlastDuckBlow',,, Location);
    00164
    00165	        // ----------- Lauch Sound for the Death ---------------------
    00166	        // 1: PlaySound( Sound'XIIIsound.Multi__SFXMulti.SFXMulti__hHuntPafed' );
    00167	        soundcounter1++;
    00168	        if( soundcounter1 == 255 )
    00169	            soundcounter1 =0;
    00170	        PlaySoundOfTheDeath();
    00171	        // ------------------------------------------------------------
    00172	    }
    00173
    00174	    level.Game.CheckScore(instigatedBy.PlayerReplicationInfo);
    00175
    00176
    00177	    return;
    00178	}
    00179
    00180	//_____________________________________________________________________________
    00181
    00182
    00183
    00184
    00185
    00186	defaultproperties
    00187	{
    00188	     OldLoopAnimID=-1
    00189	     bBoss=True
    00190	     GroundSpeed=1200.000000
    00191	     ControllerClass=Class'XIIIMP.XIIIMPDuckController'
    00192	     Mesh=SkeletalMesh'XIIIPersos.DeathM'
    00193	     SaturationDistance=600.000000
    00194	     StabilisationDistance=2000.000000
    00195	     CollisionRadius=20.000000
    00196	     CollisionHeight=45.000000
    00197	}

End Source Code