Sing system like cast

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
8 months 3 weeks ago - 8 months 3 weeks ago #7036 by JTP
Sing system like cast was created by JTP
If i wanted to copy the cast system and also make a sing system, what parts of the code do i need to copy and rename ?

And what about a hole new define song..... list ?

Any ideas, thoughts about this ?
Last edit: 8 months 3 weeks ago by JTP.

Please Log in or Create an account to join the conversation.

More
8 months 2 weeks ago #7042 by WhiskyTest
Replied by WhiskyTest on topic Sing system like cast
The spellcasting system is kind of ingrained in all sorts of places. I think it would be more efficient to make songs the same way you make spells, just adding the cosmetic changes needed so players are singing not casting.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
8 months 2 weeks ago - 8 months 2 weeks ago #7047 by JTP
Replied by JTP on topic Sing system like cast
Can you be more specific about what you mean cosmetic changes ?

I still need the cast for all other classes, but need sing for one class, and that class must not be able to use cast. And others May not use the sing.
Last edit: 8 months 2 weeks ago by JTP.

Please Log in or Create an account to join the conversation.

More
8 months 2 weeks ago - 8 months 2 weeks ago #7049 by WhiskyTest
Replied by WhiskyTest on topic Sing system like cast
Add two new definitions in spells.h underneath ACMD(do_cast);
#define SCMD_CAST 0
#define SCMD_SING 1

Make a new command in interpreter.c
 { "sing"     , "sing"    , POS_SITTING , do_cast     , 1, SCMD_SING },

For the cast command, add SCMD_CAST at the end instead of the 0.

Now players can type "sing 'armor'" and the code will treat it like they are casting a spell, but it lets do_cast know they are singing with the SCMD_SING being set.

So now you can make the cosmetic changes, by which I mean replacing messages about spells like 'cast', 'casting' or 'spell' with singing messages.

Eg:
if (s == NULL) {
    send_to_char(ch, "%s what where?\r\n", (subcmd == SCMD_SING ? "Sing" : "Cast"));
    return;
  }

To stop other classes being able to sing their spells, just add a class check.
if (subcmd == SCMD_SING && GET_CLASS(ch) != CLASS_ROCKSTAR) {
  send_to_char(ch, "Simon Cowell sends you a withering stare..\r\n");
  return;
}
And conversely, to stop singers from casting:
if (subcmd == SCMD_CAST && GET_CLASS(ch) == CLASS_ROCKSTAR) {
 send_to_char(ch, "You fantasize about being on the cast of Glee.\r\n");
 return;
}

There will be some changes to say_spell() to allow it to handle songs.
Update the definition to include the subcmd:
static void say_spell(struct char_data *ch, int spellnum, struct char_data *tch, struct obj_data *tobj, int subcmd);
say_spell(ch, spellnum, tch, tobj, (GET_CLASS(ch) == CLASS_CLERIC ? SCMD_SING : SCMD_CAST));

In say_spell() add code to handle the singing messages, something like this:
  if (subcmd == SCMD_SING)  {
       
    if (tch != NULL && IN_ROOM(tch) == IN_ROOM(ch)) {
       if (tch == ch)
         format = "$n begins to sing in a clear voice, '%s'.";
       else
         format = "$n stares at $N and sings the words, '%s'.";
    } else if (tobj != NULL && ((IN_ROOM(tobj) == IN_ROOM(ch)) || (tobj->carried_by == ch)))
      format = "$n stares at $p and sings the words, '%s'.";
    else
      format = "$n sings the words, '%s'.";
  }
  else {
  if (tch != NULL && IN_ROOM(tch) == IN_ROOM(ch)) {
    if (tch == ch)
      format = "$n closes $s eyes and utters the words, '%s'.";
    else
      format = "$n stares at $N and utters the words, '%s'.";
  } else if (tobj != NULL &&
	     ((IN_ROOM(tobj) == IN_ROOM(ch)) || (tobj->carried_by == ch)))
    format = "$n stares at $p and utters the words, '%s'.";
  else
    format = "$n utters the words, '%s'.";
  }
Last edit: 8 months 2 weeks ago by WhiskyTest.
The following user(s) said Thank You: thomas

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
8 months 1 week ago #7069 by JTP
Replied by JTP on topic Sing system like cast
Hmm, no matter if my test char types cast or sing, i get:

Sing what where?

Something must be slightly off with above code ?

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
8 months 1 week ago - 8 months 1 week ago #7070 by JTP
Replied by JTP on topic Sing system like cast
Infact no matter what class types cast or sing, it says

Sing what where?
if (s == NULL) {
    send_to_char(ch, "%s what where?\r\n", (subcmd == SCMD_SING ? "Sing" : "Cast"));
    return;
  }

Something must be wrong with this part, but what ?
Last edit: 8 months 1 week ago by JTP.

Please Log in or Create an account to join the conversation.

More
8 months 1 week ago #7072 by WhiskyTest
Replied by WhiskyTest on topic Sing system like cast
Double check the cast command is sending SCMD_CAST like so:
{ "cast"     , "c"       , POS_SITTING , do_cast     , 1, SCMD_CAST }, 
....
  { "sing"     , "sing"    , POS_SITTING , do_cast     , 1, SCMD_SING },

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
8 months 1 week ago #7073 by JTP
Replied by JTP on topic Sing system like cast
They are both made like that Yes.

Please Log in or Create an account to join the conversation.

More
8 months 1 week ago #7074 by WhiskyTest
Replied by WhiskyTest on topic Sing system like cast
Hmm and scmd_cast is defined as 0?

Perhaps at the start of do_cast have the subcmd sent to the character for troubleshooting.

Send_char(ch, subcmd);
It should be 0 for cast and 1 for sing.

If thats coming out correct could you post your entire do_cast function?

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
8 months 1 week ago - 8 months 1 week ago #7075 by JTP
Replied by JTP on topic Sing system like cast
Never changed anything in cast before sing's 3 if's
ACMD(do_cast)
{
  struct char_data *tch = NULL;
  struct obj_data *tobj = NULL;
  char *s, *t;
  int number, mana, spellnum, i, target = 0;

  if (IS_NPC(ch))
    return;

  /* get: blank, spell name, target name */
  s = strtok(argument, "'");

  if (s == NULL) {
    send_to_char(ch, "%s what where?\r\n", (SCMD_SING ? "Sing" : "Cast"));
    return;
  }
  if (subcmd == SCMD_SING && GET_CLASS(ch) != CLASS_BARD) {
    send_to_char(ch, "Only Bard's can entertain with song's..\r\n");
    return;
  }
  if (subcmd == SCMD_CAST && GET_CLASS(ch) == CLASS_BARD) {
    send_to_char(ch, "You fantasize about being able to cast magic..\r\n");
    return;
  }
  s = strtok(NULL, "'");
  if (s == NULL) {
    send_to_char(ch, "Spell names must be enclosed in the Holy Magic Symbols: '\r\n");
    return;
  }
  t = strtok(NULL, "\0");

  skip_spaces(&s);

  /* spellnum = search_block(s, spells, 0); */
  spellnum = find_skill_num(s);

  if ((spellnum < 1) || (spellnum > MAX_SPELLS) || !*s) {
    send_to_char(ch, "Cast what?!?\r\n");
    return;
  }
  if (GET_LEVEL(ch) < SINFO.min_level[(int) GET_CLASS(ch)]) {
    send_to_char(ch, "You do not know that spell!\r\n");
    return;
  }
  if (GET_SKILL(ch, spellnum) == 0) {
    send_to_char(ch, "You are unfamiliar with that spell.\r\n");
    return;
  }
  /* Find the target */
  if (t != NULL) {
    char arg[MAX_INPUT_LENGTH];

    strlcpy(arg, t, sizeof(arg));
    one_argument(arg, t);
    skip_spaces(&t);
    /* Copy target to global cast_arg2, for use in spells like locate object */
    strcpy(cast_arg2, t);
  }
  if (IS_SET(SINFO.targets, TAR_IGNORE)) {
    target = TRUE;
  } else if (t != NULL && *t) {
    number = get_number(&t);
    if (!target && (IS_SET(SINFO.targets, TAR_CHAR_ROOM))) {
      if ((tch = get_char_vis(ch, t, &number, FIND_CHAR_ROOM)) != NULL)
        target = TRUE;
    }
    if (!target && IS_SET(SINFO.targets, TAR_CHAR_WORLD))
      if ((tch = get_char_vis(ch, t, &number, FIND_CHAR_WORLD)) != NULL)
        target = TRUE;
    if (!target && IS_SET(SINFO.targets, TAR_OBJ_INV))
      if ((tobj = get_obj_in_list_vis(ch, t, &number, ch->carrying)) != NULL)
        target = TRUE;

    if (!target && IS_SET(SINFO.targets, TAR_OBJ_EQUIP)) {
      for (i = 0; !target && i < NUM_WEARS; i++)
        if (GET_EQ(ch, i) && isname(t, GET_EQ(ch, i)->name)) {
          tobj = GET_EQ(ch, i);
          target = TRUE;
        }
    }
    if (!target && IS_SET(SINFO.targets, TAR_OBJ_ROOM))
      if ((tobj = get_obj_in_list_vis(ch, t, &number, world[IN_ROOM(ch)].contents)) != NULL)
        target = TRUE;

    if (!target && IS_SET(SINFO.targets, TAR_OBJ_WORLD))
      if ((tobj = get_obj_vis(ch, t, &number)) != NULL)
        target = TRUE;

  } else {                      /* if target string is empty */
    if (!target && IS_SET(SINFO.targets, TAR_FIGHT_SELF))
      if (FIGHTING(ch) != NULL) {
        tch = ch;
        target = TRUE;
      }
    if (!target && IS_SET(SINFO.targets, TAR_FIGHT_VICT))
      if (FIGHTING(ch) != NULL) {
        tch = FIGHTING(ch);
        target = TRUE;
      }
    /* if no target specified, and the spell isn't violent, default to self */
    if (!target && IS_SET(SINFO.targets, TAR_CHAR_ROOM) &&
        !SINFO.violent) {
      tch = ch;
      target = TRUE;
    }
    if (!target) {
      send_to_char(ch, "Upon %s should the spell be cast?\r\n",
                IS_SET(SINFO.targets, TAR_OBJ_ROOM | TAR_OBJ_INV | TAR_OBJ_WORLD | TAR_OBJ_EQUIP) ? "what" : "who");
      return;
    }
  }

  if (target && (tch == ch) && SINFO.violent) {
    send_to_char(ch, "You shouldn't cast that on yourself -- could be bad for your health!\r\n");
    return;
  }
  if (!target) {
      send_to_char(ch, "Upon %s should the spell be cast?\r\n",
                IS_SET(SINFO.targets, TAR_OBJ_ROOM | TAR_OBJ_INV | TAR_OBJ_WORLD | TAR_OBJ_EQUIP) ? "what" : "who");
      return;
    }
  }

  if (target && (tch == ch) && SINFO.violent) {
    send_to_char(ch, "You shouldn't cast that on yourself -- could be bad for your health!\r\n");
    return;
  }
  if (!target) {
    send_to_char(ch, "Cannot find the target of your spell!\r\n");
    return;
  }
  mana = mag_manacost(ch, spellnum);
  if ((mana > 0) && (GET_MANA(ch) < mana) && (GET_LEVEL(ch) < LVL_IMMORT)) {
    send_to_char(ch, "You haven't the energy to cast that spell!\r\n");
    return;
  }

  /* You throws the dice and you takes your chances.. 101% is total failure */
  if (rand_number(0, 101) > GET_SKILL(ch, spellnum)) {
    WAIT_STATE(ch, PULSE_VIOLENCE);
    if (!tch || !skill_message(0, ch, tch, spellnum))
      send_to_char(ch, "You lost your concentration!\r\n");
    if (mana > 0)
      GET_MANA(ch) = MAX(0, MIN(GET_MAX_MANA(ch), GET_MANA(ch) - (mana / 2)));
    if (SINFO.violent && tch && IS_NPC(tch))
      hit(tch, ch, TYPE_UNDEFINED);
  } else { /* cast spell returns 1 on success; subtract mana & set waitstate */
    if (cast_spell(ch, tch, tobj, spellnum)) {
      WAIT_STATE(ch, PULSE_VIOLENCE);
      if (mana > 0)
        GET_MANA(ch) = MAX(0, MIN(GET_MAX_MANA(ch), GET_MANA(ch) - mana));
    }
  }
}
Last edit: 8 months 1 week ago by JTP.

Please Log in or Create an account to join the conversation.

More
8 months 1 week ago - 8 months 1 week ago #7076 by WhiskyTest
Replied by WhiskyTest on topic Sing system like cast
Awesome thanks, its here:
 if (s == NULL) {
    send_to_char(ch, "%s what where?\r\n", (SCMD_SING ? "Sing" : "Cast"));
    return;
  }
It should be:
 if (s == NULL) {
    send_to_char(ch, "%s what where?\r\n", (subcmd == SCMD_SING ? "Sing" : "Cast"));
    return;
  }

We need to test if subcmd is equal to SCMD_SING.
The code is asking, "Does 'subcmd' equal SCMD_SING? If it does use 'Sing', if it doesn't use 'Cast' "
Last edit: 8 months 1 week ago by WhiskyTest.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
8 months 1 week ago #7078 by JTP
Replied by JTP on topic Sing system like cast
All is well now, thanks ALOT.

Please Log in or Create an account to join the conversation.

Time to create page: 2.603 seconds