Inheritance: UnityEngine.StateMachineBehaviour
 public void displayEnemyAttack(Attack attack)
 {
     showText();
     enemyText.text = PlayerPrefs.GetString("EnemyName") + " used " + attack.attackName + "!";
     enemyText.text = enemyText.text += "\n" + attack.attackDescription;
     playerText.text = attack.effectDescription;
 }
Beispiel #2
0
 public void attack4Pressed(BaseEventData data)
 {
     eventTriggered = true;
     usersChoice = InterSceneData.main.battle_friendly.attacks[3];
     eventNo = 3;
     itemChosen = false;
 }
    public void OnClick()
    {
        if(player.TurnPhases == 4){

            //Reset time for arrowColorChange
            arrowColorTimer =(float)(Time.time + .20);
            arrow.color = Color.red;

            stopPosition = arrow.transform.localPosition;

            currentAttack = didLand(currentAttack);

            startTimer = Time.time + 1;

            if(currentAttack == Attack.Hit){
                arrow.transform.localPosition = initialPosition;

                triesCounter++;
                player.triesCounter++;

                clickCounter++;
                player.clickCounter++;

                ArrowSpeed += 100;
            }

            player.lastSwordHit = (Player.LastSwordHit) currentAttack;
        }
    }
    // Use this for initialization
    void Start()
    {
        Attack tackle = new Attack ();
        Attack tackle2 = new Attack ();
        Attack tackle3 = new Attack ();
        Attack tackle4 = new Attack ();

        Pokemon nikuh = new Pokemon ();

        tackle.aname = "Milchmelker";
        tackle.ap = 30;
        tackle.maxAp = 30;
        tackle.precise = 100;
        tackle.strenght = 10;
        tackle.type = Attack.Type.physical;

        tackle2.aname = "Gemuhe";
        tackle2.ap = 20;
        tackle2.maxAp = 30;
        tackle2.precise = 100;
        tackle2.strenght = 10;
        tackle2.type = Attack.Type.physical;

        tackle3.aname = "Hufstampfer";
        tackle3.ap = 10;
        tackle3.maxAp = 30;
        tackle3.precise = 100;
        tackle3.strenght = 10;
        tackle3.type = Attack.Type.physical;

        tackle4.aname = "Dubstepkanone";
        tackle4.ap = 40;
        tackle4.maxAp = 50;
        tackle4.precise = 100;
        tackle4.strenght = 10;
        tackle4.type = Attack.Type.physical;

        nikuh.name = "Nikuh";
        nikuh.attack = 20;
        nikuh.defense = 15;
        nikuh.specialAttack = 13;
        nikuh.specialDefense = 8;
        nikuh.experience = 300;
        nikuh.level = 6;
        nikuh.id = 0;
        nikuh.pokedexId = 1;
        nikuh.trainer = InterSceneData.main.playerName;
        nikuh.types = new Pokemon.Type[10];
        nikuh.types [0] = Pokemon.Type.grass;
        nikuh.maxHp = 50;
        nikuh.hp = 50;
        nikuh.picture = Resources.LoadAll<Sprite> ("Sprites/pokemon_battle")[245];
        nikuh.attacks = new Attack[4];
        nikuh.attacks [0] = tackle;
        nikuh.attacks [1] = tackle2;
        nikuh.attacks [2] = tackle3;
        nikuh.attacks [3] = tackle4;

        insertPokemon (nikuh);
    }
Beispiel #5
0
    // Update is called once per frame
    void Update()
    {
        if (ChoseToAttack) {
            PlayerAttack = FIGHTscreen.S.ChosenAttack;
            ChoseToAttack = false;

            if(PlayersPokemon.SpeedStat > EnemyPokemon.SpeedStat) {
                int dmg = Damage (PlayersPokemon, EnemyPokemon, PlayerAttack);
                EnemyPokemon.HealthCurrent -= dmg;
                if(EnemyPokemon.HealthCurrent > 0) {
                    Attack att = EnemyAI (EnemyPokemon);
                    dmg = Damage(EnemyPokemon, PlayersPokemon, att);
                    PlayersPokemon.HealthCurrent -= dmg;
                }
            } else {
                Attack att = EnemyAI (EnemyPokemon);
                int dmg = Damage(EnemyPokemon, PlayersPokemon, att);
                PlayersPokemon.HealthCurrent -= dmg;
                if(PlayersPokemon.HealthCurrent > 0) {
                    dmg = Damage(PlayersPokemon, EnemyPokemon, PlayerAttack);
                    EnemyPokemon.HealthCurrent -= dmg;
                }
            }
            print (PlayersPokemon.Name + " HP: " + PlayersPokemon.HealthCurrent + "/" + PlayersPokemon.HealthFull);
            print (EnemyPokemon.Name + " HP: " + EnemyPokemon.HealthCurrent + "/" + EnemyPokemon.HealthFull);
        } else if (ChoseToRun) {
            //say Ran Away
            ChoseToRun = false;
            gameObject.SetActive(false);
        }
    }
 private void BT_Add_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Attack retVal = new Attack()
         {
             // Basics
             Name              = TB_Name.Text != "" ? TB_Name.Text : "Dynamic",
             DamageType        = (ItemDamageType)CB_DmgType.SelectedIndex,
             DamagePerHit      = (float)NUD_DmgPerHit.Value,
             DamageIsPerc      = CK_DamageIsPerc.IsChecked.GetValueOrDefault(false),
             MaxNumTargets     = (float)NUD_MaxNumTargs.Value,
             AttackSpeed       = (float)NUD_AtkSpeed.Value,
             AttackType        = (ATTACK_TYPES)CB_AtkType.SelectedIndex,
             // Phase Info
             //PhaseStartTime    = (float)NUD_PhaseStartTime.Value,
             //PhaseEndTime      = (float)NUD_PhaseEndTime.Value,
             // DoT Stats
             IsDoT             = CK_IsDoT.IsChecked.GetValueOrDefault(false),
             DamagePerTick     = (float)NUD_DmgPerTick.Value,
             TickInterval      = (float)NUD_TickInterval.Value,
             Duration          = (float)NUD_Duration.Value,
             // Advanced
             Interruptable     = CK_Interruptable.IsChecked.GetValueOrDefault(false),
             IsTheDefaultMelee = CK_IsDefaultMelee.IsChecked.GetValueOrDefault(false),
             IsDualWielding    = CK_IsDualWielding.IsChecked.GetValueOrDefault(false),
             IsFromAnAdd       = CK_IsFromAnAdd.IsChecked.GetValueOrDefault(false),
             // Player Avoidances
             Missable          = (bool)CK_Missable.IsChecked,
             Dodgable          = (bool)CK_Dodgable.IsChecked,
             Parryable         = (bool)CK_Parryable.IsChecked,
             Blockable         = (bool)CK_Blockable.IsChecked,
         };
         // Targeting Includes
         retVal.AffectsRole[PLAYER_ROLES.MainTank]             = CK_AffectsMTank.IsChecked.GetValueOrDefault(false);
         retVal.AffectsRole[PLAYER_ROLES.OffTank]              = CK_AffectsOTank.IsChecked.GetValueOrDefault(false);
         retVal.AffectsRole[PLAYER_ROLES.TertiaryTank]         = CK_AffectsTTank.IsChecked.GetValueOrDefault(false);
         retVal.AffectsRole[PLAYER_ROLES.MeleeDPS]             = CK_AffectsMeleeDPS.IsChecked.GetValueOrDefault(false);
         retVal.AffectsRole[PLAYER_ROLES.RangedDPS]            = CK_AffectsRangedDPS.IsChecked.GetValueOrDefault(false);
         retVal.AffectsRole[PLAYER_ROLES.MainTankHealer]       = CK_AffectsMainTankHealer.IsChecked.GetValueOrDefault(false);
         retVal.AffectsRole[PLAYER_ROLES.OffAndTertTankHealer] = CK_AffectsOffTankHealer.IsChecked.GetValueOrDefault(false);
         retVal.AffectsRole[PLAYER_ROLES.RaidHealer]           = CK_AffectsRaidHealer.IsChecked.GetValueOrDefault(false);
         //
         if (isEditing) {
             // Affect your changes to the currently selected one
             isEditing = false;
             int index = LB_TheList.SelectedIndex;
             TheList.RemoveAt(LB_TheList.SelectedIndex);
             TheList.Insert(index, retVal);
         } else { TheList.Add(retVal); }
         SetListBox();
     } catch (Exception ex) {
         new Base.ErrorBox()
         {
             Title = "Error Adding a Boss Attack",
             Function = "BT_Add_Clicked()",
             TheException = ex,
         }.Show();
     }
 }
 /// <summary>
 /// Called by other hitboxes when an attack connects.
 /// This is called BY the affecting, ON the affected.
 /// </summary>
 /// <param name="attack">The attack this hitbox is being hit with.</param>
 public override void Hit(Attack attack)
 {
     if (debug) {
         Debug.Log (gameObject.name + " has been hit by " + attack.kData.name);
     }
     switch (state) {
         case State.Normal:
             m_hitManager.AddAttack (attack);
             break;
         case State.Block:
             attack.damageMultiplier *= attack.kData.Chip;
             attack.launchScale.x = blockingLaunchScale;
             attack.launchScale.y = (m_parent.Grounded ? 0 : blockingLaunchScale);
             attack.wasBlocked = true;
             goto case State.Normal;
         case State.Attack:
             if (attack.kData.Priority > m_attack.Priority) goto case State.Normal;
             else if (attack.kData.Priority == m_attack.Priority)
                 m_hitManager.AddAttack (GenerateAttack(m_conflcitResolution));
             break;
         default:
             Debug.LogError (InvalidStateSelectionError);
             goto case State.Normal;
     }
 }
Beispiel #8
0
    /*
     * Decide what the character should do.
     */
    public override void Think()
    {
        FindTarget ();
        Transform fighterTarget = fighter.GetTarget ();
        // Fall back to patrol if we have no target.
        if (fighterTarget == null) {
            return;
        }

        if (fighter.IsAttacking ()) {
            return;
        }

        if (nextAttack == null) {
            nextAttack = GetNextAttack ();
        }
        // Use the attack, or else walk up to the target if not in range
        // If enemy doesn't have half it's stamina, it will back up.
        if (nextAttack != null && IsTargetInRange (nextAttack)) {
            fighter.SwingWeapon (nextAttack);
            nextAttack = null;
        } else if (stamina.HasAnyStamina ()){
            Vector3 moveDirection = fighterTarget.position - transform.position;
            fighter.Run (moveDirection);
        } else {
            Vector3 moveDirection = transform.position - fighterTarget.position;
            fighter.Run (moveDirection);
        }
    }
    // Use this for initialization
    void Start()
    {
        // Setup first

        Setup();

        // Set attack

        attackSet = new Attack[1];
        attackSet[0] = new Attack("Shoot", "fire an arrow at", "try to hit", 3, 2, 6, "pierce", 1, "arrow");
        attackSet[0].spCost = 2;
        attackSet[0].hitSound = "hit1";
        attackSet[0].startSound = "shoot1";
        attackSet[0].failSound = "miss1";

        // Set details

        descShort = "An unidentified shortbow.";

        if(effectMain == "normal"){

            descShortHidden = "A common shortbow.";

        }else{

            descShortHidden = "A shortbow of "+effectMain+".";

        }

        descLong = "Shortbows are light ranged weapons which use arrows.";

        // Apply effects to attacks

        ApplyEffectsToAttacks();
    }
Beispiel #10
0
    public void OnReceiveAttack(Attack attack)
    {
        // TODO: Calculate skill effects, evade, block, etc.

        ReceiveDamage(attack);
        //        ReceiveKnockback(attack.knockback);
    }
    public virtual void Awake()
    {
        agent = gameObject.GetComponent<NavMeshAgent>();

        //Patrol instance START
        points = new Vector3[patrolWaypoints.Length];

        for(int i=0; i<patrolWaypoints.Length; i++ ){
            if(!moveYAxis){
                points[i] = new Vector3(patrolWaypoints[i].transform.position.x, transform.position.y, patrolWaypoints[i].transform.position.z);
            }else{
                points[i] = new Vector3(patrolWaypoints[i].transform.position.x, patrolWaypoints[i].transform.position.y, patrolWaypoints[i].transform.position.z);
            }
        }

        if(points.Length == 1){
            vectorIndex = 0;
        }
        //Patrol instance END

        enemyStats = GetComponent<EnemyStats>();
        enemyAttack = GetComponent<Attack>();
        enemyAttack.setMoveYAxis(moveYAxis);

        if(enemyStats.spriteObject != null){
            enemyAnimator = enemyStats.spriteObject.GetComponent<Animator>();
            hashAnimator = enemyStats.spriteObject.GetComponent<HashAnimatorUnit>();
        }
    }
Beispiel #12
0
    double CalcDamage(Combatant attacker, Combatant defender, Attack attack)
    {
        System.Random gen = new System.Random();
        double crit = 1.0;
        double attackPower = 0.0;
        double defensePower = 0.0;

        //does hit
        if(gen.NextDouble() * 100 > (attack.accuracy + attacker.perception))
        {
            return 0.0;
        }
        //is crit

        if(gen.NextDouble()*100 < (0.05+0.02 * attacker.luck))
        {
            crit = 1.5;
        }
        //do damage
        attackPower = attack.power * attacker.strength;
        defensePower = defender.defense + defender.getArmorValue();

        //return

        return (attackPower / defensePower) * crit;
    }
Beispiel #13
0
	// Update is called once per frame
	void FixedUpdate () {

		UpdateCoolDowns ();

		if (!attacking) {

			timeSinceLastAttack += Time.fixedDeltaTime;

			if (withinMeleeRange) {
				if (nextAttack == null) {
					//Debug.Log ("Dont have an attack so lets choose a new one");
					nextAttack = DetermineNextMove ();
				}

				if (!nextAttack.isOnCoolDown () && timeSinceLastAttack >= attackRate) {
					attacking = true;
					timeSinceLastAttack = 0f;
					anim.SetInteger ("CurrentAction", nextAttack.getCurrentActionInt ());
					// set the attack for the cooldown
					nextAttack.startCooldown();
					//Debug.Log (nextAttack.getName() + " should hit for: " + damage);

					StartCoroutine (completeTheAttack (nextAttack));
					nextAttack = null;
				}
			}
		}
	}
        /**
         * {@inheritDoc}
         */
        //@Override
        //@POST
        //@Path("/attacks")
        public void addAttack(Attack attack) { // throws NotAuthorizedException
            accessControlUtils.checkAuthorization(org.owasp.appsensor.accesscontrol.Action.ADD_ATTACK, requestContext);

            attack.setDetectionSystemId(getClientApplicationName());

            appSensorServer.getAttackStore().addAttack(attack);
        }
    public override void DTRMStart()
    {
        base.DTRMStart();

        attack = GetComponent<Attack>();
        legs = GetComponent<Legs>();
    }
Beispiel #16
0
 public void OnDamage(Attack attack)
 {
     CurHealth -= attack.damage;
     if (CurHealth <= 0)
     {
         Destroy(this.gameObject);
     }
 }
 public void SmallAttack(Attack atk)
 {
     if(atk.Value >0)
     {
         this.m_Animator.SetTrigger(this.AttackSmall);
         Invoke("Hurt", hurtDelay);
     }
 }
 public void displayPlayerAttack(Attack attack)
 {
     showText();
     playerTurnEnd();
     playerText.text = "You used " + attack.attackName + "!";
     playerText.text = playerText.text += "\n" + attack.attackDescription;
     enemyText.text = attack.effectDescription;
 }
Beispiel #19
0
 protected virtual void Awake()
 {
     Transform = transform;
     GameObject = gameObject;
     lineRenderer = GetComponent<LineRenderer>();
     lineRenderer.SetWidth(BeamWidth, BeamWidth);
     attack = new Attack(Damage, OwnType, AimType);
 }
Beispiel #20
0
 public override void Cast_Spell(Summon s)
 {
     base.Cast_Spell(s);
     if (Random.Range(0, 101) > 90)
     {
         results += new Attack().Do_Ability(s);
     }
 }
Beispiel #21
0
 // Use this for initialization
 void Start()
 {
     core = GameObject.FindGameObjectWithTag("core");
     player = GameObject.FindGameObjectWithTag("Player");
     anim = GetComponent<Animator>();
     a = player.GetComponent<Attack>();
     sprite = GetComponent<SpriteRenderer>();
 }
Beispiel #22
0
 public void Activate(Attack attack)
 {
     players = new HashSet<GameObject>();
     players.Add(owner);
     this.attack = attack;
     activated = true;
     collider.enabled = true;
 }
Beispiel #23
0
                public static Attack GoblinAttack()
                {
                    Attack attack = new Attack();
                    attack.APCost = 1;
                    attack.Method = Methods.BasicAttack;

                    return attack;
                }
 // Use this for initialization
 void Start()
 {
     anFish = gameObject.GetComponent<Animator> () as Animator;
     anStars = (gameObject.GetComponentsInChildren<Animator>() as Animator[])[1];
     attackCollider = gameObject.GetComponent<AttackCollider> () as AttackCollider;
     attack = gameObject.GetComponent<Attack> () as Attack;
     touch = false;
 }
Beispiel #25
0
        public override void ApplyDamage(Attack param)
        {
            if (hitPoints <= 0.0) return;

            hitPoints -= param.damage;
            if (hitPoints <= 0.0)
                Death(param.attacker);
        }
        private void AddNewPartyMember(Attack newAttack, String partyMemberName)
        {
            var result = MessageBox.Show("Is this character an NPC?", "NPC?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            var npc = (result != DialogResult.No);
            var newPerson = new Participant(partyMemberName, npc, newAttack);

            group.Add(newPerson);
        }
Beispiel #27
0
 protected bool AttackInvalid(Attack goal)
 {
     Target currentTarget = goal.Target;
     return currentTarget == null ||
             (currentTarget.transform.position - transform.position).sqrMagnitude > SQUARED_AGGRO_RANGE ||
             currentTarget.Team == target.Team ||
             !projectile.CanPay;
 }
Beispiel #28
0
 public AttackEditWindow(Attack at)
 {
     InitializeComponent();
     _attack = at;
     textBox1.Text = at.ToHit.ToString();
     textBox2.Text = at.Damage;
     textBox3.Text = at.Name;
 }
Beispiel #29
0
    public override void OnAttack(Attack attack)
    {
        base.OnAttack (attack);

        if (attack.attackTarget != null) {
            ((BattleController)app.controller).OnMeleeAttack (attack);
        }
    }
Beispiel #30
0
 public UnitType(string name, Attack attack, int defense, int armor, int health)
 {
     this.Name = name;
     this.Attack = attack;
     this.Defense = defense;
     this.Armor = armor;
     this.Health = health;
 }
Beispiel #31
0
 public WaitingInputForPush(AttackStateMachine ASM, Attack attack) : base(ASM, attack)
 {
 }
Beispiel #32
0
    public override void Apply(BaseCharacter attacker, BaseCharacter target, int damageDealt, Attack attack)
    {
        BaseCharacter statChange = (appliesToAttackUser ? attacker : target);

        if (stat == Stat.ATK)
        {
            statChange.currentATK += amount;
        }
        else if (stat == Stat.DEF)
        {
            statChange.currentDEF += amount;
        }
        else if (stat == Stat.EVA)
        {
            statChange.currentEVA += amount;
        }
        else if (stat == Stat.HP)
        {
            statChange.currentHP += amount;
        }
        else if (stat == Stat.MP)
        {
            statChange.currentMP += amount;
        }
        else if (stat == Stat.SKL)
        {
            statChange.currentSKL += amount;
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     attack = GetComponent <Attack>();
 }
Beispiel #34
0
    private IEnumerator Turn(Character attacker, Character defender)
    {
        // Initialization
        state    = BattleState.InGame;
        atkIndex = -1;
        defIndex = -1;

        // Updata attacker's pool and generate attack choices randomly
        UpdatePool(attacker);
        List <Attack> attackChoices = GenerateAttackChoices(attacker);

        // - If the attacker is player
        // 1. Enable buttons and update their texts
        // 2. Block until player selects
        // 3. After player selects, disable buttons
        // - Else
        // 1. Defender randomly selects one attack
        if (attacker.isPlayer)
        {
            int i = 0;
            for (; i < attackChoices.Count; i += 1)
            {
                uim.RemoveEventBtnListeners(i);
                int index = i;
                uim.AddEventBtnListener(i, delegate { OnSelect(index); });
                uim.SetEventBtnText(i, attackChoices[i].choice);
            }
            for (; i < uim.GetEventBtnsNumber(); i += 1)
            {
                uim.RemoveEventBtnListeners(i);
            }
            // uim.SetEventInfo("你想要如何进攻:\n", true);

            atkIndex = -1;
            yield return(new WaitWhile(() => atkIndex == -1));
        }
        else
        {
            atkIndex = Random.Range(0, attackChoices.Count);
        }

        // Get attack choice and show text
        Attack atkChoice = attackChoices[atkIndex];

        uim.SetEventInfo(atkChoice.description.ToBattleString(attacker, defender) + "\n", true);

        // Updata defender's pool and generate defend choices randomly
        UpdatePool(defender);
        List <Defend> defendChoices = GenerateDefendChoices(defender, atkChoice.types);

        // - If the attacker is player
        // 1. Enable buttons and update their texts
        // 2. Block until player selects
        // 3. After player selects, disable buttons
        // - Else
        // 1. Defender randomly selects one attack
        if (defender.isPlayer)
        {
            int i = 0;
            for (; i < defendChoices.Count; i += 1)
            {
                uim.RemoveEventBtnListeners(i);
                int index = i;
                uim.AddEventBtnListener(i, delegate { OnSelect(index); });
                uim.SetEventBtnText(i, defendChoices[i].description.ToBattleString(attacker, defender));
            }
            for (; i < uim.GetEventBtnsNumber(); i += 1)
            {
                uim.RemoveEventBtnListeners(i);
            }
            // uim.SetEventInfo("你想要如何防御:\n", true);

            defIndex = -1;
            yield return(new WaitWhile(() => defIndex == -1));
        }
        else
        {
            defIndex = Random.Range(0, defendChoices.Count);
        }

        // Get defend choice
        Defend defChoice = defendChoices[defIndex];

        // Calculate result
        float totalProb = 0f;

        foreach (int resultID in defChoice.results)
        {
            totalProb += Data.AllResults[resultID].param;
        }
        float  randProb = Random.Range(0f, totalProb);
        Result result   = new Result(-1);

        foreach (int resultID in defChoice.results)
        {
            result    = Data.AllResults[resultID];
            randProb -= result.param;
            if (randProb <= 0f)
            {
                break;
            }
        }

        // Process result
        defender.GetDamage(result.atkFactor * atkChoice.pDamage, result.atkFactor * atkChoice.mDamage);

        // Show result's text
        uim.SetEventInfo(result.description.ToBattleString(attacker, defender) + "\n", true);
        // Show enemy's hp (only in demo)
        // string hpStr = defender.currentProperty.hp.ToString() + " / " + defender.originalProperty.hp.ToString();
        // uim.SetEventInfo(defender.name + "的血量 : " + hpStr + "\n", true);

        // Add sepration text
        uim.SetEventInfo("--------------------\n", true);
    }
Beispiel #35
0
 protected override void Setup()
 {
     base.Setup();
     m_Attack = GetComponentInChildren <Attack>();
 }
Beispiel #36
0
    void OnCollisionEnter(Collision col)
    {
        if (playerWeapon)
        {
            if (equipped && col.gameObject.tag != "Player")
            {
                Vector3 playerToHitPoint = col.contacts[0].point - PlayerManager.Instance.player.transform.position;
                Attack  attack           = new Attack(BaseDamage, playerToHitPoint, knockbackStrength, SwingTypes.None, weaponType, col.contacts[0].point);

                AnimatorStateInfo currentAnimation = PlayerManager.Instance.playerAnimator.GetCurrentAnimatorStateInfo(0);
                if (currentAnimation.IsName("Player_RightSwing"))
                {
                    attack.swingType = SwingTypes.Right;
                    WeaponCombo1.SetValue();
                }
                else if (currentAnimation.IsName("Player_LeftSwing"))
                {
                    attack.swingType = SwingTypes.Left;
                    WeaponCombo2.SetValue();
                }
                else if (currentAnimation.IsName("Player_TopSwing"))
                {
                    attack.swingType = SwingTypes.Top;
                    WeaponCombo3.SetValue();
                }

                if (!alreadyHitObjects.Contains(col.gameObject))
                {
                    //get material of the contact point
                    SoundMaterial sm = col.gameObject.GetComponent <SoundMaterial>();
                    if (sm != null)
                    {
                        uint thisSwitch = 0;
                        AkSoundEngine.GetSwitch((uint)sm.material.GroupId, transform.parent.gameObject, out thisSwitch);
                        //print("Current Switch: "+ thisSwitch +", New: "+ sm.material.ID);

                        if (thisSwitch != (uint)sm.material.Id)
                        {
                            sm.material.SetValue(transform.parent.gameObject); // Set Impact Material
                                                                               //print("New Impact Material: "+ sm.gameObject.name);
                        }
                    }

                    SetAndPlayWeaponImpact(col.gameObject);
                    GameManager.DamageObject(col.gameObject, attack);

                    GameObject hit = Instantiate(hitEffect, transform.position, Quaternion.identity) as GameObject; //TODO: Pool hit effects
                    Destroy(hit, 5f);

                    if (col.gameObject.layer == LayerMask.NameToLayer("Agent"))
                    {
                        //ComboEvent.Post(transform.parent.gameObject);
                        attack.damage += applyBonusDamage ? comboCompletionBonusDamage : 0;

                        float newTimeScale   = applyBonusDamage ? 0.2f : 0.5f;
                        float transitionTime = 0.1f;
                        float holdTime       = applyBonusDamage ? 0.2f : 0.1f;
                        float shakeDuration  = applyBonusDamage ? 0.3f : 0.15f;
                        float shakeScale     = applyBonusDamage ? 0.2f : 0.1f;

                        GameManager.Instance.gameSpeedHandler.SetGameSpeed(gameObject.GetInstanceID(), newTimeScale, transitionTime, transitionTime, holdTime);
                        PlayerManager.Instance.CamShake(new PlayerCamera.CameraShake(shakeScale, shakeDuration));
                    }
                }
            }
        }
        else
        {
            if (col.gameObject.CompareTag("Player"))
            {
                Attack attack = new Attack(BaseDamage, col.contacts[0].point - PlayerManager.Instance.player.transform.position, BaseDamage);
                GameManager.DamageObject(col.gameObject, attack);
                WeaponTypeSwitch.SetValue(transform.parent.gameObject); // Weapon Type
                WeaponImpact.Post(transform.parent.gameObject);
            }
        }
    }
Beispiel #37
0
        private static List <WarRank> CalculateWarRanks(string clanTag)
        {
            var clan = DB.GetCollection <ClanResponse>("clans").FindOne(x => x.tag == clanTag);

            if (clan == null)
            {
                return(null);
            }
            var wars = DB.GetCollection <WarResponse>("wars").Find(x => x.clan.tag == clanTag);

            if (wars.Count() == 0)
            {
                return(null);
            }
            var members     = ApiService.Get <MemberListResponse>(UrlConstants.ListClanMembersUrlTemplate, clanTag).Result;
            var blankAttack = new Attack
            {
                destructionPercentage = 0,
                stars = 0
            };
            var result = new List <WarRank>();

            //now we need to somehow join them togather....
            foreach (var m in members.items)
            {
                if (!wars.Any(x => x.clan.members.Any(z => z.tag == m.tag)))
                {
                    continue;
                }
                //get all wars this member has been in
                var mw     = wars.Where(x => x.clan.members.Any(z => z.tag == m.tag)).ToList();
                var scores = new List <double>();
                foreach (var w in mw)
                {
                    var them       = w.clan.members.FirstOrDefault(x => x.tag == m.tag);
                    var starsLost  = them.bestOpponentAttack?.stars ?? 0;
                    var totalStars = them.attacks?.Sum(x => x.stars) ?? 0;
                    var rank       = them.mapPosition;
                    var netStars   = totalStars - starsLost;
                    //who they attacked
                    double aRav = 35;
                    if (them.attacks != null)
                    {
                        var a1m = w.opponent.members.FirstOrDefault(x => x.tag == them.attacks[0].defenderTag);

                        Member a2m;
                        if (them.attacks.Length == 2)
                        {
                            a2m  = w.opponent.members.FirstOrDefault(x => x.tag == them.attacks[1].defenderTag);
                            aRav = (a1m.mapPosition + a2m.mapPosition) / (double)2;
                        }
                        else
                        {
                            aRav = a1m.mapPosition;
                        }
                        //average rank of those attacks
                    }
                    var defenseMembers = w.opponent.members.Where(x => x.attacks != null && x.attacks.Any(a => a.defenderTag == m.tag)).ToList();
                    var defenses       = defenseMembers.SelectMany(x => x.attacks.Where(a => a.defenderTag == m.tag)).ToList();
                    var dRav           = defenseMembers.Any() ? defenseMembers.Average(x => x.mapPosition) : 1;
                    if (dRav == 0)
                    {
                        dRav = 1;
                    }
                    var numD = defenses.Count();
                    //var nD = numD - starsLost;

                    //now some fun....
                    var dPower     = (10 * (double)numD) * ((double)1 / (double)5);
                    var rawPower   = 10 * (((((totalStars * ((double)4 / (double)6)) - (starsLost - 3)) + ((15 - aRav) * (1 / 13.5))) + ((15 - dRav) * (0.5 / 14))) + (numD * (0.5 / 5)));
                    var unStarred  = (starsLost > 0) ? rawPower + 10 : rawPower;
                    var unRaided   = (numD == 0) ? rawPower + 10 : rawPower;
                    var defBonus   = (numD > 0 && starsLost > 0) ? rawPower + dPower : rawPower;
                    var powerFinal = Math.Max(defBonus, Math.Max(unRaided, unStarred));
                    scores.Add(powerFinal);
                    //Console.WriteLine(powerFinal);

                    //calculate some things....
                }
                if (scores.Count() > 1)
                {
                    //drop lowest score, to be nice
                    scores.Remove(scores.Min());
                }

                var avgScore = scores.Average();
                var user     = DB.GetCollection <Player>("player").FindOne(x => x.CoCId == m.tag);
                var name     = $"<b>{m.name.FormatHTML()}</b>";
                if (user != null)
                {
                    var urlName = $"<a href=\"tg://user?id={user.TelegramId}\">{m.name.FormatHTML()}</a>";
                    name = $"{urlName}";
                }
                var thisPlayer = new WarRank
                {
                    Id       = user?.TelegramId ?? 0,
                    Name     = name,
                    Rank     = avgScore,
                    WarCount = mw.Count()
                };
                result.Add(thisPlayer);

                //Console.WriteLine($"{m.name}: {avgScore}");

                //var memberStats = mw.SelectMany(x => x.clan.members.Where(z => z.tag == m.tag)).ToList();
                //var attacks = new List<Attack>();

                //foreach (var s in memberStats)
                //{
                //    if (s.attacks == null)
                //    {
                //        attacks.Add(blankAttack);
                //        attacks.Add(blankAttack);
                //    }
                //    else
                //    {
                //        foreach (var a in s.attacks)
                //        {
                //            attacks.Add(a);
                //        }
                //        if (s.attacks.Count() == 1)
                //        {
                //            attacks.Add(blankAttack);
                //        }
                //    }
                //}
                ////var attacks = memberStats.Where(x => x.attacks != null).SelectMany(x => x.attacks).Where(x => x != null);

                //var starAvg = attacks.Average(x => x.stars);
                //var destAvg = attacks.Average(x => x.destructionPercentage);
                //var starsLost = memberStats.Average(x => x.bestOpponentAttack?.stars);

                //Console.WriteLine($"{m.name} - {mw.Count} Wars with {attacks.Count(x => x.attackerTag != null)} attacks\nAVG Stars: {starAvg:N2} | AVG Destruction: {destAvg:N2} | AVG Stars Lost: {starsLost:N2}\n");
                ////calculate a war ranking somehow...
            }

            return(result);
        }
Beispiel #38
0
        public Packet HijackTest(Packet p)
        {
            EthernetPacket ethernet = (EthernetPacket)p;
            IpPacket       ip       = (IpPacket)p.PayloadPacket;
            UdpPacket      udp      = (UdpPacket)p.PayloadPacket.PayloadPacket;

            MemoryStream ms = new MemoryStream(udp.PayloadData);
            BinaryReader br = new BinaryReader(ms);

            StringBuilder sbName = new StringBuilder();

            string x = ASCIIEncoding.ASCII.GetString(udp.PayloadData);

            // trans id
            short id = br.ReadInt16();

            // flags
            br.ReadInt16();
            // questions
            short questions = IPAddress.NetworkToHostOrder(br.ReadInt16());
            // answers
            short answers = IPAddress.NetworkToHostOrder(br.ReadInt16());
            // authority rrs
            short authorityRRs = IPAddress.NetworkToHostOrder(br.ReadInt16());
            // aditional rrs
            short aditionalRRs = IPAddress.NetworkToHostOrder(br.ReadInt16());

            for (int i = 0; i < questions; i++)
            {
                sbName = new StringBuilder();

                // En este while lee el nombre del dominio al que se le hace la peticion
                while (true)
                {
                    byte b = br.ReadByte();

                    if (b == 0x00)
                    {
                        break;
                    }

                    if ((b > 0 && b < Convert.ToByte('0')))
                    {
                        if (sbName.Length > 0)
                        {
                            sbName.Append(".");
                        }
                    }
                    else
                    {
                        sbName.Append((char)b);
                    }
                }

                // type
                br.ReadInt16();
                // class
                br.ReadInt16();
            }

            for (int i = 0; i < answers; i++)
            {
                // name ¿puntero?
                br.ReadInt16();
                // type
                short type = IPAddress.NetworkToHostOrder(br.ReadInt16());
                // class
                br.ReadInt16();
                // ttl
                br.ReadInt32();
                // length
                short lenAnswer = IPAddress.NetworkToHostOrder(br.ReadInt16());

                if (type == 0x01)       // 0x01 -> 'A'
                {
                    if (lenAnswer == 4) // ipv4. Si es tipo 0x01 ('A') la IP siempre debería tener un tamaño de 4 bytes.
                    {
                        byte[] raw = new byte[p.PayloadPacket.PayloadPacket.PayloadData.Length];
                        for (int b = 0; b < p.PayloadPacket.PayloadPacket.PayloadData.Length; b++)
                        {
                            raw[b] = p.PayloadPacket.PayloadPacket.PayloadData[b];
                        }

                        IPAddress ipSpoof = GetIpFromSpoofDomain(sbName.ToString());
                        if (ip != null)
                        {
                            if (ipSpoof.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                            {
                                raw[ms.Position + 0] = ipSpoof.GetAddressBytes()[0];
                                raw[ms.Position + 1] = ipSpoof.GetAddressBytes()[1];
                                raw[ms.Position + 2] = ipSpoof.GetAddressBytes()[2];
                                raw[ms.Position + 3] = ipSpoof.GetAddressBytes()[3];
                                // Avanzamos el stream con los 4 bytes que hemos modificado
                                for (int fool = 0; fool < lenAnswer; fool++)
                                {
                                    br.ReadByte();
                                }
                            }
                        }

                        p.PayloadPacket.PayloadPacket.PayloadData = raw;
                    }
                }
                else
                {
                    for (int fool = 0; fool < lenAnswer; fool++)
                    {
                        br.ReadByte();
                    }
                }
            }
            Attack thisAttack = GetAttackFromSpoofDomain(sbName.ToString());

            if (thisAttack != null)
            {
                // Esto siempre deberia pasar, pero por si acaso hacemos la comprobacón del NULL
                if (thisAttack is DNSHijackAttack)
                {
                    ((DNSHijackAttack)thisAttack).spoofsAttacks++;
                    Program.LogThis("Domain " + sbName.ToString() + " spoofed to " + ip.DestinationAddress.ToString(), Logs.Log.LogType.DNSHijacking);
                }
            }
            return(p);
        }
Beispiel #39
0
 public SpAttackDestination(Creature creature, Attack attack, Creature target = null)
 {
     Creature = creature;
     Attack   = attack;
     Target   = target;
 }
Beispiel #40
0
        public static Monster BuildVrock(string name = "")
        {
            Monster vrock = new Monster();

            if (string.IsNullOrEmpty(name))
            {
                vrock.name = "Clyde";
            }
            else
            {
                vrock.name = name;
            }

            vrock.race             = "Vrock";
            vrock.creatureSize     = CreatureSize.Large;
            vrock.alignmentStr     = AlignmentNames.ChaoticEvil;
            vrock.kind             = CreatureKinds.Fiend;
            vrock.baseArmorClass   = 15;
            vrock.naturalArmor     = true;
            vrock.hitPoints        = 104;
            vrock.hitPointsDice    = Dice.d10x11.Plus(44);;
            vrock.baseWalkingSpeed = 40;
            vrock.flyingSpeed      = 60;
            vrock.SetAbilities(17, +3, 15, +2, 18, +4, 8, -1, 13, +1, 8, -1);
            vrock.savingDexterityMod = +5;
            vrock.savingWisdomMod    = +4;
            vrock.savingCharismaMod  = +2;
            vrock.advantages         = Against.spellsAndMagicalEffects;
            vrock.AddDamageResistance(DamageType.Cold | DamageType.Fire | DamageType.Lightning | DamageType.Bludgeoning | DamageType.Piercing | DamageType.Slashing, AttackKind.NonMagical);
            vrock.AddDamageImmunity(DamageType.Poison);
            vrock.conditionImmunities = Conditions.Poisoned;
            vrock.darkvisionRadius    = 120;
            vrock.passivePerception   = 11;
            vrock.AddLanguages(Languages.Abyssal);
            vrock.telepathyRadius  = 120;
            vrock.challengeRating  = 6;
            vrock.experiencePoints = 2300;
            vrock.AddAttack(Attack.Melee(AttackNames.Beak, +6, 5, 1).AddDamage(DamageType.Piercing, Dice.d6x2.Plus(3), AttackKind.NonMagical));

            vrock.AddAttack(Attack.Melee(AttackNames.Talons, +6, 5, 1).AddDamage(DamageType.Slashing, Dice.d10x2.Plus(3), AttackKind.NonMagical));

            Attack sporesAttack = Attack.Area(AttackNames.Spores, 15).AddDamage(DamageType.Poison, Dice.d10x1, AttackKind.NonMagical, TimePoint.StartOfTurn, TimePoint.EndOfTurn, Conditions.Poisoned, 14, Ability.constitution);

            sporesAttack.description = "A 15­-foot­-radius cloud of toxic spores extends out from the vrock. The spores spread around corners. Each creature in that area must succeed on a DC 14 Constitution saving throw or become poisoned. While poisoned in this way, a target takes 5 (1d10) poison damage at the start of each of its turns. A target can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. Emptying a vial of holy water on the target also ends the effect on it.";
            //sporesAttack.releaseTrigger = new ReleaseTrigger("Target receives splashes of holy water.");
            sporesAttack.AddRecharge(RechargeOdds.OneInSix);
            vrock.AddAttack(sporesAttack);

            Attack screech = Attack.Area(AttackNames.StunningScreech, 20).AddCondition(Conditions.Stunned, 14, Ability.constitution);

            screech.LastDamage.IncludeTargetSenses = Senses.Hearing;
            // TODO: Add test to determine if an attack hits a player using screech.includeTargetSenses.
            screech.LastDamage.ExcludeCreatureKinds(CreatureKinds.Fiend);
            screech.recharges = DndTimeSpan.FromDays(1);
            vrock.AddAttack(screech);

            vrock.AddMultiAttack(AttackNames.Beak, AttackNames.Talons);

            vrock.traits.Add("Magic Resistance. The vrock has advantage on saving throws against spells and other magical effects.");

            return(vrock);
        }
Beispiel #41
0
 public void Hurt(Attack attack)
 {
     Health -= attack.Damage;
 }
 void OnHit(Character hit, Attack hit_by)
 {
     character.DealDamage(character.power * damage_multiplier, hit, false);
 }
Beispiel #43
0
 protected ItemWeaponModel(Gameplay.GameItems.IDs _id, string aName, string theNames, string imageID, Attack attack, string flavor, bool is_artifact)
     : base(_id, aName, theNames, imageID, flavor, DollPart.RIGHT_HAND)
 {
     m_Attack = attack;
     if (is_artifact)
     {
         IsProper      = true;
         IsUnbreakable = true;
         IsUnique      = true;
     }
 }
 public virtual void makeAttack(Attack attack)
 {
     return;
 }
Beispiel #45
0
    public override void Start()
    {
        // upon first creation, create the common "attackAI" instance
        Attack = this.gameObject.AddComponent <attackAI>();

        Attack.attackInterval = attackInterval;
        Attack.attackRadius   = attackRadius;
        Attack.damage         = attackDamage;

        // Guard_on_Zombie = GetComponent<AudioSource>();

        // At present, can only attack zombies and werewolves
        Attack.AddAttackTarget(eNavTargets.Zombie);

        // if ever moving, look for Zombies or Werewolves.
        // Originally, the java script code was looking for safe-zones and
        // finish entities.  By default, normal targets are safe-zone and finish.
        // however, start by looking for zombies, then move to safe/finish zones
        defaultNavTargets.Clear();
        defaultNavTargets.Add(eNavTargets.Zombie);
        defaultNavTargets.Add(eNavTargets.Werewolf);
        //defaultNavTargets.Add(eNavTargets.SafeZone);
        //defaultNavTargets.Add(eNavTargets.Finish);
        // if all else fails, find SOME place in the playable area of the board
        //defaultNavTargets.Add(eNavTargets.Playable);

        // do baseline start actions first...
        // also grabs default animation component too.
        base.Start();

        // pass pointer to the one animation object so this and
        // the attack object are working with the same animator and
        // not thinking of them as two separate instances of an animator

        // via the "Hero Guard" prefab, it has a child element
        // of "LittleKnight2_solo" which has animations of
        // R2L_swipe, walk, die, idle_lookaround, idle, hurt
        Attack.AssignAnimation(gameObject, animComponent, "R2L_swipe");

        // special animation flags uses in commonAI when attacked and dying
        // so as to not duplicate code at this or zombie levels.
        hasHurtAnimation = true;
        hasDieAnimation  = true;

        // Guards (walk, idle, idle_lookaround, hurt, die, R2L_swipe)
        AnimationClip ac = animComponent.GetClip("idle");

        ac.wrapMode = WrapMode.Loop;
        ac          = animComponent.GetClip("idle_lookaround");
        ac.wrapMode = WrapMode.Loop;
        ac          = animComponent.GetClip("hurt");
        ac.wrapMode = WrapMode.Once;
        ac          = animComponent.GetClip("die");
        ac.wrapMode = WrapMode.Once;
        ac          = animComponent.GetClip("R2L_swipe");
        ac.wrapMode = WrapMode.Once;

        if (stationary)
        {
            // if ever in combat, retain your post if marked as stationary.
            moveAfterCombat = false;

            // default animation is to be idle...
            //animComponent.Play("idle");
        }
        else
        {
            // moving to new target will always initiate walking mode.
            moveToNewTarget();
        }
    }
    public override Attack Apply(Attack attack)
    {
        attack.ModifiedDamage += attack.BaseDamage * 0.05f * attack.Attacker.DistanceMoved;

        return(attack);
    }
Beispiel #47
0
    //For Trigger Collisions
    public virtual void OnTriggerEnter2D(Collider2D other)
    {
        if (!IsDead())
        {
            //If character can take damage from this source
            if (damageSources.Contains(other.gameObject.tag))
            {
                if (gameObject.tag == "Player")
                {
                    bool inFrontOfShield = false;
                    if ((transform.localScale.x < 0 && other.transform.position.x < transform.position.x) ||
                        (transform.localScale.x > 0 && other.transform.position.x > transform.position.x))
                    {
                        inFrontOfShield = true;
                    }
                    if (gameObject.GetComponent <PlayerControllerScript>().IsBlocking&& inFrontOfShield)
                    {
                        return;
                    }
                }

                Attack attack = other.gameObject.GetComponent <DamageDealer>().Attack;

                //If the damage source was a Character then calculate his stats else do Base damage
                if (other.gameObject.transform.parent && other.gameObject.transform.parent.gameObject.GetComponent <Character>())
                {
                    CharacterStats enemyStats = other.gameObject.transform.parent.gameObject.GetComponent <Character>().characterStats;

                    TakeDamage(CalculateDamage(attack, enemyStats), true);
                }
                //Else A character did not do the damage, it was an object or the world so take base damage
                else
                {
                    TakeDamage(new Damage(attack.BaseDamage - DefenseToReducedDamage()), true);
                }


                //Check Force push values of attack and compare them to our stats
                //Adds a force based on collision direction but only if Character didn't resits it then applies the remainder of force after resistence
                AddTriggerForce(attack, other);

                //Check if this attack apllies damage overtime
                if ((attack.DamageOvertime.IsDamageOvertime))
                {
                    if (attack.DamageOvertime.DamageInstances > 0)
                    {
                        attack.DamageOvertime.totalDuration = attack.DamageOvertime.Duration;
                    }
                    else
                    {
                        attack.DamageOvertime.totalDuration = attack.DamageOvertime.Duration + Time.time;
                    }


                    attack.DamageOvertime.DamageInstances++;
                    //Start coroutine that will damage this character at each interval until duration is over
                    StartCoroutine(doDamageOverTime(attack));
                }
            }
        }
    }
Beispiel #48
0
    protected override void initialize()
    {
        Attack rangedAttackA = attackController.getAttack(rangedAttack);

        rangedAttackA.informParent(gameObject);
    }
Beispiel #49
0
    public float HorizontalMovement(Vector3 axis)
    {
        float horizontalMovement = 0;


        if (axis.x == 0 || damaged)
        {
            if (accelerationTracker > 0)
            {
                if (grounded)
                {
                    accelerationTracker -= Time.deltaTime / decelerationTime;
                }
                else
                {
                    accelerationTracker -= Time.deltaTime / airDecelerationTime;
                }
                accelerationTracker = Mathf.Clamp(accelerationTracker, 0, 1);
            }
            else if (accelerationTracker < 0)
            {
                if (grounded)
                {
                    accelerationTracker += Time.deltaTime / decelerationTime;
                }
                else
                {
                    accelerationTracker += Time.deltaTime / airDecelerationTime;
                }
                accelerationTracker = Mathf.Clamp(accelerationTracker, -1, 0);
            }
        }
        else
        {
            if (grounded)
            {
                accelerationTracker  = Mathf.Abs(accelerationTracker) * axis.x;
                accelerationTracker += Time.deltaTime * Mathf.Sign(axis.x) / timeToMaxSpeed;
            }
            else
            {
                accelerationTracker += Time.deltaTime * axis.x * airControl / timeToMaxSpeed;
            }
        }

        if (attacking)
        {
            switch (attack)
            {
            case Attack.AirDash:
                airDashTracker    += Time.deltaTime / airDashDuration;
                horizontalMovement = airDashCurve.Evaluate(airDashTracker) * airDashSpeed * attackDir;

                if (airDashTracker >= 1)
                {
                    attacking      = false;
                    attack         = Attack.None;
                    airDashTracker = 0;
                }
                break;

            case Attack.Slide:
                slideTracker      += Time.deltaTime / slideDuration;
                horizontalMovement = slideCurve.Evaluate(slideTracker) * slideSpeed * attackDir;

                if (slideTracker >= 1)
                {
                    attacking    = false;
                    attack       = Attack.None;
                    slideTracker = 0;
                }
                break;
            }
        }


        else if (dodging)
        {
            dodgeTracker      += Time.deltaTime / dodgeDuration;
            horizontalMovement = dodgeCurve.Evaluate(dodgeTracker) * dodgeDirection * dodgeLength;
            if (dodgeTracker >= 1)
            {
                dodging      = false;
                dodgeTracker = 0;
            }
        }
        else
        {
            accelerationTracker = Mathf.Clamp(accelerationTracker, -1, 1);
            horizontalMovement  = accelerationCurve.Evaluate(Mathf.Abs(accelerationTracker)) * Mathf.Sign(accelerationTracker) * runSpeed;
        }

        if (wallRide != WallRide.None && !grounded)
        {
            if (!wallJumping)
            {
                //if (wallRide == WallRide.Right && movementAxis.x >= 0) accelerationTracker = 1;
                //else if (wallRide == WallRide.Left && movementAxis.x <= 0) accelerationTracker = -1;

                accelerationTracker = 0;
            }
        }

        if (horizontalMovement > 0)
        {
            dir = 1;
        }
        else if (horizontalMovement < 0)
        {
            dir = -1;
        }


        return(horizontalMovement);
    }
Beispiel #50
0
 public abstract void Apply(BaseCharacter attacker, BaseCharacter target, int damageDealt, Attack attack);
Beispiel #51
0
 public virtual bool AppliesTo(BaseCharacter attacker, BaseCharacter target, int damageDealt, Attack attack)
 {
     return(true);
 }
Beispiel #52
0
 public void Shoot()
 {
     Attack.Shoot();
 }
Beispiel #53
0
        public void ResolveIncomingAttackEffects(AttackResult p_result, Monster p_attacker, Attack p_attackvalue)
        {
            if (p_result.Result == EResultType.HIT || p_result.Result == EResultType.CRITICAL_HIT)
            {
                for (Int32 i = 0; i < 10; i++)
                {
                    Equipment equipment = m_character.Equipment.GetItemAt((EEquipSlots)i) as Equipment;
                    if (equipment == null)
                    {
                        break;
                    }
                    foreach (SuffixStaticData suffixStaticData in equipment.Suffixes)
                    {
                        if (suffixStaticData.Effect == ESuffixEffect.DECREASE_INCOMING_DAMAGE)
                        {
                            for (Int32 j = 0; j < p_attackvalue.Damages.Count; j++)
                            {
                                Damage item = p_attackvalue.Damages[j];
                                p_attackvalue.Damages.RemoveAt(j);
                                item.Value -= (Int32)Math.Round(item.Value * suffixStaticData.GetValueForLevel(equipment.SuffixLevel, equipment.ItemSlot == EItemSlot.ITEM_SLOT_2_HAND), MidpointRounding.AwayFromZero);
                                p_attackvalue.Damages.Insert(j, item);
                            }
                        }
                    }
                }
            }
            Shield shield = m_character.Equipment.GetItemAt(EEquipSlots.OFF_HAND) as Shield;

            if (shield != null && p_result.Result == EResultType.BLOCK)
            {
                m_equipment    = shield;
                m_target       = p_attacker;
                m_attackResult = p_result;
                foreach (SuffixStaticData suffixStaticData2 in shield.Suffixes)
                {
                    if (suffixStaticData2.ConditionHitByType == EHitTypeCondition.BLOCKED && IsEffectTriggered(suffixStaticData2))
                    {
                        ResolveSuffixEffects(suffixStaticData2, true);
                    }
                }
            }
        }
Beispiel #54
0
 public override void Defend(Attack attack)
 {
     attack.Messages.Add("One hand defended the attack: -" + DefenseValue);
     attack.Value -= DefenseValue;
     base.Defend(attack);
 }
Beispiel #55
0
        public void AfflictDamageOfTargetsHP(Monster p_target, List <SuffixStaticData> e, Attack p_attack)
        {
            Int32 currentHealth = p_target.CurrentHealth;

            for (Int32 i = 0; i < e.Count; i++)
            {
                if (e[i].Effect == ESuffixEffect.DEAL_PRIMORDIAL_DAMAGE_IN_HP_AMOUNT)
                {
                    for (Int32 j = 0; j < p_attack.Damages.Count; j++)
                    {
                        Damage item = p_attack.Damages[j];
                        p_attack.Damages.RemoveAt(j);
                        item.Value = currentHealth;
                        p_attack.Damages.Insert(j, item);
                    }
                }
            }
        }
Beispiel #56
0
 public ItemRangedWeaponModel(string aName, string theNames, string imageID, Attack attack, int maxAmmo, AmmoType ammoType)
     : base(aName, theNames, imageID, attack)
 {
     m_MaxAmmo  = maxAmmo;
     m_AmmoType = ammoType;
 }
    private void ChooseAction()
    {
        actionSelectionEffectController.ActivateSpriteObjects();

        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            if (actionChoice == 0)
            {
                actionChoice = 0;
            }
            else
            {
                actionChoice -= 1;
            }
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            if (actionChoice == 3)
            {
                actionChoice = 3;
            }
            else
            {
                actionChoice += 1;
            }
        }

        actionSelectionEffectController.ChangeSprite(actionChoice);

        if (Input.GetKeyDown(KeyCode.Z))
        {
            if (actionChoice == 0)
            {
                // Normal Attack
                myAction[indexOfAction] = new Attack(selectedAlly);
            }
            else if (actionChoice == 1)
            {
                // Normal Defend
                myAction[indexOfAction] = new Defend(selectedAlly);

                // if not the end of ally action, continue to another ally
                currentState = SelectionState.ALLY;

                // after chose action, check if current ally list is zero => means no more available ally to choose
                // if correct, end the phase and disable self
                if (currentAllyList.Count <= 0)
                {
                    GameStateManager.Instance.SetGameState(GameState.BATTLE_PHASE);
                    this.enabled = false;
                }

                // quit running rest of the code since no need to choose target
                return;
            }
            else if (actionChoice == 2)
            {
                currentState = SelectionState.SKILL_SELECTION;

                return;
            }
            else if (actionChoice == 3)
            {
                // Run
                myAction[indexOfAction] = new Run(selectedAlly);
                // Deactivate this script as battle ends
                this.enabled = false;

                // quit running rest of the code since girl runs away
                // change to battle phase for run action
                GameStateManager.Instance.SetGameState(GameState.BATTLE_PHASE);
            }

            actionSelectionEffectController.DeactivateSpriteObjects();

            currentState = SelectionState.TARGET;

            // debug
            Debug.Log("Selected Action: " + myAction[indexOfAction]);
        }
    }
Beispiel #58
0
 public void StopWaitingAndAttack(Attack attack)
 {
     StopCoroutine("WaitSpecifiedTime");
     SetAIState(new AIAttack(this, attack));
 }
Beispiel #59
0
    /*
     * //System to prevent stealth abuse
     * //Pops when certain attacks find no target and instantly reveals all enemies/allies depending
     * public void SAPEnemy()
     * {
     *
     *  foreach(GameObject e in enemies)
     *  {
     *      e.GetComponent<SlotHolder>().SAP();
     *  }
     *
     * }
     *
     *
     * public void SAPFriendly()
     * {
     *
     *  foreach (GameObject e in friendlies)
     *  {
     *      e.GetComponent<SlotHolder>().SAP();
     *  }
     *
     * }
     */


    public void DealFullAoe(Attack a, bool flying)
    {
        OneSideAoe(a, true, flying);
        OneSideAoe(a, false, flying);
    }
Beispiel #60
0
        public virtual void DoAttack(L2Character target)
        {
            if (target == null)
            {
                return;
            }

            if (target.Dead)
            {
                return;
            }

            if ((AttackToHit != null) && AttackToHit.Enabled)
            {
                return;
            }

            if ((AttackToEnd != null) && AttackToEnd.Enabled)
            {
                return;
            }

            double dist  = 60,
                   reqMp = 0;

            L2Item weapon  = ActiveWeapon;
            double timeAtk = 100;//attackspeed
            bool   dual    = false,
                   ranged  = false,
                   ss      = false;

            if (weapon != null)
            {
            }
            else
            {
                timeAtk = (1362 * 345) / timeAtk;
            }

            if (!Calcs.CheckIfInRange((int)dist, this, target, true))
            {
                TryMoveTo(target.X, target.Y, target.Z);
                return;
            }

            if ((reqMp > 0) && (reqMp > CharStatus.CurrentMp))
            {
                SendMessage($"no mp {CharStatus.CurrentMp} {reqMp}");
                return;
            }

            Attack atk = new Attack(this, target, ss, 5);

            if (dual)
            {
                Hit1 = GenHitSimple(true, ss);
                atk.AddHit(target.ObjId, (int)Hit1.Damage, Hit1.Miss, Hit1.Crit, Hit1.ShieldDef > 0);

                Hit2 = GenHitSimple(true, ss);
                atk.AddHit(target.ObjId, (int)Hit2.Damage, Hit2.Miss, Hit2.Crit, Hit2.ShieldDef > 0);
            }
            else
            {
                Hit1 = GenHitSimple(false, ss);
                atk.AddHit(target.ObjId, (int)Hit1.Damage, Hit1.Miss, Hit1.Crit, Hit1.ShieldDef > 0);
            }

            Target = target;

            if (AttackToHit == null)
            {
                AttackToHit          = new Timer();
                AttackToHit.Elapsed += AttackDoHit;
            }

            double timeToHit = ranged ? timeAtk * 0.5 : timeAtk * 0.6;

            AttackToHit.Interval = timeToHit;
            AttackToHit.Enabled  = true;

            if (dual)
            {
                if (AttackToHitBonus == null)
                {
                    AttackToHitBonus          = new Timer();
                    AttackToHitBonus.Elapsed += AttackDoHit2Nd;
                }

                AttackToHitBonus.Interval = timeAtk * 0.78;
                AttackToHitBonus.Enabled  = true;
            }

            if (AttackToEnd == null)
            {
                AttackToEnd          = new Timer();
                AttackToEnd.Elapsed += AttackDoEnd;
            }

            AttackToEnd.Interval = timeAtk;
            AttackToEnd.Enabled  = true;

            BroadcastPacket(atk);
        }