示例#1
0
        // Function from file: martial.dm
        public override bool harm_act(dynamic A = null, Mob_Living D = null)
        {
            dynamic atk_verb      = null;
            int     damage        = 0;
            dynamic affecting     = null;
            dynamic armor_block   = null;
            dynamic knockout_prob = null;

            ((Ent_Dynamic)A).do_attack_animation(D);
            atk_verb = Rand13.Pick(new object [] { "left hook", "right hook", "straight punch" });
            damage   = Rand13.Int(5, 8) + A.dna.species.punchdamagelow;

            if (!(damage != 0))
            {
                GlobalFuncs.playsound(D.loc, A.dna.species.miss_sound, 25, 1, -1);
                D.visible_message("<span class='warning'>" + A + " has attempted to hit " + D + " with a " + atk_verb + "!</span>");
                GlobalFuncs.add_logs(A, D, "attempted to hit", atk_verb);
                return(false);
            }
            affecting   = ((dynamic)D).get_organ(GlobalFuncs.ran_zone(A.zone_selected));
            armor_block = D.run_armor_check(affecting, "melee");
            GlobalFuncs.playsound(D.loc, A.dna.species.attack_sound, 25, 1, -1);
            D.visible_message("<span class='danger'>" + A + " has hit " + D + " with a " + atk_verb + "!</span>", "<span class='userdanger'>" + A + " has hit " + D + " with a " + atk_verb + "!</span>");
            D.apply_damage(damage, "stamina", affecting, armor_block);
            GlobalFuncs.add_logs(A, D, "punched");

            if (Convert.ToDouble(D.getStaminaLoss()) > 50)
            {
                knockout_prob = D.getStaminaLoss() + Rand13.Int(-15, 15);

                if (D.stat != 2 && Rand13.PercentChance(Convert.ToInt32(knockout_prob)))
                {
                    D.visible_message("<span class='danger'>" + A + " has knocked " + D + " out with a haymaker!</span>", "<span class='userdanger'>" + A + " has knocked " + D + " out with a haymaker!</span>");
                    D.apply_effect(10, "weaken", armor_block);
                    D.SetSleeping(5);
                    ((dynamic)D).forcesay(GlobalVars.hit_appends);
                }
                else if (Lang13.Bool(D.lying))
                {
                    ((dynamic)D).forcesay(GlobalVars.hit_appends);
                }
            }
            return(true);
        }