aeroson

witcher 3 dismemberement wound KNG

Jan 29th, 2017
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.93 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 wounds : array< name >;
  89. var usedWound, woundName : name;
  90. var usableWoundNames, allWoundNames : array<name>;
  91. var i : int;
  92.  
  93. actor = thePlayer.GetTarget();
  94. if(!actor) return;
  95. dismembermentComp = (CDismembermentComponent)(actor.GetComponentByClassName( 'CDismembermentComponent' ));
  96. if(!dismembermentComp) return;
  97.  
  98. dismembermentComp.GetWoundsNames(allWoundNames, WTF_All);
  99. for( i=0; i<allWoundNames.Size(); i+=1 ) {
  100. woundName = allWoundNames[i];
  101. if(!actor.HasTag(woundName) && ArrayOfNamesCount(useTheseWoundNames, woundName) > 0)
  102. usableWoundNames.PushBack(woundName);
  103. }
  104.  
  105. if ( usableWoundNames.Size() > 0 ) {
  106.  
  107. usedWound = usableWoundNames[ RandRange( usableWoundNames.Size() ) ];
  108. theGame.GetGuiManager().ShowNotification(usedWound);
  109.  
  110. actor.AddTag(usedWound);
  111. actor.SetDismembermentInfo( usedWound, actor.GetWorldPosition() - actor.GetWorldPosition(), true );
  112. actor.AddTimer( 'DelayedDismemberTimer', 0.05f );
  113.  
  114. }
  115.  
  116. }
  117.  
  118.  
  119. function TryFillWoundsArray() {
  120. if(useTheseWoundNames.Size() == 0) {
  121. useTheseWoundNames.PushBack('gash_01');
  122. useTheseWoundNames.PushBack('gash_02');
  123. useTheseWoundNames.PushBack('gash_03');
  124. useTheseWoundNames.PushBack('cut_arm2');
  125. useTheseWoundNames.PushBack('cut_forearm1_finisher');
  126. }
  127. }
  128.  
  129.  
  130. function TryFillTrailEffect() {
  131. if(bloodFx.Size() == 0) {
  132. bloodFx.PushBack('default_blood_trail');
  133. bloodFx.PushBack('cutscene_blood_trail');
  134. bloodFx.PushBack('cutscene_blood_trail_02');
  135. bloodFx.PushBack('blood_trail_horseriding');
  136. bloodFx.PushBack('blood_trail_finisher');
  137. bloodFx.PushBack('fast_trail_blood_fx');
  138. bloodFx.PushBack('weapon_blood');
  139. bloodFx.PushBack('weapon_blood_stage1');
  140. bloodFx.PushBack('weapon_blood_stage2');
  141. }
  142. }
  143.  
  144. public function ImpactBlood() {
  145.  
  146. var weaponEntity : CEntity;
  147. var weaponSlotMatrix : Matrix;
  148. var bloodFxPos : Vector;
  149. var bloodFxRot : EulerAngles;
  150. var tempEntity : CEntity;
  151.  
  152. weaponEntity = thePlayer.GetInventory().GetItemEntityUnsafe(thePlayer.GetInventory().GetItemFromSlot('r_weapon'));
  153. weaponEntity.CalcEntitySlotMatrix('blood_fx_point', weaponSlotMatrix);
  154.  
  155. bloodFxPos = MatrixGetTranslation(weaponSlotMatrix);
  156. bloodFxRot = weaponEntity.GetWorldRotation();
  157.  
  158. tempEntity = theGame.CreateEntity( (CEntityTemplate)LoadResource('finisher_blood'), bloodFxPos, bloodFxRot);
  159. tempEntity.PlayEffect(bloodFx[RandRange(bloodFx.Size())]);
  160.  
  161. }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment