Welcome to the Builder Academy

Question Improving a weapon proficiency

More
11 Jan 2017 04:30 - 11 Jan 2017 04:33 #6505 by Dvinn
Hello! I have a quick question about the improve_skill and the weaponprof snippets and making them work together. I have both of the working but I want successful hits with certain weapon types to increase the weapon type's skill. My plan was to add it under "void hit" in fight.c, but simply sticking:

Code:
improve_skill(ch, SKILL_SWORDS);

when damage is calculated would increase the wrong skill if the player was using a different weapon type (like SKILL_DAGGERS). If possible, may someone please let me know the best way to go about doing this? Thanks for reading!
Last edit: 11 Jan 2017 04:33 by Dvinn.

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

More
12 Jan 2017 01:35 #6507 by Liko
Replied by Liko on topic Improving a weapon proficiency

Dvinn wrote: Hello! I have a quick question about the improve_skill and the weaponprof snippets and making them work together. I have both of the working but I want successful hits with certain weapon types to increase the weapon type's skill. My plan was to add it under "void hit" in fight.c, but simply sticking:

Code:
improve_skill(ch, SKILL_SWORDS);

when damage is calculated would increase the wrong skill if the player was using a different weapon type (like SKILL_DAGGERS). If possible, may someone please let me know the best way to go about doing this? Thanks for reading!


fight.c is a great place to do the improving. I would program a if statement checking to see what weapon type is equipped and then add an increase to the skill.

Randian(0.0.0)
Owner/Developer
The following user(s) said Thank You: Dvinn

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

More
12 Jan 2017 01:57 #6508 by WhiskyTest
Hi Dvinn!

Two ways you could go about this:
a) add the weapon skill as a saved value on the object (Whisky's recommended way!)

If you haven't changed the object values from stock code you could use GET_OBJ_VAL(obj, 0)
In oedit.c you'll find that value 0 has a comment saying /* This doesn't seem to be used if I remember right. */
And they are right, although in oedit you get prompted for 'Modifer to Hitroll', it isn't ever implemented.
So GET_OBJ_VAL(obj, 0) can be used to find the skill required for the weapon.

Change the Modifier to Hitroll to say 'Number of weapon skill' or you can add a function to list the skills by name
if you want to be fancy.

Search for case OEDIT_VALUE_1:
and under the item type remove the values -50 and 50 like this:
Code:
case ITEM_WEAPON: GET_OBJ_VAL(OLC_OBJ(d), 0) = MIN(MAX(atoi(arg), LOWEST_WEAPON_SKILL_HERE), HIGHEST_WEAPON_SKILL_HERE); break;

Then just use the improve_skill function like this:
Code:
struct obj_data *weapon = GET_EQ(ch, WEAR_WIELD); if (weapon) improve_skill(ch, GET_OBJ_VALUE(weapon, 0));

Beware that calling GET_OBJ_VALUE will crash the MUD if you haven't confirmed the object exists.

b) use the weaponprof method of determining the skill based on the attack message (limits weapon messages - eg: all swords slashing etc)
You can quickly duplicate the code from 'int get_weapon_prof()' to just return the actual skill number.

Happy to help if you need a hand with either way.
The following user(s) said Thank You: Dvinn

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

More
12 Jan 2017 03:02 - 12 Jan 2017 03:03 #6509 by Dvinn
Thanks for the responses guys. I tried doing it your way first, Whiskey, and my compiler isn't very happy. Instead of posting the error here I just wanted to understand the "LOWEST_WEAPON_SKILL_HERE), HIGHEST_WEAPON_SKILL_HERE)" part of your code. Are those my spells.h defintions like SKILL_KICK is? So I would put SKILL_WEAPON_SWORDS or WEAPON_SWORDS? I'm not really a coder, to be honest - so I'm really just a glorified copy/paster with some ability to read C.
Last edit: 12 Jan 2017 03:03 by Dvinn.

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

More
12 Jan 2017 20:11 #6510 by WhiskyTest
That's right, its just setting the range of valid numbers. I wasn't sure if you've added any skills but if it is exactly like the snippets you linked we have:

#define SKILL_WEAPON_SWORDS 160
...
#define SKILL_WEAPON_EXOTICS 165

So lowest is SKILL_WEAPON_SWORDS, highest is SKILL_WEAPON_EXOTICS.
That line of code is the same as saying 'make sure the number is between 160 and 165'
The following user(s) said Thank You: Dvinn

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

More
12 Jan 2017 20:19 #6511 by Dvinn
Ok, that's what I thought. Do I include the 160 and 165 or just the actual name? I'm at work right now so I can't tinker with it but I tried WEAPON_SWORDS and SKILL_WEAPON_SWORDS and it gave me a few compiler errors that I don't quite remember. I'll update this post once I get home. I appreciate your help!

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

Time to create page: 0.203 seconds