 |
Crossfire Server, Trunk
1.75.0
|
Go to the documentation of this file.
35 #define WANT_UNARMED_SKILLS
84 LOG(
llevError,
"init_skills: too many skills, increase MAX_SKILLS and rebuild server!");
123 assert(
"invalid skill!");
150 if (!
skill && !skill_tool)
215 int num_names, highest_level_skill=0, i;
221 if (!strchr(
name,
',')) {
223 skill_tools[0] = NULL;
229 ourname = strdup(
name);
231 if ((
skill_names[0] = strtok_r(ourname,
",", &lasts)) == NULL) {
233 LOG(
llevError,
"find_skill_by_name: strtok_r returned null, but strchr did not?\n");
237 skill_tools[0] = NULL;
241 while ((
skill_names[num_names] = strtok_r(NULL,
",", &lasts)) != NULL) {
248 skill_tools[num_names] = NULL;
263 for (i = 0; i<num_names; i++) {
266 if (tmp->type ==
SKILL) {
270 highest_level_skill=i;
279 skill_tools[i] = tmp;
315 object *
skill = NULL, *skill_tool = NULL;
322 if (tmp->type ==
SKILL && tmp->subtype == skillno)
328 else if (tmp->type ==
SKILL_TOOL && tmp->subtype == skillno) {
431 int do_skill(
object *op,
object *part,
object *
skill,
int dir,
const char *
string) {
432 int success = 0, exp = 0;
449 LOG(
llevError,
"do_skill: asked for skill %s but couldn't find matching SKILL archetype.\n",
skill->skill);
456 if (
skill->anim_suffix)
459 switch (
skill->subtype) {
469 "You come to earth.");
473 "You rise into the air!.");
568 "This skill is not currently implemented.");
574 "There is no special attack for this skill.");
595 "This skill is already in effect.");
670 float base, value, lvl_mult;
696 op_lvl += 5*abs(op->
magic);
704 return ((int64_t)(op_exp*0.1)+1);
713 base +=
skill->arch->clone.stats.exp;
715 if (
skill->arch->clone.level)
716 lvl_mult = (float)
skill->arch->clone.level/100.0;
721 lvl_mult = ((float)
skill->arch->clone.level*(
float)op_lvl)/((
float)
skill->level*100.0);
727 lvl_mult = (float)op_lvl/(
float)(
skill->level ?
skill->level : 1);
732 value = base*lvl_mult;
736 #ifdef SKILL_UTIL_DEBUG
737 LOG(
llevDebug,
"calc_skill_exp(): who: %s(lvl:%d) op:%s(lvl:%d)\n", who->
name,
skill->level, op ? op->
name :
"", op_lvl);
739 return ((int64_t)value);
762 if (!scroll->
skill) {
763 LOG(
llevError,
"skill scroll %s does not have skill pointer set.\n", scroll->
name);
773 if (inv->type ==
SKILL && !strncasecmp(scroll->
skill, inv->skill, strlen(scroll->
skill))) {
794 LOG(
llevError,
"skill scroll %s does not have valid skill name (%s).\n", scroll->
name, scroll->
skill);
820 rv = (int)((100.0f*((
float)
a)/((
float)b))+0.5f);
841 return num == 0 ? 1 :
floor( log10( labs(num) ) ) + 1;
862 int i, num_skills_found = 0;
865 const char *search = parms;
866 bool long_format =
false;
868 if ( parms && strncmp(parms,
"-l",2) == 0 ) {
871 while ( *search && *search !=
' ' ) ++search;
872 while ( *search ==
' ' ) ++search;
875 if (tmp->type ==
SKILL) {
876 if (search && strstr(tmp->name, search) == NULL)
883 tmp->name, tmp->level,
893 tmp->name, tmp->level,
900 tmp->name, tmp->level,
912 "Your character has too many skills.\n"
913 "Something isn't right - contact the server admin");
919 if ( search && *search ) {
921 "Player skills%s: (matching '%s')", long_format ?
" (long format)":
"",search);
924 "Player skills%s:", long_format ?
" (long format)":
"");
927 if (num_skills_found > 1)
928 qsort(
skills, num_skills_found,
MAX_BUF, (
int (*)(
const void *,
const void *))strcmp);
930 for (i = 0; i < num_skills_found; i++) {
936 if (strcmp(cp,
"none") == 0)
940 "You can handle %d weapon improvements.\n"
942 "Your equipped item power is %d out of %d\n",
944 cp ? cp :
"no god at current time",
973 if (tmp->type ==
SKILL
975 && !strncasecmp(
string, tmp->skill,
MIN(strlen(
string), strlen(tmp->skill)))) {
980 && !strncasecmp(
string, tmp->skill,
MIN(strlen(
string), strlen(tmp->skill)))) {
987 "Unable to find skill %s",
992 len = strlen(skop->
skill);
999 if (len >= strlen(
string)) {
1003 while (*
string == 0x20)
1005 if (strlen(
string) == 0)
1009 #ifdef SKILL_UTIL_DEBUG
1043 object *best_skill = NULL;
1062 "Unable to find skill %s - using default unarmed skill",
1067 for (i = 0; i <
sizeof(unarmed_skills); i++)
1068 if (best_skill->
subtype == unarmed_skills[i])
1070 if (i <
sizeof(unarmed_skills))
1092 last_skill =
sizeof(unarmed_skills);
1094 if (tmp->type ==
SKILL) {
1105 for (i = 0; i < last_skill; i++) {
1151 for (i = 0; unarmed_skills[i] != 0; i++)
1164 "You have no unarmed combat skills!");
1174 "Couldn't change to skill %s",
1187 LOG(
llevError,
"Player %s does not have current weapon set but flag_ready_weapon is set\n", op->
name);
1204 assert(found_skill != NULL);
1229 }
else if (
string != NULL) {
1315 "There is nothing to attack!");
1345 if (weapon != NULL) {
1352 "You are unable to unwield %s in order to attack with %s.",
1353 weaponname,
skill->name);
1357 "You unwield your weapon in order to attack.");
1388 "You have no ready weapon to attack with!");
New face structure - this enforces the notion that data is face by face only - you can not change the...
#define UP_OBJ_FACE
Only thing that changed was the face.
Player Stats effect how well a character can survie and interact inside the crossfire world This section discusses the various what they and how they effect the player s actions Also in this section are the stat modifiers that specific classes professions bring Player and sps the current and maximum the Current and Maximum The Current Sp can go somewhat negative When Sp is negative not all spells can be and a more negative Sp makes spell casting less likey to succeed can affect Damage and how the characters as well as how often the character can attack this affects the prices when buying and selling items if this drops the player will start losing hit points wd Cleric or Dwarf sm Elf wd Fireborn ft Human ra Mage C Monk se Ninja hi Priest C Quetzalcoatl mw Swashbuckler si Thief st Viking ba Warrior or Wizard C Wraith C Class Prof Str Dex Con Wis Cha Int Pow Net Skills Enclosed are codes used for the skills above The ones in and fighting should all be pretty self explanatory For the other skills
struct Settings settings
Server settings.
uint8_t simple_exp
If true, use the simple experience system.
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
@ SK_FIRE_MAGIC
Fire magic, unused.
object * object_find_by_type_applied(const object *who, int type)
Find applied object in inventory.
#define MSG_TYPE_ATTACK_MISS
attack didn't hit
const char * unarmed_skill
Prefered skill to use in unarmed combat.
#define AP_APPLY
Item is to be applied.
@ llevError
Error, serious thing.
int learn_skill(object *pl, object *scroll)
Player is trying to learn a skill.
uint16_t difficulty
What level the player should be to play here.
@ SK_INSCRIPTION
Inscription.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
int use_alchemy(object *op)
Handle use_skill for alchemy-like items.
static void do_skill_attack(object *tmp, object *op, const char *string, object *skill)
We have got an appropriate opponent from either move_player_attack() or skill_attack().
#define MSG_TYPE_SKILL
Messages related to skill use.
#define QUERY_FLAG(xyz, p)
void archetypes_for_each(arch_op op)
uint8_t permanent_exp_ratio
How much exp should be 'permenant' and unable to be lost.
#define MSG_TYPE_ATTACK_DID_HIT
Player hit something else.
@ SK_DET_MAGIC
Detect magic.
int16_t invisible
How much longer the object will be invis.
@ SK_DISARM_TRAPS
Disarm traps.
float speed_left
How much speed is left to spend this round.
struct mapstruct * map
Pointer to the map in which this object is present.
object * give_skill_by_name(object *op, const char *skill_name)
Given the skill name skill_name, we find the skill archetype/object, set appropriate values,...
double expmul
needed experience = (calc_exp*expmul) - means some races/classes can need less/more exp to gain level...
int write_on_item(object *pl, const char *params, object *skill)
Implement the 'inscription' skill, which checks for the required skills and marked items before runni...
@ range_none
No range selected.
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
int use_oratory(object *pl, int dir, object *skill)
Oratory skill handling.
@ SKILL
Also see SKILL_TOOL (74) below.
int singing(object *pl, int dir, object *skill)
Singing skill handling.
int skill_ident(object *pl, object *skill)
Main identification skill handling.
void fix_object(object *op)
Updates all abilities given by applied objects in the inventory of the given object.
object * object_find_by_type_and_skill(const object *who, int type, const char *skill)
Find object in inventory by type and skill.
int find_traps(object *pl, object *skill)
Checks for traps on the spaces around the player or in certain objects.
@ SK_MEDITATION
Meditation.
@ SK_SET_TRAP
Set traps, unused.
uint8_t hide
The object is hidden, not invisible.
object * find_skill_by_number(object *who, int skillno)
This returns the first skill pointer of the given subtype (the one that accumulates exp,...
sstring skill_messages[MAX_SKILLS]
Will contain the message for the skills, initialized by init_skill().
#define P_IS_ALIVE
Something alive is on this space.
#define FLAG_APPLIED
Object is ready for use by living.
int16_t level
Level of creature or object.
static int digits_in_long(int64_t num)
Gives the number of digits that ld will print for a long int.
#define MSG_TYPE_VICTIM
Something bad is happening to the player.
static int free_skill_index()
Plugin animator file specs[Config] name
@ SK_EARTH_MAGIC
Earth magic, unused.
#define FLAG_ALIVE
Object can fight (or be fought)
int16_t y
Position in the map for this object.
static event_registration m
const char * skill_names[MAX_SKILLS]
Will contain a number-name mapping for skills, initialized by init_skills().
void object_update(object *op, int action)
object_update() updates the array which represents the map.
struct player * contr
Pointer to the player which control this object.
object * chosen_skill
The skill chosen to use.
int pick_lock(object *pl, int dir, object *skill)
Lock pick handling.
uint8_t subtype
Subtype of object.
@ SK_HARVESTING
Harvesting.
int change_skill(object *who, object *new_skill, int flag)
This changes the object's skill to new_skill.
sstring add_refcount(sstring str)
This will increase the refcount of the string str.
@ SK_TWO_HANDED_WEAPON
Two handed weapons.
const char * determine_god(object *op)
Determines if op worships a god.
short freearr_y[SIZEOFFREE]
Y offset when searching around a spot.
static void attack_hth(object *pl, int dir, const char *string, object *skill)
This handles all hand-to-hand attacks.
static int clipped_percent(int64_t a, int64_t b)
Gives a percentage clipped to 0% -> 100% of a/b.
void query_name(const object *op, char *buf, size_t size)
Describes an item.
int shop_describe(const object *op)
Give the player a description of the shop on their current map.
object * ranges[range_size]
Object for each range.
int remove_trap(object *op, object *skill)
This skill will disarm any previously discovered trap.
@ SK_DET_CURSE
Detect curse.
object clone
An object from which to do object_copy()
sstring add_string(const char *str)
This will add 'str' to the hash table.
void apply_anim_suffix(object *who, const char *suffix)
Applies a compound animation to an object.
#define FLAG_FREED
Object is in the list of free objects.
int do_skill(object *op, object *part, object *skill, int dir, const char *string)
Main skills use function-similar in scope to cast_spell().
const Face * skill_faces[MAX_SKILLS]
Will contain the face numbers for the skills, initialized by init_skill().
const Face * face
Face with colors.
int exp_level(int64_t exp)
Returns the level for a given exp.
#define MSG_TYPE_ATTACK
Attack related messages.
uint32_t tmp_invis
Will invis go away when we attack?
uint8_t type
PLAYER, BULLET, etc.
int8_t magic
Any magical bonuses to this item.
#define GET_MAP_MOVE_BLOCK(M, X, Y)
Gets the blocking state of a square.
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
#define FLAG_CAN_ROLL
Object can be rolled.
int16_t item_power
Total item power of objects equipped.
#define MSG_TYPE_SKILL_MISSING
Don't have the skill.
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Changes experience to a player/monster.
rangetype
What range is currently selected by the player.
@ SK_BARGAINING
Bargaining.
int64_t level_exp(int level, double expmul)
Returns how much experience is needed for a player to become the given level.
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
rangetype shoottype
Which range-attack is being used by player.
int pray(object *pl, object *skill)
Praying skill handling.
@ SK_AIR_MAGIC
Air magic, unused.
void skill_attack(object *tmp, object *pl, int dir, const char *string, object *skill)
Core routine for use when we attack using a skills system.
static void do_each_skill(archetype *at)
#define MAX_SKILLS
This is the maximum number of skills the game may handle.
#define FLAG_CAN_USE_SKILL
The monster can use skills.
#define MSG_TYPE_VICTIM_WAS_HIT
Player was hit by something.
int skill_throw(object *op, object *part, int dir, object *skill)
Throwing skill handling.
int get_skill_client_code(const char *skill_name)
Return the code of the skill for a client, the index in the skill_names array.
void clear_skill(object *who)
This function just clears the chosen_skill and range_skill values in the player.
int random_roll(int min, int max, const object *op, int goodbad)
Roll a random number between min and max.
int8_t facing
Object is oriented/facing that way.
static void attack_melee_weapon(object *op, int dir, const char *string, object *skill)
This handles melee weapon attacks -b.t.
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
#define P_OUT_OF_MAP
This space is outside the map.
#define MAX_BUF
Used for all kinds of things.
static object * find_best_player_hth_skill(object *op)
Finds the best unarmed skill the player has, and returns it.
static object * adjust_skill_tool(object *who, object *skill, object *skill_tool)
This returns specified skill if it can be used, potentially using tool to help.
object * current_weapon
Pointer to the weapon currently used.
@ SK_FLAME_TOUCH
Flame-touch.
@ SK_LEVITATION
Levitation.
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Constructs a loop iterating over all objects of a map tile.
#define FLAG_READY_SKILL
(Monster or Player) has a skill readied
#define PERM_EXP(exptotal)
Convert saved total experience into permanent experience.
@ SK_LOCKPICKING
Lockpicking.
#define MSG_TYPE_SKILL_ERROR
Doing something wrong.
#define NDI_UNIQUE
Print immediately, don't buffer.
sstring name
The name of the object, obviously...
#define MSG_TYPE_SKILL_FAILURE
Failure in using skill.
int use_skill(object *op, const char *string)
Similar to invoke command, it executes the skill in the direction that the user is facing.
int is_dragon_pl(const object *op)
Checks if player is a dragon.
int get_learn_spell(int stat)
#define MSG_TYPE_SKILL_LIST
List of skills.
@ SK_WRAITH_FEED
Wraith feed.
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
This rolls up wall, blocks_magic, blocks_view, etc, all into one function that just returns a P_.
const typedef char * sstring
Magical Runes Runes are magical inscriptions on the dungeon floor
sstring skill
Name of the skill this object uses/grants.
sstring msg
If this is a book/sign/magic mouth/etc.
@ SKILL_TOOL
Allows the use of a skill.
@ SK_MISSILE_WEAPON
Missile weapon.
#define CLEAR_FLAG(xyz, p)
void do_harvest(object *pl, int dir, object *skill)
Player is trying to harvest something.
#define SK_SUBTRACT_SKILL_EXP
Used when removing exp.
int apply_special(object *who, object *op, int aflags)
Apply an object.
#define AP_NOPRINT
Don't print messages - caller will do that may be some that still print.
@ SK_ONE_HANDED_WEAPON
One handed weapon.
void show_skills(object *op, const char *parms)
Displays a player's skill list, and some other non skill related info (god, max weapon improvements,...
partylist * party
Party this player is part of.
void meditate(object *pl, object *skill)
Meditation skill handling.
int steal(object *op, int dir, object *skill)
Main stealing function.
int64_t calc_skill_exp(const object *who, const object *op, const object *skill)
Calculates amount of experience can be gained for successful use of a skill.
void init_skills(void)
This just sets up the skill_names table above.
Magical Runes Runes are magical inscriptions on the dungeon which cast a spell or detonate when something steps on them Flying objects don t detonate runes Beware ! Runes are invisible most of the time They are only visible occasionally ! There are several runes which are there are some special runes which may only be called with the invoke and people may apply it to read it Maybe useful for mazes ! This rune will not nor is it ordinarily invisible Partial Visibility of they ll be visible only part of the time They have a(your level/2) chance of being visible in any given round
#define FLAG_UNPAID
Object hasn't been paid for yet.
@ SK_THAUMATURGY
Thaumaturgy.
#define OB_TYPE_MOVE_BLOCK(ob1, type)
Basic macro to see if if ob1 can not move onto a space based on the 'type' move_block parameter Add c...
living stats
Str, Con, Dex, etc.
#define MSG_TYPE_SKILL_SUCCESS
Successfully used skill.
#define AP_UNAPPLY
Item is to be remvoed.
int attack_ob(object *op, object *hitter)
Simple wrapper for attack_ob_simple(), will use hitter's values.
@ SK_FIND_TRAPS
Find traps.
@ SK_USE_MAGIC_ITEM
Use magic item.
short freearr_x[SIZEOFFREE]
X offset when searching around a spot.
void link_player_skills(object *op)
This function goes through the player inventory and sets up the last_skills[] array in the player obj...
#define FLAG_READY_WEAPON
(Monster or Player) has a weapon readied
object * find_skill_by_name(object *who, const char *name)
This returns the skill pointer of the given name (the one that accumulates exp, has the level,...
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
@ SK_WATER_MAGIC
Water magic, unused.
@ llevDebug
Only for debugging purposes.
int jump(object *pl, int dir, object *skill)
Jump skill handling.