Welcome to the Builder Academy

Question AFF_PROT_**** issue

More
11 Nov 2016 21:31 - 12 Nov 2016 11:44 #6262 by JTP
AFF_PROT_**** issue was created by JTP
Trying to make protections from various elements, tryed this:
Code:
case SPELL_CALL_LIGHTNING: dam = dice(7, 8) + 7; if (AFF_PROT_ELECTRICITY(victim)) dam = 0; break; I get this when i compile: gcc -g -O2 -Wall -c -o magic.o magic.c magic.c: In function ‘mag_damage’: magic.c:322: error: called object ‘34’ is not a function make[1]: *** [magic.o] Error 1


What is wrong ?





And what if i wanted a light that burns out just vanish

send_to_char(ch, "Your light sputters out and dies.\r\n");
act("$n's light sputters out and dies.", FALSE, ch, 0, 0, TO_ROOM);
world[IN_ROOM(ch)].light--;

Suppose this is the place in the code, but cant see anywhere else in the actual code where an item is purged ?
Last edit: 12 Nov 2016 11:44 by JTP.

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

More
12 Nov 2016 20:22 #6264 by WhiskyTest
Replied by WhiskyTest on topic AFF_PROT_**** issue
You would set up your new affect (define it and create a string "Protection Electricity" etc.) and check it like this:
Code:
if (AFF_FLAGGED(ch, AFF_PROT_ELECTRICITY)) dam = 0;

To remove objects is this one:
Code:
extract_obj(obj);

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

More
12 Nov 2016 20:39 - 12 Nov 2016 23:45 #6265 by JTP
Replied by JTP on topic AFF_PROT_**** issue
The AFF worked great now :)

But
Code:
void update_char_objects(struct char_data *ch) { int i; struct obj_data *obj; <<added if (GET_EQ(ch, WEAR_LIGHT) != NULL) if (GET_OBJ_TYPE(GET_EQ(ch, WEAR_LIGHT)) == ITEM_LIGHT) if (GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2) > 0) { i = --GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2); if (i == 1) { send_to_char(ch, "Your light begins to flicker and fade.\r\n"); act("$n's light begins to flicker and fade.", FALSE, ch, 0, 0, TO_ROOM); } else if (i == 0) { send_to_char(ch, "Your light sputters out and dies.\r\n"); act("$n's light sputters out and dies.", FALSE, ch, 0, 0, TO_ROOM); extract_obj(obj); <<<added world[IN_ROOM(ch)].light--; } }

Compile:
handler.c: In function ‘update_char_objects’:
handler.c:884: warning: ‘obj’ is used uninitialized in this function


I also tried extract_obj(WEAR_LIGHT)
That crashed the mud when light ran out,
Item was still in my eq list


Also tried putting the extract last after world[IN_ROOM......
That also crashed the mud, BUT when i got the game back up, the item was actually gone. But sucks it crashed it.
Last edit: 12 Nov 2016 23:45 by JTP.

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

More
13 Nov 2016 00:32 #6268 by JTP
Replied by JTP on topic AFF_PROT_**** issue
Any ideas how to get it to work ? Maybe even also if its torches only cus they burn away, so lanterns dont extract.

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

More
13 Nov 2016 19:47 #6269 by thomas
Replied by thomas on topic AFF_PROT_**** issue

JTP wrote:

Code:
void update_char_objects(struct char_data *ch) { int i; - struct obj_data *obj; if (GET_EQ(ch, WEAR_LIGHT) != NULL) if (GET_OBJ_TYPE(GET_EQ(ch, WEAR_LIGHT)) == ITEM_LIGHT) if (GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2) > 0) { i = --GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2); if (i == 1) { send_to_char(ch, "Your light begins to flicker and fade.\r\n"); act("$n's light begins to flicker and fade.", FALSE, ch, 0, 0, TO_ROOM); } else if (i == 0) { send_to_char(ch, "Your light sputters out and dies.\r\n"); act("$n's light sputters out and dies.", FALSE, ch, 0, 0, TO_ROOM); - extract_obj(obj); + extract_obj(GET_EQ(ch, WEAR_LIGHT)); world[IN_ROOM(ch)].light--; } }

Because this warning tells us that "obj" is not set to anything useful before being used. And in the function, GET_EQ(ch, WEAR_LIGHT) is consistently used to get a pointer to the object.

JTP wrote: Compile:
handler.c: In function ‘update_char_objects’:
handler.c:884: warning: ‘obj’ is used uninitialized in this function


I like that you write what you tried - I'm making the assumption that you are literal here:

JTP wrote: I also tried extract_obj(WEAR_LIGHT)
That crashed the mud when light ran out,
Item was still in my eq list


Also tried putting the extract last after world[IN_ROOM......
That also crashed the mud, BUT when i got the game back up, the item was actually gone. But sucks it crashed it.

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

Time to create page: 0.196 seconds