コード例 #1
0
        /*
         * Mega-Hack -- Attempt to create one of the "Special Objects".
         *
         * We are only called from "make_object()"
         *
         * Note -- see "make_artifact()" and "apply_magic()".
         *
         * We *prefer* to create the special artifacts in order, but this is
         * normally outweighed by the "rarity" rolls for those artifacts.
         */
        static bool make_artifact_special(ref Object o_ptr, int level)
        {
            int         i;
            Object_Kind kind;

            /* No artifacts, do nothing */
            if (Option.birth_no_artifacts.value)
            {
                return(false);
            }

            /* No artifacts in the town */
            if (Misc.p_ptr.depth == 0)
            {
                return(false);
            }

            /* Check the special artifacts */
            for (i = 0; i < Misc.ART_MIN_NORMAL; ++i)
            {
                Artifact a_ptr = Misc.a_info[i];

                /* Skip "empty" artifacts */
                if (a_ptr == null)
                {
                    continue;
                }

                /* Cannot make an artifact twice */
                if (a_ptr.created)
                {
                    continue;
                }

                /* Enforce minimum "depth" (loosely) */
                if (a_ptr.alloc_min > Misc.p_ptr.depth)
                {
                    /* Get the "out-of-depth factor" */
                    int d = (a_ptr.alloc_min - Misc.p_ptr.depth) * 2;

                    /* Roll for out-of-depth creation */
                    if (Random.randint0(d) != 0)
                    {
                        continue;
                    }
                }

                /* Enforce maximum depth (strictly) */
                if (a_ptr.alloc_max < Misc.p_ptr.depth)
                {
                    continue;
                }

                /* Artifact "rarity roll" */
                if (Random.randint1(100) > a_ptr.alloc_prob)
                {
                    continue;
                }

                /* Find the base object */
                kind = Object_Kind.lookup_kind(a_ptr.tval, a_ptr.sval);

                /* Make sure the kind was found */
                if (kind == null)
                {
                    continue;
                }

                /* Enforce minimum "object" level (loosely) */
                if (kind.level > level)
                {
                    /* Get the "out-of-depth factor" */
                    int d = (kind.level - level) * 5;

                    /* Roll for out-of-depth creation */
                    if (Random.randint0(d) != 0)
                    {
                        continue;
                    }
                }

                /* Assign the template */
                o_ptr.prep(kind, a_ptr.alloc_min, aspect.RANDOMISE);

                /* Mark the item as an artifact */
                o_ptr.artifact = a_ptr;

                /* Copy across all the data from the artifact struct */
                o_ptr.copy_artifact_data(a_ptr);

                /* Mark the artifact as "created" */
                a_ptr.created = true;

                /* Success */
                return(true);
            }

            /* Failure */
            return(false);
        }
コード例 #2
0
ファイル: Object_Make.cs プロジェクト: jobjingjo/csangband
        /*
         * Mega-Hack -- Attempt to create one of the "Special Objects".
         *
         * We are only called from "make_object()"
         *
         * Note -- see "make_artifact()" and "apply_magic()".
         *
         * We *prefer* to create the special artifacts in order, but this is
         * normally outweighed by the "rarity" rolls for those artifacts.
         */
        static bool make_artifact_special(ref Object o_ptr, int level)
        {
            int i;
            Object_Kind kind;

            /* No artifacts, do nothing */
            if (Option.birth_no_artifacts.value) return false;

            /* No artifacts in the town */
            if (Misc.p_ptr.depth == 0) return false;

            /* Check the special artifacts */
            for (i = 0; i < Misc.ART_MIN_NORMAL; ++i) {
                Artifact a_ptr = Misc.a_info[i];

                /* Skip "empty" artifacts */
                if (a_ptr == null) continue;

                /* Cannot make an artifact twice */
                if (a_ptr.created) continue;

                /* Enforce minimum "depth" (loosely) */
                if (a_ptr.alloc_min > Misc.p_ptr.depth) {
                    /* Get the "out-of-depth factor" */
                    int d = (a_ptr.alloc_min - Misc.p_ptr.depth) * 2;

                    /* Roll for out-of-depth creation */
                    if (Random.randint0(d) != 0) continue;
                }

                /* Enforce maximum depth (strictly) */
                if (a_ptr.alloc_max < Misc.p_ptr.depth) continue;

                /* Artifact "rarity roll" */
                if (Random.randint1(100) > a_ptr.alloc_prob) continue;

                /* Find the base object */
                kind = Object_Kind.lookup_kind(a_ptr.tval, a_ptr.sval);

                /* Make sure the kind was found */
                if (kind == null) continue;

                /* Enforce minimum "object" level (loosely) */
                if (kind.level > level) {
                    /* Get the "out-of-depth factor" */
                    int d = (kind.level - level) * 5;

                    /* Roll for out-of-depth creation */
                    if (Random.randint0(d) != 0) continue;
                }

                /* Assign the template */
                o_ptr.prep(kind, a_ptr.alloc_min, aspect.RANDOMISE);

                /* Mark the item as an artifact */
                o_ptr.artifact = a_ptr;

                /* Copy across all the data from the artifact struct */
                o_ptr.copy_artifact_data(a_ptr);

                /* Mark the artifact as "created" */
                a_ptr.created = true;

                /* Success */
                return true;
            }

            /* Failure */
            return false;
        }