I made this spell, the code compiles, spell works when there is an ITEM_TREE in the room.
BUT
When there is no tree, i some times only get an Okay. when cast. Other times i get the correct send_to_char.
So whats up, would be good to get the send_to_char every time there is no tree.
Code:
/* Every spell that does an affect comes through here. This determines the
* effect, whether it is added or replacement, whether it is legal or not, etc.
* affect_join(vict, aff, add_dur, avg_dur, add_mod, avg_mod) */
#define MAX_SPELL_AFFECTS 5 /* change if more needed */
void mag_affects(int level, struct char_data *ch, struct char_data *victim,
int spellnum, int savetype)
{
struct affected_type af[MAX_SPELL_AFFECTS];
bool accum_affect = FALSE, accum_duration = FALSE;
const char *to_vict = NULL, *to_room = NULL;
int i, j;
if (victim == NULL || ch == NULL)
return;
for (i = 0; i < MAX_SPELL_AFFECTS; i++) {
new_affect(&(af[i]));
af[i].spell = spellnum;
}
switch (spellnum) {
case SPELL_TREE_TRAVEL:
{
struct obj_data *tree;
for (tree = world[ch->in_room].contents; tree; tree = tree->next_content) {
if (GET_OBJ_TYPE(tree) != ITEM_TREE) {
send_to_char(ch, "But there is no tree around to travel from.\r\n");
return;
}
af[0].duration = 24;
SET_BIT_AR(af[0].bitvector, AFF_TREE_TRAVEL);
accum_duration = FALSE;
to_vict = "You feel one with the trees!";
}
}
break;
} /* end of cases */