Author Topic: Suggestions wanted  (Read 6258 times)

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Suggestions wanted
« Reply #15 on: September 14, 2006, 08:03:12 AM »
Both of you offered great suggestions... here's what happened when I added the debug("") text:



quote:




You narrowly avoid Test quick swing.

The magical shield around you shatters into nothingness.



DEBUG:  /spells/globe

 "Globe destructed"



Test spits derisively and hammers you painfully in your right hand with his

attack.

Test lashes out at your body, but misses it completely.

You narrowly avoid Test's quick swing.





The code representing this:



code:


int eventDestruct()
   {
    this_object()->eventMove("domains/default/room/furnace.c");
    debug("Globe destructed");
    return ::eventDestruct();
   }




Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Suggestions wanted
« Reply #16 on: September 14, 2006, 08:25:20 AM »
code:


#include <lib.h>
#include <magic.h>
#include <damage_types.h>
#include <magic_protection.h>

inherit LIB_ITEM;
inherit LIB_SPELL;

int hitCallback(object who, object agent, int x, class MagicProtection cl);
void endCallback(object who);

static void create()
{
    spell::create();
    SetSpell("globe");
    SetRules("");
    SetSpellType(SPELL_DEFENSE);
    SetRequiredMagic(100);
    SetSkills(([ "magic defense" : 1 ]));
    SetMagicCost( 100, 0);
    SetDifficulty(1);
    SetHelp("Syntax: <cast globe>\n\n"
      "This powerful spell harnesses the power of light and surrounds the user with a globe of invulnerbility.");
}

int eventCast(object who, int level, mixed limbs, object array targets)
   {
    object target;
    class MagicProtection protection;
    object thing;
    int prot_level;
    int skill;
    int wis;

    target = this_player();
    thing = new("/domains/foo/obj/light_globe.c");
    thing->eventMove(this_player());

    wis = who->GetStatLevel("wisdom");
    skill = who->GetSkillLevel("magic defense");
    prot_level = level;
    prot_level *= (random(skill/10) + 1);
    prot_level += random(wis/2);
    protection = new(class MagicProtection);
    protection->bits = BLUNT | BLADE | KNIFE | MAGIC;
    protection->caster = who;
    protection->absorb = 2*prot_level;
    protection->args = level;
    protection->hit = (: hitCallback :);
    protection->end = (: endCallback :);
    target->AddMagicProtection(protection);
    if( target == who )
         {
          send_messages("", "\n%^BOLD%^CYAN%^A translucent magical barrier suddenly appears around $agent_possessive_noun body.%^RESET%^\n", who, 0, environment(target));
         }
    else
        {
          send_messages("", "\n%^BOLD%^CYAN%^A translucent magical barrier suddenly appears around $agent_possessive_noun body.%^RESET%^\n", who, 0, environment(target));
        }
    return 1;
    }

int hitCallback(object who, object agent, int x, class MagicProtection cl)
    {
    string str;
    object Caster = cl->caster;

    if( (int)agent->GetUndead() ) return 0;
    str = (string)agent->GetName() || (string)agent->GetShort();
    if( who == Caster )
           {
        who->eventTrainSkill("magic defense",cl->args,x,1);
       }
    else if( Caster && playerp(who) && Caster != who )
          {
        Caster->eventTrainSkill("magic defense",cl->args,0,1);
      }

    send_messages("", "The %^YELLOW%^magical shield%^RESET%^ around $agent_name wavers as $target_name strikes it.", who, agent, environment(who));
    return x;
    }

void endCallback(object who)
   {
    if( who )
         {
        send_messages("", "The %^BOLD%^CYAN%^magical shield around $agent_name shatters into nothingness.%^RESET%^", who, 0, environment(who));
        this_object()->eventDestruct();
     }
   }

int eventDestruct()
   {
    this_object()->eventMove("/domains/default/room/furnace.c");
    debug("Globe destructed");
    return ::eventDestruct();
   }







code:


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


inherit LIB_ITEM;
inherit LIB_DETERIORATION;

void create()
 {
    item::create();
    SetId(({"light_globe"}));
    SetInvis(1);
    SetMass(0);
    set_heart_beat(3);
 }


string GetAffectLong(object ob)
   {
    if(!ob || !living(ob)) return 0;
    return "%^RESET%^%^CYAN%^*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n" +
           "%^RESET%^%^YELLOW%^       " + ob->GetName() + " surrounded by a glowing orb of light%^RESET%^%^CYAN%^            " +
           "%^RESET%^%^CYAN%^*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*%^RESET%^";
   }


void heart_beat()
  {
    object ob;
    ob=environment();

    if(!living(ob))
       {
        this_object()->eventDestruct();
                return;
       }
   }
int eventDestruct()
   {
    this_object()->eventMove("domains/default/room/furnace.c");
    return ::eventDestruct();
   }





Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1020
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Suggestions wanted
« Reply #17 on: September 14, 2006, 08:31:06 AM »

Try this:



#include <lib.h>

#include <damage_types.h>

#include <vendor_types.h>





inherit LIB_ITEM;

inherit LIB_DETERIORATION;



void create()

 {

    item::create();

    SetId(({"light_globe"}));

    SetInvis(1);

    SetMass(0);

    set_heart_beat(3);

 }





string GetAffectLong(object ob)

   {

    if(!ob || !living(ob)) return 0;

    return "%^RESET%^%^CYAN%^*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n" +

           "%^RESET%^%^YELLOW%^       " + ob->GetName() + " surrounded by a glowing orb of light%^RESET%^%^CYAN%^            " +

           "%^RESET%^%^CYAN%^*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*%^RESET%^";

   }





void heart_beat()

  {

    object ob;

    ob=environment();



   if(ob && !living(ob))

       {

        this_object()->eventDestruct();

                return;

       }

   }

int eventDestruct()

   {

    this_object()->eventMove("/domains/default/room/furnace.c");

    return ::eventDestruct();

   }



Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1020
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Suggestions wanted
« Reply #18 on: September 14, 2006, 09:01:20 AM »

#include <lib.h>

#include <damage_types.h>

#include <vendor_types.h>





inherit LIB_ITEM;

inherit LIB_DETERIORATION;



void create()

{

    item::create();

    SetId(({"light_globe"}));

    SetLong("");

    SetShort("");

    SetInvis(1);

    SetMass(0);

    set_heart_beat(3);

}





string GetAffectLong(object ob)

{

    if(!ob || !living(ob)) return 0;

    return "%^RESET%^%^CYAN%^*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n" +

    "%^RESET%^%^YELLOW%^ " + ob->GetName() + " surrounded by a glowing orb of light%^RESET%^%^CYAN%^ " +

    "%^RESET%^%^CYAN%^*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*%^RESET%^";

}





void heart_beat()

{

    object ob;

    ob=environment();



   if(ob && !living(ob))

    {

        this_object()->eventDestruct();

        return;

    }

}

int eventDestruct()

{

    this_object()->eventMove("/domains/default/room/furnace.c");

    return ::eventDestruct();

}





I ran into a weird problem running your code in my mud,

and discovered that a lack of a short desc screwed things up.



You need to have something in set short, even a null string,

otherwise it's 0, an integer, and that apparently screws

messaging.



You'll want to do this, after making the changes indicated:



findobj light_globe



And for every lobject returned (including the parent,

non-cloned object) do this:



eval return find_object("/path/goes/here")->eventDestruct()





then update the file and try again.



This may not be *the* problem, but it is *a* problem.



Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Suggestions wanted
« Reply #19 on: September 14, 2006, 09:14:50 AM »

I made said changes with no success.. I think this is what Im going to have to do, and it seems a little confusing to me still:



1- Take out most of the damage reduction/interception from the globe.c spell file.

2- Edit the object to take the damage.

3- When damage = x, destruct



The question is, how do I route that damage to the object instead of the player.



Hmm.


Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1020
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Suggestions wanted
« Reply #20 on: September 14, 2006, 09:44:05 AM »

#include <lib.h>

#include <magic.h>

#include <damage_types.h>

#include <magic_protection.h>



inherit LIB_ITEM;

inherit LIB_SPELL;



int hitCallback(object who, object agent, int x, class MagicProtection cl);

void endCallback(object who);



static void create()

{

    spell::create();

    SetSpell("globo");

    SetRules("");

    SetSpellType(SPELL_DEFENSE);

    SetRequiredMagic(100);

    SetSkills(([ "magic defense" : 1 ]));

    SetMagicCost( 10, 10);

    SetDifficulty(1);

    SetHelp("Syntax: <cast globe>\n\n"

      "This powerful spell harnesses the power of light and surrounds the user with a globe of invulnerbility.");

}



int eventCast(object who, int level, mixed limbs, object array targets)

{

    object target;

    class MagicProtection protection;

    object thing;

    int prot_level;

    int skill;

    int wis;



   target = this_player();

    thing = new("/open/thingy");

    if(thing) thing->eventMove(this_player());



   wis = who->GetStatLevel("wisdom");

    skill = who->GetSkillLevel("magic defense");

    prot_level = level;

    prot_level *= (random(skill/10) + 1);

    prot_level += random(wis/2);

    protection = new(class MagicProtection);

    protection->bits = BLUNT | BLADE | KNIFE | MAGIC;

    protection->caster = who;

    protection->absorb = 2*prot_level;

    protection->args = level;

    protection->hit = (: hitCallback :);

    protection->end = (: endCallback :);

    target->AddMagicProtection(protection);

    if( target == who )

    {

        send_messages("", "\n%^BOLD%^CYAN%^A translucent magical barrier suddenly appears around $agent_possessive_noun body.%^RESET%^\n", who, 0, environment(target));

    }

    else

    {

        send_messages("", "\n%^BOLD%^CYAN%^A translucent magical barrier suddenly appears around $agent_possessive_noun body.%^RESET%^\n", who, 0, environment(target));

    }

    return 1;

}



int hitCallback(object who, object agent, int x, class MagicProtection cl)

{

    string str;

    object Caster = cl->caster;



   if( (int)agent->GetUndead() ) return 0;

    str = (string)agent->GetName() || (string)agent->GetShort();

    if( who == Caster )

    {

        who->eventTrainSkill("magic defense",cl->args,x,1);

    }

    else if( Caster && playerp(who) && Caster != who )

    {

        Caster->eventTrainSkill("magic defense",cl->args,0,1);

    }



   send_messages("", "The %^YELLOW%^magical shield%^RESET%^ around $agent_name wavers as $target_name strikes it.", who, agent, environment(who));

    return x;

}



void endCallback(object who)

{

    if( who )

    {

        object bonus = present("light_globe",who);

        send_messages("", "The %^BOLD%^CYAN%^magical shield around $agent_name shatters into nothingness.%^RESET%^", who, 0, environment(who));

        if(bonus){

            bonus->eventMove("/domains/default/room/furnace.c");

        }

    }

}



//int eventDestruct()

//   {

//    this_object()->eventMove("/domains/default/room/furnace.c");

//    debug("Globe destructed");

//    return ::eventDestruct();

//   }





--------------------------





#include <lib.h>

#include <damage_types.h>

#include <vendor_types.h>





inherit LIB_ITEM;

inherit LIB_DETERIORATION;



void create()

{

    item::create();

    SetId(({"light_globe"}));

    SetLong("");

    SetShort("");

    SetInvis(1);

    SetMass(0);

    set_heart_beat(3);

}





string GetAffectLong(object ob)

{

    if(!ob || !living(ob)) return 0;

    return "%^RESET%^%^CYAN%^*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n" +

    "%^RESET%^%^YELLOW%^ " + ob->GetName() + " surrounded by a glowing orb of light%^RESET%^%^CYAN%^ " +

    "%^RESET%^%^CYAN%^*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*%^RESET%^";

}





void heart_beat()

{

    object ob;

    ob=environment();



   if(ob && !living(ob))

    {

        this_object()->eventDestruct();

        return;

    }

}

int eventDestruct()

{

    this_object()->eventMove("/domains/default/room/furnace.c");

    return ::eventDestruct();

}



 



 



The main problem was that you were trying to destruct the

spell, not the object.



Bote that this example was modified to wrk on my mud.

You'll need to change the spell name and object path name.



But i ested this and it works on my mud exactly as you want it to

work on yours.