Welcome to the Builder Academy

Question Sing system like cast

More
09 Nov 2017 00:38 #7072 by WhiskyTest
Replied by WhiskyTest on topic Sing system like cast
Double check the cast command is sending SCMD_CAST like so:
Code:
{ "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.

More
09 Nov 2017 06:33 #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
09 Nov 2017 19:12 #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.

More
09 Nov 2017 19:44 - 09 Nov 2017 19:47 #7075 by JTP
Replied by JTP on topic Sing system like cast
Never changed anything in cast before sing's 3 if's
Code:
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: 09 Nov 2017 19:47 by JTP.

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

More
09 Nov 2017 20:48 - 09 Nov 2017 20:49 #7076 by WhiskyTest
Replied by WhiskyTest on topic Sing system like cast
Awesome thanks, its here:
Code:
if (s == NULL) { send_to_char(ch, "%s what where?\r\n", (SCMD_SING ? "Sing" : "Cast")); return; }
It should be:
Code:
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: 09 Nov 2017 20:49 by WhiskyTest.

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

More
09 Nov 2017 21:25 #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: 0.307 seconds