35 #define WANT_UNARMED_SKILLS 52 static void attack_hth(
object *
pl,
int dir,
const char *
string,
object *skill);
74 skill_faces[i] = NULL;
80 if (i == MAX_SKILLS) {
81 LOG(
llevError,
"init_skills: too many skills, increase MAX_SKILLS and rebuild server!");
104 assert(
"invalid skill!");
131 if (!skill && !skill_tool)
196 int num_names, highest_level_skill=0, i;
202 if (!strchr(name,
',')) {
203 skill_names[0] = name;
204 skill_tools[0] = NULL;
212 if ((skill_names[0] =
strtok_r(ourname,
",", &lasts)) == NULL) {
214 LOG(
llevError,
"find_skill_by_name: strtok_r returned null, but strchr did not?\n");
218 skill_tools[0] = NULL;
222 while ((skill_names[num_names] =
strtok_r(NULL,
",", &lasts)) != NULL) {
226 while (isspace(*skill_names[num_names]))
227 skill_names[num_names]++;
228 skills[num_names] = NULL;
229 skill_tools[num_names] = NULL;
244 for (i = 0; i<num_names; i++) {
245 if (!
strncasecmp(skill_names[i], tmp->skill, strlen(skill_names[i])) &&
246 strlen(tmp->skill) >= strlen(skill_names[i])) {
247 if (tmp->type ==
SKILL) {
251 highest_level_skill=i;
260 skill_tools[i] = tmp;
270 return adjust_skill_tool(who, skills[highest_level_skill], skill_tools[highest_level_skill]);
296 object *skill = NULL, *skill_tool = NULL;
303 if (tmp->type ==
SKILL && tmp->subtype == skillno)
309 else if (tmp->type ==
SKILL_TOOL && tmp->subtype == skillno) {
412 int do_skill(
object *op,
object *part,
object *skill,
int dir,
const char *
string) {
413 int success = 0, exp = 0;
430 LOG(
llevError,
"do_skill: asked for skill %s but couldn't find matching SKILL archetype.\n", skill->
skill);
450 "You come to earth.");
454 "You rise into the air!.");
461 exp = success =
steal(op, dir, skill);
465 exp = success =
pick_lock(op, dir, skill);
469 exp = success =
hide(op, skill);
473 success =
jump(op, dir, skill);
516 exp = success =
singing(op, dir, skill);
549 "This skill is not currently implemented.");
555 "There is no special attack for this skill.");
559 success =
pray(op, skill);
576 "This skill is already in effect.");
649 float base, value, lvl_mult;
675 op_lvl += 5*abs(op->
magic);
683 return ((
int64_t)(op_exp*0.1)+1);
706 lvl_mult = (float)op_lvl/(
float)(skill->
level ? skill->
level : 1);
711 value = base*lvl_mult;
715 #ifdef SKILL_UTIL_DEBUG 741 if (!scroll->
skill) {
742 LOG(
llevError,
"skill scroll %s does not have skill pointer set.\n", scroll->
name);
773 LOG(
llevError,
"skill scroll %s does not have valid skill name (%s).\n", scroll->
name, scroll->
skill);
799 rv = (int)((100.0f*((
float)a)/((
float)b))+0.5f);
820 return num == 0 ? 1 : floor( log10( labs(num) ) ) + 1;
841 int i, num_skills_found = 0;
844 const char *search = parms;
845 bool long_format =
false;
847 if ( parms && strncmp(parms,
"-l",2) == 0 ) {
850 while ( *search && *search !=
' ' ) ++search;
851 while ( *search ==
' ' ) ++search;
854 if (tmp->type ==
SKILL) {
855 if (search && strstr(tmp->name, search) == NULL)
862 tmp->name, tmp->level,
872 tmp->name, tmp->level,
879 tmp->name, tmp->level,
891 "Your character has too many skills.\n" 892 "Something isn't right - contact the server admin");
898 if ( search && *search ) {
900 "Player skills%s: (matching '%s')", long_format ?
" (long format)":
"",search);
903 "Player skills%s:", long_format ?
" (long format)":
"");
906 if (num_skills_found > 1)
907 qsort(skills, num_skills_found,
MAX_BUF, (
int (*)(
const void *,
const void *))strcmp);
909 for (i = 0; i < num_skills_found; i++) {
915 if (strcmp(cp,
"none") == 0)
919 "You can handle %d weapon improvements.\n" 921 "Your equipped item power is %d out of %d\n",
923 cp ? cp :
"no god at current time",
952 if (tmp->type ==
SKILL 954 && !
strncasecmp(
string, tmp->skill,
MIN(strlen(
string), strlen(tmp->skill)))) {
958 && !
strncasecmp(
string, tmp->skill,
MIN(strlen(
string), strlen(tmp->skill)))) {
965 "Unable to find skill %s",
970 len = strlen(skop->
skill);
977 if (len >= strlen(
string)) {
981 while (*
string == 0x20)
983 if (strlen(
string) == 0)
987 #ifdef SKILL_UTIL_DEBUG 988 LOG(
llevDebug,
"use_skill() got skill: %s\n", sknum > -1 ? skills[sknum].name :
"none");
1021 object *best_skill = NULL;
1040 "Unable to find skill %s - using default unarmed skill",
1045 for (i = 0; i <
sizeof(unarmed_skills); i++)
1046 if (best_skill->
subtype == unarmed_skills[i])
1048 if (i <
sizeof(unarmed_skills))
1070 last_skill =
sizeof(unarmed_skills);
1072 if (tmp->type ==
SKILL) {
1083 for (i = 0; i < last_skill; i++) {
1129 for (i = 0; unarmed_skills[i] != 0; i++)
1142 "You have no unarmed combat skills!");
1152 "Couldn't change to skill %s",
1165 LOG(
llevError,
"Player %s does not have current weapon set but flag_ready_weapon is set\n", op->
name);
1182 assert(found_skill != NULL);
1259 void skill_attack(
object *tmp,
object *
pl,
int dir,
const char *
string,
object *skill) {
1304 "There is nothing to attack!");
1329 static void attack_hth(
object *
pl,
int dir,
const char *
string,
object *skill) {
1334 if (weapon != NULL) {
1341 "You are unable to unwield %s in order to attack with %s.",
1342 weaponname, skill->
name);
1346 "You unwield your weapon in order to attack.");
1377 "You have no ready weapon to attack with!");
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
int apply_special(object *who, object *op, int aflags)
const char * determine_god(object *op)
int skill_ident(object *pl, object *skill)
int64_t level_exp(int level, double expmul)
static void attack_melee_weapon(object *op, int dir, const char *string, object *skill)
void apply_anim_suffix(object *who, const char *suffix)
#define MSG_TYPE_SKILL_LIST
sstring add_refcount(sstring str)
object * object_find_by_type_applied(const object *who, int type)
static int digits_in_long(int64_t num)
void link_player_skills(object *op)
static int clipped_percent(int64_t a, int64_t b)
int attack_ob(object *op, object *hitter)
int exp_level(int64_t exp)
const char * skill_names[MAX_SKILLS]
void fatal(enum fatal_error err)
int shop_describe(const object *op)
int use_skill(object *op, const char *string)
short freearr_x[SIZEOFFREE]
int pick_lock(object *pl, int dir, object *skill)
static object * adjust_skill_tool(object *who, object *skill, object *skill_tool)
int change_skill(object *who, object *new_skill, int flag)
#define MSG_TYPE_SKILL_MISSING
object * ranges[range_size]
int do_skill(object *op, object *part, object *skill, int dir, const char *string)
#define MSG_TYPE_SKILL_ERROR
int jump(object *pl, int dir, object *skill)
int remove_trap(object *op, object *skill)
void object_update(object *op, int action)
int64_t calc_skill_exp(const object *who, const object *op, const object *skill)
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
short freearr_y[SIZEOFFREE]
object * give_skill_by_name(object *op, const char *skill_name)
int use_alchemy(object *op)
struct obj * chosen_skill
int skill_throw(object *op, object *part, int dir, object *skill)
#define strtok_r(x, y, z)
#define FLAG_CAN_USE_SKILL
int hide(object *op, object *skill)
int is_dragon_pl(const object *op)
#define PERM_EXP(exptotal)
static void attack_hth(object *pl, int dir, const char *string, object *skill)
void show_skills(object *op, const char *parms)
const Face * skill_faces[MAX_SKILLS]
#define MSG_TYPE_VICTIM_WAS_HIT
int steal(object *op, int dir, object *skill)
struct obj * current_weapon
#define OB_TYPE_MOVE_BLOCK(ob1, type)
#define GET_MAP_MOVE_BLOCK(M, X, Y)
#define MSG_TYPE_ATTACK_MISS
static object * find_best_player_hth_skill(object *op)
#define MSG_TYPE_SKILL_FAILURE
void do_harvest(object *pl, int dir, object *skill)
#define QUERY_FLAG(xyz, p)
#define CLEAR_FLAG(xyz, p)
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
#define MSG_TYPE_ATTACK_DID_HIT
int strncasecmp(const char *s1, const char *s2, int n)
int learn_skill(object *pl, object *scroll)
#define FLAG_READY_WEAPON
uint8_t permanent_exp_ratio
int get_skill_client_code(const char *skill_name)
int pray(object *pl, object *skill)
object * object_find_by_type_and_skill(const object *who, int type, const char *skill)
int singing(object *pl, int dir, object *skill)
int find_traps(object *pl, object *skill)
char * strdup(const char *str)
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
int use_oratory(object *pl, int dir, object *skill)
void LOG(LogLevel logLevel, const char *format,...)
int get_learn_spell(int stat)
object * find_skill_by_name(object *who, const char *name)
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
#define MSG_TYPE_SKILL_SUCCESS
void query_name(const object *op, char *buf, size_t size)
#define SK_SUBTRACT_SKILL_EXP
int random_roll(int min, int max, const object *op, int goodbad)
void clear_skill(object *who)
object * find_skill_by_number(object *who, int skillno)
int write_on_item(object *pl, const char *params, object *skill)
const char * unarmed_skill
void fix_object(object *op)
void meditate(object *pl, object *skill)
EXTERN archetype * first_archetype
void skill_attack(object *tmp, object *pl, int dir, const char *string, object *skill)
#define FOR_INV_PREPARE(op_, it_)
static void do_skill_attack(object *tmp, object *op, const char *string, object *skill)