aeroson

Untitled

Jan 29th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.79 KB | None | 0 0
  1. class CKNGMoreBlood {
  2.  
  3. var bloodFx : array<CName>;
  4. var woundComponents : array<CName>;
  5.  
  6. var attackAction : W3Action_Attack;
  7. var weaponId : SItemUniqueId;
  8. var actorAttacker : CActor;
  9. var playerAttacker : CR4Player;
  10. var npc : CNewNPC;
  11. var bloodTrailParam : CBloodTrailEffect;
  12. var showMoreBloodOnlyOnCriticalHits : bool;
  13. var trailFxName : name;
  14. //var usedWound : name;
  15.  
  16.  
  17. public function Init(act : W3DamageAction, isCriticalHit : bool) {
  18.  
  19. showMoreBloodOnlyOnCriticalHits = false;
  20.  
  21. FillTrailEffect();
  22. FillWoundsArray();
  23.  
  24. IWantMoreBlood(act, isCriticalHit);
  25.  
  26. }
  27.  
  28. public function IWantMoreBlood(act : W3DamageAction, isCriticalHit : bool) {
  29.  
  30. attackAction = (W3Action_Attack)act;
  31. weaponId = attackAction.GetWeaponId();
  32. actorAttacker = (CActor)act.attacker;
  33. playerAttacker = (CR4Player)act.attacker;
  34. npc = (CNewNPC)act.victim;
  35.  
  36. if(!attackAction || !actorAttacker || !playerAttacker || !npc) return;
  37.  
  38. if(act.IsActionMelee() && act.DealtDamage() && !npc.HasTag('AerondightIgnore') && npc.isAttackableByPlayer && !attackAction.IsParried() && !attackAction.IsCountered() && (!showMoreBloodOnlyOnCriticalHits || isCriticalHit)) {
  39.  
  40. if ( attackAction.IsActionRanged() || thePlayer.IsWeaponHeld('fist') || attackAction.WasDodged()) {
  41.  
  42. return;
  43.  
  44. } else {
  45.  
  46. if(npc.GetBloodType() == BT_Red) {
  47.  
  48. thePlayer.inv.GetItemEntityUnsafe( attackAction.GetWeaponId() ).PlayEffect( bloodFx[RandRange(bloodFx.Size())]);
  49. thePlayer.PlayEffect('covered_blood');
  50.  
  51. ImpactBlood();
  52.  
  53. //theGame.GetGuiManager().ShowNotification(CheckCurrentWounds());
  54.  
  55. TryDismember();
  56.  
  57. }
  58.  
  59. if(npc.GetBloodType() == BT_Green) {
  60.  
  61. thePlayer.inv.GetItemEntityUnsafe( weaponId ).PlayEffect( 'aerondight_blood_green' );
  62.  
  63. }
  64.  
  65. if(npc.GetBloodType() == BT_Yellow) {
  66.  
  67. thePlayer.inv.GetItemEntityUnsafe( attackAction.GetWeaponId() ).PlayEffect( 'aerondight_blood_yellow' );
  68.  
  69. }
  70.  
  71. if(npc.GetBloodType() == BT_Black) {
  72.  
  73. thePlayer.inv.GetItemEntityUnsafe( attackAction.GetWeaponId() ).PlayEffect( 'aerondight_blood_black' );
  74.  
  75. }
  76.  
  77.  
  78. //bloodTrailParam = (CBloodTrailEffect)actorAttacker.GetGameplayEntityParam( 'CBloodTrailEffect' );
  79.  
  80. //playerAttacker.inv.GetItemEntityUnsafe( attackAction.GetWeaponId() ).PlayEffect( trailFxName );
  81.  
  82. //thePlayer.inv.PlayItemEffect(weaponId, 'blood_trail_horseriding');
  83.  
  84. //ImpactBlood();
  85.  
  86. }
  87.  
  88. }
  89.  
  90. }
  91.  
  92. function GetPossibleWounds() : bool {
  93.  
  94. var target : CActor;
  95. var dismembermentComp : CDismembermentComponent;
  96. var hasWound : bool;
  97. var woundNames : array<name>;
  98. var possibleWounds : array<name>;
  99. var woundName : name;
  100. var woundComponent : name;
  101.  
  102. var i : int;
  103.  
  104. target = thePlayer.GetTarget();
  105.  
  106. dismembermentComp.GetWoundsNames(woundNames, WTF_All);
  107.  
  108. if(woundNames.Size() > 0) {
  109.  
  110. // we want to find woundComponents which are not inside woundNames
  111. for(i=0; i < woundComponents.Size(); i+=1) {
  112.  
  113. woundComponent = woundComponents[i];
  114.  
  115. if(ArrayOfNamesCount(woundNames, woundComponent) == 0) {
  116. possibleWounds.PushBack(woundComponent);
  117. theGame.GetGuiManager().ShowNotification(woundComponent);
  118. }
  119. }
  120. }
  121.  
  122.  
  123. return possibleWounds;
  124. }
  125.  
  126.  
  127. function TryDismember() {
  128.  
  129. var actor : CActor;
  130. var dismembermentComp : CDismembermentComponent;
  131. var wounds : array< name >;
  132. var usedWound : name;
  133. var possibleWounds : array<name>;
  134.  
  135. actor = thePlayer.GetTarget();
  136. if(!actor) return;
  137. dismembermentComp = (CDismembermentComponent)(actor.GetComponentByClassName( 'CDismembermentComponent' ));
  138. if(!dismembermentComp) return;
  139.  
  140. possibleWounds = GetPossibleWounds();
  141.  
  142. if ( possibleWounds.Size() > 0 ) {
  143.  
  144. usedWound = possibleWounds[ RandRange( possibleWounds.Size() ) ];
  145. theGame.GetGuiManager().ShowNotification(usedWound);
  146.  
  147. actor.SetDismembermentInfo( usedWound, actor.GetWorldPosition() - actor.GetWorldPosition(), true );
  148. actor.AddTimer( 'DelayedDismemberTimer', 0.05f );
  149.  
  150. }
  151.  
  152. }
  153.  
  154.  
  155. function FillWoundsArray() {
  156.  
  157. if(woundComponents.size() == 0) {
  158.  
  159. woundComponents.PushBack('gash_01');
  160. woundComponents.PushBack('gash_02');
  161. woundComponents.PushBack('gash_03');
  162. woundComponents.PushBack('cut_arm2');
  163. woundComponents.PushBack('cut_forearm1_finisher');
  164.  
  165. }
  166. }
  167.  
  168.  
  169. function FillTrailEffect() {
  170.  
  171. if(bloodFx.size() == 0) {
  172. bloodFx.PushBack('default_blood_trail');
  173. bloodFx.PushBack('cutscene_blood_trail');
  174. bloodFx.PushBack('cutscene_blood_trail_02');
  175. bloodFx.PushBack('blood_trail_horseriding');
  176. bloodFx.PushBack('blood_trail_finisher');
  177. bloodFx.PushBack('fast_trail_blood_fx');
  178. bloodFx.PushBack('weapon_blood');
  179. bloodFx.PushBack('weapon_blood_stage1');
  180. bloodFx.PushBack('weapon_blood_stage2');
  181. }
  182. }
  183.  
  184. public function ImpactBlood() {
  185.  
  186. var weaponEntity : CEntity;
  187. var weaponSlotMatrix : Matrix;
  188. var bloodFxPos : Vector;
  189. var bloodFxRot : EulerAngles;
  190. var tempEntity : CEntity;
  191.  
  192. weaponEntity = thePlayer.GetInventory().GetItemEntityUnsafe(thePlayer.GetInventory().GetItemFromSlot('r_weapon'));
  193. weaponEntity.CalcEntitySlotMatrix('blood_fx_point', weaponSlotMatrix);
  194.  
  195. bloodFxPos = MatrixGetTranslation(weaponSlotMatrix);
  196. bloodFxRot = weaponEntity.GetWorldRotation();
  197.  
  198. tempEntity = theGame.CreateEntity( (CEntityTemplate)LoadResource('finisher_blood'), bloodFxPos, bloodFxRot);
  199. tempEntity.PlayEffect(bloodFx[RandRange(bloodFx.Size())]);
  200.  
  201. }
  202. }
Advertisement
Add Comment
Please, Sign In to add comment