Author Topic: AddSkillBonus for my sword!  (Read 3572 times)

Offline Zombie

  • Acquaintance
  • *
  • Posts: 31
    • View Profile
AddSkillBonus for my sword!
« on: May 14, 2008, 05:47:28 pm »
Here is the code::
Code: [Select]
#include <lib.h>
#include <damage_types.h>
#include <vendor_types.h>

inherit LIB_ITEM;
int WieldMe();
int CheckBlade();

static void create () {
        item::create();
    SetKeyName("zonbi slayer slaying sword");
    SetId( ({"zonbi", "zonbi slayer", "zonbi slayer slaying", "slayer slaying", "zonbi sword", "zonbi
slayer sword", "zonbi slayer slaying sword", "slayer slaying sword"}) );
    SetShort("the 'Zonbi Slaayer'-Slaying Sword");
    SetLong("This is the sword that destroys all who oppose Zonbi.");
    SetVendorType(VT_WEAPON);
    SetDamagePoints(10000);
    SetClass(50);
    SetMass(100);
    SetWeaponType("blade");
    SetDamageType(BLADE);
    SetWield((: WieldMe :));
}

int WieldMe() {
    this_player()->AddSkillBonus("blade attack", (: CheckBlade :));
    if( (int)this_player()->GetName("Zonbi") ) {
        write("You smile as your friend returns to your hand.");
        say((string)this_player()->GetName() + " smiles as his friend returns to    his hand.");
        return 1;
    }
    else {
        write("Your are not Zonbi! Begone!");
        return 0;
    }
}

int CheckBlade(string skill) {
    if( !GetWorn() ) {
        previous_object()->RemoveSkillBonus("blade", this_object());
        return 0;
    }
    else return 20;
}

Here is the problem:: The stat bonus doesn't work. Pretty simple. Any help appreciated!


Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: AddSkillBonus for my sword!
« Reply #1 on: May 14, 2008, 06:14:06 pm »
I commented out your "only works for me" code and returned 1 for wielding,
and it seems to work fine:

Code: [Select]
#include <lib.h>
#include <damage_types.h>
#include <vendor_types.h>

inherit LIB_ITEM;

int WieldMe();
int CheckBlade();
static void create () {
        item::create();
    SetKeyName("zonbi slayer slaying sword");
    SetId( ({"zonbi", "zonbi slayer", "zonbi slayer slaying", "slayer slaying", "zonbi sword", "zonbi
slayer sword", "zonbi slayer slaying sword", "slayer slaying sword"}) );
    SetShort("the 'Zonbi Slaayer'-Slaying Sword");
    SetLong("This is the sword that destroys all who oppose Zonbi.");
    SetVendorType(VT_WEAPON);
    SetDamagePoints(10000);
    SetClass(50);
    SetMass(100);
    SetWeaponType("blade");
    SetDamageType(BLADE);
    SetWield((: WieldMe :));
}
int WieldMe() {
    this_player()->AddSkillBonus("blade attack", (: CheckBlade :));
/*
    if( (int)this_player()->GetName("Zonbi") ) {
        write("You smile as your friend returns to your hand.");
        say((string)this_player()->GetName() + " smiles as his friend returns to    his hand.");
        return 1;
    }
    else {
        write("Your are not Zonbi! Begone!");
        return 0;
    }
*/
return 1;
}
int CheckBlade(string skill) {
    if( !GetWorn() ) {
        previous_object()->RemoveSkillBonus("blade", this_object());
        return 0;
    }
    else return 20;
return 20;
}
void init(){
::init();
}



call me->GetSkillLevel("blade attack")
OBJ(cratylus /secure/save/creators/c/cratylus) -> GetSkillLevel( "blade attack") = 21

-Crat

Offline Zombie

  • Acquaintance
  • *
  • Posts: 31
    • View Profile
Re: AddSkillBonus for my sword!
« Reply #2 on: May 14, 2008, 06:28:31 pm »
I didnt even use your fix and it turns out it works, just that when you hit skills/prac, it doesn't show (still shows blade attack : 1/44)

Offline daelaskai

  • BFF
  • ***
  • Posts: 174
    • View Profile
Re: AddSkillBonus for my sword!
« Reply #3 on: May 15, 2008, 09:46:51 am »
My question is, if only you are able to wield the item, why do you have the:

this_player()->AddSkillBonus("blade attack", (: CheckBlade :));

outside of the if() check?

Daelas

Offline Zombie

  • Acquaintance
  • *
  • Posts: 31
    • View Profile
Re: AddSkillBonus for my sword!
« Reply #4 on: May 17, 2008, 01:34:54 am »
I don't think I quite understand what your saying... the CheckBlade bit is just to prevent potential bugs with the lib thinking the sword is still equipped when it's not.

Offline daelaskai

  • BFF
  • ***
  • Posts: 174
    • View Profile
Re: AddSkillBonus for my sword!
« Reply #5 on: May 17, 2008, 06:36:03 am »
Yes, I understand what you are attempting to do with it; however, I do not
think it is doing exactly as you hoped.  If I am reading it properly the flow
of the current code is like this:

-->player types "wield sonbi"
-->sonbi checks to see if it is worn and since it is not, it returns 0
    (adding 0 skillbonus);
-->sonbi checks the name of the player to see if it is "Zonbi". and if so
     allow the player to wield the sword.  If not, do not wield.

The way I see it, this function will not work as you are hoping, unless I'm
just very tired and am not thinking clearly.  Whether you are "Zonbi" or not
I do not believe the skill bonus will ever be added because when it checks
for if "sonbi" is worn, it will always return 0 since the "WieldMe" function has
not returned 1 yet.

Maybe someone else (who isn't tired) can look this over too.  I certainly
could be wrong.

Daelas