Go to the documentation of this file.
35 #define WANT_UNARMED_SKILLS
53 static void attack_hth(
object *
pl,
int dir,
const char *
string,
object *skill);
78 LOG(
llevError,
"init_skills: too many skills, increase MAX_SKILLS and rebuild server!");
114 assert(
"invalid skill!");
141 if (!skill && !skill_tool)
206 int num_names, highest_level_skill=0, i;
212 if (!strchr(
name,
',')) {
214 skill_tools[0] = NULL;
220 ourname = strdup(
name);
222 if ((
skill_names[0] = strtok_r(ourname,
",", &lasts)) == NULL) {
224 LOG(
llevError,
"find_skill_by_name: strtok_r returned null, but strchr did not?\n");
228 skill_tools[0] = NULL;
232 while ((
skill_names[num_names] = strtok_r(NULL,
",", &lasts)) != NULL) {
238 skills[num_names] = NULL;
239 skill_tools[num_names] = NULL;
254 for (i = 0; i<num_names; i++) {
259 if (!skill ||
tmp->level > skill->
level) {
261 highest_level_skill=i;
270 skill_tools[i] =
tmp;
306 object *skill = NULL, *skill_tool = NULL;
356 old_range =
who->contr->shoottype;
359 if (new_skill &&
who->chosen_skill &&
who->chosen_skill->skill == new_skill->
skill) {
366 if (
who->chosen_skill)
377 who->contr->shoottype = old_range;
390 who->chosen_skill = NULL;
422 int do_skill(
object *
op,
object *part,
object *skill,
int dir,
const char *
string) {
423 int success = 0, exp = 0;
440 LOG(
llevError,
"do_skill: asked for skill %s but couldn't find matching SKILL archetype.\n", skill->
skill);
460 "You come to earth.");
464 "You rise into the air!.");
471 exp = success =
steal(
op, dir, skill);
479 exp = success =
hide(
op, skill);
483 success =
jump(
op, dir, skill);
559 "This skill is not currently implemented.");
565 "There is no special attack for this skill.");
569 success =
pray(
op, skill);
586 "This skill is already in effect.");
598 LOG(
llevDebug,
"%s attempted to use unknown skill: %d\n",
name,
op->chosen_skill->stats.sp);
611 op->speed_left -= 1.0;
661 float base,
value, lvl_mult;
677 op_lvl =
MAX(
who->map->difficulty, 1);
681 op_exp =
op->stats.Cha > 1 ?
op->stats.Cha :
op->stats.exp;
684 op_exp =
op->stats.exp;
687 op_lvl += 5*abs(
op->magic);
695 return ((int64_t)(op_exp*0.1)+1);
718 lvl_mult = (float)op_lvl/(
float)(skill->
level ? skill->
level : 1);
723 value = base*lvl_mult;
727 #ifdef SKILL_UTIL_DEBUG
728 LOG(
llevDebug,
"calc_skill_exp(): who: %s(lvl:%d) op:%s(lvl:%d)\n",
who->name, skill->
level,
op ?
op->name :
"", op_lvl);
730 return ((int64_t)
value);
753 if (!scroll->
skill) {
754 LOG(
llevError,
"skill scroll %s does not have skill pointer set.\n", scroll->
name);
785 LOG(
llevError,
"skill scroll %s does not have valid skill name (%s).\n", scroll->
name, scroll->
skill);
811 rv = (
int)((100.0f*((
float)
a)/((
float)
b))+0.5f);
832 return num == 0 ? 1 : floor( log10( labs(num) ) ) + 1;
853 int i, num_skills_found = 0;
856 const char *search =
parms;
857 bool long_format =
false;
862 while ( *search && *search !=
' ' ) ++search;
863 while ( *search ==
' ' ) ++search;
867 if (search && strstr(
tmp->name, search) == NULL)
873 snprintf(skills[num_skills_found++],
MAX_BUF,
"[fixed]%-20slvl:%3d (xp:%"FMT64"/%"FMT64")%-*sperm lvl:%3d (xp:%"FMT64"/%"FMT64") ",
883 snprintf(skills[num_skills_found++],
MAX_BUF,
"[fixed]%-20slvl:%3d (xp:%"FMT64"/%"FMT64"/%d%%)",
890 snprintf(skills[num_skills_found++],
MAX_BUF,
"[fixed]%-20slvl:%3d (xp:%"FMT64"/%"FMT64")",
903 "Your character has too many skills.\n"
904 "Something isn't right - contact the server admin");
910 if ( search && *search ) {
912 "Player skills%s: (matching '%s')", long_format ?
" (long format)":
"",search);
915 "Player skills%s:", long_format ?
" (long format)":
"");
918 if (num_skills_found > 1)
919 qsort(skills, num_skills_found,
MAX_BUF, (
int (*)(
const void *,
const void *))strcmp);
921 for (i = 0; i < num_skills_found; i++) {
927 if (strcmp(cp,
"none") == 0)
931 "You can handle %d weapon improvements.\n"
933 "Your equipped item power is %d out of %d\n",
935 cp ? cp :
"no god at current time",
936 op->contr->item_power,
op->level);
966 && !strncasecmp(
string,
tmp->skill,
MIN(strlen(
string), strlen(
tmp->skill)))) {
971 && !strncasecmp(
string,
tmp->skill,
MIN(strlen(
string), strlen(
tmp->skill)))) {
978 "Unable to find skill %s",
983 len = strlen(skop->
skill);
990 if (len >= strlen(
string)) {
994 while (*
string == 0x20)
996 if (strlen(
string) == 0)
1000 #ifdef SKILL_UTIL_DEBUG
1001 LOG(
llevDebug,
"use_skill() got skill: %s\n", sknum > -1 ? skills[sknum].
name :
"none");
1034 object *best_skill = NULL;
1037 if (
op->contr->unarmed_skill) {
1053 "Unable to find skill %s - using default unarmed skill",
1054 op->contr->unarmed_skill);
1058 for (i = 0; i <
sizeof(unarmed_skills); i++)
1059 if (best_skill->
subtype == unarmed_skills[i])
1061 if (i <
sizeof(unarmed_skills))
1083 last_skill =
sizeof(unarmed_skills);
1096 for (i = 0; i < last_skill; i++) {
1139 if (
op->chosen_skill) {
1142 for (i = 0; unarmed_skills[i] != 0; i++)
1143 if (
op->chosen_skill->subtype == unarmed_skills[i]) {
1144 skill =
op->chosen_skill;
1155 "You have no unarmed combat skills!");
1160 if (skill !=
op->chosen_skill) {
1165 "Couldn't change to skill %s",
1175 if (!
op->current_weapon) {
1178 LOG(
llevError,
"Player %s does not have current weapon set but flag_ready_weapon is set\n",
op->name);
1181 LOG(
llevError,
"Could not find applied weapon on %s\n",
op->name);
1182 op->current_weapon = NULL;
1188 op->current_weapon =
tmp;
1193 if (!
op->chosen_skill ||
op->current_weapon->skill !=
op->chosen_skill->skill) {
1195 assert(found_skill != NULL);
1203 if (
op->type ==
PLAYER &&
op->contr->tmp_invis) {
1204 op->contr->tmp_invis = 0;
1307 && (
pl->contr->
party != NULL &&
pl->contr->
party == tmp2->contr->party))
1317 "There is nothing to attack!");
1342 static void attack_hth(
object *
pl,
int dir,
const char *
string,
object *skill) {
1347 if (weapon != NULL) {
1354 "You are unable to unwield %s in order to attack with %s.",
1355 weaponname, skill->
name);
1359 "You unwield your weapon in order to attack.");
1390 "You have no ready weapon to attack with!");
sstring add_refcount(sstring str)
static int free_skill_index()
#define MSG_TYPE_ATTACK_MISS
object * object_find_by_type_and_skill(const object *who, int type, const char *skill)
int use_alchemy(object *op)
void object_update(object *op, int action)
int use_skill(object *op, const char *string)
#define QUERY_FLAG(xyz, p)
void archetypes_for_each(arch_op op)
int get_learn_spell(int stat)
uint8_t permanent_exp_ratio
#define MSG_TYPE_ATTACK_DID_HIT
int write_on_item(object *pl, const char *params, object *skill)
int use_oratory(object *pl, int dir, object *skill)
object * object_find_by_type_applied(const object *who, int type)
int singing(object *pl, int dir, object *skill)
int skill_ident(object *pl, object *skill)
int do_skill(object *op, object *part, object *skill, int dir, const char *string)
int find_traps(object *pl, object *skill)
static int clipped_percent(int64_t a, int64_t b)
int get_skill_client_code(const char *skill_name)
short freearr_x[SIZEOFFREE]
short freearr_y[SIZEOFFREE]
static event_registration m
void link_player_skills(object *op)
int pick_lock(object *pl, int dir, object *skill)
const char * determine_god(object *op)
void query_name(const object *op, char *buf, size_t size)
int shop_describe(const object *op)
int remove_trap(object *op, object *skill)
void fatal(enum fatal_error err)
int64_t calc_skill_exp(const object *who, const object *op, const object *skill)
void fix_object(object *op)
#define GET_MAP_MOVE_BLOCK(M, X, Y)
void clear_skill(object *who)
#define MSG_TYPE_SKILL_MISSING
void skill_attack(object *tmp, object *pl, int dir, const char *string, object *skill)
int pray(object *pl, object *skill)
const char * skill_names[MAX_SKILLS]
#define FLAG_CAN_USE_SKILL
#define MSG_TYPE_VICTIM_WAS_HIT
int skill_throw(object *op, object *part, int dir, object *skill)
int is_dragon_pl(const object *op)
static void do_skill_attack(object *tmp, object *op, const char *string, object *skill)
int exp_level(int64_t exp)
int64_t level_exp(int level, double expmul)
static void attack_melee_weapon(object *op, int dir, const char *string, object *skill)
int change_skill(object *who, object *new_skill, int flag)
int random_roll(int min, int max, const object *op, int goodbad)
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
#define PERM_EXP(exptotal)
int learn_skill(object *pl, object *scroll)
#define MSG_TYPE_SKILL_ERROR
#define MSG_TYPE_SKILL_FAILURE
#define MSG_TYPE_SKILL_LIST
void apply_anim_suffix(object *who, const char *suffix)
void LOG(LogLevel logLevel, const char *format,...)
const Face * skill_faces[MAX_SKILLS]
#define CLEAR_FLAG(xyz, p)
void do_harvest(object *pl, int dir, object *skill)
#define SK_SUBTRACT_SKILL_EXP
int apply_special(object *who, object *op, int aflags)
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
static void do_each_skill(archetype *at)
void meditate(object *pl, object *skill)
int steal(object *op, int dir, object *skill)
static void attack_hth(object *pl, int dir, const char *string, object *skill)
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
void show_skills(object *op, const char *parms)
#define OB_TYPE_MOVE_BLOCK(ob1, type)
static object * adjust_skill_tool(object *who, object *skill, object *skill_tool)
object * find_skill_by_number(object *who, int skillno)
#define MSG_TYPE_SKILL_SUCCESS
int attack_ob(object *op, object *hitter)
object * give_skill_by_name(object *op, const char *skill_name)
int hide(object *op, object *skill)
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
static object * find_best_player_hth_skill(object *op)
#define FLAG_READY_WEAPON
static int digits_in_long(int64_t num)
#define FOR_INV_PREPARE(op_, it_)
object * find_skill_by_name(object *who, const char *name)
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
int jump(object *pl, int dir, object *skill)