Author Topic: Suggestions wanted  (Read 7361 times)

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Suggestions wanted
« on: September 13, 2006, 04:43:29 pm »

Tig this is what I was going for:



> cast shield



You cast shield and are surrounded by a globe of energy.



l me

Capo the creator



*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

*                            Surrounded by Energy                              *

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

Standing before you is Capo the administrator of Haven_RPG

The male human is in top condition.

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



Now.. I know that I need to create an object that uses eventReceiveDamage... I think the idea is to set damage at whatever amount I want it to absorb before going away and then go away.



But how do I get the above output?  Any ideas?



Thanks!


Offline tigwyk

  • Acquaintance
  • *
  • Posts: 45
    • View Profile
Suggestions wanted
« Reply #1 on: September 13, 2006, 04:46:02 pm »

AHA!



Yes, if you look at /domains/town/obj/wound.c, it uses a function to add a line of description to someone's long description. It will do EXACTLY what you want, how bout that, eh? :)


Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Suggestions wanted
« Reply #2 on: September 13, 2006, 05:22:30 pm »
code:


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

inherit LIB_SPELL;

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;
    object thing;
    target = this_player();
    thing = new("/domains/foo/obj/light_globe.c");
    send_messages("", "A %^BOLD%^CYAN%^translucent magical barrier suddenly appears around $agent_possessive_noun body.%^RESET%^", who, 0, environment(target));
    thing->eventMove(environment(target));
   }
    return 1;
}




code:


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

inherit LIB_ITEM;

int Duration = 50;

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 glowi$
   }

void heart_beat()

 {
    object ob;
    ob=environment();


        if(!living(ob))
          {
           this_object()->eventDestruct();
           return;
          }

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







When I go to update globe.c this is what I get:





update globe.c

/spells/globe.c line 31: syntax error

   

---

*Error in loading object '/spells/globe'

Object: /secure/sefun/sefun at /secure/sefun/load_object.c:14



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

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

'cmd' at /secure/cmds/creators/update at line 109

'eventUpdate' at /secure/cmds/creators/update at line 135

'load_object' at /secure/sefun/sefun at /secure/sefun/load_object.c:14

'CATCH' at /secure/sefun/sefun at /secure/sefun/load_object.c:14

Trace written to /log/catch

/spells/globe.c line 31: syntax error

   

---

*Error in loading object '/spells/globe'

Object: /secure/cmds/creators/update at line 148



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

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

'cmd' at /secure/cmds/creators/update at line 109

'eventUpdate' at /secure/cmds/creators/update at line 148

'CATCH' at /secure/cmds/creators/update at line 148

Trace written to /log/catch

/spells/globe: Error in update

*Error in loading object '/spells/globe

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Suggestions wanted
« Reply #3 on: September 13, 2006, 05:28:50 pm »
code:


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%^*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n";
   }



Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Suggestions wanted
« Reply #4 on: September 13, 2006, 05:36:06 pm »

From my pov:



cast globe

You close your eyes and begin uttering an incantation.

A translucent magical barrier suddenly appears around your body.

> l me

Capo the creator

Standing before you is Capo the administrator of Haven_RPG

The male human is in top condition.



a wooden staff

a medical tricorder



Capo closes his eyes and closes uttering an incantation.

A translucent magical barrier suddenly appears around Capo's body.



> l capo

Capo the creator

Standing before you is Capo the administrator of Haven_RPG

The male human is in top condition.



a wooden staff

a medical tricorder


Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Suggestions wanted
« Reply #5 on: September 13, 2006, 05:49:50 pm »

Success... Thanks for the help.  Now I need to add in the damage absorption part.



l me

Capo the creator

Standing before you is Capo the administrator of Haven_RPG

The male human is in top condition.

*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

       Capo surrounded by a glowing orb of light          

*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*



silver sword (wielded in right hand)


Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Suggestions wanted
« Reply #6 on: September 13, 2006, 06:54:31 pm »

Tig:



I looked at the eventReceiveDamage function in both combat.c, armor.c, deterioration.c, etc... but Im still not clear on how what we discussed should work.



If there's an example of this sitting around I would be grateful!


Offline tigwyk

  • Acquaintance
  • *
  • Posts: 45
    • View Profile
Suggestions wanted
« Reply #7 on: September 13, 2006, 07:24:44 pm »
Well unfortunately you may end up having to use a shadow, but dear god I hope not. Basically you need to steal eventReceiveDamage before it hits the player, otherwise your shield will never deteriorate and the player will get hit as usual. Does buffer offer any enlightenment? I haven't looked at it but I thought it was basically the same idea. I guess I'll check it out further.

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Suggestions wanted
« Reply #8 on: September 13, 2006, 07:56:18 pm »
code:


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

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;
    target = this_player();
    thing = new("/domains/foo/obj/light_globe.c");
    send_messages("", "\n%^BOLD%^CYAN%^A translucent magical barrier suddenly appears around $agent_possessive_noun body.%^RESET%^\n", who, 0, environment(target));
    thing->eventMove(this_player());
    int prot_level, skill, wis;
    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");
    return ::eventDestruct();
   }







Doesn't seem to work :(



Thoughts?

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1022
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Suggestions wanted
« Reply #9 on: September 13, 2006, 07:57:03 pm »

While using a shadow *would* work, I don't

recommend it, because there's already a system in place

for intercepting damage.



LIB_BODY has a function called eventCheckProtection() which

is, admittedly, rather complicated. The way you add a protection

to someone is to call AddMagicProtection() on them, and

send that function a class containing the details of the

protection.



The buffer spell provides an example of how to add a protection. Take

a look at eventCast(). You'll see how a protection is

assembled and sent to the player. This is what you'll want

to emulate in your shielding process.



Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1022
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Suggestions wanted
« Reply #10 on: September 13, 2006, 07:59:39 pm »

This line: int prot_level, skill, wis;



It declares vars, but it does so after other statements.

That's a no-no. Any declarations have to happen

before anything else in a function.


Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Suggestions wanted
« Reply #11 on: September 13, 2006, 08:17:00 pm »
Yeah, I had noticed and fixed that after I posted... I can get the spell to cast, and to work, but I cant get it to go "away" properly.

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
Suggestions wanted
« Reply #12 on: September 13, 2006, 08:25:53 pm »

This is what I am refering to:



ighter easily dodges your inept attack.

After a flurry of attacks, you hit absolutely nothing.

     HP { 550/550 }      SP { 455/550}     EP { 534/550 }



The magical shield around you shatters into nothingness.

The magical shield around you shatters into nothingness.

Your right hand is severed!

Your right arm is severed!

Fighter bellows loudly and destroys you utterly in your right arm with his



At this point the globes surrounding my character should be removed but:



> l me

Capo the creator

Standing before you is Capo the administrator of Haven_RPG

The male human is badly injured.

He is missing a right arm and a right hand.

*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

       Capo surrounded by a glowing orb of light          

*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

       Capo surrounded by a glowing orb of light          

*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*



silver sword



Any ideas?


Offline detah

  • BFF
  • ***
  • Posts: 190
  • Ruler of 2D
    • View Profile
Suggestions wanted
« Reply #13 on: September 14, 2006, 06:28:09 am »

It seems that eventDestruct() is not being called at all.

To confirm this, add



write("Globe destructed.\n");



right before the eventMove line in eventDestruct().



Now if you dont see that message, then you know that eventDestruct is not being called at all.



As an aside, you could also make the globe visible during testing, so you can see it in your inventory. This will eliminate the need to add debugging code in the eventDestruct() fun.


Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1022
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Suggestions wanted
« Reply #14 on: September 14, 2006, 07:16:45 am »

Excellent idea.



I might suggest using debug() rather than write(), because

debug messages flush to the user immediately. writes

get queued.