Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Wielding weapons based upon skills

Wielding weapons based upon skills

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by NixonInnes   (4 posts)  Bio
Date Thu 07 Jan 2010 05:36 AM (UTC)
Message
I'm trying to restrict which weapons players can wield in my MUD by restricting them to only be able to wield weapons in which they have trained their type in.

Here is what i've tried so far which doesnt seem to be working...

The following into the wear_obj function under the ITEM_WIELD case.


 switch ( obj->value[4] )
         {
         default:
            gsn_wep = -1;
            break;
         case WEP_BAREHAND:
            gsn_wep = gsn_pugilism;
            break;
         case WEP_SWORD:
            gsn_wep = gsn_swords;
            break;
         case WEP_DAGGER:
            gsn_wep = gsn_daggers;
            break;
         case WEP_WHIP:
            gsn_wep = gsn_whips;
            break;
         case WEP_TALON:
            gsn_wep = gsn_talonous_arms;
            break;
         case WEP_MACE:
            gsn_wep = gsn_maces_hammers;
            break;
         case WEP_ARCHERY:
            gsn_wep = gsn_archery;
            break;
         case WEP_BLOWGUN:
            gsn_wep = gsn_blowguns;
            break;
         case WEP_SLING:
            gsn_wep = gsn_slings;
            break;
         case WEP_AXE:
            gsn_wep = gsn_axes;
            break;
         case WEP_SPEAR:
            gsn_wep = gsn_spears;
            break;
         case WEP_STAFF:
            gsn_wep = gsn_staves;
            break;
         }
         
         if( !LEARNED( ch, gsn_wep ) )
         {
            send_to_char( "You have not trained in this form of weaponry.\r\n", ch );
            return;
         }
Top

Posted by Hanaisse   Canada  (114 posts)  Bio
Date Reply #1 on Thu 07 Jan 2010 03:11 PM (UTC)
Message
Is gsn_wep something new you created?
Did you declare it in mud.h and db.c and add an assign_gsn in db.c?

aka: Hana
Owner in Training of: Fury of the Gods
alm-dev.org:4000
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #2 on Thu 07 Jan 2010 03:40 PM (UTC)

Amended on Thu 07 Jan 2010 03:41 PM (UTC) by Zeno

Message
gsn_wep shouldn't matter, and I wouldn't think you need it in mud.h or db.c. It just seems like gsn_wep is a local int used to store what gsn is being used.

Are you sure it's entering the switch case?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by NixonInnes   (4 posts)  Bio
Date Reply #3 on Thu 07 Jan 2010 03:45 PM (UTC)
Message
Yeah, sorry I should have stated "gsn_wep" is a local int.

As to whether it's entering the switch case, i'll take a look into that.
Top

Posted by NixonInnes   (4 posts)  Bio
Date Reply #4 on Fri 08 Jan 2010 10:26 AM (UTC)

Amended on Fri 08 Jan 2010 08:33 PM (UTC) by NixonInnes

Message
Ok, I have fixed the problem.

There were a few things that were the issue;
Firstly LEARNED returns the % of the skill, rather than it being a boolean.
Secondly, I was missing some of the skills from my skills.dat so it was defaulting the gsn_wep to -1.

It's all working exactly as it should now :)


in wear_obj() in act_obj.c after the following:

      case ITEM_WIELD:
      case ITEM_MISSILE_WIELD:

Add:

        switch ( obj->value[4] )
         {
         default:
            gsn_wep = -1;
            break;
         case WEP_BAREHAND:
            gsn_wep = gsn_pugilism;
            break;
         case WEP_SWORD:
            gsn_wep = gsn_swords;
            break;
         case WEP_DAGGER:
            gsn_wep = gsn_daggers;
            break;
         case WEP_WHIP:
            gsn_wep = gsn_whips;
            break;
         case WEP_TALON:
            gsn_wep = gsn_talonous_arms;
            break;
         case WEP_MACE:
            gsn_wep = gsn_maces_hammers;
            break;
         case WEP_ARCHERY:
            gsn_wep = gsn_archery;
            break;
         case WEP_BLOWGUN:
            gsn_wep = gsn_blowguns;
            break;
         case WEP_SLING:
            gsn_wep = gsn_slings;
            break;
         case WEP_AXE:
            gsn_wep = gsn_axes;
            break;
         case WEP_SPEAR:
            gsn_wep = gsn_spears;
            break;
         case WEP_STAFF:
            gsn_wep = gsn_staves;
            break;
         }    
         
         ch_printf( ch, "gsn_wep = %d", gsn_wep );
         if( LEARNED( ch, gsn_wep ) < 1 )
         {
            send_to_char( "You have not trained in this form of weaponry.\r\n", ch );
            return;
         }


Bare in mind if you are using stock SmaugFUSS that my weapon code uses the Samsons' weapon snippet.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


17,837 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.