Advertisement
Darkhitori

vRagdoll/ApplyDamage

Jan 14th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.56 KB | None | 0 0
  1. //Darkhitori v1.0
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Invector.CharacterController;
  6.  
  7. namespace HutongGames.PlayMaker.Actions
  8. {
  9.     [ActionCategory("Invector/vRagdoll")]
  10.     [Tooltip(" ")]
  11.     public class vR_ApplyDamage : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vRagdoll))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         [ActionSection("vDamage")]
  18.         [Tooltip("Apply damage to the Character Health")]
  19.         public FsmInt damageValue;
  20.         [Tooltip("How much stamina the target will lost when blocking this attack")]
  21.         public FsmFloat staminaBlockCost;
  22.         [Tooltip("How much time the stamina of the target will wait to recovery")]
  23.         public FsmFloat staminaRecoveryDelay;
  24.         [Tooltip("Apply damage even if the Character is blocking")]
  25.         public FsmBool ignoreDefense;
  26.         [Tooltip("Activated Ragdoll when hit the Character")]
  27.         public FsmBool activeRagdoll;
  28.         public FsmGameObject sender;
  29.         public FsmGameObject receiver;
  30.         public FsmVector3 hitPosition;
  31.         public FsmInt recoil_id;
  32.         public FsmInt reaction_id;
  33.         public FsmString attackName;
  34.        
  35.         [ActionSection("-----------------")]
  36.         public FsmBool everyFrame;
  37.  
  38.         vRagdoll theScript;
  39.         vDamage dam;
  40.  
  41.  
  42.         public override void Reset()
  43.         {
  44.             gameObject = null;
  45.             damageValue = 15;
  46.             staminaBlockCost = 5;
  47.             staminaRecoveryDelay = 1;
  48.             ignoreDefense = false;
  49.             activeRagdoll = false;
  50.             sender = null;
  51.             receiver = null;
  52.             hitPosition = null;
  53.             recoil_id = null;
  54.             reaction_id = null;
  55.             attackName = "";
  56.             everyFrame = true;
  57.         }
  58.        
  59.         public override void OnEnter()
  60.         {
  61.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  62.  
  63.             theScript = go.GetComponent<vRagdoll>();
  64.  
  65.  
  66.             if (!everyFrame.Value)
  67.             {
  68.                 DoTheMagic();
  69.                 Finish();
  70.             }
  71.  
  72.         }
  73.  
  74.         public override void OnUpdate()
  75.         {
  76.             if (everyFrame.Value)
  77.             {
  78.                 DoTheMagic();
  79.             }
  80.         }
  81.  
  82.         void DoTheMagic()
  83.         {
  84.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  85.             if (go == null)
  86.             {
  87.                 return;
  88.             }
  89.            
  90.             dam.damageValue = damageValue.Value;
  91.             dam.staminaBlockCost = staminaBlockCost.Value;
  92.             dam.staminaRecoveryDelay = staminaRecoveryDelay.Value;
  93.             dam.ignoreDefense = ignoreDefense.Value;
  94.             dam.activeRagdoll = activeRagdoll.Value;
  95.             dam.sender = sender.Value.transform;
  96.             dam.receiver = receiver.Value.transform;
  97.             dam.hitPosition = hitPosition.Value;
  98.             dam.recoil_id = recoil_id.Value;
  99.             dam.reaction_id = reaction_id.Value;
  100.             dam.attackName = attackName.Value;
  101.             var vDam = dam;
  102.            
  103.             theScript.ApplyDamage(vDam);
  104.            
  105.         }
  106.  
  107.     }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement