CONSIDER.C
LIB3/STD/COMMANDS/CONSIDER.C · 3.1 KB
From the archive nm4dos.zip
Download the archive « Back to the archive contents
#include "money.h"
#define TEACH_LEVEL 10
#define LEARN_LEVEL 2
#define SKILL "other"
int consider(string str)
{
object *obs;
int level, i, ok, dif;
if (!str)
{
notify_fail("Syntax: consider <name(s)>.\n");
return 0;
}
obs = find_match(str, environment(this_player()) );
if (!sizeof(obs))
{
notify_fail("Cannot find "+str+" to consider!\n");
return 0;
}
level = (int)this_player()->query_level();
for (i=0;i<sizeof(obs);i++)
{
if (!living(obs[i])) continue;
ok = 1;
dif = (int)obs[i]->query_level() - level;
if (dif > 100)
{
write(obs[i]->query_cap_name()+" is way too tough for you.\n");
continue;
}
if (level > 5)
{
dif /= 10;
if (dif > 2 || dif < -2) dif /= 2;
if (dif > 5) dif = 5;
if (dif < -5) dif = -5;
dif += 5;
write(obs[i]->query_cap_name()+({ " is too weak to bother attacking.\n",
" is some one you look down on.\n",
" is a lot weaker than you are.\n",
" is weaker than you are.\n",
" is slightly weaker than you are.\n",
" is about equal with you.\n",
" is marginally tougher than you.\n",
" is a bit tougher than you.\n",
" is slightly tougher than you are.\n",
" is tougher than you are.\n",
" is a lot tougher than you are.\n",
" looks pretty nasty.\n",
" is way tougher than you.\n"
})[dif]);
}
else
if (dif < 0)
write(obs[i]->query_cap_name()+" would be an easy target.\n");
else
{
dif /= 2;
if (dif > 5) dif = 5;
write(obs[i]->query_cap_name()+({ " is about equal with you.\n",
" is slightly tougher than you are.\n",
" is tougher than you are.\n",
" is a lot tougher than you are.\n",
" looks pretty nasty.\n",
" is into don't think about it region.\n"
})[dif]);
}
}
if (!ok)
{
notify_fail("Failed to consider "+str+".\n");
return 0;
}
return 1;
}
string help()
{
return
"Syntax: consider <monster(s)>\n\n"
+"Consider is the command used to see if the monster you are thinking"
+"about attacking is too high or too low a level for you. Of course I"
+"know all of you are insane. But don't complain if the dragon kills you"
+"ok?\n"
+"Examples\n"
+"> consider dragon\n"
+"You would have to insane to attack the dragon!\n"
+"> consider rat"
+"The rat is an easy target.\n";
}
int teach(object ob)
{
if (this_player()->query_skill(SKILL) < TEACH_LEVEL)
return -2;
if (ob->query_skill(SKILL) < LEARN_LEVEL)
return -1;
ob->add_known_command("consider");
return 1;
}