Welcome to the Builder Academy

Question case spell hickup - whats wrong ?

More
15 Oct 2017 15:07 #7005 by JTP
What you posted, works when there is a tree.

It also gives the right message if there is no tree.


But if i cast the spell 2 times after eachother, it also checks for if there is a tree.
It didnt before.

Standard TBAmud message if spell is already in effect is:
Okay.
Nothing seems to happen.

But now it suddently says:
Okay.
But there is no tree around to travel from.
Nothing seems to happen.


With all other spells its still just:
Okay.
Nothing seems to happen.

So something is alittle off in the tree_travel spell still

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

More
15 Oct 2017 15:50 #7006 by zusuk
so just add an affection check in the message display... there is no error in the code that i can see... unless i am simply not understanding again

i.e. this
if (found_tree == FALSE) {
/* did not find any trees! */
send_to_char(ch, "But there is no tree around to travel from.\r\n");
}

turns into this:
if (found_tree == FALSE && !affected_by_spell(vict, SPELL_TREE_TRAVEL)) {
/* did not find any trees! */
send_to_char(ch, "But there is no tree around to travel from.\r\n");
}

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100
The following user(s) said Thank You: JTP

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

More
15 Oct 2017 19:38 #7007 by thomas
the call to new_affect() allocates memory.
You will want to move your validation code up above that call:
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; if (spellnum == 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) break; if (tree == NULL) { send_to_char(ch, "But there is no tree around to travel from.\r\n"); return; } } for (i = 0; i < MAX_SPELL_AFFECTS; i++) { new_affect(&(af[i])); af[i].spell = spellnum; } switch (spellnum) { case SPELL_TREE_TRAVEL: 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 */

Let us know if that fixes the message, too :)

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

More
15 Oct 2017 23:52 #7008 by JTP
Both ways seems to work now, but your Way is better because ?

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

More
16 Oct 2017 05:54 #7009 by zusuk
Hope Thomas does not mind me jumping in here :)

It is more efficient! Less memory, which probably is not an issue, but still proper practice.

The way I did it is just trying to kinda throw a bandage on your issue instead of thinking it out from top-to-bottom for optimal performance.

-Zusuk

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

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

More
16 Oct 2017 06:52 #7010 by JTP
Well still Big Thanks to both of you !

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

Time to create page: 0.245 seconds