'Empower' spell 90% done ...aaargh!

Posted by Buck on Tue 27 Jul 2004 03:01 AM — 6 posts, 20,699 views.

USA #0
I want to make a higher level skill that does what scribe and brew do, but without need of fire, scrolls, etc... to execute it. I used brew as a template and got it plugged into all the right files. This is what I have so far:

void do_empower( CHAR_DATA *ch, char *argument )
{
    OBJ_DATA *obj;
    /*OBJ_DATA *fire;*/
    int sn;
    char buf1[MAX_STRING_LENGTH];
    char buf2[MAX_STRING_LENGTH];
    char buf3[MAX_STRING_LENGTH];
    int mana;
    /*bool found;*/

    if ( IS_NPC(ch) )
        return;

    if ( !IS_NPC(ch)
    &&   ch->level < skill_table[gsn_empower]->skill_level[ch->class] )
    {
        send_to_char( "A skill such as this requires more magical ability than that of your class.\n\r", ch );
	return;
    }

    if ( argument[0] == '\0' || !str_cmp(argument, "") )
    {
	send_to_char( "Empower what?\n\r", ch );
	return;
    }

    if ( ms_find_obj(ch) )
	return;

    if ( (sn = find_spell( ch, argument, TRUE )) < 0 )
    {
         send_to_char( "You have not learned that spell.\n\r", ch );
         return;
    }

    if ( skill_table[sn]->spell_fun == spell_null )
    {
        send_to_char( "That's not a spell!\n\r", ch );
        return;
    }

    if ( SPELL_FLAG(skill_table[sn], SF_NOBREW) && SPELL_FLAG(skill_table[sn], SF_NOSCRIBE))
    {
        send_to_char( "You cannot bind that spell to a potion.\n\r", ch );
        return;
    }

    mana = IS_NPC(ch) ? 0 : UMAX(skill_table[sn]->min_mana,
     100 / ( 2 + ch->level - skill_table[sn]->skill_level[ch->class] ) );

    mana *=4;

    if ( !IS_NPC(ch) && ch->mana < mana )
    {
        send_to_char( "You lack the necessary mana, soldier!.\n\r", ch );
        return;
    }  /*  Took out references to fire with no problem
  
    found = TRUE;

    for ( fire = ch->in_room->first_content; fire; 
          fire = fire->next_content )
    {
       if( fire->item_type = ITEM_FIRE)
       {
	  found = TRUE;
	  break;
       }
    }

     if ( !found )
     {
        send_to_char(
        "There must be a fire in the room to brew a potion.\n\r", ch );
        return;
     }   now back to the sticky part */

     if ( ( obj = get_eq_char( ch, WEAR_HOLD ) ) == NULL )
     {
        send_to_char(
        "You must be holding an empty flask to brew a potion.\n\r", ch );
        return;
     }

     if( obj->pIndexData->vnum != OBJ_VNUM_FLASK_BREWING )
     {
	send_to_char( "You must be holding an empty flask to brew a potion.\n\r", ch );
	return;
     }

     if ( ( obj->value[1] != -1 )
     && ( obj->pIndexData->vnum == OBJ_VNUM_FLASK_BREWING ) )
     {
	send_to_char( "That's not an empty flask.\n\r", ch);
	return;
     }

     if ( !process_spell_components( ch, sn ) )
     {
	learn_from_failure( ch, gsn_empower );
	ch->mana -= (mana / 2);
	return;
     }

     if ( !can_use_skill(ch, number_percent(), gsn_empower ) )
     { /* I want to comment all above, too, but I need to put something... */ 
       set_char_color ( AT_MAGIC, ch );
       send_to_char("You failed.\n\r", ch);
       learn_from_failure( ch, gsn_brew );
       ch->mana -= (mana / 2);
       return;
     } 
     /* ...here to create the flask, I think. */
     obj->value[1] = sn;
     obj->value[0] = ch->level;
     sprintf(buf1, "%s potion", skill_table[sn]->name);
     STRFREE(obj->short_descr);
     obj->short_descr = STRALLOC( aoran(buf1) );

     sprintf(buf2, "A strange potion labelled '%s' sizzles in a glass flask.",
                                              skill_table[sn]->name);

     STRFREE(obj->description);
     obj->description = STRALLOC(buf2);

     sprintf(buf3, "flask potion %s", skill_table[sn]->name);
     STRFREE(obj->name);
     obj->name = STRALLOC(buf3);

     act( AT_MAGIC, "$n brews up $p.",   ch,obj, NULL, TO_ROOM );
     act( AT_MAGIC, "You brew up $p.",   ch,obj, NULL, TO_CHAR );

     learn_from_success( ch, gsn_empower );
    
     ch->mana -= mana;
     
}


I tried to work in some form of create_object but couldn't get the syntax right. What can I do to make the command autocreate the finished flask? The above prototype is compiled OK and working as tweaked so far, but still requires an empty flask to execute. Am I overcomplicating this? I'm running 1.4a.mxp via Cygwin. Thanks for any help on this, I've tried to come up with it all on my own, but I'm stumped on how to finish this...I'm soooo close! Many thanks in advance to anyone who can shed some light.

Amended on Tue 27 Jul 2004 03:09 AM by Buck
USA #1
I figured out a solution, sorta:

obj = create_object( get_obj_index(OBJ_VNUM_FLASK_BREWING), 0 );
     obj->value[1] = sn;
     obj->value[0] = ch->level;
     obj_to_char(obj, ch);



...but the level isn't assigning like brew does. I'll try to figure it out.
USA #2
How about actually giving the char the object? :P

Use obj_to_char.
USA #3
Well I did that in line 4, see? Its working pretty well now, but I want to assign the caster's level to the object, because its defaulting to 0. Brew doesn't do that as I thought it did, either. Any thoughts on how to parse a command that makes the object the same level as the caster?
Amended on Tue 27 Jul 2004 09:15 PM by Buck
USA #4
Ah, didn't see that in your second post.

Have you tried:

obj->level = ch->level;


That should be it.
USA #5
YES!!!! That did the trick! I had tried...

obj->level[0] = ch->level;

...but got an error. Thanks alot, the skill works perfectly now :) Thanks again!