Wielding weapons based upon skills

Posted by NixonInnes on Thu 07 Jan 2010 05:36 AM — 5 posts, 23,884 views.

#0
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;
         }
Canada #1
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?
USA #2
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?
Amended on Thu 07 Jan 2010 03:41 PM by Zeno
#3
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.
#4
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.