Пример #1
0
    public void Do_Area_Effect(List<Vector3> squares, Characters attacker, Actions act)
    {
        GameObject instance;
        instance = Instantiate(effects[1], act._area_start, Quaternion.identity) as GameObject;
        instance.transform.SetParent(effectholder);
        Vector3 dir = (act._area_target - act._area_start);
        dir.Normalize ();
        float ang = Vector3.Angle (new Vector3(1,0,0), dir);
        if (dir.y < 0)
            ang *= -1;
        instance.transform.Translate (dir/2);
        instance.transform.Rotate ( new Vector3 (0, 0, ang) );
        effecttime = 30;

        // write log
        Append_Log (attacker.charname + " uses " + act._name);

        // roll damage
        int dmg = Dice.roll (act.Get_Damage());

        disp_dmgpos.Clear();
        disp_dmgstr.Clear();

        // Get affected target
        foreach (Vector3 pos in squares) {
            int target = map.Get_Char_At (pos);
            if (target>0){

                int sv =characters[target].Roll_Save (act._save_type);
                int dd = sv < act._save_dc ? dmg : dmg/2;

                disp_dmgpos.Add(pos);
                disp_dmgstr.Add (dd.ToString());
                // "Char rolls reflex save (20). Pass! Take 10 damage!"
                string passfail=sv < act._save_dc ? "Fail" : "Pass";
                Append_Log(characters[target].charname + " rolls " + Parser.Get_Save_Name(act._save_type) + " save ("
                           + sv + "). " + passfail + "! Takes " + dd + " damage!");
            }
        }

        showdmg = _dmgshowtime + effecttime;
    }
Пример #2
0
    /// <summary>
    /// Perform an attack action
    /// </summary>
    /// <param name="pos">Position of the attack target</param>
    /// <param name="attacker">The attacker</param>
    /// <param name="act">Action used for this attack</param>
    public void Do_Attack(Vector3 pos, Characters attacker, Actions act)
    {
        int roll = Dice.roll ("1d20");
        bool iscrit = false;
        if (roll >= act._atk_crit_num) {
            iscrit=true;
        }
        int atk = roll + act._atk_bonus;
        string dmg_str = act.Get_Damage (iscrit);
        int dmg = Dice.roll(dmg_str);

        // Get attack target
        int target = map.Get_Char_At(pos);

        // " A attack B with weapon, roll (1d20 + N) = M "
        string log = attacker.charname + " attack " + characters[target].charname + " with " + act._name;
        log += ", roll 1d20 (" + roll + ") +" + act._atk_bonus + " = " + atk;

        Append_Log (log);
        log = " ";

        // A natural 20 always hit, and 1 always miss
        if (roll == 20)
            atk = 1000;
        else if (roll == 1)
            atk = -1000;

        // Check hit and damage
        int? dmgtaken = characters[target].Get_Hit(atk, dmg);
        disp_dmgpos.Clear();
        disp_dmgstr.Clear();

        disp_dmgpos.Add(pos);
        if (dmgtaken == null)
        {
            log += " Miss!";
            disp_dmgstr.Add("Miss");
        }
        else
        {
            disp_dmgstr.Add(dmgtaken.ToString());
            if (iscrit) log+=" Crit!!";
            else log+=" Hit!";
            log += " Deal " + dmg_str + " = " + dmgtaken + " damage.";
        }
        showdmg = _dmgshowtime;

        Show_effect(new Vector3(pos.x, pos.y, 0), 0,_dmgshowtime);
        Append_Log(log);
    }