sword example with special hit

sword example with special hit

Postby Suhis » 08.07.2011 15:17:54

Code: Select all
inherit "inherit/weapon";


void reset(status arg) {
  if(arg) return;
  set_name("titanium sword");
  set_alias("sword");
  set_short("a titanium sword");
  set_long(
    "This is a powerful sword, made from a silvery grey, light weight,\n"+
    "metallic substance. It has intricate carvings on the hilt.\n");
  set_value(2000);
  set_wc(20);
  set_weight(1);
  set_type("2h sword");

  //CONVI
  set_read("There is nothing readable you can make out in the carvings.\n");
}

//this is called from battle, it allows players to have special hits when this weapon hits, it isn't needed if you don't want to make special hits
void special_hit(object target)
{   
    //this throws dice which has numbers 0-19, when ever 0 comes it will do whatever is inside of that if
    if(!random(20))
    {
        tell_object(target, "what we tell to target.\n"); //that \n is linefeed
        tell_object(environment(this_object()), "what we tell to wielder of this.\n");
        tell_room(environment(target), "what we tell to others who are in same room with target.\n", ({ target, environment(this_object()) }) ); // things inside of that ({ }) is who we exclude from that telling
        target -> hit_player(100);
    }
}

//this isn't needed if you don't want to make wield check for weapon
status wield(string str)
{
  if(this_player()->query_dexterity() > 15)
  {
    write("As you wield the sword you notice how easily "+
          "you can work with it.\n");
  }
  else if (this_player()->query_dexterity() > 10)
  {
    write("This sword feels a little difficult to handle, "+
          "but will still serve\nyou well in battle.\n");
  }
  else if (this_player()->query_dexterity() > 5)
  {
    write("Wielding the sword, you notice how much heavier it now seems,\n"+
     "but you get the feeling you will still hit well with it.\n");
  }
  else
  {
    write("The sword suddenly gets too heavy for you to wield.\n");
    return 1;
  }
  return ::wield(str);
}


//if you want it to show your name with creator <item> command
string query_creator() { return "CreatorName"; }
Suhis
 
Posts: 180
Joined: 31.01.2004 13:31:16

Return to Manuals

Who is online

Users browsing this forum: No registered users and 1 guest

cron