Author Topic: Help with items + random damage  (Read 3601 times)

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Help with items + random damage
« on: September 12, 2006, 06:12:31 PM »
Hey guys,



I thought I would adapt the random damage done by a skill to a weapon and got tripped up... This is what I have:



code:


#include <lib.h>
#include <damage_types.h>
#include <vendor_types.h>

inherit LIB_ITEM;

static void create()
  {
    item::create();
    SetKeyName("sword");
    SetId( ({"silver sword", "sword", "weapon", "silver"}) );
    SetAdjectives( ({ "generic" }));
    SetShort("%^BOLD%^%^WHITE%^silver sword%^RESET%^");
    SetLong("This sword is a really generic silver sword that Capo made to test out random events on an object.");
    SetHands(1);
    SetMass(10);
    SetVendorType(VT_WEAPON);
    SetClass(100);
    SetDamageType(BLADE);
    SetWeaponType("blade");
  }

int eventStrike(object target)
  {
    object thing;
    thing = new("/domains/foo/obj/critical_wound.c");
    message("environment", " %^WHITE%^The sword glows as it cuts throw its target%^RESET%^ leaving horrible %^RED%^wounds%^RESET%^", 0);
    thing->eventMove(target);
    return 1;
   }

void init(){
    ::init();
}







Right now, when I wield this sword I do nothing... totally confusing.

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Help with items + random damage
« Reply #1 on: September 12, 2006, 06:31:08 PM »
This seemed to work:



code:


#include <lib.h>
#include <damage_types.h>
#include <vendor_types.h>

inherit LIB_ITEM;

static void create()
  {
    item::create();
    SetKeyName("sword");
    SetId( ({"silver sword", "sword", "weapon", "silver"}) );
    SetAdjectives( ({ "generic" }));
    SetShort("%^BOLD%^%^WHITE%^silver sword%^RESET%^");
    SetLong("This sword is a really generic silver sword that Capo made to test out random events on an object.");
    SetHands(1);
    SetMass(10);
    SetVendorType(VT_WEAPON);
    SetClass(100);
    SetDamageType(BLADE);
    SetWeaponType("blade");
  }

int eventStrike(object target)
        {
           object thing;
           thing = new("/domains/foo/obj/critical_wound.c");
           thing->eventMove(target);
 // send a cool message to everyone in the room
 // environment() is the person using the sword
 // environment(environment()) thus would be the room
           environment()->eventPrint("%^WHITE%^The sword glows as it cuts throw its target%^RESET%^ leaving horrible %^RED%^wounds%^RESET%^");
           environment(environment())->eventPrint("%^WHITE%^The sword glows as it cuts throw its target%^RESET%^ leaving horrible %^RED%^wounds%^RESET%^");
           environment(environment(target))->eventPrint("%^WHITE%^The sword glows as it cuts throw you%^RESET%^ leaving horrible %^RED%^wounds%^RESET%^");
           thing->eventMove(target);
           return 1;
        }



void init(){
    ::init();
}

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Help with items + random damage
« Reply #2 on: September 12, 2006, 07:28:19 PM »
code:


#include <lib.h>
#include <damage_types.h>
#include <vendor_types.h>

inherit LIB_ITEM;

static void create()
{
    item::create();
    SetKeyName("sword");
    SetId( ({"silver sword", "sword", "weapon", "silver"}) );
    SetAdjectives( ({ "generic" }));
    SetShort("%^BOLD%^%^WHITE%^silver sword%^RESET%^");
    SetLong("This sword is a really generic silver sword that Capo made to test out random events on an object.");
    SetHands(1);
    SetMass(10);
    SetVendorType(VT_WEAPON);
    SetDamagePoints(10000);
    SetClass(100);
    SetNoCondition(1);
    SetDamageType(BLADE);
    SetWeaponType("blade");
}

int eventStrike(object target)
{

    if(random(100) < 10)
    {
        object thing;
        thing = new("/domains/foo/obj/critical_wound.c");
        thing->eventMove(target);
        environment(environment())->eventPrint("%^BOLD%^%^WHITE%^The sword glows as it cuts throw its target%^RESET%^ leaving horrible %^RED%^wounds%^RESET%^");
        environment(environment(target))->eventPrint("%^BOLD%^%^WHITE%^The sword glows as it cuts throw you%^RESET%^ leaving horrible %^RED%^wounds%^RESET%^");
        return 1;
    }
}
void init(){
    ::init();
}






It appears that only the damage from the critical_wound object is being returned... after about 1000 rounds with the dummy, never once was damage returned from the actual weapon strike.   Thoughts?

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Help with items + random damage
« Reply #3 on: September 12, 2006, 07:36:34 PM »
code:

#include <lib.h>
#include <damage_types.h>
#include <vendor_types.h>

inherit LIB_ITEM;

static void create()
{
    item::create();
    SetKeyName("sword");
    SetId( ({"silver sword", "sword", "weapon", "silver"}) );
    SetAdjectives( ({ "generic" }));
    SetShort("%^BOLD%^%^WHITE%^silver sword%^RESET%^");
    SetLong("This sword is a really generic silver sword that Capo made to test out random events on an object.");
    SetHands(1);
    SetMass(10);
    SetVendorType(VT_WEAPON);
    SetDamagePoints(10000);
    SetClass(100);
    SetNoCondition(1);
    SetDamageType(BLADE);
    SetWeaponType("blade");
}

int eventStrike(object target)
{
  int x = item::eventStrike(target);
    if(random(100) < 10)
    {
        object thing;
        thing = new("/domains/foo/obj/critical_wound.c");
        thing->eventMove(target);
        environment(environment())->eventPrint("%^BOLD%^%^WHITE%^The sword glows as it cuts throw its target%^RESET%^ leaving horrible %^RED%^wounds%^RESET%^");
        environment(environment(target))->eventPrint("%^BOLD%^%^WHITE%^The sword glows as it cuts throw you%^RESET%^ leaving horrible %^RED%^wounds%^RESET%^");
     return x;
    }
}
void init(){
    ::init();
}







Still no love :(

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Help with items + random damage
« Reply #4 on: September 12, 2006, 08:15:11 PM »
code:



#include <lib.h>
#include <damage_types.h>
#include <vendor_types.h>

inherit LIB_ITEM;

static void create()
{
    item::create();
    SetKeyName("sword");
    SetId( ({"silver sword", "sword", "weapon", "silver"}) );
    SetAdjectives( ({ "generic" }));
    SetShort("%^BOLD%^%^WHITE%^silver sword%^RESET%^");
    SetLong("This sword is a really generic silver sword that Capo made to test out random events on an object.");
    SetHands(1);
    SetMass(10);
    SetVendorType(VT_WEAPON);
    SetDamagePoints(10000);
    SetClass(100);
    SetNoCondition(1);
    SetDamageType(BLADE);
    SetWeaponType("blade");
}

int eventStrike(object target)
{
  int x = item::eventStrike(target);
    if(random(100) < 10)
    {
        object thing;
        thing = new("/domains/foo/obj/critical_wound.c");
        thing->eventMove(target);
        environment(environment())->eventPrint("%^BOLD%^%^WHITE%^The sword glows as it
cuts throw its target%^RESET%^ leaving horrible %^RED%^wounds%^RESET%^");
        environment(environment(target))->eventPrint("%^BOLD%^%^WHITE%^The sword glows
as it cuts throw you%^RESET%^ leaving horrible %^RED%^wounds%^RESET%^");
    }
  return x;
}
void init(){
    ::init();
}


Offline tigwyk

  • Acquaintance
  • *
  • Posts: 45
    • View Profile
Help with items + random damage
« Reply #5 on: September 12, 2006, 09:26:11 PM »
I think you still need to do this...

LPC code:

int eventStrike(object target) {
 
 //int x = item::eventStrike(target);
    if(random(100) < 10)
    {
        object thing;
        thing = new("/domains/foo/obj/critical_wound.c");
        thing->eventMove(target);
        environment(environment())->eventPrint("%^BOLD%^%^WHITE%^The sword glows as it
cuts throw its target%^RESET%^ leaving horrible %^RED%^wounds%^RESET%^");
        environment(environment(target))->eventPrint("%^BOLD%^%^WHITE%^The sword glows
as it cuts throw you%^RESET%^ leaving horrible %^RED%^wounds%^RESET%^");
    }
    return item::eventStrike(target);
}

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Help with items + random damage
« Reply #6 on: September 13, 2006, 11:23:40 AM »

See above!



P.S. Intermud is still down for me, no idea what's going on with it.


Offline tigwyk

  • Acquaintance
  • *
  • Posts: 45
    • View Profile
Help with items + random damage
« Reply #7 on: September 13, 2006, 12:39:41 PM »

Hiya Capo,



From what I can see, your code works, even without my minor modification. Is it supposed to work as of your latest post, or was that still requesting help?


Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Help with items + random damage
« Reply #8 on: September 13, 2006, 12:51:08 PM »

Oh! Im sorry, because IMC is down for me... not sure why... I couldn't reply over DS (cant even see the ds line now).



Someone wanted me to post a working version so that they could copy it.


Offline tigwyk

  • Acquaintance
  • *
  • Posts: 45
    • View Profile
Help with items + random damage
« Reply #9 on: September 13, 2006, 01:06:55 PM »
Oh haha, I see. Excellent, glad to know it works. But you know, you can remove the int x part, because you can just return item::eventStrike(target); without need to put that in a variable. Saves you a line of code.