Advertisement
Guest User

Untitled

a guest
Dec 10th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 4.12 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.TribesGame.TrDevice;
  12. private import UnrealScript.TribesGame.TrInventoryManager;
  13. private import UnrealScript.Engine.Actor;
  14. private import UnrealScript.UTGame.UTPlayerController;
  15.  
  16. private import UnrealScript.TribesGame.TrDevice_ChainGun;
  17. private import UnrealScript.TribesGame.TrDevice_LightSpinfusor;
  18. private import UnrealScript.TribesGame.TrDevice_GrenadeLauncher;
  19. private import UnrealScript.TribesGame.TrDevice_PlasmaGun;
  20. private import UnrealScript.TribesGame.TrDevice_MortarLauncher;
  21.  
  22. //SDK example mod
  23.  
  24. //Spawn time 2 seconds
  25. //Chain, disc, nade, plasma, mortar for everyone
  26.  
  27. public enum CUSTOM_EQUIP_POINT : TrObject.TR_EQUIP_POINT
  28. {
  29.     EQP_Tertiary = cast(TrObject.TR_EQUIP_POINT)(13),
  30.     EQP_Quaternary = cast(TrObject.TR_EQUIP_POINT)(14),
  31.     EQP_Quinary = cast(TrObject.TR_EQUIP_POINT)(15),
  32. }
  33.  
  34. extern(C) HookType TribesGame_TrPlayerController_GetRespawnDelayTotalTime(TrPlayerController pThis, ref float result)
  35. {
  36.     result = 2.0f;
  37.    
  38.     return HookType.Block;
  39. }
  40.  
  41. extern(C) HookType TribesGame_TrPlayerReplicationInfo_GetEquipDevice(TrPlayerReplicationInfo pThis, ref ScriptClass result, ScriptClass FamilyInfo, TrObject.TR_EQUIP_POINT EquipSlot)
  42. {
  43.     //Handle weapons
  44.     if (EquipSlot == TrObject.TR_EQUIP_POINT.EQP_Primary)
  45.     {
  46.         result = TrDevice_ChainGun.StaticClass();
  47.         return HookType.Block;
  48.     } else if (EquipSlot == TrObject.TR_EQUIP_POINT.EQP_Secondary)
  49.     {
  50.         result = TrDevice_LightSpinfusor.StaticClass();
  51.         return HookType.Block;
  52.     } else if (EquipSlot == CUSTOM_EQUIP_POINT.EQP_Tertiary)
  53.     {
  54.         result = TrDevice_GrenadeLauncher.StaticClass();
  55.         return HookType.Block;
  56.     } else if (EquipSlot == CUSTOM_EQUIP_POINT.EQP_Quaternary)
  57.     {
  58.         result = TrDevice_PlasmaGun.StaticClass();
  59.         return HookType.Block;
  60.     } else if (EquipSlot == CUSTOM_EQUIP_POINT.EQP_Quinary)
  61.     {
  62.         result = TrDevice_MortarLauncher.StaticClass();
  63.         return HookType.Block;
  64.     }
  65.  
  66.     //Otherwise hand it off to the game
  67.     return HookType.Continue;
  68. }
  69.  
  70. extern(C) void TribesGame_TrPawn_RefreshInventory(TrPawn pThis, void* result, bool bIsRespawn, bool bCallin)
  71. {
  72.     pThis.EquipBestPossibleDevice(CUSTOM_EQUIP_POINT.EQP_Tertiary);
  73.     pThis.EquipBestPossibleDevice(CUSTOM_EQUIP_POINT.EQP_Quaternary);
  74.     pThis.EquipBestPossibleDevice(CUSTOM_EQUIP_POINT.EQP_Quinary);
  75. }
  76.  
  77. extern(C) HookType TribesGame_TrPlayerController_SwitchToCallIn(TrPlayerController pThis, void* result, ubyte T)
  78. {
  79.     TrPawn pawn = cast(TrPawn)(pThis.PawnVar);
  80.  
  81.     if (pawn)
  82.     {
  83.         TrInventoryManager invManager = cast(TrInventoryManager)(pawn.InvManager);
  84.  
  85.         if (invManager)
  86.         {
  87.             TrDevice device = invManager.GetDeviceByEquipPoint(TrObject.TR_EQUIP_POINT.EQP_LaserTarget);
  88.  
  89.             if (cast(TrDevice)(pawn.WeaponVar) != device) //Make sure it's not already equipped
  90.             {
  91.                 if (T == 1)
  92.                     invManager.SwitchWeaponByEquipPoint(CUSTOM_EQUIP_POINT.EQP_Tertiary);
  93.                 else if (T == 2)
  94.                     invManager.SwitchWeaponByEquipPoint(CUSTOM_EQUIP_POINT.EQP_Quaternary);
  95.                 else if (T == 3)
  96.                     invManager.SwitchWeaponByEquipPoint(CUSTOM_EQUIP_POINT.EQP_Quinary);
  97.             }
  98.         }
  99.     }
  100.    
  101.     return HookType.Block;
  102. }
  103.  
  104. void ModInit()
  105. {
  106.     AddHook(TrPlayerController.Functions.GetRespawnDelayTotalTime, &TribesGame_TrPlayerController_GetRespawnDelayTotalTime, HookOrder.Pre);
  107.     AddHook(TrPlayerReplicationInfo.Functions.GetEquipDevice, &TribesGame_TrPlayerReplicationInfo_GetEquipDevice, HookOrder.Pre);
  108.     AddHook(TrPawn.Functions.RefreshInventory, &TribesGame_TrPawn_RefreshInventory, HookOrder.Post);
  109.     AddHook(TrPlayerController.Functions.SwitchToCallIn, &TribesGame_TrPlayerController_SwitchToCallIn, HookOrder.Pre);
  110.  
  111.     //State functions aren't in Class.Functions yet, you have to use the following method to hook them
  112.     //"Function Package.Class.State.Function"
  113.     //AddHook("Function TribesGame.TrPlayerController.PlayerWalking.PlayerMove", &TribesGame_TrPlayerController_PlayerMove);
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement