Advertisement
Guest User

Untitled

a guest
Oct 28th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 2.97 KB | None | 0 0
  1. module TestMod;
  2.  
  3. import IndentedStreamWriter;
  4. import ScriptHooks;
  5. import ScriptClasses;
  6.  
  7. private import UnrealScript.TribesGame.TrObject;
  8. private import UnrealScript.TribesGame.TrPlayerController;
  9. private import UnrealScript.TribesGame.TrPawn;
  10. private import UnrealScript.TribesGame.TrPlayerReplicationInfo;
  11. private import UnrealScript.Engine.Actor;
  12.  
  13. private import UnrealScript.TribesGame.TrDevice_RemoteArxBuster;
  14. private import UnrealScript.TribesGame.TrDevice_ChainGun;
  15.  
  16. //SDK example mod
  17.  
  18. //Spawn time 2 seconds
  19. //Chainguns and AutoJackals for everyone
  20. //Jetpack makes you fly forward
  21.  
  22. const float metersToUnits = 50.0f;
  23.  
  24. extern(C) HookType TribesGame_TrPlayerController_GetRespawnDelayTotalTime(TrPlayerController pThis, ref float result)
  25. {
  26.     result = 2.0f;
  27.    
  28.     return HookType.Block;
  29. }
  30.  
  31. extern(C) HookType TribesGame_TrPlayerReplicationInfo_GetEquipDevice(TrPlayerReplicationInfo pThis, ref ScriptClass result, ScriptClass FamilyInfo, TrObject.TR_EQUIP_POINT EquipSlot)
  32. {
  33.     //Replace primary/secondary
  34.     if (EquipSlot == TrObject.TR_EQUIP_POINT.EQP_Primary)
  35.     {
  36.         result = TrDevice_RemoteArxBuster.StaticClass();
  37.         return HookType.Block;
  38.     } else if (EquipSlot == TrObject.TR_EQUIP_POINT.EQP_Secondary)
  39.     {
  40.         result = TrDevice_ChainGun.StaticClass();
  41.         return HookType.Block;
  42.     }
  43.  
  44.     //Otherwise hand it off to the game
  45.     return HookType.Continue;
  46. }
  47.  
  48. extern(C) HookType TribesGame_TrPlayerController_PlayerMove(TrPlayerController pThis, ref void* result, float deltaTime)
  49. {
  50.     TrPawn pawn = cast(TrPawn)pThis.PawnVar;
  51.     if (pawn)
  52.     {
  53.         if (pThis.m_bPressingJetpack)
  54.         {
  55.             Rotator oldRotation = pThis.Rotation;
  56.             pThis.UpdateRotation( deltaTime );
  57.  
  58.             Vector acceleration = pThis.Rotation.GetForward() * 90.0f * metersToUnits;
  59.  
  60.             if (pThis.Role < Actor.ENetRole.ROLE_Authority)
  61.             {
  62.                 pThis.ReplicateMove(deltaTime, acceleration, Actor.EDoubleClickDir.DCLICK_None, oldRotation - pThis.Rotation);
  63.             }
  64.             else
  65.             {
  66.                 pThis.ProcessMove(deltaTime, acceleration, Actor.EDoubleClickDir.DCLICK_None, oldRotation - pThis.Rotation);
  67.             }
  68.  
  69.             return HookType.Block;
  70.         }
  71.     }
  72.  
  73.     return HookType.Continue;
  74. }
  75.  
  76. void ModInit()
  77. {
  78.     ScriptObject.Find!(ScriptClass)("Class TribesGame.TrDevice_ChainGun");
  79.  
  80.     TrDevice_RemoteArxBuster.DefaultProperties.m_nCarriedAmmo = 100;
  81.     TrDevice_RemoteArxBuster.DefaultProperties.m_nMaxCarriedAmmo = 100;
  82.     TrDevice_RemoteArxBuster.DefaultProperties.MaxAmmoCount = 100;
  83.     TrDevice_RemoteArxBuster.DefaultProperties.FireInterval[0] = 0.15f;
  84.  
  85.     AddHook(TrPlayerController.Functions.GetRespawnDelayTotalTime, &TribesGame_TrPlayerController_GetRespawnDelayTotalTime);
  86.     AddHook(TrPlayerReplicationInfo.Functions.GetEquipDevice, &TribesGame_TrPlayerReplicationInfo_GetEquipDevice);
  87.  
  88.     //State functions aren't in Class.Functions yet, you have to use the following method to hook them
  89.     //"Function Package.Class.State.Function"
  90.     AddHook("Function TribesGame.TrPlayerController.PlayerWalking.PlayerMove", &TribesGame_TrPlayerController_PlayerMove);
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement