55 object *owner, *tmp, *attacker, *tmp3;
124 object *tmp2 =
HEAD(tmp);
156 if (attacker != NULL) {
185 object *tmp2 =
HEAD(tmp);
193 assert(tmp3 == NULL);
247 for (cur = link; cur != NULL; cur = cur->
next) {
269 for (cur = list; cur != NULL; cur = cur->
next) {
270 if (cur->ob->type !=
PLAYER 273 && (for_owner == NULL || for_owner == owner)
303 if (owner->
map == NULL) {
308 LOG(
llevError,
"Owner of the pet not on a map in memory!?\n");
320 "Your pet magically appears next to you");
355 for (i = 0; i < 15; i++) {
385 for (part = ob; part != NULL; part = part->
more) {
411 if (new_ob->
enemy == NULL)
417 "You stand in the way of someones pet.");
449 object *tmp = NULL, *prev = NULL, *head = NULL;
451 for (atmp = at; atmp != NULL; atmp = atmp->
more) {
500 if (head->randomitems) {
511 head->last_grace = 0;
513 head->other_arch = NULL;
576 for (tmp = op; tmp; tmp = tmp->
more) {
577 int16_t x = tmp->
x+
DIRX(op), y = tmp->
y+
DIRY(op);
603 if (victim != NULL && victim != op && victim->
head != op) {
608 if (victim->
race != NULL && op->
race != NULL && strstr(op->
race, victim->
race)) {
612 "%s avoids damaging %s.",
614 }
else if (victim == owner) {
618 "%s avoids damaging you.",
666 const object *god = NULL;
678 "You dismiss your existing golem.");
687 else if (spob->
race != NULL) {
692 "You must worship a god to cast %s.",
701 "%s has no %s for you to call.",
717 "There is something in the way.");
725 "Your spell fails.");
786 snprintf(buf,
sizeof(buf),
"%s of %s", spob->
name, god->
name);
787 buf[0] = toupper(buf[0]);
788 for (tmp2 = tmp; tmp2; tmp2 = tmp2->
more) {
789 if (tmp2->
name != NULL)
795 if (tmp->
race != NULL)
797 if (god->
race != NULL)
841 race = strtok(buf,
",");
844 race = strtok(NULL,
",");
849 racenr =
rndm(0, racenr-1);
851 race = strtok(buf,
",");
852 for (i = 0; i < racenr; i++)
853 race = strtok(NULL,
",");
861 "The spell fails! %s's creatures are beyond the range of your summons",
885 int pets_summon_object(
object *op,
object *caster,
object *spell_ob,
int dir,
const char *stringarg) {
886 int16_t x, y, nrof = 1, i;
901 if (level < tr->magic)
904 if (stringarg != NULL && !strcmp(tr->
item->
name, stringarg))
909 if (lasttr == NULL) {
913 "The spell fails to summon any monsters.");
916 summon_arch = lasttr->
item;
918 }
else if (spell_ob->
race != NULL && !strcmp(spell_ob->
race,
"GODCULTMON")) {
921 int summon_level, tries;
933 if (god->
race == NULL) {
936 "%s has no creatures that you may summon!",
942 if (summon_level == 0)
950 "%s fails to send anything.",
963 "There is something in the way.");
967 }
while (ndir == -1);
968 if (mon->
level > summon_level/2)
972 summon_arch = mon->
arch;
980 if (summon_arch == NULL) {
982 "There is no monsters available for summoning.");
992 "There is something in the way.");
997 mult = (
RANDOM()%2 ? -1 : 1);
999 for (i = 1; i <= nrof; i++) {
1001 object *prev = NULL, *head = NULL, *tmp;
1004 ndir =
absdir(dir+(i/2)*mult);
1014 for (atmp = summon_arch; atmp != NULL; atmp = atmp->
more) {
1016 if (atmp == summon_arch) {
1037 tmp->speed_left = -1;
1048 head->stats.exp = 0;
1050 if (head != NULL && head->randomitems) {
1073 object *realowner = ob;
1075 if (realowner == NULL)
1100 object *rowner, *towner;
1103 if (target == NULL || pet == NULL || owner == NULL)
1116 if (rowner == NULL) {
1123 if (towner == NULL && target->
type !=
PLAYER) {
1124 LOG(
llevError,
"Target is not a player but has no owner. We should not be here.\n");
1143 if (target->
type !=
PLAYER && rowner == towner)
void free_objectlink(objectlink *ol)
Recursively frees all objectlinks.
int on_same_map(const object *op1, const object *op2)
Checks whether 2 objects are on the same map or not.
static object * fix_summon_pet(archetype *at, object *op, int dir)
This makes multisquare/single square monsters proper for map insertion.
#define MSG_TYPE_MISC
Messages that don't go elsewhere.
#define FLAG_NO_DROP
Object can't be dropped.
static void mark_inventory_as_no_drop(object *ob)
Mark all inventory items as FLAG_NO_DROP.
uint16_t attack_movement
What kind of attack movement.
const char * determine_god(object *op)
Determines if op worships a god.
object * ranges[range_size]
Object for each range.
#define MOVE_WALK
Object walks.
#define UP_OBJ_FACE
Only thing that changed was the face.
This is used by get_rangevector to determine where the other creature is.
#define AT_GHOSTHIT
Attacker dissolves (512)
struct archetype * arch
Pointer to archetype.
const object * find_god(const char *name)
Returns a god's object from its name.
#define FLAG_SLEEP
NPC is sleeping.
int caster_level(const object *caster, const object *spell)
This function returns the effective level the spell is being cast at.
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
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.
#define FABS(x)
Decstations have trouble with fabs()...
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...
int monster_can_see_enemy(object *op, object *enemy)
Assuming no walls/barriers, lets check to see if its possible to see an enemy.
#define FLAG_STAND_STILL
NPC will not (ever) move.
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 attack_ob(object *op, object *hitter)
Simple wrapper for attack_ob_simple(), will use hitter's values.
#define FLAG_FRIENDLY
Will help players.
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...
#define MSG_TYPE_SPELL
Spell related info.
int16_t maxgrace
Maximum grace.
#define MSG_TYPE_SPELL_FAILURE
Spell failure messages.
int object_find_free_spot(const object *ob, mapstruct *m, int x, int y, int start, int stop)
object_find_free_spot(object, map, x, y, start, stop) will search for a spot at the given map and coo...
int pets_should_arena_attack(object *pet, object *owner, object *target)
Determines if checks so pets don't attack players or other pets should be overruled by the arena petm...
partylist * party
Party this player is part of.
object * more
Pointer to the rest of a large body of objects.
sstring slaying
Which race to do double damage to.
sstring add_string(const char *str)
Share a string.
object * monster_check_enemy(object *npc, rv_vector *rv)
Checks npc->enemy and returns that enemy if still valid, NULL otherwise.
void remove_friendly_object(object *op)
Removes the specified object from the linked list of friendly objects.
#define FLAG_CONFUSED
Will also be unable to cast spells.
int16_t y
Position in the map for this object.
int SP_level_dam_adjust(const object *caster, const object *spob)
Returns adjusted damage based on the caster.
object * pets_get_enemy(object *pet, rv_vector *rv)
Given that 'pet' is a friendly object, this function returns a monster the pet should attack...
#define object_was_destroyed(op, old_tag)
Checks if an object still exists.
object * attacked_by
This object start to attack us! only player & monster.
int16_t duration
Number of moves (see 'speed') spell lasts.
void object_set_owner(object *op, object *owner)
Sets the owner and sets the skill and exp pointers to owner's current skill and experience objects...
Attack other players in arena.
Global type definitions and header inclusions.
#define PETMOVE
If the upper four bits of attack_movement are set to this number, the monster follows a player until ...
struct player * contr
Pointer to the player which control this object.
void pets_terminate_all(object *owner)
Removes all pets someone owns.
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Sends message to player(s).
#define FLAG_REMOVED
Object is not in any map or invenory.
object * owner
Pointer to the object which controls this one.
rangetype shoottype
Which range-attack is being used by player.
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
object * races_get_random_monster(const char *race, int level)
Get a random monster of specified race and level at most the specified one.
#define MAP_IN_MEMORY
Map is fully loaded.
int16_t level
Level of creature or object.
#define FLAG_ALIVE
Object can fight (or be fought)
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
This calls the appropriate treasure creation function.
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
sstring name
More definite name, like "generate_kobold".
float speed
Frequency of object 'moves' relative to server tick rate.
int SP_level_wc_adjust(const object *caster, const object *spob)
Returns adjusted wc based on the caster and the spell.
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
#define FLAG_UNAGGRESSIVE
Monster doesn't attack players.
#define QUERY_FLAG(xyz, p)
void monster_check_apply_all(object *monster)
Calls monster_check_apply() for all inventory objects.
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.
tag_t attacked_by_count
The tag of attacker, so we can be sure.
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
int SP_level_duration_adjust(const object *caster, const object *spob)
Adjust the duration of the spell based on level.
sstring msg
If this is a book/sign/magic mouth/etc.
uint32_t golem_count
To track the golem.
object * head
Points to the main object of a large body.
sstring race
Human, goblin, dragon, etc.
objectlink * get_friends_of(const object *owner)
Get a list of friendly objects for the specified owner.
#define FLAG_CHANGING
Changes to other_arch when anim is done.
void get_search_arr(int *search_arr)
New function to make monster searching more efficient, and effective! This basically returns a random...
void pets_move_golem(object *op)
Handles a golem's movement.
int ob_blocked(const object *ob, mapstruct *m, int16_t x, int16_t y)
Returns true if the given object can't fit in the given spot.
void pets_terminate(object *pet)
Removes a pet, taking care of clearning the owner's fields if needed.
Used to link together several objects.
int monster_can_detect_enemy(object *op, object *enemy, rv_vector *rv)
Determine if we can 'detect' the enemy.
#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.
int move_ob(object *op, int dir, object *originator)
Op is trying to move in direction dir.
int op_on_battleground(object *op, int *x, int *y, archetype **trophy)
Check if the given object (usually a player) is standing on a battleground tile.
#define FREE_AND_CLEAR_STR(xyz)
Release the shared string, and set it to NULL.
int random_roll(int min, int max, const object *op, int goodbad)
Roll a random number between min and max.
uint32_t tag_t
Object tag, unique during the whole game.
int16_t dam
How much damage this object does when hitting.
#define AT_PHYSICAL
Basic attack (1)
#define HEAD(op)
Returns the head part of an object.
int freedir[SIZEOFFREE]
Direction we're pointing on this spot.
living stats
Str, Con, Dex, etc.
#define MAX_BUF
Used for all kinds of things.
int16_t invisible
How much longer the object will be invis.
void add_friendly_object(object *op)
Add a new friendly object to the list of friendly objects.
mapstruct * get_map_from_coord(mapstruct *m, int16_t *x, int16_t *y)
This is basically the same as out_of_map above(), but instead we return NULL if no map is valid (coor...
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.
uint32_t in_memory
Combination of IN_MEMORY_xxx flags.
#define AT_DRAIN
Victim loses 2% exp, attacker gains half of that (128)
short freearr_y[SIZEOFFREE]
Y offset when searching around a spot.
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
struct archetype * other_arch
Pointer used for various things - mostly used for what this objects turns into or what this object cr...
struct treasurelist * randomitems
Items to be generated.
object * monster_find_nearest_enemy(object *npc, object *owner)
Returns the nearest enemy (monster or generator) which is visible to npc.
#define FLAG_GENERATOR
Will generate type ob->stats.food.
void pets_follow_owner(object *ob, object *owner)
A pet is trying to follow its owner.
static event_registration m
archetype * determine_holy_arch(const object *god, const char *type)
Determines the archetype for holy servant and god avatar.
treasure * next
Next treasure-item in a linked list.
int SP_level_range_adjust(const object *caster, const object *spob)
Adjust the range of the spell based on level.
#define MSG_TYPE_SPELL_PET
Pet related messages.
MoveType move_type
Type of movement this object uses.
sstring name
The name of the object, obviously...
void set_spell_skill(object *op, object *caster, object *spob, object *dest)
Utility function to assign the correct skill when casting.
Only for debugging purposes.
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_...
sstring name
Usually monster-name/combination.
void pets_move(object *ob)
Handles a pet's movement.
void object_set_enemy(object *op, object *enemy)
Sets the enemy of an object.
void pets_attempt_follow(object *for_owner, int force)
Check pets so they try to follow their master around the world.
#define CLEAR_FLAG(xyz, p)
treasure * items
Items in this list, linked.
uint8_t type
PLAYER, BULLET, etc.
int direction
General direction to the targer.
#define FLAG_SPLITTING
Object splits into stats.food other objs.
uint16_t nrof
Random 1 to nrof items are generated.
int get_rangevector(object *op1, const object *op2, rv_vector *retval, int flags)
From map.c This is used by get_player to determine where the other creature is.
treasure is one element in a linked list, which together consist of a complete treasure-list.
#define MIN_ACTIVE_SPEED
Cut off point of when an object is put on the active list or not.
uint32_t attacktype
Bitmask of attacks this object does.
#define FLAG_MONSTER
Will attack players.
int pets_summon_object(object *op, object *caster, object *spell_ob, int dir, const char *stringarg)
General purpose summoning function.
#define NDI_UNIQUE
Print immediately, don't buffer.
static object * choose_cult_monster(object *pl, const object *god, int summon_level)
Returns a monster (chosen at random) that this particular player (and his god) find acceptable...
archetype * more
Next part of a linked object.
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.
static object * get_real_owner(object *ob)
Recursively look through the owner property of objects until the real owner is found.
struct archetype * item
Which item this link can be.
void pets_control_golem(object *op, int dir)
Makes the golem go in specified direction.
int16_t maxhp
Max hit points.
#define P_IS_ALIVE
Something alive is on this space.
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...
int8_t wc
Weapon Class, lower WC increases probability of hitting.
int pets_summon_golem(object *op, object *caster, int dir, object *spob)
Summons a monster.
void object_update(object *op, int action)
object_update() updates the array which represents the map.
tag_t count
Unique object number for this object.
petmode_t petmode
Which petmode?
int die_roll(int num, int size, const object *op, int goodbad)
Roll a number of dice (2d3, 4d6).
object clone
An object from which to do object_copy()
objectlink * next
Next item to link to.
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
Generated items have the FLAG_STARTEQUIP.
object * enemy
Monster/player to follow even if not closest.