Welcome to the Builder Academy

Question What am i missing ?

More
24 Dec 2016 00:15 - 25 Dec 2016 00:20 #6455 by JTP
Replied by JTP on topic What am i missing ?
Those two sets of changes gives:


act.item.c: In function ‘perform_wear’:
act.item.c:1312: error: too few arguments to function ‘free_hands’
make[1]: *** [act.item.o] Error 1


Line 1312:
int hands = free_hands(ch);


Code used for above:
Code:
static int free_hands(struct char_data *ch, struct obj_data *obj); static int free_hands(struct char_data *ch, struct obj_data *obj) { int used = 2; if (GET_EQ(ch, WEAR_HOLD)) { used -= 1; } if (GET_EQ(ch, WEAR_LIGHT)) { used -= 1; } if (GET_EQ(ch, WEAR_SHIELD)) { used -= 1; } if (GET_EQ(ch, WEAR_WIELD)) { if (OBJ_FLAGGED(obj, ITEM_TWO_HANDED)) { used -= 2; } else { used -= 1; } } return used; } /* And in: static void perform_wear(struct char_data *ch, struct obj_data *obj, int where) */ if (where == WEAR_WIELD || where == WEAR_SHIELD || where == WEAR_LIGHT || where == WEAR_HOLD) { int hands = free_hands(ch); if (hands < 1 && !OBJ_FLAGGED(obj, ITEM_TWO_HANDED)) { send_to_char(ch, "Your hands are full!\r\n"); return; } if (hands < 2 && OBJ_FLAGGED(obj, ITEM_TWO_HANDED)) { send_to_char(ch, "Your hands are full!\r\n"); return; } }
Last edit: 25 Dec 2016 00:20 by JTP.

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

More
24 Dec 2016 03:55 #6456 by Liko
Replied by Liko on topic What am i missing ?

JTP wrote: Those two sets of changes gives:


act.item.c: In function ‘perform_wear’:
act.item.c:1312: error: too few arguments to function ‘free_hands’
make[1]: *** [act.item.o] Error 1


Line 1312:
int hands = free_hands(ch);


Code used for above:

Code:
static int free_hands(struct char_data *ch, struct obj_data *obj); static int free_hands(struct char_data *ch, struct obj_data *obj) { int used = 2; if (GET_EQ(ch, WEAR_HOLD)) { used -= 1; } if (GET_EQ(ch, WEAR_LIGHT)) { used -= 1; } if (GET_EQ(ch, WEAR_SHIELD)) { used -= 1; } if (GET_EQ(ch, WEAR_WIELD)) { if (GET_EQ(ch, WEAR_WIELD) || OBJ_FLAGGED(obj, ITEM_TWO_HANDED)) { used -= 2; } else { used -= 1; } } return used; } /* And in: static void perform_wear(struct char_data *ch, struct obj_data *obj, int where) */ if (where == WEAR_WIELD || where == WEAR_SHIELD || where == WEAR_LIGHT || where == WEAR_HOLD) { int hands = free_hands(ch); if (hands < 1 && !OBJ_FLAGGED(obj, ITEM_TWO_HANDED)) { send_to_char(ch, "Your hands are full!\r\n"); return; } if (hands < 2 && OBJ_FLAGGED(obj, ITEM_TWO_HANDED)) { send_to_char(ch, "Your hands are full!\r\n"); return; } }


If I am reading the above code right, your free_hands is calling for a character and object.
Code:
free_hands(ch, obj);

That is just an example.

Randian(0.0.0)
Owner/Developer

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

More
25 Dec 2016 00:12 - 25 Dec 2016 00:41 #6459 by JTP
Replied by JTP on topic What am i missing ?
Ok I got it compiling and almost working..


If I Wear shield/light/hold first, and then try to wield the two-handed, then I cant do it, this works as it should.

BUT if I wield the two-handed first, and then Wear shield/light/hold, then I can do that, but should not be able to.



So why is that, any idea ?
Last edit: 25 Dec 2016 00:41 by JTP.

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

More
25 Dec 2016 01:22 #6460 by Liko
Replied by Liko on topic What am i missing ?

JTP wrote: Ok I got it compiling and almost working..


If I Wear shield/light/hold first, and then try to wield the two-handed, then I cant do it, this works as it should.

BUT if I wield the two-handed first, and then Wear shield/light/hold, then I can do that, but should not be able to.



So why is that, any idea ?


Sounds like you need to program a check that says if already holding a two-handed, then can't hold anything else.

Randian(0.0.0)
Owner/Developer

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

More
25 Dec 2016 09:01 #6461 by JTP
Replied by JTP on topic What am i missing ?
Kinda thought it did, int used = 2

And if you wield a two-handed its -=2

Then it should be at 0

Then with either a shield or hold or light it would end up at -1


So if anyone could show me how to fix this, i would apreciate it.

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

More
25 Dec 2016 11:42 - 25 Dec 2016 11:43 #6462 by thomas
Replied by thomas on topic What am i missing ?
Get rid of the useless "struct obj_data *obj " from that call. And fix this check:
Code:
if (GET_EQ(ch, WEAR_WIELD)) { - if (GET_EQ(ch, WEAR_WIELD) || OBJ_FLAGGED(obj, ITEM_TWO_HANDED)) { + if (OBJ_FLAGGED(GET_EQ(ch, WEAR_WIELD), ITEM_TWO_HANDED)) { used -= 2; } else { used -= 1; } }
Last edit: 25 Dec 2016 11:43 by thomas.

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

Time to create page: 0.256 seconds