Author Topic: message() question  (Read 2426 times)

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
message() question
« on: September 17, 2006, 08:35:09 am »
Recently created this spell:



code:


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

inherit LIB_SPELL;

static void create()
{
    spell::create();
    SetSpell("pblast");
    SetRules("","LIV");
    SetSpellType(SPELL_COMBAT);
    SetRequiredMagic(10);
    SetSkills(([ "conjuring" : 8, "magic attack" : 10 ]));
    SetMagicCost(30, 0);
    SetStaminaCost(20, 16);
    SetDifficulty(0);
    SetHelp("Syntax: <cast pblast>\n\n"
      " ");
}

int eventCast(object who, int level, mixed limbs, object array targets)
   {
    object target;
    target = targets[0];

    send_messages("", "%^BOLD%^WHITE%^A ray of white light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^",
get_livings(environment(this_player())), target);
    target->eventReceiveDamage(target,MAGIC,(10 *5),0);

    send_messages("", "%^BOLD%^GREEN%^A ray of green light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^",
get_livings(environment(this_player())), target);
    target->eventReceiveDamage(target,ACID,(10 *5),0);

    send_messages("", "%^BOLD%^BLUE%^A ray of blue light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^",
get_livings(environment(this_player())), target);
    target->eventReceiveDamage(target,GAS,(10 *5),0);

    send_messages("", "%^BOLD%^MAGENTA%^A ray of purple light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^",
get_livings(environment(this_player())), target);
    target->eventReceiveDamage(target,DISEASE,(10 *5),0);

    send_messages("", "%^ORANGE%^A ray of orange light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^",
get_livings(environment(this_player())), target);
    target->eventReceiveDamage(target,PSIONIC,(10 *5),0);
    send_messages("", "%^BOLD%^YELLOW%^A ray of yellow light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^",
get_livings(environment(this_player())), target);
    target->eventReceiveDamage(target,ANOXIA,(10 *5),0);

    send_messages("", "%^BOLD%^RED%^A ray of red light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^",
get_livings(environment(this_player())), target);
    target->eventReceiveDamage(target,SONIC,(10 *5),0);

    send_messages("", "%^BOLD%^BLACK%^A ray of DEATH leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^",
get_livings(environment(this_player())), target);
    target->eventReceiveDamage(target,DEATHRAY,(10 *5),0);
  return 1;
  }





And it produces:



A ray of white light leaps from your hands and strikes Mage!

You lash out at Mage's body, but miss it completely.

     HP { 791/800 }      SP { 402/550}     EP { 373/550 }



When I change the code to :



code:


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

inherit LIB_SPELL;

static void create()
{
    spell::create();
    SetSpell("pblast");
    SetRules("","LIV");
    SetSpellType(SPELL_COMBAT);
    SetRequiredMagic(10);
    SetSkills(([ "conjuring" : 8, "magic attack" : 10 ]));
    SetMagicCost(30, 0);
    SetStaminaCost(20, 16);
    SetDifficulty(0);
    SetHelp("Syntax: <cast pblast>\n\n"
      " ");
}

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

    object target;
    target = targets[0];

    send_messages("", "%^BOLD%^WHITE%^A ray of white light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^",who, target);
    target->eventReceiveDamage(target,MAGIC,(10 *5),0);

    send_messages("", "%^BOLD%^GREEN%^A ray of green light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^", who, target);
    target->eventReceiveDamage(target,ACID,(10 *5),0);

    send_messages("", "%^BOLD%^BLUE%^A ray of blue light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^", who, target);
    target->eventReceiveDamage(target,GAS,(10 *5),0);

    send_messages("", "%^BOLD%^MAGENTA%^A ray of purple light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^", who, target);
    target->eventReceiveDamage(target,DISEASE,(10 *5),0);

    send_messages("", "%^ORANGE%^A ray of orange light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^", who, target);
    target->eventReceiveDamage(target,PSIONIC,(10 *5),0);

    send_messages("", "%^BOLD%^YELLOW%^A ray of yellow light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^", who, target);
    target->eventReceiveDamage(target,ANOXIA,(10 *5),0);

    send_messages("", "%^BOLD%^RED%^A ray of red light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^", who, target);
    target->eventReceiveDamage(target,SONIC,(10 *5),0);

    send_messages("", "%^BOLD%^BLACK%^A ray of DEATH leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^", who, target);
    target->eventReceiveDamage(target,DEATHRAY,(10 *5),0);


  return 1;
  }








It produces this:





A ray of white light leaps from your hands and strikes Mage!

A ray of green light leaps from your hands and strikes Mage!

A ray of blue light leaps from your hands and strikes Mage!

A ray of purple light leaps from your hands and strikes Mage!

A ray of orange light leaps from your hands and strikes Mage!

A ray of yellow light leaps from your hands and strikes Mage!

A ray of red light leaps from your hands and strikes Mage!

A ray of DEATH leaps from your hands and strikes Mage!



BUT no one else in the room can see the spell hitting the target.  Could someone point me to the right syntax, or maybe a better way of doing this?

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1022
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
message() question
« Reply #1 on: September 17, 2006, 01:04:11 pm »

#include <lib.h>

#include <armor_types.h>

#include <damage_types.h>

#include <position.h>

#include <terrain_types.h>



inherit LIB_ITEM;



static void create() {

    item::create();

    SetKeyName("key");

    SetId( ({ "key", "sample key" }) );

    SetAdjectives( ({ "simple","sample" }) );

    SetShort("a sample key");

    SetLong("It is a simple sample key with no markings.");

    SetMass(50);

    SetBaseCost(1);

    SetDisableChance(100);

}

void init(){

::init();

add_action("DoThing","thing");

}



int DoThing()

   {



   object target = get_random_living(environment(this_player()),2);

    object who = this_player();

    object env = environment(this_player());



   send_messages("", "%^BOLD%^WHITE%^A ray of white light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^",who, target,env);

    target->eventReceiveDamage(target,MAGIC,(10 *5),0);



   send_messages("", "%^BOLD%^GREEN%^A ray of green light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^", who, target,env);

    target->eventReceiveDamage(target,ACID,(10 *5),0);



   send_messages("", "%^BOLD%^BLUE%^A ray of blue light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^", who, target,env);

    target->eventReceiveDamage(target,GAS,(10 *5),0);



   send_messages("", "%^BOLD%^MAGENTA%^A ray of purple light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^", who, target,env);

    target->eventReceiveDamage(target,DISEASE,(10 *5),0);



   send_messages("", "%^ORANGE%^A ray of orange light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^", who, target,env);

    target->eventReceiveDamage(target,PSIONIC,(10 *5),0);



   send_messages("", "%^BOLD%^YELLOW%^A ray of yellow light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^", who, target,env);

    target->eventReceiveDamage(target,ANOXIA,(10 *5),0);



   send_messages("", "%^BOLD%^RED%^A ray of red light leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^", who, target,env);

    target->eventReceiveDamage(target,SONIC,(10 *5),0);



   send_messages("", "%^BOLD%^BLACK%^A ray of DEATH leaps from $agent_possessive_noun hands and strikes $target_name!%^RESET%^", who, target,env);

    target->eventReceiveDamage(target,DEATHRAY,(10 *5),0);





  return 1;

  }



 



This key will smite a random npc in your environment

when you type the command: thing



You were pretty much almost there, but you omitted

the object that these messages were going to. In this case,

it's the room, as specified by the env variable.



Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
message() question
« Reply #2 on: September 17, 2006, 08:18:05 pm »
I see, that's what I was trying to do... oh well! Thanks, I've got it now.