Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Bing, Google, Yahoo!

Members: 0
Guests: 25
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SWFOTE FUSS » Did I do this right?
Forum Rules | Mark all | Recent Posts

Did I do this right?
< Newer Topic :: Older Topic > Shot in the dark at a new skill

Pages:<< prev 1 next >>
Post is unread #1 Sep 6, 2009, 9:59 pm
Go to the top of the page
Go to the bottom of the page

Scoyn
Fledgling
GroupMembers
Posts7
JoinedSep 6, 2009

Ok, here's what I did. I took makepike (to make a forcepike) and changed it a little to be a new skill makesaberpike. Why? Because lightsaber pikes are the shit! Only issue with it... I've never made a skill before. So! That being said, here's what I did.

/* 

makesaberpike code "written" by
Brandon "Scoyn" Feder (scoyn@malevolentwhispers.org)

SWFotE copyright (c) 2002 was created by
Chris 'Tawnos' Dary (cadary@uwm.edu),
Korey 'Eleven' King (no email),
Matt 'Trillen' White (mwhite17@ureach.com),
Daniel 'Danimal' Berrill (danimal924@yahoo.com),
Richard 'Bambua' Berrill (email unknown),
Stuart 'Ackbar' Unknown (email unknown)

SWR 1.0 copyright (c) 1997, 1998 was created by Sean Cooper
based on a concept and ideas from the original SWR immortals: 
Himself (Durga), Mark Matt (Merth), Jp Coldarone (Exar), Greg Baily (Thrawn), 
Ackbar, Satin, Streen and Bib as well as much input from our other builders 
and players.

Original SMAUG 1.4a written by Thoric (Derek Snider) with Altrag,
Blodkai, Haus, Narn, Scryn, Swordbearer, Tricops, Gorog, Rennard,
Grishnakh, Fireblade, and Nivek.

Original MERC 2.1 code by Hatchet, Furey, and Kahn.

Original DikuMUD code by: Hans Staerfeldt, Katja Nyboe, Tom Madsen,
Michael Seifert, and Sebastian Hammer.

*/
swrskills.c

void do_makesaberpike( CHAR_DATA * ch, const char *argument )
{
   char arg[MAX_INPUT_LENGTH];
   char buf[MAX_STRING_LENGTH];
   int level, schance, charge;
   bool checktool, checkdura, checkoven, checksaber;
   OBJ_DATA *obj;
   OBJ_INDEX_DATA *pObjIndex;
   int vnum;
   AFFECT_DATA *paf;

   strcpy( arg, argument );

   switch ( ch->substate )
   {
      default:

         if( arg[0] == '\0' )
         {
            send_to_char( "&RUsage: Makesaberpike <name>\r\n&w", ch );
            return;
         }

         checktool = FALSE;
         checkdura = FALSE;
         checkoven = FALSE;
		 checksaber = FALSE;
         if( !IS_SET( ch->in_room->room_flags, ROOM_FACTORY ) )
         {
            send_to_char( "&RYou need to be in a factory or workshop to do that.\r\n", ch );
            return;
         }

         for( obj = ch->last_carrying; obj; obj = obj->prev_content )
         {
            if( obj->item_type == ITEM_TOOLKIT )
               checktool = TRUE;
            if( obj->item_type == ITEM_DURASTEEL )
               checkdura = TRUE;
            if( obj->item_type == WEAPON_LIGHTSABER )
               checksaber = TRUE;

            if( obj->item_type == ITEM_OVEN )
               checkoven = TRUE;
         }

         if( !checktool )
         {
            send_to_char( "&RYou need toolkit to make a lightsaber pike.\r\n", ch );
            return;
         }

         if( !checkdura )
         {
            send_to_char( "&RYou need something to make it out of.\r\n", ch );
            return;
         }

         if( !checksaber )
         {
            send_to_char( "&RYou need a lightsaber to attach your pike.\r\n", ch );
            return;
         }

         if( !checkoven )
         {
            send_to_char( "&RYou need a small furnace to heat the metal.\r\n", ch );
            return;
         }

         schance = IS_NPC( ch ) ? ch->top_level : ( int )( ch->pcdata->learned[gsn_makesaberpike] );
         if( number_percent(  ) < schance )
         {
            send_to_char( "&GYou begin the long process of crafting a lightsaber pike.\r\n", ch );
            act( AT_PLAIN, "$n takes $s tools and a small oven and begins to work on something.", ch,
                 NULL, argument, TO_ROOM );
            add_timer( ch, TIMER_DO_FUN, 30, do_makepike, 1 );
            ch->dest_buf = str_dup( arg );
            return;
         }
         send_to_char( "&RYou can't figure out how to fit the parts together.\r\n", ch );
         learn_from_failure( ch, gsn_makepike );
         return;

      case 1:
         if( !ch->dest_buf )
            return;
         strcpy( arg, ( const char * )ch->dest_buf );
         DISPOSE( ch->dest_buf );
         break;

      case SUB_TIMER_DO_ABORT:
         DISPOSE( ch->dest_buf );
         ch->substate = SUB_NONE;
         send_to_char( "&RYou are interrupted and fail to finish your work.\r\n", ch );
         return;
   }

   ch->substate = SUB_NONE;

   level = IS_NPC( ch ) ? ch->top_level : ( int )( ch->pcdata->learned[gsn_maksaberpike] );
   vnum = 74;

   if( ( pObjIndex = get_obj_index( vnum ) ) == NULL )
   {
      send_to_char
         ( "&RThe item you are trying to create is missing from the database.\r\nPlease inform the administration of this error.\r\n",
           ch );
      return;
   }

   checktool = FALSE;
   checkdura = FALSE;
   checksaber = FALSE;
   checkoven = FALSE;

   for( obj = ch->last_carrying; obj; obj = obj->prev_content )
   {
      if( obj->item_type == ITEM_TOOLKIT )
         checktool = TRUE;
      if( obj->item_type == ITEM_OVEN )
         checkoven = TRUE;
      if( obj->item_type == ITEM_DURASTEEL && checkdura == FALSE )
      {
         checkdura = TRUE;
         separate_obj( obj );
         obj_from_char( obj );
         extract_obj( obj );
      }
      if( obj->item_type == WEAPON_LIGHTSABER && checksaber == FALSE )
      {
         charge = UMAX( 5, obj->value[0] );
         separate_obj( obj );
         obj_from_char( obj );
         extract_obj( obj );
         checkbatt = TRUE;
      }
   }

   schance = IS_NPC( ch ) ? ch->top_level : ( int )( ch->pcdata->learned[gsn_makepike] );

   if( number_percent(  ) > schance * 2 || ( !checktool ) || ( !checkdura ) || ( !checkbatt ) || ( !checkoven ) )
   {
      send_to_char( "&RYou activate your newly created lightsaber pike.\r\n", ch );
      send_to_char( "&RIt hums softly for a few seconds then begins to shake violently.\r\n", ch );
      send_to_char( "&RIt finally shatters breaking apart into a dozen pieces.\r\n", ch );
      learn_from_failure( ch, gsn_makepike );
      return;
   }

   obj = create_object( pObjIndex, level );

      obj->item_type = ITEM_WEAPON;
   SET_BIT( obj->wear_flags, ITEM_WIELD );
   SET_BIT( obj->wear_flags, ITEM_TAKE );
   SET_BIT( obj->extra_flags, ITEM_ANTI_SOLDIER );
   SET_BIT( obj->extra_flags, ITEM_ANTI_THIEF );
   SET_BIT( obj->extra_flags, ITEM_ANTI_HUNTER );
   SET_BIT( obj->extra_flags, ITEM_ANTI_PILOT );
   SET_BIT( obj->extra_flags, ITEM_ANTI_CITIZEN );
   obj->level = level;
   obj->weight = 5;
   STRFREE( obj->name );
   obj->name = STRALLOC( "lightsaber saber" );
   strcpy( buf, arg );
   STRFREE( obj->short_descr );
   obj->short_descr = STRALLOC( buf );
   STRFREE( obj->description );
   strcat( buf, " was carelessly misplaced here." );
   obj->description = STRALLOC( buf );
   STRFREE( obj->action_desc );
   strcpy( buf, arg );
   strcat( buf, " ignites with a hum and a soft glow." );
   obj->action_desc = STRALLOC( buf );
   CREATE( paf, AFFECT_DATA, 1 );
   paf->type = -1;
   paf->duration = -1;
   paf->location = get_atype( "hitroll" );
   paf->modifier = URANGE( 0, gems, level / 10 );
   paf->bitvector = 0;
   paf->next = NULL;
   LINK( paf, obj->first_affect, obj->last_affect, next, prev );
   ++top_affect;
   CREATE( paf2, AFFECT_DATA, 1 );
   paf2->type = -1;
   paf2->duration = -1;
   paf2->location = get_atype( "parry" );
   paf2->modifier = ( level / 3 );
   paf2->bitvector = 0;
   paf2->next = NULL;
   LINK( paf2, obj->first_affect, obj->last_affect, next, prev );
   ++top_affect;
   obj->value[0] = INIT_WEAPON_CONDITION; /* condition  */
   obj->value[1] = ( int )( level / 10 + gemtype * 2 );  /* min dmg  */
   obj->value[2] = ( int )( level / 5 + gemtype * 6 );   /* max dmg */
   obj->value[3] = WEAPON_LIGHTSABER;
   obj->value[4] = charge;
   obj->value[5] = charge;
   obj->cost = obj->value[2] * 75;

   obj = obj_to_char( obj, ch );
   send_to_char( "&GYou finish your work and hold up your newly created lightsaber pike.&w\r\n", ch );
   act( AT_PLAIN, "$n finishes crafting a lightsaber pike.", ch, NULL, argument, TO_ROOM );

   {
      long xpgain;

      xpgain =
         UMIN( obj->cost * 200,
               ( exp_level( ch->skill_level[ENGINEERING_ABILITY] + 1 ) -
                 exp_level( ch->skill_level[ENGINEERING_ABILITY] ) ) );
      gain_exp( ch, xpgain, ENGINEERING_ABILITY );
      ch_printf( ch, "You gain %d engineering experience.", xpgain );
   }

   learn_from_success( ch, gsn_makesaberpike );
}

mud.h
add:
DECLARE_DO_FUN( do_makepike );
extern short gsn_makepike;

db.c
short gsn_makesaberpike;


Did I do everything right?
       
Post is unread #2 Sep 7, 2009, 3:38 am   Last edited Sep 7, 2009, 3:44 am by Kayle
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

- You have a force ability giving engineering experience.
- You have two separate names for the function: do_makesaberpike and do_makepike.
- You use two different gsn's: gsn_makepike and gsn_makesaberpike.
- You don't check for the presence of a lightsaber properly. WEAPON_LIGHTSABER wouldn't be in obj->item_type. You'd need to check item_type for item_weapon, and then check value[3] for WEAPON_LIGHTSABER.
- You left the item name as "lightsaber saber" that would need changed to signify the new type of item.
- When you determine the amount of damage, you're looking at gemtype, but you don't use any gems in the function.
       
Post is unread #3 Sep 7, 2009, 11:20 am
Go to the top of the page
Go to the bottom of the page

Scoyn
Fledgling
GroupMembers
Posts7
JoinedSep 6, 2009

Actually, the plan was for this to be an engineering skill for a Jedi/Sith to use to make their lightsaber a two-handed weapon. Much like the "wookie stun stick," only with a lightsaber on the end.
       
Post is unread #4 Sep 7, 2009, 11:26 am
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 2, 2008

That makes no sense. Just my opinion.
       
Post is unread #5 Sep 7, 2009, 12:08 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

If a Jedi/Sith is using it, then it should give force experience and be a force skill, just like makelightsaber.
       
Post is unread #6 Sep 7, 2009, 9:57 pm
Go to the top of the page
Go to the bottom of the page

Scoyn
Fledgling
GroupMembers
Posts7
JoinedSep 6, 2009

Fair enough, but to me it makes more sense for it to be an engineering skill. The lightsaber will already be made. All that would be happening is lightsaber + durasteel pike = Lightsaber ... on a steek!
       
Post is unread #7 Sep 7, 2009, 11:39 pm   Last edited Sep 7, 2009, 11:40 pm by Andril
Go to the top of the page
Go to the bottom of the page

Andril
Magician
GroupMembers
Posts147
JoinedJun 9, 2009

When checking for the presence of a lightsaber after the switch on the characters substate, you have it setting checkbatt to TRUE instead of checksaber.

When setting the hitroll effect modifier, gems is not declared or set anywhere within the function. The same thing with the gemtype further down, as Kayle already pointed out.

Also, what's the point of this new weapon type, which you haven't actually made a new type for? It's still, as far as the mud is concerned, nothing more than a lightsaber. The only difference is in the descriptions. It'll be the same way for players. All they'll see is that hey, engineers have a new skill, which is nice, but the force users will get absolutely nothing out of it as is from what I can see, due to the fact that they'll still be using the lightsaber weapons skill. They might as well make their lightsabers with a lightsaber pike name/description and get the exact same functionality out of it.

And one last thing. There's a huge difference between putting a lightsaber on a stick when compared to putting, say, a jalapeno on one. The latter is, if nothing else, more interesting.
       
Post is unread #8 Sep 8, 2009, 5:43 pm
Go to the top of the page
Go to the bottom of the page

Scoyn
Fledgling
GroupMembers
Posts7
JoinedSep 6, 2009

I thought about making it a two handed weapon, the skill for which I'm pretty sure is already implemented. If not, I'll write it (same process as with this, so be prepared to troubleshoot that, too :P).
       
Post is unread #9 Sep 8, 2009, 6:07 pm
Go to the top of the page
Go to the bottom of the page

Scoyn
Fledgling
GroupMembers
Posts7
JoinedSep 6, 2009

Take 2! I took what Kayle said was wrong with it and fixed it... I think. Anyway! Here's what I ended up with. The changed lines are in red.

swrskills.c

void do_makesaberpike( CHAR_DATA * ch, const char *argument )
{
char arg[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
int level, schance, charge;
bool checktool, checkdura, checkoven, checksaber;
OBJ_DATA *obj;
OBJ_INDEX_DATA *pObjIndex;
int vnum;
AFFECT_DATA *paf;

strcpy( arg, argument );

switch ( ch->substate )
{
default:

if( arg[0] == '\0' )
{
send_to_char( "&RUsage: Makesaberpike <name>\r\n&w", ch );
return;
}

checktool = FALSE;
checkdura = FALSE;
checkoven = FALSE;
checksaber = FALSE;
if( !IS_SET( ch->in_room->room_flags, ROOM_FACTORY ) )
{
send_to_char( "&RYou need to be in a factory or workshop to do that.\r\n", ch );
return;
}

for( obj = ch->last_carrying; obj; obj = obj->prev_content )
{
if( obj->item_type == ITEM_TOOLKIT )
checktool = TRUE;
if( obj->item_type == ITEM_DURASTEEL )
checkdura = TRUE;
if( obj->item_type == item_weapon && WEAPON_LIGHTSABER )
checksaber = TRUE;

if( obj->item_type == ITEM_OVEN )
checkoven = TRUE;
}

if( !checktool )
{
send_to_char( "&RYou need toolkit to make a lightsaber pike.\r\n", ch );
return;
}

if( !checkdura )
{
send_to_char( "&RYou need something to make it out of.\r\n", ch );
return;
}

if( !checksaber )
{
send_to_char( "&RYou need a lightsaber to attach your pike.\r\n", ch );
return;
}

if( !checkoven )
{
send_to_char( "&RYou need a small furnace to heat the metal.\r\n", ch );
return;
}

schance = IS_NPC( ch ) ? ch->top_level : ( int )( ch->pcdata->learned[gsn_makesaberpike] );
if( number_percent( ) < schance )
{
send_to_char( "&GYou begin the long process of crafting a lightsaber pike.\r\n", ch );
act( AT_PLAIN, "$n takes $s tools and a small oven and begins to work on something.", ch,
NULL, argument, TO_ROOM );
add_timer( ch, TIMER_DO_FUN, 30, do_makesaberpike, 1 );
ch->dest_buf = str_dup( arg );
return;
}
send_to_char( "&RYou can't figure out how to fit the parts together.\r\n", ch );
learn_from_failure( ch, gsn_makesaberpike );
return;

case 1:
if( !ch->dest_buf )
return;
strcpy( arg, ( const char * )ch->dest_buf );
DISPOSE( ch->dest_buf );
break;

case SUB_TIMER_DO_ABORT:
DISPOSE( ch->dest_buf );
ch->substate = SUB_NONE;
send_to_char( "&RYou are interrupted and fail to finish your work.\r\n", ch );
return;
}

ch->substate = SUB_NONE;

level = IS_NPC( ch ) ? ch->top_level : ( int )( ch->pcdata->learned[gsn_maksaberpike] );
vnum = 74;

if( ( pObjIndex = get_obj_index( vnum ) ) == NULL )
{
send_to_char
( "&RThe item you are trying to create is missing from the database.\r\nPlease inform the administration of this error.\r\n",
ch );
return;
}

checktool = FALSE;
checkdura = FALSE;
checksaber = FALSE;
checkoven = FALSE;

for( obj = ch->last_carrying; obj; obj = obj->prev_content )
{
if( obj->item_type == ITEM_TOOLKIT )
checktool = TRUE;
if( obj->item_type == ITEM_OVEN )
checkoven = TRUE;
if( obj->item_type == ITEM_DURASTEEL && checkdura == FALSE )
{
checkdura = TRUE;
separate_obj( obj );
obj_from_char( obj );
extract_obj( obj );
}
if( obj->item_type == item_weapon && WEAPON_LIGHTSABER && checksaber == FALSE )
{
charge = UMAX( 5, obj->value[0] );
separate_obj( obj );
obj_from_char( obj );
extract_obj( obj );
checksaber = TRUE;
}
}

schance = IS_NPC( ch ) ? ch->top_level : ( int )( ch->pcdata->learned[gsn_makesaberpike] );

if( number_percent( ) > schance * 2 || ( !checktool ) || ( !checkdura ) || ( !checksaber ) || ( !checkoven ) )
{
send_to_char( "&RYou activate your newly created lightsaber pike.\r\n", ch );
send_to_char( "&RIt hums softly for a few seconds then begins to shake violently.\r\n", ch );
send_to_char( "&RIt finally shatters breaking apart into a dozen pieces.\r\n", ch );
learn_from_failure( ch, gsn_makesaberpike );
return;
}

obj = create_object( pObjIndex, level );

obj->item_type = ITEM_WEAPON;
SET_BIT( obj->wear_flags, ITEM_WIELD );
SET_BIT( obj->wear_flags, ITEM_TAKE );
SET_BIT( obj->extra_flags, ITEM_ANTI_SOLDIER );
SET_BIT( obj->extra_flags, ITEM_ANTI_THIEF );
SET_BIT( obj->extra_flags, ITEM_ANTI_HUNTER );
SET_BIT( obj->extra_flags, ITEM_ANTI_PILOT );
SET_BIT( obj->extra_flags, ITEM_ANTI_CITIZEN );
obj->level = level;
obj->weight = 5;
STRFREE( obj->name );
obj->name = STRALLOC( "lightsaberpike saberpike pike" );
strcpy( buf, arg );
STRFREE( obj->short_descr );
obj->short_descr = STRALLOC( buf );
STRFREE( obj->description );
strcat( buf, " was carelessly misplaced here." );
obj->description = STRALLOC( buf );
STRFREE( obj->action_desc );
strcpy( buf, arg );
strcat( buf, " ignites with a hum and a soft glow." );
obj->action_desc = STRALLOC( buf );
CREATE( paf, AFFECT_DATA, 1 );
paf->type = -1;
paf->duration = -1;
paf->location = get_atype( "hitroll" );
//paf->modifier = URANGE( 0, gems, level / 10 );
paf->bitvector = 0;
paf->next = NULL;
LINK( paf, obj->first_affect, obj->last_affect, next, prev );
++top_affect;
CREATE( paf2, AFFECT_DATA, 1 );
paf2->type = -1;
paf2->duration = -1;
paf2->location = get_atype( "parry" );
paf2->modifier = ( level / 3 );
paf2->bitvector = 0;
paf2->next = NULL;
LINK( paf2, obj->first_affect, obj->last_affect, next, prev );
++top_affect;
obj->value[0] = INIT_WEAPON_CONDITION; /* condition */
obj->value[1] = ( int )( level / 10 * 2 ); /* min dmg */
obj->value[2] = ( int )( level / 5 * 6 ); /* max dmg */

obj->value[3] = WEAPON_LIGHTSABER;
obj->value[4] = charge;
obj->value[5] = charge;
obj->cost = obj->value[2] * 75;

obj = obj_to_char( obj, ch );
send_to_char( "&GYou finish your work and hold up your newly created lightsaber pike.&w\r\n", ch );
act( AT_PLAIN, "$n finishes crafting a lightsaber pike.", ch, NULL, argument, TO_ROOM );

{
long xpgain;

xpgain =
UMIN( obj->cost * 200,
( exp_level( ch->skill_level[ENGINEERING_ABILITY] + 1 ) -
exp_level( ch->skill_level[ENGINEERING_ABILITY] ) ) );
gain_exp( ch, xpgain, ENGINEERING_ABILITY );
ch_printf( ch, "You gain %d engineering experience.", xpgain );
}

learn_from_success( ch, gsn_makesaberpike );
}
       
Post is unread #10 Sep 9, 2009, 12:23 am
Go to the top of the page
Go to the bottom of the page

Andril
Magician
GroupMembers
Posts147
JoinedJun 9, 2009

Weapon type is set in the objects value[3] spot. Double check the itemvalues help file to see what value needs to be set for weapon type though.

Change if( obj->item_type == item_weapon && WEAPON_LIGHTSABER && checksaber == FALSE ) and the other stuff like it to if( obj->item_type == item_weapon && obj->value[3] == WEAPON_LIGHTSABER && checksaber == FALSE )
       
Post is unread #11 Sep 9, 2009, 7:56 am
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

item_weapon should be ITEM_WEAPON
       
Post is unread #12 Sep 9, 2009, 1:10 pm
Go to the top of the page
Go to the bottom of the page

Scoyn
Fledgling
GroupMembers
Posts7
JoinedSep 6, 2009

Andril said:

Change if( obj->item_type == item_weapon && WEAPON_LIGHTSABER && checksaber == FALSE ) and the other stuff like it to if( obj->item_type == item_weapon && obj->value[3] == WEAPON_LIGHTSABER && checksaber == FALSE )


Should the V3 part of that be in it's own subset of parenthesis?
       
Post is unread #13 Sep 9, 2009, 1:22 pm
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

It doesn't have to be parenthesized; equality (==) has higher precedence than boolean and (&&;). So,

a == b && c == d
is the same thing as
(a == b) && (c == d)
       
Post is unread #14 Sep 9, 2009, 1:34 pm
Go to the top of the page
Go to the bottom of the page

Scoyn
Fledgling
GroupMembers
Posts7
JoinedSep 6, 2009

Spiffy. Thanks. :D
       
Pages:<< prev 1 next >>