Beispiel #1
0
    void UseAbility(Being attacker, Ability ability, Being target)
    {
        ability.Use(target);  //dumps stat modulations into the right place

        ResolveEffectQueue(); //runs through the EffectQueue and uses the tokens

        Debug.Log(target.beingName + " HP:" + target.GetResourceValue("HP", 1));
    }
Beispiel #2
0
    IEnumerator SelectAbility(Being being) //should perhaps be called Select ability
    {
        Debug.Log("starting " + being.beingName + "'s turn" + " HP:" + being.GetResourceValue("HP", 1) + " STAMINA:" + being.GetResourceValue("STAMINA", 1));

        //Any looking for passive or some such would go here

        being.GetUseableActiveAbilities();

        if (being.useableAbilities.Count > 0)
        {
            if (being.playerControlled == true)
            {
                for (int i = 0; i < being.useableAbilities.Count; i++)
                {
                    Debug.Log(i + ". " + being.useableAbilities[i].abilityName);
                }

                if (playerSelection > -1)
                {
                    being.SelectTargets(being.useableAbilities[playerSelection - 1]);
                }
                if (being.selectedAbility == null)
                {
                    currentState = CombatStates.WAITFORPLAYERINPUT;
                }
                savedState = CombatStates.SELECTABILITY;
            }
            if (being.playerControlled == false)
            {
                being.SelectAnAbility();
                being.SelectTargets(being.selectedAbility);
                Debug.Log(being.beingName + " chooses " + being.selectedAbility.abilityName);
                yield return(new WaitForSeconds(textSpeed));

                CalculateToHit(being, being.selectedAbility, being.selectedTargets);
                yield return(new WaitForSeconds(textSpeed));

                nextTurnDone = false;
            }
        }
        else
        {
            Debug.Log(being.beingName + " can't do anything! (is this an error?)");
            nextTurnDone = false;
            yield return(null);
        }
    }
Beispiel #3
0
    public override void Use(Being target)
    {
        float damageRoll = 0;

        for (int i = 0; i < baseDamage; i++)
        {
            //roll 1d6
            damageRoll += UnityEngine.Random.Range(1, 6);
        }

        float plModulation = actionManager.GetPowerLevelComparison(parentBeing, target);

        float finalDamage = 0 - (damageRoll * plModulation); //0- makes it negative because it's damage


        Debug.Log("base damage: " + baseDamage + " damage roll: " + damageRoll + " parentPL " + parentBeing.GetResourceValue("POWERLEVEL", 1) + " targetpl " + target.GetResourceValue("POWERLEVEL", 1) + " plmodulation: " + plModulation + " final damage" + finalDamage);

        Resource targetResourceInTargetBeing;

        targetResourceInTargetBeing = target.GetResource(targetResource);
        ResourceModifier rm = new ResourceModifier(finalDamage);

        targetResourceInTargetBeing.Modify(rm);
    }
Beispiel #4
0
    void CalculateToHit(Being attacker, Ability ability, List <Being> defenders)
    {
        Debug.Log(attacker.beingName + " uses " + ability.abilityName);
        //any looking for passives etc would come here. //this would include effects like 'Goblin punch gets +5 to hit against Goblins' <-- that would be a separate passive ability to Goblin Punch

        for (int i = 0; i < defenders.Count; i++)
        {
            //Debug.Log("for target " + (i+1) + "...");
            //check to see if any effect of this ability will change the toHit values (eg it adds +5 to hit or similar)
            for (int ii = 0; ii < ability.effects.Count; ii++)
            {
                if (ability.effects[ii] is ModulateToHitSelf_Effect) //here I'm literally only looking for one type of effect, I couldnt think of another way of doing it but it seems a but ugly.
                {
                    ability.effects[ii].Use(attacker);               //This should add any relevent statmodulations into the beings statmodulation list
                }
            }


            if (effectQueue.Count > 0)                                        //if we have some effects in the effect queue...
            {
                List <StatModulation> tempList = new List <StatModulation>(); //create a temporary list of stat modulatons

                for (int iii = 0; iii < effectQueue.Count; iii++)
                {
                    if (effectQueue[iii] is StatModulation)
                    {
                        StatModulation sm = effectQueue[iii] as StatModulation;
                        if (sm.targetStat.statName == "TOHIT")                //if it's a TOHIT modulator
                        {
                            tempList.Add(effectQueue[iii] as StatModulation); //Add it to our temporary list
                        }
                    }
                }

                //now we run through our temporary list of stat modulations and fire them in BODMAS order

                for (int iiii = 0; iiii < tempList.Count; iiii++) //first +
                {
                    if (tempList[iiii].modifier == "+")
                    {
                        tempList[iiii].Use();
                    }
                }
                for (int iiii = 0; iiii < tempList.Count; iiii++) //then for -
                {
                    if (tempList[iiii].modifier == "-")
                    {
                        tempList[iiii].Use();
                    }
                }
                //If we need to remove those used Stat Modulations from the beings statMOdulations list then here is where we would do it.
                //It's not in yet because we might have statmods that last for X turns or count themselves down to death etc.
            }


            //actually calculate the toHit value

            //Debug.Log("Calculating to hit...");
            float tohit  = attacker.GetStatValue("TOHIT", 2);
            float dex    = attacker.GetStatValue("DEXTERITY", 2);
            float random = Random.Range(1, 101);
            float pl     = attacker.GetResourceValue("POWERLEVEL", 1);
            float final  = pl + ((dex / 100) * ability.ranks) + random + tohit;
            Debug.Log(pl + " + (" + (dex / 100) + " * " + ability.ranks + ") + " + random + " + " + tohit + " = " + final);

            //Debug.Log("To Hit value is " + final);

            CalculateDefence(attacker, ability, final, defenders[i]);
        }


        //yield return new WaitForSeconds(textSpeed);
    }
 public float GetPowerLevelComparison(Being origin, Being comparator)
 {
     return(origin.GetResourceValue("POWERLEVEL", 1) / comparator.GetResourceValue("POWERLEVEL", 1));
 }