174 if (--op->
range < 0) {
261 int16_t new_x, new_y;
266 if (--op->
range <= 0) {
276 new_x = op->
x+
DIRX(op);
277 new_y = op->
y+
DIRY(op);
334 for (i = 1; i < 9; i++) {
351 if (Dx==-1 && Dy==-1){
354 if (Dx==0 && Dy==-1){
357 if (Dx==1 && Dy==-1){
369 if (Dx==-1 && Dy==-1){
372 if (Dx==-1 && Dy==0){
399 LOG(
llevError,
"Tried to move_cone object %s without a map.\n", op->
name ? op->
name :
"unknown");
433 if (--op->
range < 0) {
438 for (i = -1; i < 2; i++) {
472 if (env->
map == NULL)
486 for (i = 1; i < 9; i++) {
560 int i, j, dam_save,
dir, mflags;
561 int16_t nx, ny, hx, hy;
576 for (i = 1; i <= 9; i++) {
581 int offset = ((i^j)&1) ? (i/2) : -(i/2);
608 for (j = 0; j < 9; j++) {
659 static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 };
660 static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 };
661 int16_t target_x, target_y, origin_x, origin_y;
662 int basedir, adjustdir;
667 if (op->
duration == 0 || owner == NULL || owner->
x != op->
x || owner->
y != op->
y) {
685 adjustdir = cardinal_adjust[
rndm(0, 8)];
687 adjustdir = diagonal_adjust[
rndm(0, 9)];
732 uint8_t aura_animation_state = 0;
733 sstring whole_aura_animation = NULL;
734 char aura_animation_name[200];
737 if (whole_aura_animation) {
738 snprintf(aura_animation_name,
sizeof(aura_animation_name),
"%s_0_0", whole_aura_animation);
743 whole_aura_animation = NULL;
763 if (caster == NULL || caster->
map == NULL) {
768 for (i = -aura->
range; i <= aura->range; i++) {
769 for (j = -aura->
range; j <= aura->range; ++j) {
786 if (aura->
attacktype != 0 && (i != 0 || j != 0)) {
807 if (new_ob && whole_aura_animation) {
808 snprintf(aura_animation_name,
sizeof(aura_animation_name),
"%s_%d_%d", whole_aura_animation, i + aura->
range, j + aura->
range);
813 new_ob->
state = aura_animation_state;
818 else if (i != 0 || j != 0) {
913 int num_sections = 1;
928 for (tmp2 = tmp; tmp2 != NULL; tmp2 = tmp2->
more)
940 if (
rndm(0, weight_move-1) > ((tmp->
weight/num_sections)*frictionmod)) {
int on_same_map(const object *op1, const object *op2)
Checks whether 2 objects are on the same map or not.
static void move_missile(object *op)
Move a missile object.
void enter_exit(object *op, object *exit_ob)
Tries to move 'op' to exit_ob.
This represents one animation.
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
void animate_object(object *op, int dir)
Updates the face-variable of an object.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
int8_t direction
Means the object is moving that way.
method_ret common_pre_ob_move_on(object *trap, object *victim, object *originator)
int rndm(int min, int max)
Returns a number between min and max.
#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...
#define FLAG_FRIENDLY
Will help players.
#define FLAG_IS_FLOOR
Can't see what's underneath this object.
archetype * find_archetype(const char *name)
int get_random_dir(void)
Returns a random direction (1..8).
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
static void check_spell_knockback(object *op)
Checks to see if a spell pushes objects as well as flies over and damages them (only used for cones f...
void object_update_turn_face(object *op)
If an object with the IS_TURNABLE() flag needs to be turned due to the closest player being on the ot...
object * more
Pointer to the rest of a large body of objects.
int32_t value
How much money it is worth (or contains)
object * above
Pointer to the object stacked above this one.
static void move_cone(object *op)
Causes cone object 'op' to move a space/hit creatures.
int16_t y
Position in the map for this object.
void check_spell_expiry(object *spell)
Checks if player should be warned of soon expiring spell.
void register_move_on(int ob_type, move_on_func method)
Registers the move_on method for the given type.
#define FREE_OBJ_NO_DESTROY_CALLBACK
Do not run the destroy callback.
uint16_t material
What materials this object consist of.
sstring add_refcount(sstring str)
Like add_string(), but the string is already a shared string.
#define object_was_destroyed(op, old_tag)
Checks if an object still exists.
int16_t duration
Number of moves (see 'speed') spell lasts.
void cone_drop(object *op)
Drops an object based on what is in the cone's "other_arch".
#define FLAG_REFLECTING
Object reflects from walls (lightning)
Global type definitions and header inclusions.
int reflwall(mapstruct *m, int x, int y, object *sp_op)
Decides weither the (spell-)object sp_op will be reflected from the given mapsquare.
#define SP_WORD_OF_RECALL
void register_process(int ob_type, process_func method)
Registers the process method for the given type.
#define FLAG_REMOVED
Object is not in any map or invenory.
int32_t weight
Attributes of the object.
static std::shared_ptr< inja::Environment > env
Rendering environment.
void check_bullet(object *op)
Checks to see what op should do, given the space it is on (eg, explode, damage player, etc).
char method_ret
Define some standard return values for callbacks which don't need to return any other results...
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
static void move_ball_spell(object *op)
This handles ball type spells that just sort of wander about.
method_ret ob_process(object *op)
Processes an object, giving it the opportunity to move or react.
int16_t level
Level of creature or object.
static object * move_bullet(object *op)
Moves bullet 'op'.
object * spell
Spell that was being cast.
void object_free(object *ob, int flags)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
#define FREE_OBJ_FREE_INVENTORY
Free inventory objects; if not set, drop inventory.
#define FLAG_ALIVE
Object can fight (or be fought)
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
uint8_t num_animations
How many different faces to animate, size of the faces array.
sstring materialname
Specific material name.
int8_t range
Range of the spell.
float speed
Frequency of object 'moves' relative to server tick rate.
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
static bool IS_PLAYER(object *op)
object * env
Pointer to the object which is the environment.
#define FLAG_UNAGGRESSIVE
Monster doesn't attack players.
#define QUERY_FLAG(xyz, p)
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
short freearr_x[SIZEOFFREE]
X offset when searching around a spot.
#define MOVE_FLYING
Combo of fly_low and fly_high.
static method_ret spell_effect_type_process(object *op)
Handle ob_process for all SPELL_EFFECT objects.
object * head
Points to the main object of a large body.
const Animations * animation
Animation of this item, NULL if not animated.
int hit_map(object *op, int dir, uint32_t type, int full_hit)
Attack a spot on the map.
int out_of_map(mapstruct *m, int x, int y)
Return 1 if coordinates X and Y are out of the map M, taking into account tiling. ...
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
int adjust_dir(int dir, int destination_dir)
Adjusts a given direction by +/-1 towards a destination direction.
static void move_swarm_spell(object *op)
#define P_OUT_OF_MAP
This space is outside the map.
#define GET_MAP_MOVE_BLOCK(M, X, Y)
Gets the blocking state of a square.
static void move_bolt(object *op)
Moves bolt 'op'.
uint8_t state
How the object was last drawn (animation)
object * object_get_env_recursive(object *op)
Utility function.
object * object_new(void)
Grabs an object from the list of unused objects, makes sure it is initialised, and returns it...
uint32_t tag_t
Object tag, unique during the whole game.
int16_t dam
How much damage this object does when hitting.
static void explosion(object *op)
Expands an explosion.
#define FLAG_WIZ
Object has special privilegies.
living stats
Str, Con, Dex, etc.
static void forklightning(object *op, object *tmp)
Causes op to fork.
static void execute_word_of_recall(object *op)
Handles the actual word of recalling.
int ok_to_put_more(mapstruct *m, int16_t x, int16_t y, object *op, uint32_t immune_stop)
Returns true if it is ok to put spell op on the space/may provided.
uint8_t facings
How many facings (1,2,4,8).
void explode_bullet(object *op)
Causes an object to explode, eg, a firebullet, poison cloud ball, etc.
float speed_left
How much speed is left to spend this round.
void object_copy(const object *src_ob, object *dest_ob)
Copy object first frees everything allocated by the second object, and then copies the contents of th...
struct mapstruct * map
Pointer to the map in which this object is present.
void save_throw_object(object *op, uint32_t type, object *originator)
Object is attacked with some attacktype (fire, ice, ...).
short freearr_y[SIZEOFFREE]
Y offset when searching around a spot.
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
void common_post_ob_move_on(object *trap, object *victim, object *originator)
void remove_unpaid_objects(object *op, object *env, int free_items)
This goes throws the inventory and removes unpaid objects, and puts them back in the map (location an...
struct archetype * other_arch
Pointer used for various things - mostly used for what this objects turns into or what this object cr...
#define FLAG_ANIMATE
The object looks at archetype for faces.
static void animate_bomb(object *op)
This handles an exploding bomb.
static event_registration m
void object_merge_spell(object *op, int16_t x, int16_t y)
This sees if there are any objects on the space that can merge with op.
#define NUM_ANIMATIONS(ob)
Animations * try_find_animation(const char *name)
MoveType move_type
Type of movement this object uses.
sstring name
The name of the object, obviously...
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_...
uint8_t type
PLAYER, BULLET, etc.
static void move_aura(object *aura)
Process an aura.
int move_object(object *op, int dir)
Try to move op in the direction "dir".
#define FLAG_LIFESAVE
Saves a players' life once, then destr.
void object_update_speed(object *op)
Updates the speed of an object.
object * inv
Pointer to the first object in the inventory.
int fire_arch_from_position(object *op, object *caster, int16_t x, int16_t y, int dir, object *spell)
Fires an archetype.
void object_copy_owner(object *op, object *clone)
Set the owner to clone's current owner and set the skill and experience objects to clone's objects (t...
#define GET_MAP_OB(M, X, Y)
Gets the bottom object on a map.
sstring skill
Name of the skill this object uses/grants.
uint32_t attacktype
Bitmask of attacks this object does.
int absdir(int d)
Computes an absolute direction.
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Constructs a loop iterating over all objects of a map tile.
int16_t maxhp
Max hit points.
uint8_t subtype
Subtype of object.
#define P_IS_ALIVE
Something alive is on this space.
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
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...
tag_t count
Unique object number for this object.
#define FLAG_NO_PICK
Object can't be picked up.
int spell_find_dir(mapstruct *m, int x, int y, object *exclude)
Search what direction a spell should go in, first the center square then some close squares in the gi...
int hit_player(object *op, int dam, object *hitter, uint32_t type, int full_hit)
Object is attacked by something.
Object type functions and variables.
object clone
An object from which to do object_copy()
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Main dispatch when someone casts a spell.
void init_type_spell_effect(void)
Initializer for the SPELL_EFFECT object type.
static method_ret spell_effect_type_move_on(object *trap, object *victim, object *originator)
Move on this Spell Effect object.
#define FLAG_FREED
Object is in the list of free objects.