Author Topic: teaching skill the fun... </sarcasm>  (Read 2922 times)

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
teaching skill the fun... </sarcasm>
« on: September 16, 2006, 09:02:48 AM »
Ok, well it's really not that bad.  I started off making a command and then realized it would be best to do this through a verb (I think).  



Right now the syntax that I want is > teach player skill and then have them taught the skill.



I do plan on putting in a lot of if checks later, but right now I would like to get the general skill running.  Right now my problem is this:



> teach test blade attack

You can't teach that blade attack.



> teach test multi-hand

There is no test multi- here.



> teach test missile

You can't teach that missile.



Note that Test is a player and Test is in the room with my character.



Here is the code:



code:


/*    /verbs/players/teach.c
 *    teach
 *    teach LIV WRD
 *    created by Capo of Haven_RPG
 */

#include <lib.h>
#include <daemons.h>
#include <position.h>

inherit LIB_SENTIENT;
inherit LIB_VERB;


static void create()
{
    verb::create();
    SetVerb("teach");
    SetRules("LIV WRD");
    SetErrorMessage("Syntax: teach <%^BOLD%^%^CYAN%^player%^RESET%^> (%^BOLD%^%^ORANGE%^ability%^RESET%^)");
    SetHelp("Syntax: teach <%^BOLD%^%^CYAN%^player%^RESET%^> <%^BOLD%^%^ORANGE%^ability%^RESET%^>\n"
      "This command allows you to teach another player an ability, spell, or skill.\n\n");
}

mixed can_teach_liv_wrd()
{
    int pos = this_player()->GetPosition();

    if( (int)this_player()->GetParalyzed() ) {
        return "You cannot move!";
    }
    if( pos == POSITION_SITTING || pos == POSITION_LYING &&
      !RACES_D->GetLimblessCombatRace(this_player()->GetRace()) ){
        return "You cannot teach in that position!";
    }
    return 1;
}

mixed do_teach_liv_wrd(object target, string spell)
{
  object ob = SPELLS_D->GetSpell(spell);

    if( ob )
      {
       foreach(string skill in ob->GetSkills())
         {
          if( GetSkillLevel(skill) < ob->GetRequiredSkill(skill) )
            {
             message("", "You do not know " + spell + " or how to teach it.", this_player());
            }
         }
       if( !target->eventLearnSpell(spell) )
          {
            message("", "Your target is not ready to learn that spell", this_player());
            return 1;
          }
        target->eventPrint(GetName() + " instructs you in the way of" + spell + ".");
        environment()->eventPrint(GetName() + " instructs " + objective(target) + " in the way of " + spell + ".", target);
        return 1;
      }
    else
       {
        message("", "You do not know that spell.", this_player());
        return 1;
       }
}





As stated above it updates fine, shows no errors that keep it from running.  



Any suggestions you have that will allow me to teach test lightning (a spell) and teach test multi-weapons (a skill) would be great!!

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1020
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
teaching skill the fun... </sarcasm>
« Reply #1 on: September 16, 2006, 09:05:38 AM »

Have you reviewed the verb creation tutorial?



http://dead-souls.net/verbs.html">http://dead-souls.net/verbs.html





I agree with you that a verb is best for this, but it might

be easier to tackle only one lib system at once, and start off with a cmd.



Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
teaching skill the fun... </sarcasm>
« Reply #2 on: September 16, 2006, 09:15:15 AM »

After updating the direct applies in living.c I get the following when trying to use the command:





> teach test lightning

You do not know lightning or how to teach it.

You do not know lightning or how to teach it.

Your target is not ready to learn that spell


Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1020
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
teaching skill the fun... </sarcasm>
« Reply #3 on: September 16, 2006, 09:23:59 AM »

Oh neat.



This isn't a verb problem. This is just a logic problem now. Looks

to me like you have a working verb, it just doesn't

do what you want yet.



Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
teaching skill the fun... </sarcasm>
« Reply #4 on: September 16, 2006, 09:24:51 AM »
<Death> Capo is slain by logic.

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
teaching skill the fun... </sarcasm>
« Reply #5 on: September 16, 2006, 09:30:22 AM »
code:


/*    /verbs/players/teach.c
 *    teach
 *    teach LIV WRD
 *    created by Capo of Haven_RPG
 */

#include <lib.h>
#include <daemons.h>
#include <position.h>

inherit LIB_SENTIENT;
inherit LIB_VERB;


static void create()
{
    verb::create();
    SetVerb("teach");
    SetRules("LIV WRD");
    SetErrorMessage("Syntax: teach <%^BOLD%^%^CYAN%^player%^RESET%^> (%^BOLD%^%^ORANGE%^ability%^RESET%^)");
    SetHelp("Syntax: teach <%^BOLD%^%^CYAN%^player%^RESET%^> <%^BOLD%^%^ORANGE%^ability%^RESET%^>\n"
      "This command allows you to teach another player an ability, spell, or skill.\n\n");
}

mixed can_teach_liv_wrd()
{
    int pos = this_player()->GetPosition();

    if( (int)this_player()->GetParalyzed() ) {
        return "You cannot move!";
    }
    if( pos == POSITION_SITTING || pos == POSITION_LYING &&
      !RACES_D->GetLimblessCombatRace(this_player()->GetRace()) ){
        return "You cannot teach in that position!";
    }
    return 1;
}

mixed do_teach_liv_wrd(object target, string spell)
{
  object ob = SPELLS_D->GetSpell(spell);

    if( ob )
      {
       foreach(string skill in ob->GetSkills())
         {
          if( GetSkillLevel(skill) < ob->GetRequiredSkill(skill) )
            {
             message("", "You do not know " + spell + " or how to teach it.", this_player());
             return 1;
            }
         }
       if( !target->eventLearnSpell(spell) )
          {
            message("", "Your student is not ready to learn that spell", this_player());
            return 1;
          }
        target->eventPrint(GetName() + " instructs you in the way of" + spell + ".");
        environment()->eventPrint(GetName() + " instructs " + objective(target) + " in the way of " + spell + ".", target);
        return 1;
      }
    else
       {
        message("", "You do not know that spell.", this_player());
        return 1;
       }
}





Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
teaching skill the fun... </sarcasm>
« Reply #6 on: September 16, 2006, 09:47:51 AM »

The teaching part is clearly not working, and as you said there's something wrong with my logic.



Right now the errors that I see, but do not know how to overcome are:



1- Checking to see if the teacher has the skill in his spellbook to teach it.

2- If he does can the student learn it.

3- How do you identify the student?



When I take out the checks on the teacher this is what I get:





> teach test lightning

Your student is not ready to learn that spell

---

*Bad argument 1 to call_other()

Expected: string or array or object Got: 0.

Object: /verbs/players/teach at line 62



'<function>' at /secure/save/creators/c/capo (<function>) at /:0

'cmdAll' at /secure/save/creators/c/capo (/lib/command.c) at line 72

'do_teach_liv_wrd' at /verbs/players/teach at line 62

Trace written to /log/runtime





If any of you can help me with 1,2 or 3 I would be greatful!


Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1020
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
teaching skill the fun... </sarcasm>
« Reply #7 on: September 16, 2006, 10:41:58 AM »

1) Herkimer checks whether you know a spell yet. Take a look at how he does it: http://dead-souls.net/code/ds2.1/lib/domains/town/npc/herkimer.c">http://dead-souls.net/code/ds2.1/lib/domains/town/npc/herkimer.c



2) He also checks for the student's ability to learn it.



3) You've already identified the student as the object "target".



Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
teaching skill the fun... </sarcasm>
« Reply #8 on: September 16, 2006, 05:22:06 PM »
Figured it out! WOo