Advertisement
Drakten

Untitled

Sep 21st, 2020
1,723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class X2Item_DroneWeapons extends X2Item_HeavyWeapons config(DronesSetup);
  2.  
  3. var config int                  SKULLBIT_WPN_CHARGES;
  4.  
  5. var config array<int>           SB_WPN_RANGE_CV;
  6. var config WeaponDamageValue    SB_WPN_DMG_CV;
  7. var config int                  SB_WPN_CRIT_CV;
  8. var config int                  SB_WPN_WORLD_DMG_CV;
  9.  
  10. static function array<X2DataTemplate> CreateTemplates()
  11. {
  12.     local array<X2DataTemplate> Weapons;
  13.  
  14.     Weapons.AddItem(SkullBITWpn_CV());
  15.        
  16.     return Weapons;
  17. }
  18.  
  19. // **************************************************************************
  20. // ***                       Heavy Weapons Slot                           ***
  21. // **************************************************************************
  22.  
  23. static function X2WeaponTemplate SkullBITWpn_CV()
  24. {
  25.     local X2WeaponTemplate      Template;
  26.     local AltGameArchetypeUse   GameArch;
  27.  
  28.     `CREATE_X2TEMPLATE(class'X2WeaponTemplate', Template, 'SkullBITWpn_CV');
  29.    
  30.     Template.ItemCat = 'weapon';
  31.     Template.WeaponCat = 'droneweapon';
  32.     Template.WeaponTech = 'conventional';
  33.     Template.strImage = "img:///DraktenSkullRipper.InventoryIcons.Inv_SBWPN_CV";
  34.     Template.Tier = 0;
  35.     Template.EquipSound = "StrategyUI_Heavy_Weapon_Equip";
  36.    
  37.     Template.OnEquippedFn = SBWpnEquipped;
  38.    
  39.     Template.Aim = 0;
  40.     Template.iPhysicsImpulse = 5;
  41.     Template.BaseDamage = default.SB_WPN_DMG_CV;        //modeled after the bullpup
  42.     Template.RangeAccuracy = default.SB_WPN_RANGE_CV;   //modeled after the shotgun array more or less
  43.     Template.CritChance = default.SB_WPN_CRIT_CV;       //modeled after the shotgun
  44.     Template.iClipSize = 99;
  45.     Template.InfiniteAmmo = true;
  46.     Template.bMergeAmmo = true;
  47.     Template.bHideClipSizeStat = true;
  48.     Template.iSoundRange = 15;
  49.     Template.iEnvironmentDamage = default.SB_WPN_WORLD_DMG_CV;
  50.    
  51.     Template.PointsToComplete = 0;
  52.     Template.InventorySlot = eInvSlot_HeavyWeapon;
  53.     Template.StowedLocation = eSlot_HeavyWeapon;
  54.    
  55.     Template.GameArchetype = "DraktenSkullRipper.Archetypes.WP_HWslot_SkullBIT_CV";
  56.     GameArch.UseGameArchetypeFn = SoldierHeavyWeaponCheck;
  57.     GameArch.ArchetypeString = "DraktenSkullRipper.Archetypes.WP_Empty";
  58.     AddAltGameArchetype(GameArch, 'SkullBITWpn_CV') ;
  59.    
  60.     Template.DamageTypeTemplateName = 'Electrical';
  61.    
  62.     Template.Abilities.AddItem('SbWpnAbility');
  63.     Template.Abilities.AddItem('HotLoadAmmo');
  64.     Template.Abilities.AddItem('Reload');
  65.    
  66.     Template.CanBeBuilt = false;
  67.     Template.StartingItem = true;
  68.     Template.bInfiniteItem = true;
  69.            
  70.     Template.SetUIStatMarkup(class'XLocalizedData'.default.ChargesLabel, , default.SKULLBIT_WPN_CHARGES);
  71.            
  72.     return Template;
  73. }
  74.  
  75. function SBWpnEquipped(XComGameState_Item ItemState, XComGameState_Unit UnitState, XComGameState NewGameState)
  76. {
  77.     local XComGameState_Item            DroneHeavyWeapon;
  78.     local array<XComGameState_Unit>     AttachedUnits;
  79.    
  80.     UnitState.GetAttachedUnits(AttachedUnits);
  81.    
  82.     if (AttachedUnits.Length > 0)
  83.         {
  84.             DroneHeavyWeapon = ItemState.GetMyTemplate().CreateInstanceFromTemplate(NewGameState);
  85.             AttachedUnits[0].bIgnoreItemEquipRestrictions = true;
  86.             AttachedUnits[0].AddItemToInventory(DroneHeavyWeapon, eInvSlot_HeavyWeapon, NewGameState);
  87.             AttachedUnits[0].bIgnoreItemEquipRestrictions = false;
  88.  
  89.             XGUnit(AttachedUnits[0].GetVisualizer()).ApplyLoadoutFromGameState(AttachedUnits[0], NewGameState);
  90.         }  
  91. }
  92.  
  93. static function AddAltGameArchetype(AltGameArchetypeUse GameArch, Name BaseTemplateName)
  94. {
  95.     local X2ItemTemplateManager     ItemMgr;
  96.     local X2WeaponTemplate          WeaponTemplate;
  97.     local array<X2DataTemplate>     DataTemplates;
  98.     local int                       i;
  99.  
  100.     ItemMgr = class'X2ItemTemplateManager'.static.GetItemTemplateManager();
  101.     ItemMgr.FindDataTemplateAllDifficulties(BaseTemplateName, DataTemplates);
  102.     for (i = 0; i < DataTemplates.Length; ++i)
  103.     {
  104.         WeaponTemplate = X2WeaponTemplate(DataTemplates[i]);
  105.         if (WeaponTemplate != none)
  106.         {
  107.             WeaponTemplate.AltGameArchetypeArray.AddItem(GameArch);
  108.         }
  109.     }
  110. }
  111.  
  112. static function bool SoldierHeavyWeaponCheck(XComGameState_Item ItemState, XComGameState_Unit UnitState, string ConsiderArchetype)
  113. {
  114.     switch(UnitState.GetMyTemplateName())
  115.     {
  116.     case 'DRAKTEN_SkullRipper':
  117.         return true;
  118.     }
  119.     return false;
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement