Skill wear off messages

More
2 weeks 5 hours ago #9846 by thomas
Replied by thomas on topic Skill wear off messages
Ah, now I see. You know, this is what happens when I write code directly into an answer and you copy it without understanding what it does.

There are two problems. First off, I asked you to add the second log lines a line too low, it needs to be immediaely following the first log() or it breaks the logic of the function.
Secondly, the comma should have been a semicolon at the end there. Like this:
+ log("Wearoff: char: %s, af->spell: %d, wear_off_msg: %s", GET_NAME(i), af->spell, spell_info[af->spell].wear_off_msg);
+ log("((%d > 0) && (%d <= %d)): %d, second check: %d", 
af->spell, af->spell, MAX_SPELLS, ((af->spell > 0) && (af->spell <= MAX_SPELLS)));
      if ((af->spell > 0) && (af->spell <= MAX_SPELLS))
	  if (!af->next || (af->next->spell != af->spell) ||
	      (af->next->duration > 0))
	    if (spell_info[af->spell].wear_off_msg)
	      send_to_char(i, "%s\r\n", spell_info[af->spell].wear_off_msg);
	affect_remove(i, af);

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
1 week 6 days ago #9847 by JTP
Replied by JTP on topic Skill wear off messages
Ok adding this give me one error:

magic.c:72: error: `af_spell’ undeclared (first use in this function)

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

More
1 week 6 days ago #9848 by thomas
Replied by thomas on topic Skill wear off messages
Have a look at your code. I never wrote that, so it's probably a typo on your part.

However, this makes me seriously reconsider helping out in the future. Even if you are not a coder, when you get an error message, double check your input first.

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
1 week 6 days ago - 1 week 6 days ago #9849 by JTP
Replied by JTP on topic Skill wear off messages
Ok I had made a typo

now it’s 100% the same as you posted But it says to few arguments for format when I compile it
Last edit: 1 week 6 days ago by JTP.

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

More
1 week 5 days ago #9851 by thomas
Replied by thomas on topic Skill wear off messages
Browser code strikes again :D
+ log("Wearoff: char: %s, af->spell: %d, wear_off_msg: %s", GET_NAME(i), af->spell, spell_info[af->spell].wear_off_msg);
+ log("((%d > 0) && (%d <= %d)): %d", 
af->spell, af->spell, MAX_SPELLS, ((af->spell > 0) && (af->spell <= MAX_SPELLS)));
+ log("second check: %d", 
(!af->next || (af->next->spell != af->spell) || (af->next->duration > 0)));

      if ((af->spell > 0) && (af->spell <= MAX_SPELLS))
	  if (!af->next || (af->next->spell != af->spell) ||
	      (af->next->duration > 0))
	    if (spell_info[af->spell].wear_off_msg)
	      send_to_char(i, "%s\r\n", spell_info[af->spell].wear_off_msg);
	affect_remove(i, af);
The following user(s) said Thank You: JTP

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
1 week 5 days ago - 1 week 5 days ago #9853 by JTP
Replied by JTP on topic Skill wear off messages
Ok here is the result of the 3 logs:

May 2 12:45:46 :: Wearoff: char: Testchar, af->spell: 201, wear_off_msg: You feel you have meditated all that you can now.

May 2 12:45:46 :: ((201 > 0) && (201 <= 130)): 0

May 2 12:45:46 :: second check: 1


What do you make of it and what’s happening with the missing messages to the player ?
Last edit: 1 week 5 days ago by JTP.

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

More
1 week 5 days ago #9854 by thomas
Replied by thomas on topic Skill wear off messages
It is obvious which of the if's return false now. And we see we have a comparison between af->spell and 130. But af->spell is 201, which is way higher than 130, so the if returns false, and we never get to the message.

The reason for this is that until you made the changes earlier in this topic, only spells could have wear-off messages. Now, skills can too. So, instead of comparing to MAX_SPELLS, you need to compare to MAX_SKILLS:
- if ((af->spell > 0) && (af->spell <= MAX_SPELLS))
+ if ((af->spell > 0) && (af->spell <= MAX_SKILLS))
	  if (!af->next || (af->next->spell != af->spell) ||
	      (af->next->duration > 0))
	    if (spell_info[af->spell].wear_off_msg)
	      send_to_char(i, "%s\r\n", spell_info[af->spell].wear_off_msg);
	affect_remove(i, af);

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
1 week 4 days ago - 1 week 4 days ago #9855 by JTP
Replied by JTP on topic Skill wear off messages
It’s working. Thanks a lot. Much apreciated.
Last edit: 1 week 4 days ago by JTP.

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

Time to create page: 0.107 seconds