Welcome to the Builder Academy

Question prevent bash - Issue could use help pls

More
29 Dec 2024 15:36 - 29 Dec 2024 19:09 #10495 by JTP
Hi

Im trying to prevent a player from bashing a mob that is a giant, unless you yourself is a giant.

Ok I can bash a mob that is not a giant, and I get the correct message if I try to bash a NPC who is a giant when im not.

But if I try to bash a player who is not half giant, then I still get told that Im not tall enough to bash a giant.

What is wrong ?


  if ((GET_CLASS(vict) == CLASS_NPC_GIANT || GET_RACE(vict) == RACE_HALF_GIANT) && (GET_RACE(ch) != RACE_HALF_GIANT)) {
    send_to_char(ch, "You aren't tall enough to bash a giant!\r\n");
    return;
  }
Last edit: 29 Dec 2024 19:09 by JTP.

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

More
30 Dec 2024 11:29 #10500 by thomas
Your logic looks sound; the parenthesis are matched at the right places. I'd check the values of the fields and compare them to the constants. (add a log where you print out GET_CLASS(vict), GET_RACE(vict) and GET_RACE(ch) to debug)

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

More
16 Jan 2025 23:03 - 17 Jan 2025 11:42 #10521 by JTP
Hi

How do I add a log to show that ?

I tried to split them up:

  if ((GET_CLASS(vict) == CLASS_NPC_GIANT) && (GET_RACE(ch) != RACE_HALF_GIANT)) {
    send_to_char(ch, "You aren't tall enough to bash a giant!\r\n");
    return;
  }
  if ((GET_RACE(vict) == RACE_HALF_GIANT) && (GET_RACE(ch) != RACE_HALF_GIANT)) {
    send_to_char(ch, "You aren't tall enough to bash a half giant!\r\n");
    return;
  }

the first if works fine. I can bash any mob that isn’t giant. And i can’t bash a mob that is giant unless I’m half giant. Great….

But if I try to bash a player that is not half giant, and im not a half giant, then it stops and tells me that im not tall enough. Wierd.


but if I am a half giant and bash a non half giant then it works and I bash. But if a human warrior bash a human then it wont let me.
Last edit: 17 Jan 2025 11:42 by JTP.

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

More
17 Jan 2025 18:16 #10524 by cunning
You add a log("%d", GET_RACE(vict)); just before the check or after the check to ensure you keep your values before and after it validates. 

This is just an example and you can add what you need to validate. Then it goes to the syslog
The following user(s) said Thank You: thomas

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

More
19 Jan 2025 18:22 #10526 by JTP
hmm im not getting any logs at all from this, absolutely nothing :


log("%d", GET_RACE(vict));
if ((GET_RACE(vict) == RACE_HALF_GIANT) && (GET_RACE(ch) != RACE_HALF_GIANT)) {
log("%d", GET_RACE(vict));
send_to_char(ch, "You aren't tall enough to bash a half giant!\r\n");
return;
}

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

More
22 Jan 2025 21:40 #10527 by thomas
hm, that's strange. It should be in the usual place in the logs.

I just tested this by adding this line to do_kick:

log("ch class = %d vict class = %d", GET_CLASS(ch), GET_CLASS(vict));

Then I logged on and kicked a mob and got this in my syslog:

Jan 22 22:39:43 2025 :: ch class = 1 vict class = 0

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

Time to create page: 0.255 seconds