Autoloot and Autosplit Code [by Ron Hensley]
Snippet Posted Wednesday, August 12th @ 11:24:26 PM, by George Greer in the Commands dept.
. Click the link below to read it or download it.

From: Ron Hensley <ron@peace.dmv.com>
Subject: CODE: Autosplit

This code adds the ability to automatically 'get all corpse' upon killing
a mob, as well as automatically splitting the gold you get with your
group.

act.other.c:

   "autoexits enabled.\r\n},
  {"AutoSplit disabled.\r\n",
   "AutoSplit enabled.\r\n"},
  {"AutoLooting disabled.\r\n",
   "AutoLooting enabled.\r\n"},
                              ^
* Make sure if AutoLooting is your last entry, you get rid of the ,
  at the end

Also to the switch(subcmd) block, add:

  case SCMD_AUTOEXIT:
    result = PRF_TOG_CHK(ch, PRF_AUTOEXIT);
    break;
+ case SCMD_AUTOSPLIT:
+   result = PRF_TOG_CHK(ch, PRF_AUTOSPLIT);
+   break;
+ case SCMD_AUTOLOOT:
+   result = PRF_TOG_CHK(ch, PRF_AUTOLOOT);
+   break;

constants.c

  "!GTZ",
  "RMFLG",
+ "AUTOSPLIT",
+ "AUTOLOOT",

fight.c:

in damage():

+   ACMD(do_get);
+   ACMD(do_split);
   int exp;
+  long local_gold = 0;
+  char local_buf[256];

And farther down...

      if (MOB_FLAGGED(ch, MOB_MEMORY))
        forget(ch, victim);
    }
+    /* Cant determine GET_GOLD on corpse, so do now and store */
+    if (IS_NPC(victim)) {
+      local_gold = GET_GOLD(victim);
+      sprintf(local_buf,"%ld", (long)local_gold);
+    }
  die(victim);

+    /* If Autoloot enabled, get all corpse */
+    if (IS_NPC(victim) && !IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOLOOT)) {
+      do_get(ch,"all corpse",0,0);
+    }
+    /* If Autoloot AND AutoSplit AND we got money, split with group */
+    if (IS_AFFECTED(ch, AFF_GROUP) && (local_gold > 0) &&
+        PRF_FLAGGED(ch, PRF_AUTOSPLIT) && PRF_FLAGGED(ch,PRF_AUTOLOOT)) {
+      do_split(ch,local_buf,0,0);
+    }

interpreter.c:

  {"autoexit"...
+ {"autosplit", POS_DEAD, do_gen_tog, 0, SCMD_AUTOSPLIT},
+ {"autoloot", POS_DEAD, do_gen_tog, 0, SCMD_AUTOLOOT},

interpreter.h:

  #define SCMD_AUTOEXIT  15
+ #define SCMD_AUTOSPLIT 16
+ #define SCMD_AUTOLOOT  17

structs.h:

  #define PRF_ROOMFLAGS (1 << 21)
+ #define PRF_AUTOSPLIT (1 << 22)
+ #define PRF_AUTOLOOT  (1 << 23)

act.informative.c

          " Auto Show Exit: %-3s    "
+          "   Auto Looting: %-3s    "
+          " Auto Splitting: %-3s\r\n"

Further on down ..

          ONOFF(PRF_FLAGGED(ch, PRF_AUTOEXIT)),
+          ONOFF(PRF_FLAGGED(ch, PRF_AUTOLOOT)),
+          ONOFF(PRF_FLAGGED(ch, PRF_AUTOSPLIT)),


Note this is NOT a patch.  Just showing how I did it in my code, you'd
probably have to play a bit to make it work in yours, it is just a
guideline, although I believe just following the steps given will
work.


<< Autoexit (New Exits Format) [by Nashak] | Reply | View as text | Flattened | Beep Command [by Lord Kyu] >>

 


Related Links
  download
Related Articles
More by greerga
 
 

CircleMUD Snippets
 
Note: Not all of these snippets will work perfectly with your version of code, so be prepared to fix one or two bugs that may arise, and please let me know what you needed to do to fix it. Sending a corrected version is always welcome.
Finally, if you wish to use any of the snippets from this page, you are more than welcome, just mention the authors in your credits. If you wish to release any of these snippets to the public on another site, contact me FIRST.
 
 


Missing com_msg
by Adam Hallam (ahallam@efortress.com) on Wednesday, November 1st @ 07:51:39 AM
http://
Without the com_msg for noprivate, this code will not work.
[ Reply to this comment ]