Welcome to the Builder Academy

Question I have a question about perform_violence(void)

More
29 Dec 2024 19:46 #10498 by narthkain
I have a question about the following code:

if (MOB_FLAGGED(ch, MOB_SPEC) && GET_MOB_SPEC(ch) && !MOB_FLAGGED(ch, MOB_NOTDEADYET)) {
char actbuf[MAX_INPUT_LENGTH] = "";
(GET_MOB_SPEC(ch)) (ch, ch, 0, actbuf);
}

I am curious about the role of this code that exists within the perform_violence(void) function. My assumption is that it turns off the SPEC function when the SPECIAL feature is on and GET_POS() is POS_DEAD. Is my assumption correct? If this code is omitted, would it be handled by free() in extract_char()? Would there be any issues afterwards?

I have been continuously modifying the circle30bpl11 version for Windows console, and recently I have been debugging it with VS 2022, which resulted in an exception handling error. I am referring to tbamud, and I am curious about this."

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

More
05 Jan 2025 18:50 #10505 by thomas
Sorry about the delay in approving - there seems to be a problem with emails from the site. I'll look into it asap.

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

More
05 Jan 2025 19:06 #10506 by thomas
To answer your question: not exactly.

The code checks if the mob:
1. has set the mob_spec flag. The flag is set via olc or mob-file, and must be set for a spec_proc to fire.
2. actually has a spec_proc. This is set for mobs that is assigned a spec proc via SPEC_ASSIGN. The check is simply "GET_MOB_SPEC(ch)" to check if this is non-NULL.
3. finally checks if the mob is alive. A mob is in a special state after it has been killed, since removing it from the character list right away turned out to give a lot of trouble. This means we need to check that the mob is not in the "not dead (yet)" state where it is just awaiting extraction.

Given all those are true, the next is a call to the actual spec_proc. But this needs to receive a valid command buffer, so we pass it a largish buffer with an empty string.
The code "(GET_MOB_SPEC(ch)) (ch, ch, 0, actbuf);" basically says "I expect a function exists at the address pointed to by the GET_MOB_SPEC(ch) pointer. Please call it with these arguments".

This section of code makes it so you can have a spec_proc that triggers whenever a round ends, for instance if you want to trigger certain attacks or other behaviour.

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

Time to create page: 0.176 seconds