 |
Crossfire Server, Trunk
1.75.0
|
Go to the documentation of this file.
34 #define CONV_FROM(xyz) xyz->slaying
35 #define CONV_TO(xyz) xyz->other_arch
36 #define CONV_NR(xyz) (unsigned char)xyz->stats.sp
37 #define CONV_LIMIT(xyz) ((xyz->stats.wc > 0) ? ((unsigned long)xyz->stats.wc) : INT32_MAX)
38 #define CONV_NEED(xyz) (unsigned long)xyz->stats.food
39 #define CONV_FROM_MATCH(xyz,_match) (CONV_FROM(xyz) == (_match) || ((strchr(CONV_FROM(xyz),'*')) && wildcard_match(CONV_FROM(xyz),(_match))))
41 static int convert_item(
object *item,
object *converter);
53 if (
string[0]==
'*' &&
string[1]==0 )
return 1;
54 if (
string[0] ==
'*' ) head=
TRUE;
55 if (
string[strlen(
string)-1] ==
'*' ) tail=
TRUE;
56 str=strdup(&
string[head?1:0]);
57 if ( !str )
return FALSE;
58 if ( tail ) str[strlen(str)-1]=0;
62 m=strstr(str,candidate);
65 if ( strncmp(str,candidate,strlen(str)) == 0 ) ret=
TRUE;
67 if ( strlen(candidate) >= strlen(str) &&
68 strcmp(&candidate[strlen(candidate)-strlen(str)],str) == 0 ) ret=
TRUE;
96 static object *
do_item_conversion(
object *converter,
object *item,
int weight_rem,
int *status) {
104 int32_t max_conv = weight_diff > 0 && weight_rem > 0 ? weight_rem / weight_diff : -1;
117 if (!strcmp(
CONV_FROM(converter),
"money")) {
137 price_in = cost*item->
value;
159 nr =
MIN(nr, max_conv);
163 price_in = item->
value;
169 if (converter->
inv != NULL) {
174 ob_to_copy = converter->
inv;
186 LOG(
llevError,
"move_creator: Converter doesn't have other arch set: %s (%s, %d, %d)\n", converter->
name ? converter->
name :
"(null)", converter->
map->
path, converter->
x, converter->
y);
201 LOG(
llevError,
"Broken converter %s at %s (%d, %d) in value %d, out value %d for %s\n", converter->
name, converter->
map->
path, converter->
x, converter->
y, price_in, item->
nrof*item->
value, item->
name);
244 "The %s seems to be broken!",
name);
268 if (conv_src != NULL) {
273 if (conv_res != NULL) {
struct Settings settings
Global settings.
@ llevError
Error, serious thing.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
int allow_broken_converters
If set, converters will work even if price of generated item is higher than the price of converted it...
object * inv
Pointer to the first object in the inventory.
#define QUERY_FLAG(xyz, p)
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 register_move_on(int ob_type, move_on_func method)
Registers the move_on method for the given type.
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
void fix_generated_item(object *op, object *creator, int difficulty, int max_magic, int flags)
fix_generated_item(): This is called after an item is generated, in order to set it up right.
void fix_object(object *op)
Updates all abilities given by applied objects in the inventory of the given object.
static method_ret converter_type_move_on(object *trap, object *victim, object *originator)
Move on this Converter object.
int rndm(int min, int max)
Returns a number between min and max.
char path[HUGE_BUF]
Filename of the map.
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
Plugin animator file specs[Config] name
#define FOR_BELOW_FINISH()
Finishes FOR_BELOW_PREPARE().
int32_t carrying
How much weight this object contains.
#define FLAG_IS_A_TEMPLATE
Object has no ingame life until instantiated.
int16_t y
Position in the map for this object.
static event_registration m
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects,...
void query_name(const object *op, char *buf, size_t size)
Describes an item.
object clone
An object from which to do object_copy()
method_ret common_pre_ob_move_on(object *trap, object *victim, object *originator)
#define CONV_FROM_MATCH(xyz, _match)
int32_t value
How much money it is worth (or contains)
uint8_t type
PLAYER, BULLET, etc.
object * object_create_arch(archetype *at)
Create a full object using the given archetype.
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Same as object_insert_in_map() except it handle separate coordinates and do a clean job preparing mul...
struct archetype * other_arch
Pointer used for various things - mostly used for what this objects turns into or what this object cr...
object * object_create_clone(object *asrc)
Create clone from object to another.
static object * do_item_conversion(object *converter, object *item, int weight_rem, int *status)
Do the actual item conversion.
#define MAX_BUF
Used for all kinds of things.
object * create_archetype(const char *name)
Finds which archetype matches the given name, and returns a new object containing a copy of the arche...
uint32_t get_weight_limit(int stat)
int32_t weight
Attributes of the object.
char method_ret
Define some standard return values for callbacks which don't need to return any other results.
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 name
The name of the object, obviously...
object * object_find_by_arch_name(const object *who, const char *name)
Find object in inventory by archetype name.
bool shop_contains(object *ob)
Check if an object is in a shop.
void object_unset_flag_inv(object *op, int flag)
Desactivate recursively a flag on an object inventory.
#define CLEAR_FLAG(xyz, p)
#define MSG_TYPE_APPLY_FAILURE
Apply OK, but no/bad result.
static int wildcard_match(const char *string, const char *candidate)
Wildcard match where 'string' contains a '*' at the start, end, or both.
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to.
#define FLAG_UNPAID
Object hasn't been paid for yet.
void init_type_converter(void)
Initializer for the CONVERTER object type.
sstring name
More definite name, like "generate_kobold".
uint32_t nrof
Number of objects.
living stats
Str, Con, Dex, etc.
static int convert_item(object *item, object *converter)
Transforms an item into another item.
#define MSG_TYPE_APPLY
Applying objects.
void common_post_ob_move_on(object *trap, object *victim, object *originator)
@ GT_MINIMAL
Do minimal adjustments, don't make artifacts, and so on.
static method_ret converter_type_apply(object *converter, object *applier, int aflags)
Apply the converter object.