by Suhis » 08.07.2011 15:04:34
- Code: Select all
/**************************************************************************/
/* Example monster coded by Xman X */
/* Please report all typos and wrong informations to Xman, Thanks */
/**************************************************************************/
inherit "inherit/monster"; /* Note: 1. */
void reset(status arg) { /* Note: 2. */
::reset(arg); /* Note: 3. */
/*
FORGET the all stuff below, use add_object("dir1/dir2/file",amount); instead
eg. add_object("/players/xman/weapons/staff",1);
OR use the new system set_bonus( "EQ", "dir1/dir2/file") it wears automatically
*/
if(!present("staff")) { /* Note: 4. */
object staff; /* Note: 5. */
staff = clone_object("players/xman/weapons/staff"); /* Note: 6. */
move_object(staff, this_object()); /* Note: 7. */
init_command("wield staff"); /* Note: 8. */
}
if(!present("cloak")) {
object cloak;
cloak = clone_object("players/xman/armour/cloak");
move_object(cloak, this_object());
init_command("wear cloak");
}
//add eq system ends here
if(arg) return; /* Note: 9. */
set_name("citizen"); /* Note: 10. */
set_alt_name("goblin"); /* Note: 11. */
set_alias_name("goblin");
set_short("Goblin Citizen"); /* Note: 12. 13. 14. */
set_long("This is a Goblin citizen\n");
set_extra_info("The citizen is very old.\n");
set_gender(1); /* Note: 15. */
set_race("human"); /* Note: 16. */
set_level(8); /* Note: 17. */
add_spell("light", 70); /* Note: 18. */
add_skill("attack", 70); /* Note: 19. */
load_chat(8, ({"Citizen smiles happily.\n", /* Note: 20. */
"Citizen says 'What a lovely day...'\n",
"Citizen says 'What's up?'\n",}));
load_a_chat(15,({"Citizen screams 'Help! Help!'\n", /* Note: 21. */
"Citizen says 'Don't hurt me please'\n",
"Citizen yells 'That's not allowed!'\n",
"Citizen yells 'Please let me go!'\n", }));
set_smell("The citizen smells badly.\n"); /* Note: 22. */
add_money(random(100)); /* Note: 23. */
set_move_at_reset(1); /* Note: 24. */
set_wander(0,120); /* Note: 25. */
set_wander(20); /* NOTE: 25. */
set_no_wander_exits(({ "north" })); /* Note: 26. */
set_hp(5000); /* Note: 27. */
set_max_hp(5000); /* Note: 28. */
set_sp(200); /* Note: 29. */
set_max_sp(200); /* Note: 30. */
set_exp(7000); /* Note: 31. */
set_hpregen(1000); /* Note: 32. */
set_tracking(5); /* note: 33. */
set_wimpy(10); /* note: 34. */
set_new_wander_time(10); /* note: 35. */
set_agressive(1); /* note: 36. */
set_block("north"); /* note: 37. */
set_block_msg("spamspam"); /* note: 37. */
set_undead(1); /* note: 38. */
set_demon(1); /* note: 39. */
add_vmap_group("A"); /* note: 40. */
set_reputations((["wintercity": 5,
"hollowkeep": -3 ])); /*note: 41 */
set_attack_reputation((["wintercity>": -5000 ])); /* note: 42 */
set_block_reputation((["wintercity%": -30 ])); /* note: 43 */
add_cast_spell("heal",110,"kobold",6,0,12); /*note: 44 */
add_use_skill("push",110,0,1,1,5); /* note: 44 */
}
//if you want it to show your name with creator <monster> command
string query_creator() { return "CreatorName"; }
//THINGS BELOW THIS AREN'T NEEDED IF YOU DONT WANT TO USE THEM
/* talking etc */
void init()
{
//needed, without this line other commands with monsters will not work
::init();
//adds action for command ask which calls cmd_ask function with arg
add_action("cmd_ask", "ask");
}
//called with ask command
status cmd_ask(string arg)
{
//if player writes only 'ask' then we are not continuing this code
if(!arg) return 0;
//if arg is NOT milk ( == is milk)
if(arg != "milk")
{
//if for example ask bread doesn't found anything then notify fail will change that What? to Ask what?
notify_fail("Ask what?\n");
return 0;
}
//now command is 'ask milk' and we are executing that code part which gives milk
write("Here is your milk.\n");
//and saying to room, excluding this_player() (who is user), this_object() (monster) are called with query_name() (which returns citizen now)
say(this_object() -> query_name() + " gave milk to " + this_player() -> query_name() +"\n", ({ this_player() }));
//moving object which we clone to this_player() (who is again player who writed ask milk)
move_object(clone_object("dir/dir/milk.c"), this_player());
//returning 1 so we don't give that What? message
return 1;
}
/**************************************************************************
-=[ Notes ]=-
1. inherit "inherit/monster";
- Inherit is an effeicient way to use memory. Inherit means, use the
functions of the inherited object, but make a copy of all the global
variables used in that object for my use. So in effect this object only
requires memory for its 'object header' and global variables.
2. void reset(status arg)
- The reset function is called the first time when a file is loaded into
memory (then we call it an object), or when an object is cloned with an
arguement 'arg' of 0. Thereafter reset is called 1 to 2 hours later
with an 'arg' of 1.
3. ::reset(arg);
- As soon as any function is written into this file, it will override
any functions of the same name which it has inherited. Note the if
any functions in that inherited file call this function name, it will
call this function. If you wish to use an overridden function in
the parent object then you must use the scoping operator. :: is known as
the scoping operator. "inherit/monster" has the reset() function to
initialise some variables, but to most importantly enable_commands().
enable_commands() is an efun which flags this object to allow it
to use actions(). Without actions the monster cannot wear, wield, or
move. So it is important to call ::reset(arg) first.
4. if(!present("staff"))
- There are a number of ways to determine if a monster, or any object
in fact has the equipment on them. The method in the example is
recommended as it will replace equipment stolen by thieves. There
are alternative methods.
Alternative 1:
Object is unique throughout mud.
inherit "inherit/monster";
object staff;
void reset(status arg) {
::reset(arg);
if(!staff) {
Alternative 2:
Less efficient method of example. But useful when the monster is
carrying two or more pieces of the same equipment.
inherit "inherit/monster";
object staff;
void reset(status arg) {
::reset(arg);
if(!present(staff)) {
5. object staff;
- Declare the variable 'staff' as an object (object is really an LPC
data structure, but you don't need to know that).
6. staff = clone_object("players/xman/weapons/staff");
- An alternative to cloning an already pre-configured object, is to
clone the configurable object and configure it direclty. If you
are going to use the weapon more then once it is recommended that you
use a pre-configured file. Cloning is very similar to inherit. It will
make a new object that has a copy of global variables, but using the
functions of the cloned object. This saves memory, when used in
conjunction with the configurable objects (most objects in /inherit
are configurable).
Alternative 1:
staff = clone_object("inherit/weapon");
staff->set_name("staff");
staff->set_alt_name("Citizen staff");
staff->set_short("Citizen Staff");
staff->set_long("The staff is a gnarled piece of wood.\n");
staff->set_info("There is nothing magical about the staff.\n");
staff->set_smell("The wood smells quite smoky.\n");
staff->set_value(50);
staff->set_weight(3);
staff->set_wc(10);
move_object(staff, this_object());
Alternative 2:
This is a shorthand of that shown in example, though long filenames
tend to cramp it.
if(!present("staff")) {
move_object(clone_object("players/xman/weapons/staff"),this_object());
}
7. move_object(staff, this_object());
- When an object is first loaded, or cloned it has no environment. Or
in otherwords an efun environment() call will return 0. Rooms usually
have no environment, and are not moved. But equipment of monsters are
moved to the monster, which is this_object().
8. init_command("wield staff");
- This will command the monster to wield the staff. For appearances
it looks better when a monster is wielding or wearing their
equipment. (See also Note: 3)
Alternative 1:
init_command() is a left over from the original mudlib. But is still
widely used.
command("wield staff", this_object());
9. if(arg) return;
- The reset function is called every hour or so with an arg of 1 after
it is originally coded. It is really a waste of cpu time to reconfigure
stuff in the monster at each reset. So we return after checking to
see if equipment (or other statuses) is still on the monster.
10. set_name("goblin");
- This sets the living name of the monster with the efun.
The monster will be able to be located with
find_living(name). However, if there is more then one monster with
the same living name, then only the last one which used set_living_name
will be found. Flagging the monster as living will allow it to
catch write(), tell_object(), say(), and tell_room() communication
messages with the function catch_tell(). This allows greater player
- npc interaction.
11. set_alt_name("citizen");
- These set alternative ids that the goblin citizen can be identified.
So the Goblin can be call "citizen", "goblin", or "goblin citizen".
12. set_short("Goblin citizen");
- This is what a player will see when they first walk into the
room. If this is not set, then the monster is invisible to the player.
13. set_long("This is a Goblin citizen");
- This is the message the player sees when they 'look at citizen'.
14. set_extra_info("The citizen is very old.\n");
- This is the message the player sees when they 'examine citizen'
15. set_gender(1);
- 0. neuter, 1. male, and 2. female.
16. set_race("human");
- The race is very important. A lot of spells use the race for
spell/skill effects.
17. set_level(8);
- The level determines the fighting difficulty of a monster.
Setting the level will set the appropriate hit points, weapon class,
armour class and experience for that monster.
18. add_spell("light", 70);
- You can add spells on the monster, this gives spell light 70%
19. add_skill("attack", 70);
- You can add skills on the monster, this gives skill attack 70%
20. load_chat(8,({"Citizen says 'What a lovely day...'\n", }));
- You can add chat messages on the monster, this says
'What a lovely day...' when he is not fighting.
21. load_a_chat(15,({"Citizen yells 'That's not allowed!'\n", }));
- You can add chat messages when the monster is fighting, this says
'That's not allowed!' when he is fighting.
22. set_smell("The citizen smells badly.\n");
- You can 'smell citizen'
23. add_money(random(100));
- You can give some money to monster, this gives random 100 gold coins.
24. set_move_at_reset(1);
- Make him move to a new location at each reset.
25. set_wander(0,120);
- Wander every 4 minutes
set_wander(20); works also, (it doesn't need 2 arguments)
26. set_no_wander_exits(({"north"}));
- This monster won't wander north
27. set_hp(5000);
- With this you can give some hit points to monster
28. set_max_hp(5000);
- With this you can give some max hit points to monster
29. set_sp(200);
- With this you can give some spell points to monster
30. set_max_sp(200);
- With this you can give some max spell points to monster
31. set_exp(7000);
- With this you can give set monsters experience
- DON'T USE THIS IN NORMAL EXP MONSTERS (why not?.)
32. set_hpregen(1000);
- with this you can give monster additional hpregen
33. set_tracking(5);
- with this monsters start to track players after player leaves from combat.
- values are 0-5, five being the highest.
34. set_wimpy(10);
- with this monsters can wimpy when having low health.
35. set_new_wander_time(10);
- >0 will make monster move randomly every nth hb in same area
- (blocked by different directory in filename and no_wander_exits from room's inherit)
36. set_agressive(1);
- 0 not agressive, 1 agressive
37. set_block("north");
- blocks north.
set_block_msg("spamspam");
- what it says when it blocks.
38. set_undead(1);
-obvious, sets it to be undead
39. set_demon(1);
- ...
40. add_vmap_group("A");
- this is a bit more complicated, outworld (map) has mask file which has different letters for monsters which can walk where.
41. set_reputation((["wintercity": 5, "hollowkeep": -3 ]))
- this sets which reputations it will give after monster dies
- checking which reputations can be used should be checked from /adm/daemons/reputation_d.c
42. set_attack_reputation((["wintercity>": -5000 ]));
with > using reverse calculation so will attack if player has -5000 or over (-4999) reputation.
without > will attack if player has below -5000 rep,
also % can be use then numbers need to be 0- 100 or -100 - 0, then calculating from min or max reputation
43. set_block_reputation((["wintercity%": -30 ]));
same rules apply here as applies on note 42.
44. The 1st argument of add_cast_spell/add_use_skill is
the name of the spell/skill
The 2nd argument of add_cast_spell/add_use_skill is
the percent of skill/spell
The 3rd argument of add_cast_spell/add_use_skill is
the target (if 0 then primary_attack)
The 4th argument of add_cast_spell/add_use_skill is
the time, after that time you can cast THIS spell
or skill again... if this is for example 10 you
can cast THIS spell after 10 ROUNDS
The 5th argument means that monster must be in
battle to cast THIS spell/use THIS skill,
if 0 , monster doesn't have to be in battle
to cast THIS spell/use THIS skill/spell ;>
The 6th argument means the time, that after
casted THIS spell, how many ROUNDS after it
can cast NEXT spell.
*/
-
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