## XIIIMP
Class SuperDuck

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

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Inventory
             |
             +--XIIIMP.MarioSuperBonus
                |
                +--XIIIMP.SuperDuck

Direct Known Subclasses:None

class SuperDuck
extends XIIIMP.MarioSuperBonus

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

Variables
`name` | `BoneToAttach`
`PlayerReplicationInfo` | `MyPRI`
`Pawn` | `MyPawn`

Function Summary
`void` | `AttachToPawn(Pawn P)`
    //_____________________________________________________________________________
`void` | `GiveTo(Pawn Other)`
    //__________________________________________________________________________
`void` | `ReleaseTheDuck()`
    //__________________________________________________________________________

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class SuperDuck extends MarioSuperBonus;
    00005
    00006	var Pawn MyPawn;
    00007	var PlayerReplicationInfo MyPRI;
    00008	var name BoneToAttach;
    00009
    00010	//__________________________________________________________________________
    00011
    00012	function ReleaseTheDuck()
    00013	{
    00014	    XIIIMPDuckController(XIIIMPDuckGameInfo(Level.Game).TheDuck.Controller).ReInitPoint = MyPawn.Location;
    00015	    XIIIMPDuckGameInfo(Level.Game).TheDuck.Controller.GotoState('ReInit');
    00016	}
    00017
    00018	//__________________________________________________________________________
    00019
    00020	event Destroyed()
    00021	{
    00022	    XIIIMPPlayerPawn(MyPawn).HasTheDuck = false;
    00023	    XIIIMPDuckGameInfo(Level.Game).WhoHasTheDuck = none;
    00024
    00025	    MyPawn.bCanPickupInventory = true;
    00026	    MyPawn.SpeedFactorLimit = 1.0;
    00027
    00028	    SetTimer(0.0,false);
    00029	    SetTimer2(0.0,false);
    00030
    00031	    RemoveIconInPlayerHud();
    00032
    00033	    BroadcastLocalizedMessage( class'XIIIMPDuckMessage', -1, MyPRI);
    00034	    ReleaseTheDuck();
    00035
    00036	    super.Destroyed();
    00037	}
    00038
    00039	//__________________________________________________________________________
    00040
    00041	function GiveTo( pawn Other )
    00042	{
    00043	    Super.GiveTo(other);
    00044	    MyPawn = Other;
    00045
    00046	    MyPawn.SpeedFactorLimit = 1.15;
    00047	    MyPawn.bCanPickupInventory = false;
    00048
    00049	    XIIIMPDuckGameInfo(Level.Game).WhoHasTheDuck = MyPawn;
    00050	    XIIIMPPlayerPawn(MyPawn).HasTheDuck = true;
    00051
    00052	    SetTimer(1.0,true);
    00053	    SetTimer2(5.0,true);
    00054
    00055	    AddIconInPlayerHud( Other );
    00056
    00057	    MyPRI = MyPawn.Controller.PlayerReplicationInfo;
    00058
    00059	    BroadcastLocalizedMessage( class'XIIIMPDuckMessage', 0, MyPRI);
    00060
    00061	    AttachToPawn(Other);
    00062	}
    00063
    00064	//_____________________________________________________________________________
    00065
    00066	function AttachToPawn(Pawn P)
    00067	{
    00068	  	if ( ThirdPersonActor == None )
    00069	  	{
    00070	  		ThirdPersonActor = Spawn(AttachmentClass,Owner);
    00071	  		InventoryAttachment(ThirdPersonActor).InitFor(self);
    00072	  	}
    00073	  	P.AttachToBone(ThirdPersonActor,BoneToAttach);
    00074	  	ThirdPersonActor.SetRelativeLocation(ThirdPersonRelativeLocation);
    00075	  	ThirdPersonActor.SetRelativeRotation(ThirdPersonRelativeRotation);
    00076	}
    00077
    00078	//__________________________________________________________________________
    00079
    00080	event Timer()
    00081	{
    00082	    Spawn(class'BlastDuck',,, MyPawn.Location);
    00083
    00084	    MyPawn.Health += 2.5;
    00085
    00086	    if( MyPawn.Health > MyPawn.default.Health )
    00087	       MyPawn.Health = MyPawn.default.Health;
    00088	}
    00089
    00090	//__________________________________________________________________________
    00091
    00092	event Timer2()
    00093	{
    00094	    MyPawn.Controller.PlayerReplicationInfo.Score += 1;
    00095	    BroadcastLocalizedMessage( class'XIIIMPDuckMessage', MyPRI.Score, MyPRI);
    00096	    Spawn(class'BlastDuck',,, MyPawn.Location);
    00097	}
    00098
    00099	//__________________________________________________________________________
    00100
    00101
    00102
    00103
    00104	defaultproperties
    00105	{
    00106	     BoneToAttach="X Head"
    00107	     BonusIconId=256
    00108	     ThirdPersonRelativeLocation=(X=5.000000,Z=17.000000)
    00109	     ThirdPersonRelativeRotation=(Yaw=-16384,Roll=16384)
    00110	     AttachmentClass=Class'XIIIMP.DuckAttachment'
    00111	}

End Source Code