Welcome to the Builder Academy

Question Improving a weapon proficiency

More
12 Jan 2017 21:40 #6512 by WhiskyTest
Just the name:
Code:
GET_OBJ_VAL(OLC_OBJ(d), 0) = MIN(MAX(atoi(arg), SKILL_WEAPON_SWORDS), SKILL_WEAPON_EXOTICS);
When you create definitions like: '#define SKILL_WEAPON_SWORDS 160' we can use SKILL_WEAPONS_SWORDS instead of remembering that '160' is the number for the swords skill.
We can quickly search for all the places where we have used the skill etc.

Other good examples are #define MAX_SKILLS 200
If you were adding lots of skills one night because you drank too much coffee and just couldn't stop, you can update it to be #define MAX_SKILL 287. Then all the other (19) places in code that uses MAX_SKILLS automatically know it changed from 200 to 287 without having to manually update them. Woo!

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

More
13 Jan 2017 05:40 - 13 Jan 2017 05:40 #6516 by Dvinn
Here's my compiler errors:
Code:
fight.c:884:4: warning: implicit declaration of function ‘improve_skill’ [-Wimplicit-function-declaration] improve_skill(ch, GET_OBJ_VALUE(weapon, 0)); ^ fight.c:884:22: warning: implicit declaration of function ‘GET_OBJ_VALUE’ [-Wimplicit-function-declaration] improve_skill(ch, GET_OBJ_VALUE(weapon, 0)); ^ fight.c: At top level: fight.c:975:6: warning: conflicting types for ‘improve_skill’ void improve_skill(struct char_data *ch, int skill) ^ fight.c:884:4: note: previous implicit declaration of ‘improve_skill’ was here improve_skill(ch, GET_OBJ_VALUE(weapon, 0));
Last edit: 13 Jan 2017 05:40 by Dvinn.

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

More
14 Jan 2017 01:25 #6519 by WhiskyTest
Add the top of fight.c add
void improve_skill (struct char_data *ch, int skill);

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

More
14 Jan 2017 06:48 #6521 by Dvinn
Thank you! I don't know how you guys are so smart, but thank you.

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

More
14 Jan 2017 09:12 #6522 by JTP
Replied by JTP on topic Improving a weapon proficiency
Difference between static void and void. When to use one instead of the other.

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

More
14 Jan 2017 12:27 #6524 by thomas
static means "visible in this compilation unit". In tbamud code this is the same as "visible in this file".

Typically you'd use static functions for "internal" functionality. For instance, in the lists.c code, only the functions without static can be called from other places. This is a crude but functional way of limiting access to functions you don't want other parts of the code to call.

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

Time to create page: 0.190 seconds