 |
Crossfire Server, Trunk
1.75.0
|
Go to the documentation of this file.
28 static int check_item(
object *op,
const char *item);
29 static void eat_item(
object *op,
const char *item, uint32_t nrof);
31 static int improve_weapon_stat(
object *op,
object *improver,
object *weapon,
signed char *stat,
int sacrifice_count,
const char *
statname);
32 static int prepare_weapon(
object *op,
object *improver,
object *weapon);
33 static int improve_weapon(
object *op,
object *improver,
object *weapon);
59 "Something blocks the magic of the scroll.");
66 "You need to mark a weapon object.");
71 "Marked item is not a weapon or bow");
75 "Applied weapon builder.");
100 if (strcmp(tmp->arch->name, item) == 0) {
130 static void eat_item(
object *op,
const char *item, uint32_t nrof) {
137 if (strcmp(op->
arch->
name, item) == 0) {
138 if (op->
nrof >= nrof) {
168 if (improver->
slaying != NULL) {
172 "The gods want more %ss",
202 "Your sacrifice was accepted.");
204 *stat += sacrifice_count;
208 "Weapon's bonus to %s improved by %d",
219 #define IMPROVE_PREPARE 1
220 #define IMPROVE_DAMAGE 2
221 #define IMPROVE_WEIGHT 3
222 #define IMPROVE_ENCHANT 4
223 #define IMPROVE_STR 5
224 #define IMPROVE_DEX 6
225 #define IMPROVE_CON 7
226 #define IMPROVE_WIS 8
227 #define IMPROVE_CHA 9
228 #define IMPROVE_INT 10
229 #define IMPROVE_POW 11
245 static int prepare_weapon(object *op, object *improver, object *weapon) {
246 int sacrifice_count, i;
249 if (weapon->level != 0) {
251 "Weapon already prepared.");
255 if (weapon->resist[i])
263 || (weapon->stats.sp && weapon->type ==
WEAPON)
265 || weapon->stats.ac) {
267 "Cannot prepare magic weapons.");
272 if (sacrifice_count <= 0)
284 if (weapon->nrof >1) {
293 weapon->level =
isqrt(sacrifice_count);
295 "Your sacrifice was accepted.");
296 eat_item(op, improver->slaying, sacrifice_count);
299 snprintf(
buf,
sizeof(
buf),
"%s's %s", op->name, weapon->name);
304 "Your %s may be improved %d times.",
305 weapon->name, weapon->level);
308 weapon->last_eat = 0;
333 int sacrifice_count, sacrifice_needed = 0;
339 if (weapon->
level == 0) {
341 "This weapon has not been prepared.");
347 "This weapon cannot be improved any more.");
354 "Improving the weapon will make it too powerful for you to use. Unready it if you really want to improve it.");
368 "You can't enchant this weapon without unapplying it because it would consume your soul!");
382 "Damage has been increased by 5 to %d",
398 "Weapon weight reduced to %6.1f kg",
399 (
float)weapon->
weight/1000.0);
411 "Weapon magic increased to %d",
418 sacrifice_needed = weapon->
stats.
Str
426 if (sacrifice_needed < 1)
427 sacrifice_needed = 1;
428 sacrifice_needed *= 2;
431 if (sacrifice_count < sacrifice_needed) {
433 "You need at least %d %s",
434 sacrifice_needed, improver->
slaying);
464 "Unknown improvement type.");
467 LOG(
llevError,
"improve_weapon: Got to end of function\n");
struct Settings settings
Global settings.
@ llevError
Error, serious thing.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
static int check_item(object *op, const char *item)
Counts suitable items with specified archetype name.
#define QUERY_FLAG(xyz, p)
#define IMPROVE_CHA
Increase charisma bonus.
int8_t item_power
Power rating of the object.
struct archetype * arch
Pointer to archetype.
void register_apply(int ob_type, apply_func method)
Registers the apply method for the given type.
#define FOR_BELOW_PREPARE(op_, it_)
Constructs a loop iterating over all objects below an object.
struct mapstruct * map
Pointer to the map in which this object is present.
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
#define FLAG_WIZCAST
The wizard can cast spells in no-magic area.
void fix_object(object *op)
Updates all abilities given by applied objects in the inventory of the given object.
#define P_NO_MAGIC
Spells (some) can't pass this object.
void init_type_weapon_improver(void)
Initializer for the WEAPON_IMPROVER object type.
#define FLAG_APPLIED
Object is ready for use by living.
int16_t level
Level of creature or object.
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
#define FOR_BELOW_FINISH()
Finishes FOR_BELOW_PREPARE().
int16_t y
Position in the map for this object.
static int check_sacrifice(object *op, const object *improver)
Returns how many items of type improver->slaying there are under op.
struct player * contr
Pointer to the player which control this object.
#define object_decrease_nrof_by_one(xyz)
#define IMPROVE_PREPARE
Prepare the weapon.
#define MSG_TYPE_APPLY_SUCCESS
Was able to apply object.
object * below
Pointer to the object stacked below this one.
static void eat_item(object *op, const char *item, uint32_t nrof)
This removes 'nrof' items with specified archetype.
int32_t last_eat
How long since we last ate.
int isqrt(int n)
Compute the square root.
#define FREE_AND_COPY(sv, nv)
Release the shared string if not NULL, and make it a reference to nv.
uint8_t type
PLAYER, BULLET, etc.
#define IMPROVE_DAMAGE
Increase damage.
#define FLAG_DAMNED
The object is very cursed.
int16_t dam
How much damage this object does when hitting.
int8_t magic
Any magical bonuses to this item.
float item_power_factor
See note in setings file.
#define IMPROVE_INT
Increase intelligence bonus.
int16_t item_power
Total item power of objects equipped.
const char *const statname[NUM_STATS]
Name of stats.
#define IMPROVE_DEX
Increase dexterity bonus.
static method_ret weapon_improver_type_apply(object *op, object *applier, int aflags)
Attempts to apply weapon_improver.
#define MAX_BUF
Used for all kinds of things.
int32_t weight
Attributes of the object.
#define IMPROVE_WIS
Increase wisdom bonus.
#define IMPROVE_POW
Increase power bonus.
char method_ret
Define some standard return values for callbacks which don't need to return any other results.
static int prepare_weapon(object *op, object *improver, object *weapon)
This does the prepare weapon scroll.
#define IMPROVE_STR
Increase strength bonus.
object * object_decrease_nrof(object *op, uint32_t i)
Decreases a specified number from the amount of an object.
#define NDI_UNIQUE
Print immediately, don't buffer.
sstring slaying
Which race to do double damage to.
#define IMPROVE_CON
Increase constitution bonus.
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_.
int apply_check_weapon_power(const object *who, int improves)
This checks to see of the player (who) is sufficient level to use a weapon with improves improvements...
static int improve_weapon(object *op, object *improver, object *weapon)
Does the dirty job for 'improve weapon' scroll, prepare or add something.
object * object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
object_split(ob,nr) splits up ob into two parts.
#define IMPROVE_WEIGHT
Decrease weight.
void esrv_update_item(int flags, object *pl, object *op)
Updates object *op for player *pl.
int apply_special(object *who, object *op, int aflags)
Apply an object.
#define IMPROVE_ENCHANT
Increase magic.
#define FLAG_UNPAID
Object hasn't been paid for yet.
sstring name
More definite name, like "generate_kobold".
uint32_t nrof
Number of objects.
living stats
Str, Con, Dex, etc.
#define AP_UNAPPLY
Item is to be remvoed.
#define MAX_WEAPON_ITEM_POWER
Maximum item power an item can have.
#define MSG_TYPE_APPLY
Applying objects.
#define FLAG_CURSED
The object is cursed.
#define MSG_TYPE_APPLY_ERROR
object * find_marked_object(object *op)
Return the object the player has marked with the 'mark' command below.
static int improve_weapon_stat(object *op, object *improver, object *weapon, signed char *stat, int sacrifice_count, const char *statname)
Actually improves the weapon, and tells user.