The Dawn Of Time
The Official Forums for the Dawn Of Time Mud Codebase
 
Log in Register FAQ Memberlist Search The Dawn Of Time Forum Index Goto the Official Dawn Website

new skill pillify, problems with adding spells to the object

 
Post new topic   Reply to topic    The Dawn Of Time Forum Index » Migration/Porting
View previous topic :: View next topic  
Author Message
grimnard



Joined: 28 Jul 2003
Posts: 189
Location: Indiana, usa

PostPosted: Sun Dec 14, 2003 1:04 pm    Post subject: new skill pillify, problems with adding spells to the object Reply with quote

ok i found a snippet not sure what it was from but i modifided it so it will work in dawn the only problems i have is(and this looks right to me but i dont have much of to comare to to make sure)i cant get the new function i have in tehre to add spells to the obj pill to add the spell's i get that it is full

Code:
void imprint_spell( int sn, int level, char_data * ch, void *vo )
{
   static const int    sucess_rate[] = { 80, 25, 10 };

   char buf[MIL];
    OBJ_DATA *obj = ( OBJ_DATA * ) vo;
    int       free_slots;
    int       i;
    int       mana;
    int       clas;
    int       snlev = 0;

    for ( free_slots = i = 1; i < 4; i++ )
        if ( obj->value[i] != 0 )
            free_slots++;

    if ( free_slots > 3 )
    {
        act( "$p cannot contain any more spells.", ch, obj, NULL, TO_CHAR);
        return;
    }

    mana = 40;
    mana += skill_table[sn].min_mana;
    if ( !IS_NPC( ch ) && ch->mana < mana )
    {
        ch->println( "You don't have enough mana.\r\n");
        return;
    }

    if ( number_percent( ) > ch->pcdata->learned[sn] )
    {
      ch->println( "You lost your concentration.\r\n");
        ch->mana -= mana / 2;
        return;
    }

    ch->mana -= mana;
    obj->value[free_slots] = sn;

    if ( number_percent( ) > sucess_rate[free_slots - 1] )
    {
        ch->printlnf("The magic enchantment has failed: the %s vanishes.\r\n", item_name( obj->item_type ) );
        extract_obj( obj );
        return;
    }


    free_string( obj->short_descr );
    sprintf("a %s of ", item_name( obj->item_type ) );
    for ( i = 1; i <= free_slots; i++ )
        if ( obj->value[ i ] != -1 )
        {
            strcat( buf, skill_table[ obj->value[ i ] ].name );
            ( i != free_slots ) ? strcat( buf, ", " ) : strcat( buf, "" );
    }
    obj->short_descr = str_dup( buf );

    sprintf( buf, "%s %s", obj->name, item_name( obj->item_type ) );
    free_string( obj->name );
    obj->name = str_dup( buf );
    for (clas = 0;clas < MAX_CLASS;clas++)
   {
      if(skill_table[sn].skill_level[clas] < snlev)
      {
         snlev = skill_table[sn].skill_level[clas];
      }
   }
    if(obj->level < snlev)
   {
      obj->level = snlev;
   }
    ch->printlnf("You have imbued a new spell to the %s.\r\n", item_name( obj->item_type ) );
    return;
}
/************************************************************************/

now this is what i get when i do the skill
Dawn Output:
You begin focusing your magical energy.

A rainbow colored pill. suddenly pops into existence.
A rainbow colored pill. cannot contain any more spells.
this is what i get when making the pill with the spell heal
this is the stat on the pill one from stat and the other from oedit
Dawn Output:
Name(s): ranbow pill
Vnum: 421  uid:14064  Type: pill  Resets: 0
Short description: a rainbow colored pill.
Long description: A rainbow colored pill lay's here.
Wear bits: take hold
Extra bits: magic rotdeath nonmetal nolocate meltdrop
Extra2 bits: none
Number: 1/10  Weight: 0/0/0 (kg's)
Level: 57  Cost: 0  Condition: 100  Timer: 0
In room: 0  In object: (none)  Carried by: Grimnard  Wear_loc: none
Values: 57 -1 -1 -1 -1
Level 57 spells of:.
Dawn Output:
Vnum: 421     Type: pill       Level: 0          Area[23]: dawn.are
Cost: 0       Weight: 0        Condition: 100    Material: unknown       
Absolute size: 0      Relative size: 50    
Name: ranbow pill
Short desc: a rainbow colored pill.
Long descr: A rainbow colored pill lay's here.
There are no extended descriptions.
Wear Flags:    [take hold]
Extra Flags:   [magic meltdrop nolocate nonmetal rotdeath]
Extra2 Flags:  [none]
Class Allowances: all classes
[v0] Level:  [0]
[v1] Spell:  none
[v2] Spell:  none
[v3] Spell:  none
[v4] Spell:  none
if anyone knows what is wrong in the above function please let me know this is sorta bugging me. any sujestions would be apreciated.

thanks grimnard



_________________
See you all on the flip side...

telnet://play.awtw.net:5556/
http://www.awtw.net/
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
ganieda



Joined: 08 Feb 2003
Posts: 297
Location: US

PostPosted: Sun Dec 14, 2003 7:11 pm    Post subject: Reply with quote

The answer's right in front of you =] (i think, anyways)

in your stat, it shows:

Values: 57 -1 -1 -1 -1

v1-v4 are -1, not 0, so they each count +1 to your spell count even though there's no spell there.

change the if() in the beginning to
Code:
if( i = 1; i < 4; i++ )
{
     if( obj->value[i] != -1 )
          free_slots++;
}
also, just a suggestion, but free_slots is kind of confusing, because it counts the number of slots that are used, not free...i would change it if it were my code to avoid confusion.

good luck =]


Back to top
View user's profile Send private message Send e-mail
grimnard



Joined: 28 Jul 2003
Posts: 189
Location: Indiana, usa

PostPosted: Mon Dec 15, 2003 6:53 pm    Post subject: Reply with quote

well i have changed the command to the -1 and now it crashes the mud unsure why(dont bother asking for debug stuff i'm not sure how to do that(if ya want to walk me threw it once i can give it to ya)) so if anyone has any other sujestions id much apreciate it

thanks

grimnard



_________________
See you all on the flip side...

telnet://play.awtw.net:5556/
http://www.awtw.net/
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    The Dawn Of Time Forum Index » Migration/Porting All times are GMT + 13 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001-2005 phpBB Group
Theme created by Vjacheslav Trushkin