Example #1
0
        // Function from file: surgery_step.dm
        public void initiate(dynamic user = null, Mob target = null, string target_zone = null, dynamic tool = null, Surgery surgery = null)
        {
            bool   advance     = false;
            double prob_chance = 0;

            surgery.step_in_progress = true;

            if (this.preop(user, target, target_zone, tool, surgery) == -1)
            {
                surgery.step_in_progress = false;
                return;
            }

            if (GlobalFuncs.do_after(user, this.time, null, target))
            {
                advance     = false;
                prob_chance = 100;

                if (Lang13.Bool(this.implement_type))
                {
                    prob_chance = Convert.ToDouble(this.implements[this.implement_type]);
                }
                prob_chance *= GlobalFuncs.get_location_modifier(target);

                if (Rand13.PercentChance(((int)(prob_chance))) || user is Mob_Living_Silicon_Robot)
                {
                    if (this.success(user, target, target_zone, tool, surgery))
                    {
                        advance = true;
                    }
                }
                else if (this.failure(user, target, target_zone, tool, surgery))
                {
                    advance = true;
                }

                if (advance)
                {
                    surgery.status++;

                    if (surgery.status > surgery.steps.len)
                    {
                        surgery.complete(target);
                    }
                }
            }
            surgery.step_in_progress = false;
            return;
        }