worship.txt

snippets · 5.2 KB · 2010-03-30

God worship snippet v1.0: pick a god and worship (the author's first working snippet).

Download   « Back to the snippets list

God Worship Snippet Version 1.0

This is my first snippet ever made that ever worked for me so please 
feel free to use it at will. Where there are + do no add those lines,
they are marked to let you know where to stick them in.

***act_info.c***

Look for do_score and find the similar lines.

+    if (get_trust (ch) != ch->level)
+    {
+        sprintf (buf, "You are trusted at level %d.\n\r", get_trust (ch));
+        send_to_char (buf, ch);
+    }

    sprintf (buf,
             "You worship %s.\n\r",
             god_table[ch->god].name);
    send_to_char (buf, ch);

+    sprintf (buf, "Race: %s  Sex: %s  Class: %s\n\r",
+             race_table[ch->race].name,
+             ch->sex == 0 ? "sexless" : ch->sex == 1 ? "male" : "female",
+             IS_NPC (ch) ? "mobile" : class_table[ch->class].name);
+    send_to_char (buf, ch);

***const.c***

const   struct  god_type       god_table      []           = 
{
 
     { "God1"},

     { "God2"},

     { "God3"},

     { "God4"},

};

Add before this line

+ const struct pc_race_type pc_race_table[] = {

***handler.c or lookup.c***

Add down at the bottom

int god_lookup (const char *name)
{
    int god;

    for (god = 0; god < MAX_GOD; god++)
    {
        if (LOWER (name[0]) == LOWER (god_table[god].name[0])
            && !str_prefix (name, god_table[god].name))
            return god;
    }

    return -1;
}

***merc.h***

Find the similar lines

+ #define MAX_LEVEL          60
+ #define LEVEL_HERO         (MAX_LEVEL - 9)
+ #define LEVEL_IMMORTAL     (MAX_LEVEL - 8)
#define MAX_GOD                    20


+ #define CON_NOTE_TEXT			8
+ #define CON_NOTE_FINISH			9
#define CON_GET_NEW_GOD		   25

struct god_type
{
     char *      name;      
};

Add before this line

+ struct    class_type

In char_data

    sh_int             god;

Add where all the other ones are

+ extern             struct    social_type     social_table   [MAX_SOCIALS];
+ extern    char *    const    title_table [MAX_CLASS] [MAX_LEVEL+1] [2];
extern    const    struct    god_type        god_table       [MAX_GOD];

Add in prototypes of handler.c or lookup.c

+ char *  comm_bit_name    args( ( int comm_flags ) );
+ char *    cont_bit_name    args( ( int cont_flags) );
int     god_lookup      args( ( const char *name) );




***comm.c or nanny.c***

+        case CON_GET_NEW_CLASS:
+            iClass = class_lookup (argument);
+
+            if (iClass == -1)
+            {
+                send_to_desc ("That's not a class.\n\rWhat IS your class? ",
+                              d);
+                return;
+            }
+
+            ch->class = iClass;
+
+            sprintf (log_buf, "%s@%s new player.", ch->name, d->host);
+            log_string (log_buf);
+            wiznet ("Newbie alert!  $N sighted.", ch, NULL, WIZ_NEWBIE, 0, 0);
+            wiznet (log_buf, NULL, NULL, WIZ_SITES, 0, get_trust (ch));

            write_to_buffer (d, echo_on_str, 0);
            send_to_desc ("The following gods are available:\n\r  ", d);
            for (god = 0; god_table[god].name != NULL; god++)
            {
                if (!god_table[god].name)
                    break;
                write_to_buffer (d, god_table[god].name, 0);
                write_to_buffer (d, " ", 1);
            }
            write_to_buffer (d, "\n\r", 0);
            send_to_desc ("What is your race (help for more information)? ",
                          d);
            d->connected = CON_GET_NEW_GOD;
            break;

        case CON_GET_NEW_GOD:
            god = god_lookup (argument);

            if (god == 0 || !god_table[god].name)
            {
                send_to_desc ("That is not a valid god.\n\r", d);
                send_to_desc ("The following gods are available:\n\r  ", d);
                for (god = 0; god_table[god].name != NULL; god++)
                {
                    if (!god_table[god].name)
                        break;
                    write_to_buffer (d, god_table[god].name, 0);
                    write_to_buffer (d, " ", 1);
                }
                write_to_buffer (d, "\n\r", 0);
                send_to_desc
                    ("What is your god? (help for more information) ", d);
                break;
            }

            write_to_buffer (d, "\n\r", 2);
            send_to_desc ("You may be good, neutral, or evil.\n\r", d);
            send_to_desc ("Which alignment (G/N/E)? ", d);
            d->connected = CON_GET_ALIGNMENT;
            break;

+        case CON_GET_ALIGNMENT:

***save.c***

In fread_char

+    fprintf (fp, "Cla  %d\n", ch->class);
    fprintf (fp, "God  %d\n", ch->god);
+    fprintf (fp, "Levl %d\n", ch->level);

In fread_char

+            case 'G':
                KEY ("God", ch->god, fread_number (fp));
+                KEY ("Gold", ch->gold, fread_number (fp));

It's probably poor instructions trying to add them in, also I am not the
greatest of coders so don't send me junk mail that I could have done it
better blah blah blah, you get what I mean.

If you have trouble installing the snippet feel free to e-mail me at
tagman@froggy.com.au


Site Stats

Snippets: 1791
Codebases: 571