aeroson

Untitled

Jan 29th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.64 KB | None | 0 0
  1. class CKNGMoreBlood {
  2.  
  3. var bloodFx : array<CName>;
  4. var useTheseWoundNames : 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. TryFillTrailEffect();
  22. TryFillWoundsArray();
  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.  
  79. }
  80.  
  81. }
  82.  
  83.  
  84. function TryDismember() {
  85.  
  86. var actor : CActor;
  87. var dismembermentComp : CDismembermentComponent;
  88. var usedWound, currentWound : name;
  89.  
  90. actor = thePlayer.GetTarget();
  91. if(!actor) return;
  92. dismembermentComp = (CDismembermentComponent)(actor.GetComponentByClassName( 'CDismembermentComponent' ));
  93. if(!dismembermentComp) return;
  94.  
  95. currentWound = dismembermentComp.GetVisibleWoundName();
  96.  
  97. if(ArrayOfNamesCount(useTheseWoundNames, currentWound) == 0) {
  98.  
  99. usedWound = useTheseWoundNames[ RandRange( useTheseWoundNames.Size() ) ];
  100. theGame.GetGuiManager().ShowNotification(usedWound);
  101.  
  102. actor.AddTag('woundDone');
  103. actor.SetDismembermentInfo( usedWound, actor.GetWorldPosition() - actor.GetWorldPosition(), true );
  104. actor.AddTimer( 'DelayedDismemberTimer', 0.05f );
  105.  
  106. }
  107.  
  108. }
  109.  
  110.  
  111. function TryFillWoundsArray() {
  112. if(useTheseWoundNames.Size() == 0) {
  113. useTheseWoundNames.PushBack('gash_01');
  114. useTheseWoundNames.PushBack('gash_02');
  115. useTheseWoundNames.PushBack('gash_03');
  116. useTheseWoundNames.PushBack('cut_arm2');
  117. useTheseWoundNames.PushBack('cut_forearm1_finisher');
  118. }
  119. }
  120.  
  121.  
  122. function TryFillTrailEffect() {
  123. if(bloodFx.Size() == 0) {
  124. bloodFx.PushBack('default_blood_trail');
  125. bloodFx.PushBack('cutscene_blood_trail');
  126. bloodFx.PushBack('cutscene_blood_trail_02');
  127. bloodFx.PushBack('blood_trail_horseriding');
  128. bloodFx.PushBack('blood_trail_finisher');
  129. bloodFx.PushBack('fast_trail_blood_fx');
  130. bloodFx.PushBack('weapon_blood');
  131. bloodFx.PushBack('weapon_blood_stage1');
  132. bloodFx.PushBack('weapon_blood_stage2');
  133. }
  134. }
  135.  
  136. public function ImpactBlood() {
  137.  
  138. var weaponEntity : CEntity;
  139. var weaponSlotMatrix : Matrix;
  140. var bloodFxPos : Vector;
  141. var bloodFxRot : EulerAngles;
  142. var tempEntity : CEntity;
  143.  
  144. weaponEntity = thePlayer.GetInventory().GetItemEntityUnsafe(thePlayer.GetInventory().GetItemFromSlot('r_weapon'));
  145. weaponEntity.CalcEntitySlotMatrix('blood_fx_point', weaponSlotMatrix);
  146.  
  147. bloodFxPos = MatrixGetTranslation(weaponSlotMatrix);
  148. bloodFxRot = weaponEntity.GetWorldRotation();
  149.  
  150. tempEntity = theGame.CreateEntity( (CEntityTemplate)LoadResource('finisher_blood'), bloodFxPos, bloodFxRot);
  151. tempEntity.PlayEffect(bloodFx[RandRange(bloodFx.Size())]);
  152.  
  153. }
  154. }
Advertisement
Add Comment
Please, Sign In to add comment