Ejemplo n.º 1
0
        public static void wr_artifacts()
        {
            int i;
            ushort tmp16u;

            /* Hack -- Dump the artifacts */
            tmp16u = Misc.z_info.a_max;
            wr_u16b(tmp16u);
            for (i = 0; i < tmp16u; i++) {
                Artifact a_ptr = Misc.a_info[i];
                if (a_ptr == null) {
                    a_ptr = new Artifact();
                }
                wr_byte(a_ptr.created);
                wr_byte(a_ptr.seen);
                wr_byte(a_ptr.everseen);
                wr_byte(0);
            }
        }
Ejemplo n.º 2
0
        /*
         * Adding artifacts to the history list is trickier than other operations.
         * This is a wrapper function that gets some of the logic out of places
         * where it really doesn't belong.  Call this to add an artifact to the history
         * list or make the history entry visible--history_add_artifact will make that
         * determination depending on what object_is_known returns for the artifact.
         */
        public static bool add_artifact(Artifact artifact, bool known, bool found)
        {
            throw new NotImplementedException();
            //object_type object_type_body;
            //object_type *o_ptr = &object_type_body;

            //char o_name[80];
            //char buf[80];
            //u16b type;

            //assert(artifact);

            ///* Make fake artifact for description purposes */
            //object_wipe(o_ptr);
            //make_fake_artifact(o_ptr, artifact);
            //object_desc(o_name, sizeof(o_name), o_ptr,
            //            ODESC_PREFIX | ODESC_BASE | ODESC_SPOIL);
            //strnfmt(buf, sizeof(buf), (found)?"Found %s":"Missed %s", o_name);

            ///* Known objects gets different treatment */
            //if (known) {
            //    /* Try revealing any existing artifact, otherwise log it */
            //    if (history_is_artifact_logged(artifact))
            //        history_know_artifact(artifact);
            //    else
            //        history_add(buf, HISTORY_ARTIFACT_KNOWN, artifact);
            //} else {
            //    if (!history_is_artifact_logged(artifact)) {
            //        type = HISTORY_ARTIFACT_UNKNOWN |
            //                (found ? 0 : HISTORY_ARTIFACT_LOST);
            //        history_add(buf, type, artifact);
            //    } else {
            //        return false;
            //    }
            //}

            //return true;
        }
Ejemplo n.º 3
0
        /*
         * Mark artifact number `id` as lost forever, either due to leaving it on a
         * level, or due to a store purging its inventory after the player sold it.
         */
        public static bool lose_artifact(Artifact artifact)
        {
            throw new NotImplementedException();
            //size_t i = history_ctr;
            //assert(artifact);

            //while (i--) {
            //    if (history_list[i].a_idx == artifact.aidx) {
            //        history_list[i].type |= HISTORY_ARTIFACT_LOST;
            //        return true;
            //    }
            //}

            ///* If we lost an artifact that didn't previously have a history, then we missed it */
            //history_add_artifact(artifact, false, false);

            //return false;
        }
Ejemplo n.º 4
0
 /*
  * Add an entry with text `event` to the history list, with type `type`
  * ("HISTORY_xxx" in defines.h), and artifact number `id` (0 for everything
  * else).
  *
  * Returne true on success.
  */
 public static bool add(string evt, ushort type, Artifact artifact)
 {
     Player.Player p_ptr = Player.Player.instance;
     return add_full(type, artifact, p_ptr.depth, p_ptr.lev, Misc.turn, evt);
 }
Ejemplo n.º 5
0
        /*
         * Returns true if the artifact denoted by a_idx is an active entry in
         * the history log (i.e. is not marked HISTORY_ARTIFACT_LOST).  This permits
         * proper handling of the case where the player loses an artifact but (in
         * preserve mode) finds it again later.
         */
        public static bool history_is_artifact_logged(Artifact artifact)
        {
            throw new NotImplementedException();
            //size_t i = history_ctr;
            //assert(artifact);

            //while (i--) {
            //    /* Don't count ARTIFACT_LOST entries; then we can handle
            //     * re-finding previously lost artifacts in preserve mode  */
            //    if (history_list[i].type & HISTORY_ARTIFACT_LOST)
            //        continue;

            //    if (history_list[i].a_idx == artifact.aidx)
            //        return true;
            //}

            //return false;
        }
Ejemplo n.º 6
0
        /*
         * Mark artifact number `id` as known.
         */
        public static bool history_know_artifact(Artifact artifact)
        {
            throw new NotImplementedException();
            //size_t i = history_ctr;
            //assert(artifact);

            //while (i--) {
            //    if (history_list[i].a_idx == artifact.aidx) {
            //        history_list[i].type = HISTORY_ARTIFACT_KNOWN;
            //        return true;
            //    }
            //}

            //return false;
        }
Ejemplo n.º 7
0
        /*
         * Add an entry with text `event` to the history list, with type `type`
         * ("HISTORY_xxx" in defines.h), and artifact number `id` (0 for everything
         * else).
         *
         * Return true on success.
         */
        public static bool add_full(ushort type, Artifact artifact, short dlev, short clev, int turn, string text)
        {
            /* Allocate the history list if needed */
            if (history_list == null)
                init(HISTORY_BIRTH_SIZE);

            /* Expand the history list if appropriate */
            else if ((history_ctr == history_size) && !set_num(history_size + 10))
                return false;

            /* History list exists and is not full.  Add an entry at the current counter location. */
            history_list[history_ctr] = new Info();
            history_list[history_ctr].type = type;
            history_list[history_ctr].dlev = dlev;
            history_list[history_ctr].clev = clev;
            history_list[history_ctr].a_idx = (byte)(artifact != null ? artifact.aidx : 0);
            history_list[history_ctr].turn = turn;
            history_list[history_ctr].evt = text;

            history_ctr++;

            return true;
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        /* Parsing functions for artifact.txt */
        public static Parser.Error parse_a_n(Parser p)
        {
            Bitflag f = new Bitflag(Object_Flag.SIZE);
            int idx = p.getint("index");
            string name = p.getstr("name");
            Artifact h = p.priv as Artifact;

            Artifact a = new Artifact();
            a.Next = h;
            p.priv = a;
            a.aidx = (byte)idx;
            a.Name = name;

            /* Ignore all elements */
            Object_Flag.create_mask(f, false, Object_Flag.object_flag_type.IGNORE);
            a.flags.union(f);

            return Parser.Error.NONE;
        }
Ejemplo n.º 10
0
        //This has a single special use
        static Parser.Error grab_flag_helper3(string s, Artifact e)
        {
            string[] t = s.Split(new string[] { " ","|" }, StringSplitOptions.RemoveEmptyEntries);
            string temp;
            foreach(string token in t) {
                temp = token;
                if(grab_flag(e.flags, Object_Flag.list, token) == Parser.Error.NONE ||
                    grab_flag(e.pval_flags[e.num_pvals], Object_Flag.list, token) == Parser.Error.NONE) {
                        break;
                }
            }

            e.num_pvals++;
            if (e.num_pvals > Misc.MAX_PVALS)
                return Parser.Error.TOO_MANY_ENTRIES;

            return Parser.Error.NONE;
        }
Ejemplo n.º 11
0
        /**
         * Copy artifact data to a normal object, and set various slightly hacky
         * globals.
         */
        public void copy_artifact_data(Artifact a_ptr)
        {
            int i;

            /* Extract the data */
            for(i = 0; i < a_ptr.num_pvals; i++) {
                if(a_ptr.pval[i] != 0) {
                    pval[i] = a_ptr.pval[i];
                    pval_flags[i].copy(a_ptr.pval_flags[i]);
                }
            }
            num_pvals = a_ptr.num_pvals;
            ac = a_ptr.ac;
            dd = a_ptr.dd;
            ds = a_ptr.ds;
            to_a = a_ptr.to_a;
            to_h = a_ptr.to_h;
            to_d = a_ptr.to_d;
            weight = a_ptr.weight;
            flags.union(a_ptr.flags);
        }