Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CKNGMoreBlood {
- var bloodFx : array<CName>;
- var woundComponents : array<CName>;
- var attackAction : W3Action_Attack;
- var weaponId : SItemUniqueId;
- var actorAttacker : CActor;
- var playerAttacker : CR4Player;
- var npc : CNewNPC;
- var bloodTrailParam : CBloodTrailEffect;
- var showMoreBloodOnlyOnCriticalHits : bool;
- var trailFxName : name;
- //var usedWound : name;
- public function Init(act : W3DamageAction, isCriticalHit : bool) {
- showMoreBloodOnlyOnCriticalHits = false;
- FillTrailEffect();
- FillWoundsArray();
- IWantMoreBlood(act, isCriticalHit);
- }
- public function IWantMoreBlood(act : W3DamageAction, isCriticalHit : bool) {
- attackAction = (W3Action_Attack)act;
- weaponId = attackAction.GetWeaponId();
- actorAttacker = (CActor)act.attacker;
- playerAttacker = (CR4Player)act.attacker;
- npc = (CNewNPC)act.victim;
- if(!attackAction || !actorAttacker || !playerAttacker || !npc) return;
- if(act.IsActionMelee() && act.DealtDamage() && !npc.HasTag('AerondightIgnore') && npc.isAttackableByPlayer && !attackAction.IsParried() && !attackAction.IsCountered() && (!showMoreBloodOnlyOnCriticalHits || isCriticalHit)) {
- if ( attackAction.IsActionRanged() || thePlayer.IsWeaponHeld('fist') || attackAction.WasDodged()) {
- return;
- } else {
- if(npc.GetBloodType() == BT_Red) {
- thePlayer.inv.GetItemEntityUnsafe( attackAction.GetWeaponId() ).PlayEffect( bloodFx[RandRange(bloodFx.Size())]);
- thePlayer.PlayEffect('covered_blood');
- ImpactBlood();
- //theGame.GetGuiManager().ShowNotification(CheckCurrentWounds());
- TryDismember();
- }
- if(npc.GetBloodType() == BT_Green) {
- thePlayer.inv.GetItemEntityUnsafe( weaponId ).PlayEffect( 'aerondight_blood_green' );
- }
- if(npc.GetBloodType() == BT_Yellow) {
- thePlayer.inv.GetItemEntityUnsafe( attackAction.GetWeaponId() ).PlayEffect( 'aerondight_blood_yellow' );
- }
- if(npc.GetBloodType() == BT_Black) {
- thePlayer.inv.GetItemEntityUnsafe( attackAction.GetWeaponId() ).PlayEffect( 'aerondight_blood_black' );
- }
- //bloodTrailParam = (CBloodTrailEffect)actorAttacker.GetGameplayEntityParam( 'CBloodTrailEffect' );
- //playerAttacker.inv.GetItemEntityUnsafe( attackAction.GetWeaponId() ).PlayEffect( trailFxName );
- //thePlayer.inv.PlayItemEffect(weaponId, 'blood_trail_horseriding');
- //ImpactBlood();
- }
- }
- }
- function GetPossibleWounds() : bool {
- var target : CActor;
- var dismembermentComp : CDismembermentComponent;
- var hasWound : bool;
- var woundNames : array<name>;
- var possibleWounds : array<name>;
- var woundName : name;
- var woundComponent : name;
- var i : int;
- target = thePlayer.GetTarget();
- dismembermentComp.GetWoundsNames(woundNames, WTF_All);
- if(woundNames.Size() > 0) {
- // we want to find woundComponents which are not inside woundNames
- for(i=0; i < woundComponents.Size(); i+=1) {
- woundComponent = woundComponents[i];
- if(ArrayOfNamesCount(woundNames, woundComponent) == 0) {
- possibleWounds.PushBack(woundComponent);
- theGame.GetGuiManager().ShowNotification(woundComponent);
- }
- }
- }
- return possibleWounds;
- }
- function TryDismember() {
- var actor : CActor;
- var dismembermentComp : CDismembermentComponent;
- var wounds : array< name >;
- var usedWound : name;
- var possibleWounds : array<name>;
- actor = thePlayer.GetTarget();
- if(!actor) return;
- dismembermentComp = (CDismembermentComponent)(actor.GetComponentByClassName( 'CDismembermentComponent' ));
- if(!dismembermentComp) return;
- possibleWounds = GetPossibleWounds();
- if ( possibleWounds.Size() > 0 ) {
- usedWound = possibleWounds[ RandRange( possibleWounds.Size() ) ];
- theGame.GetGuiManager().ShowNotification(usedWound);
- actor.SetDismembermentInfo( usedWound, actor.GetWorldPosition() - actor.GetWorldPosition(), true );
- actor.AddTimer( 'DelayedDismemberTimer', 0.05f );
- }
- }
- function FillWoundsArray() {
- if(woundComponents.size() == 0) {
- woundComponents.PushBack('gash_01');
- woundComponents.PushBack('gash_02');
- woundComponents.PushBack('gash_03');
- woundComponents.PushBack('cut_arm2');
- woundComponents.PushBack('cut_forearm1_finisher');
- }
- }
- function FillTrailEffect() {
- if(bloodFx.size() == 0) {
- bloodFx.PushBack('default_blood_trail');
- bloodFx.PushBack('cutscene_blood_trail');
- bloodFx.PushBack('cutscene_blood_trail_02');
- bloodFx.PushBack('blood_trail_horseriding');
- bloodFx.PushBack('blood_trail_finisher');
- bloodFx.PushBack('fast_trail_blood_fx');
- bloodFx.PushBack('weapon_blood');
- bloodFx.PushBack('weapon_blood_stage1');
- bloodFx.PushBack('weapon_blood_stage2');
- }
- }
- public function ImpactBlood() {
- var weaponEntity : CEntity;
- var weaponSlotMatrix : Matrix;
- var bloodFxPos : Vector;
- var bloodFxRot : EulerAngles;
- var tempEntity : CEntity;
- weaponEntity = thePlayer.GetInventory().GetItemEntityUnsafe(thePlayer.GetInventory().GetItemFromSlot('r_weapon'));
- weaponEntity.CalcEntitySlotMatrix('blood_fx_point', weaponSlotMatrix);
- bloodFxPos = MatrixGetTranslation(weaponSlotMatrix);
- bloodFxRot = weaponEntity.GetWorldRotation();
- tempEntity = theGame.CreateEntity( (CEntityTemplate)LoadResource('finisher_blood'), bloodFxPos, bloodFxRot);
- tempEntity.PlayEffect(bloodFx[RandRange(bloodFx.Size())]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment