Ejemplo n.º 1
0
        /*
         * Attempt to make an object (normal or good/great)
         *
         * This routine plays nasty games to generate the "special artifacts".
         * We assume that the given object has been "wiped". You can optionally
         * receive the object's value in value if you pass a non-null pointer.
         *
         * Returns the whether or not creation worked.
         */
        public static bool make_object(Cave c, ref Object j_ptr, int lev, bool good, bool great, ref int value)
        {
            int         Base;
            Object_Kind kind;

            /* Try to make a special artifact */
            if (Random.one_in_(good ? 10 : 1000))
            {
                if (make_artifact_special(ref j_ptr, lev))
                {
                    if (value != 0)
                    {
                        value = j_ptr.value_real(1, false, true);
                    }
                    return(true);
                }

                /* If we failed to make an artifact, the player gets a great item */
                good = great = true;
            }

            /* Base level for the object */
            Base = (good ? (lev + 10) : lev);

            /* Get the object, prep it and apply magic */
            kind = get_obj_num(Base, good || great);
            if (kind == null)
            {
                return(false);
            }
            j_ptr.prep(kind, lev, aspect.RANDOMISE);
            j_ptr.apply_magic(lev, true, good, great);

            /* Generate multiple items */
            if (kind.gen_mult_prob >= Random.randint1(100))
            {
                j_ptr.number = (byte)Random.randcalc(kind.stack_size, lev, aspect.RANDOMISE);
            }

            if (value != 0)
            {
                value = j_ptr.value_real(j_ptr.number, false, true);
            }

            /* Return value, increased for uncursed out-of-depth objects */
            if (!Object_Flag.cursed_p(j_ptr.flags) && (kind.alloc_min > c.depth))
            {
                if (value != 0)
                {
                    value = (kind.alloc_min - c.depth) * (value / 5);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        /*
         * Attempt to make an object (normal or good/great)
         *
         * This routine plays nasty games to generate the "special artifacts".
         * We assume that the given object has been "wiped". You can optionally
         * receive the object's value in value if you pass a non-null pointer.
         *
         * Returns the whether or not creation worked.
         */
        public static bool make_object(Cave c, ref Object j_ptr, int lev, bool good, bool great, ref int value)
        {
            int Base;
            Object_Kind kind;

            /* Try to make a special artifact */
            if (Random.one_in_(good ? 10 : 1000)) {
                if (make_artifact_special(ref j_ptr, lev)) {
                    if (value != 0) value = j_ptr.value_real(1, false, true);
                    return true;
                }

                /* If we failed to make an artifact, the player gets a great item */
                good = great = true;
            }

            /* Base level for the object */
            Base = (good ? (lev + 10) : lev);

            /* Get the object, prep it and apply magic */
            kind = get_obj_num(Base, good || great);
            if (kind == null) return false;
            j_ptr.prep(kind, lev, aspect.RANDOMISE);
            j_ptr.apply_magic(lev, true, good, great);

            /* Generate multiple items */
            if (kind.gen_mult_prob >= Random.randint1(100))
                j_ptr.number = (byte)Random.randcalc(kind.stack_size, lev, aspect.RANDOMISE);

            if(value != 0) value = j_ptr.value_real(j_ptr.number, false, true);

            /* Return value, increased for uncursed out-of-depth objects */
            if (!Object_Flag.cursed_p(j_ptr.flags) && (kind.alloc_min > c.depth)) {
                if (value != 0) value = (kind.alloc_min - c.depth) * (value / 5);
            }

            return true;
        }