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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ 'Empower' spell 90% done ...aaargh!

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

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


Posted by Buck   USA  (23 posts)  Bio
Date Tue 27 Jul 2004 03:01 AM (UTC)

Amended on Tue 27 Jul 2004 03:09 AM (UTC) by Buck

Message
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.


-Buck.
tbgamecock@yahoo.com
"I am Homer of Borg. Prepare to be assim... ooooo, Doughnuts!"
Top

Posted by Buck   USA  (23 posts)  Bio
Date Reply #1 on Tue 27 Jul 2004 08:25 PM (UTC)
Message
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.

-Buck.
tbgamecock@yahoo.com
"I am Homer of Borg. Prepare to be assim... ooooo, Doughnuts!"
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #2 on Tue 27 Jul 2004 09:02 PM (UTC)
Message
How about actually giving the char the object? :P

Use obj_to_char.

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

Posted by Buck   USA  (23 posts)  Bio
Date Reply #3 on Tue 27 Jul 2004 09:14 PM (UTC)

Amended on Tue 27 Jul 2004 09:15 PM (UTC) by Buck

Message
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?

-Buck.
tbgamecock@yahoo.com
"I am Homer of Borg. Prepare to be assim... ooooo, Doughnuts!"
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #4 on Tue 27 Jul 2004 09:20 PM (UTC)
Message
Ah, didn't see that in your second post.

Have you tried:

obj->level = ch->level;


That should be it.

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

Posted by Buck   USA  (23 posts)  Bio
Date Reply #5 on Tue 27 Jul 2004 09:32 PM (UTC)
Message
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!

-Buck.
tbgamecock@yahoo.com
"I am Homer of Borg. Prepare to be assim... ooooo, Doughnuts!"
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.


19,617 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.