%advance% (madvance, oadvance, wadvance)

Login to reply  Page: « < 1 of 1 > »
17 Jul 2010 - 04:272887
%advance% (madvance, oadvance, wadvance)
Ok, first off. Yes, I know these could be dangerous if improperly used. An Onwer (IMP+1 on my MUD) or Implementor has to approve all DG Scripts on my MUD anyways... before they're copied from the build port to the play port. And on the play port, only Owners and Imps have access to trigedit. Now, on the other hand... I've got these functions pretty well locked down anyways. Not that the normal immortal advance command isn't, but obviously I had to make changes.

On that note, I've also left some key parts of adding these to a working MUD out. You could add what I put here, and it will compile fine, however it wont have any affect. This is another safety net, if you aren't competent enough to implement these without the few details that are missing... then it isn't safe for you to have them because you could not properly prevent them from abuse.

[DISCLAIMER] That isn't rudeness either, just simple fact. But if you felt abused by it, you don't have my apologies. Sometimes the truth hurts, and I am a very blunt person. I don't have problems with the truth, and if you do, it really is your problem.

madvance:
ACMD(do_madvance)
{
  struct char_data *victim;
  char name[MAX_INPUT_LENGTH], level[MAX_INPUT_LENGTH];
  int newlevel, oldlevel;

  if (!MOB_OR_IMPL(ch)) {
    send_to_char(ch, "Huh?!?\r\n");
    return;
  }
  
  two_arguments(argument, name, level);

  if (!*name) {
    mob_log(ch, "madvance: bad syntax");
    return;
  }
    
  if (*name == UID_CHAR) {
    if (!(victim = get_char(name))) {
      mob_log(ch, "madvance: victim (%s) does not exist", name);
      return;
    }
  } else if (!(victim = get_char_vis(ch, name, NULL, FIND_CHAR_WORLD))) {
      mob_log(ch, "madvance: victim (%s) not found", name);
      return;
  }

  if (IS_IMMORT(victim) == TRUE) {
    mob_log(ch, "Maybe that's not such a great idea.");
    return;
  }
  if (IS_NPC(victim)) {
    mob_log(ch, "NO!  Not on NPC's.");
    return;
  }
  if (!*level || (newlevel = atoi(level)) <= 0) {
    mob_log(ch, "That's not a level!");
    return;
  }
  if ((newlevel > LVL_OWNER && IS_IMMORT(victim)) || (newlevel > 65000)) {
	mob_log(ch, "%d is the highest possible level.", IS_IMMORT(victim) ? LVL_OWNER : 65000);
    return;
  }
  if (newlevel == GET_LEVEL(victim)) {
    mob_log(ch, "They are already at that level.");
    return;
  }
  oldlevel = GET_LEVEL(victim);
  if (newlevel < GET_LEVEL(victim)) {
    /* do_start(victim); Unneeded? */
    GET_LEVEL(victim) = newlevel;
    send_to_char(victim, "You are momentarily enveloped by darkness!\r\nYou feel somewhat diminished.\r\n");
  } else {
    act("$n makes some strange gestures.\r\n"
	"A strange feeling comes upon you,\r\n"
	"Like a giant hand, light comes down\r\n"
	"from above, grabbing your body, that\r\n"
	"begins to pulse with colored lights\r\n"
	"from inside.\r\n\r\n"
	"Your head seems to be filled with demons\r\n"
	"from another plane as your body dissolves\r\n"
	"to the elements of time and space itself.\r\n"
	"Suddenly a silent explosion of light\r\n"
	"snaps you back to reality.\r\n\r\n"
	"You feel slightly different.", FALSE, ch, 0, victim, TO_VICT);
  }

  if (newlevel < oldlevel)
    mob_log(ch, "%s demoted %s from level %d to %d.", GET_NAME(ch), GET_NAME(victim), oldlevel, newlevel);
  else
    mob_log(ch, "%s has advanced %s to level %d (from %d)", GET_NAME(ch), GET_NAME(victim), newlevel, oldlevel);

  if (oldlevel >= LVL_IMMORT && newlevel < LVL_IMMORT && IS_IMMORT(victim)) {
    /* 
	 * If they are no longer an immortal, let's remove some of the
     * nice immortal only flags, shall we?
     */
    REMOVE_BIT(PRF_FLAGS(victim), PRF_LOG1 | PRF_LOG2);
    REMOVE_BIT(PRF_FLAGS(victim), PRF_NOHASSLE | PRF_HOLYLIGHT | PRF_ROOMFLAGS);
	IS_IMMORT(victim) = FALSE;
    run_autowiz();
  } else if (oldlevel < LVL_IMMORT && newlevel >= LVL_IMMORT && IS_IMMORT(victim)) {
    SET_BIT(PRF_FLAGS(victim), PRF_LOG2);
    SET_BIT(PRF_FLAGS(victim), PRF_HOLYLIGHT | PRF_ROOMFLAGS | PRF_AUTOEXIT);
    SET_BIT(PRF_FLAGS(victim), PRF_COLOR_1 | PRF_COLOR_2);
    run_autowiz();
  }

  gain_exp_regardless(victim, level_exp(GET_CLASS(victim), newlevel) - GET_EXP(victim), oldlevel);
  save_char(victim);
}

oadvance:
OCMD(do_oadvance)
{
  struct char_data *victim;
  char name[MAX_INPUT_LENGTH], level[MAX_INPUT_LENGTH];
  int newlevel, oldlevel;

  two_arguments(argument, name, level);

  if (!*name) {
    obj_log(obj, "madvance: bad syntax");
    return;
  }
    
  if (!(victim = get_char_by_obj(obj, name))) {
      obj_log(obj, "madvance: victim (%s) not found", name);
      return;
  }

  if (IS_IMMORT(victim) == TRUE) {
    obj_log(obj, "Maybe that's not such a great idea.");
    return;
  }
  if (IS_NPC(victim)) {
    obj_log(obj, "NO!  Not on NPC's.");
    return;
  }
  if (!*level || (newlevel = atoi(level)) <= 0) {
    obj_log(obj, "That's not a level!");
    return;
  }
  if ((newlevel > LVL_OWNER && IS_IMMORT(victim)) || (newlevel > 65000)) {
	obj_log(obj, "%d is the highest possible level.", IS_IMMORT(victim) ? LVL_OWNER : 65000);
    return;
  }
  if (newlevel == GET_LEVEL(victim)) {
    obj_log(obj, "They are already at that level.");
    return;
  }
  oldlevel = GET_LEVEL(victim);
  if (newlevel < GET_LEVEL(victim)) {
    /* do_start(victim); Unneeded? */
    GET_LEVEL(victim) = newlevel;
    send_to_char(victim, "You are momentarily enveloped by darkness!\r\nYou feel somewhat diminished.\r\n");
  } else {
    act("$n makes some strange gestures.\r\n"
	"A strange feeling comes upon you,\r\n"
	"Like a giant hand, light comes down\r\n"
	"from above, grabbing your body, that\r\n"
	"begins to pulse with colored lights\r\n"
	"from inside.\r\n\r\n"
	"Your head seems to be filled with demons\r\n"
	"from another plane as your body dissolves\r\n"
	"to the elements of time and space itself.\r\n"
	"Suddenly a silent explosion of light\r\n"
	"snaps you back to reality.\r\n\r\n"
	"You feel slightly different.", FALSE, victim, 0, obj, TO_CHAR);
  }

  if (newlevel < oldlevel)
    obj_log(obj, "%s demoted %s from level %d to %d.", GET_OBJ_NAME(obj), GET_NAME(victim), oldlevel, newlevel);
  else
    obj_log(obj, "%s has advanced %s to level %d (from %d)", GET_OBJ_NAME(obj), GET_NAME(victim), newlevel, oldlevel);

  if (oldlevel >= LVL_IMMORT && newlevel < LVL_IMMORT && IS_IMMORT(victim)) {
    /* 
	 * If they are no longer an immortal, let's remove some of the
     * nice immortal only flags, shall we?
     */
    REMOVE_BIT(PRF_FLAGS(victim), PRF_LOG1 | PRF_LOG2);
    REMOVE_BIT(PRF_FLAGS(victim), PRF_NOHASSLE | PRF_HOLYLIGHT | PRF_ROOMFLAGS);
	IS_IMMORT(victim) = FALSE;
    run_autowiz();
  } else if (oldlevel < LVL_IMMORT && newlevel >= LVL_IMMORT && IS_IMMORT(victim)) {
    SET_BIT(PRF_FLAGS(victim), PRF_LOG2);
    SET_BIT(PRF_FLAGS(victim), PRF_HOLYLIGHT | PRF_ROOMFLAGS | PRF_AUTOEXIT);
    SET_BIT(PRF_FLAGS(victim), PRF_COLOR_1 | PRF_COLOR_2);
    run_autowiz();
  }

  gain_exp_regardless(victim, level_exp(GET_CLASS(victim), newlevel) - GET_EXP(victim), oldlevel);
  save_char(victim);
}

wadvance:
WCMD(do_wadvance)
{
  struct char_data *victim;
  char name[MAX_INPUT_LENGTH], level[MAX_INPUT_LENGTH];
  int newlevel, oldlevel;

  two_arguments(argument, name, level);

  if (!*name) {
    wld_log(room, "madvance: bad syntax");
    return;
  }
    
  if (!(victim = get_char_by_room(room, name))) {
      wld_log(room, "madvance: victim (%s) not found", name);
      return;
  }

  if (IS_IMMORT(victim) == TRUE) {
    wld_log(room, "Maybe that's not such a great idea.");
    return;
  }
  if (IS_NPC(victim)) {
    wld_log(room, "NO!  Not on NPC's.");
    return;
  }
  if (!*level || (newlevel = atoi(level)) <= 0) {
    wld_log(room, "That's not a level!");
    return;
  }
  if ((newlevel > LVL_OWNER && IS_IMMORT(victim)) || (newlevel > 65000)) {
	wld_log(room, "%d is the highest possible level.", IS_IMMORT(victim) ? LVL_OWNER : 65000);
    return;
  }
  if (newlevel == GET_LEVEL(victim)) {
    wld_log(room, "They are already at that level.");
    return;
  }
  oldlevel = GET_LEVEL(victim);
  if (newlevel < GET_LEVEL(victim)) {
    /* do_start(victim); Unneeded? */
    GET_LEVEL(victim) = newlevel;
    send_to_char(victim, "You are momentarily enveloped by darkness!\r\nYou feel somewhat diminished.\r\n");
  } else {
    act("$n makes some strange gestures.\r\n"
	"A strange feeling comes upon you,\r\n"
	"Like a giant hand, light comes down\r\n"
	"from above, grabbing your body, that\r\n"
	"begins to pulse with colored lights\r\n"
	"from inside.\r\n\r\n"
	"Your head seems to be filled with demons\r\n"
	"from another plane as your body dissolves\r\n"
	"to the elements of time and space itself.\r\n"
	"Suddenly a silent explosion of light\r\n"
	"snaps you back to reality.\r\n\r\n"
	"You feel slightly different.", FALSE, victim, 0, NULL, TO_CHAR);
  }

  if (newlevel < oldlevel)
    wld_log(room, "%s demoted %s from level %d to %d.", room->name, GET_NAME(victim), oldlevel, newlevel);
  else
    wld_log(room, "%s has advanced %s to level %d (from %d)", room->name, GET_NAME(victim), newlevel, oldlevel);

  if (oldlevel >= LVL_IMMORT && newlevel < LVL_IMMORT && IS_IMMORT(victim)) {
    /* 
	 * If they are no longer an immortal, let's remove some of the
     * nice immortal only flags, shall we?
     */
    REMOVE_BIT(PRF_FLAGS(victim), PRF_LOG1 | PRF_LOG2);
    REMOVE_BIT(PRF_FLAGS(victim), PRF_NOHASSLE | PRF_HOLYLIGHT | PRF_ROOMFLAGS);
	IS_IMMORT(victim) = FALSE;
    run_autowiz();
  } else if (oldlevel < LVL_IMMORT && newlevel >= LVL_IMMORT && IS_IMMORT(victim)) {
    SET_BIT(PRF_FLAGS(victim), PRF_LOG2);
    SET_BIT(PRF_FLAGS(victim), PRF_HOLYLIGHT | PRF_ROOMFLAGS | PRF_AUTOEXIT);
    SET_BIT(PRF_FLAGS(victim), PRF_COLOR_1 | PRF_COLOR_2);
    run_autowiz();
  }

  gain_exp_regardless(victim, level_exp(GET_CLASS(victim), newlevel) - GET_EXP(victim), oldlevel);
  save_char(victim);
}


__________________
Owner/Coder/Head Admin
Caer Dubrin
17 Jul 2010 - 09:182888
Some nice functions...

Just a couple of minor things...
1) in oadvance and wadvance, your obj_log error messages say it's in madvance
2) In both oadvance and wadvance, the victim would see themselves waving their own arms around, then being advanced, maybe the act message should be adjusted for obj/room advances.
3) You really have 65000 levels? Wow! But it would probably be better to replace this arbitrary number with (LVL_IMMORT-1) in case you change the number of levels in the future...

Other than those really minor things, great work!


__________________

Last edited by Jamdog (17 Jul 2010 - 09:19)
17 Jul 2010 - 14:442889
Quote Jamdog:
Some nice functions...

Just a couple of minor things...
1) in oadvance and wadvance, your obj_log error messages say it's in madvance
2) In both oadvance and wadvance, the victim would see themselves waving their own arms around, then being advanced, maybe the act message should be adjusted for obj/room advances.


Weird, I thought I changed those messages. And adjusted the act. Maybe I forgot to save after doing so. But yes you are correct those should be changed.

Quote:

3) You really have 65000 levels? Wow! But it would probably be better to replace this arbitrary number with (LVL_IMMORT-1) in case you change the number of levels in the future...


That solution actually wont work for me, since my mortals can be the same level, and higher even, than my immortals. They're separated with a flag that is checked with IS_IMMORT(ch). So I just picked the arbitrary 65000 for being close to the top of the unsigned short data type... which gives me 65535 levels to play with if I really wanted. But inside my gain_exp_regardless() I have levels limited to 500 for the moment, since my exp/level algorithm isn't finished yet (non-linear, non-exponential curve). However, for people implementing this on a stock codebase, the LVL_IMMORT - 1 is appropriate.

Quote:
Other than those really minor things, great work!


Thanks.

New act() for oadvance:
    act("$p begins to hum and vibrate strangely.\r\n"
	"A strange feeling comes upon you,\r\n"
	"Like a giant hand, light comes down\r\n"
	"from above, grabbing your body, that\r\n"
	"begins to pulse with colored lights\r\n"
	"from inside.\r\n\r\n"
	"Your head seems to be filled with demons\r\n"
	"from another plane as your body dissolves\r\n"
	"to the elements of time and space itself.\r\n"
	"Suddenly a silent explosion of light\r\n"
	"snaps you back to reality.\r\n\r\n"
	"You feel slightly different.", FALSE, victim, obj, NULL, TO_CHAR);

New act() for wadvance:
    act("The room tilts crazily and you barely remain standing.\r\n"
	"A strange feeling comes upon you,\r\n"
	"Like a giant hand, light comes down\r\n"
	"from above, grabbing your body, that\r\n"
	"begins to pulse with colored lights\r\n"
	"from inside.\r\n\r\n"
	"Your head seems to be filled with demons\r\n"
	"from another plane as your body dissolves\r\n"
	"to the elements of time and space itself.\r\n"
	"Suddenly a silent explosion of light\r\n"
	"snaps you back to reality.\r\n\r\n"
	"You feel slightly different.", FALSE, victim, NULL, NULL, TO_CHAR);

And yes I did apparently forget to save :)


__________________
Owner/Coder/Head Admin
Caer Dubrin
Login to reply  Page: « < 1 of 1 > »