![]() |
Crossfire Server, Trunk
1.75.0
|
#include "global.h"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "living.h"
#include "skills.h"
#include "spells.h"
#include "sproto.h"
#include "tod.h"
Go to the source code of this file.
Functions | |
static int | adjust_sign_msg (object *pl, short x, short y, object *tmp) |
Make the built object inherit the msg of books that are used with it. More... | |
static int | apply_builder_floor (object *pl, object *new_floor, short x, short y) |
Floor building function. More... | |
static int | apply_builder_item (object *pl, object *new_item, short x, short y) |
Generic item builder. More... | |
void | apply_builder_remove (object *pl, int dir) |
Item remover. More... | |
static int | apply_builder_wall (object *pl, object *new_wall, short x, short y) |
Wall building function. More... | |
static int | apply_builder_window (object *pl, object *new_wall_win, short x, short y) |
Window building function. More... | |
void | apply_map_builder (object *pl, int dir) |
Global building function. More... | |
static int | can_build_over (mapstruct *map, object *new_item, short x, short y) |
Check if objects on a square interfere with building. More... | |
static int | find_or_create_connection_for_map (object *pl, short x, short y, object *rune) |
Helper function for door/button/connected item building. More... | |
static int | find_unused_connected_value (mapstruct *map) |
Returns an unused value for 'connected'. More... | |
static void | fix_walls (mapstruct *map, int x, int y) |
Fixes walls around specified spot. More... | |
static object * | get_connection_rune (object *pl, short x, short y) |
Returns the marking rune on the square, for purposes of building connections. More... | |
static object * | get_msg_book (object *pl, short x, short y) |
Returns the book/scroll on the current square, for purposes of building. More... | |
static object * | get_wall (mapstruct *map, int x, int y) |
Returns first item of type WALL. More... | |
static void | remove_marking_runes (mapstruct *map, short x, short y) |
Erases all marking runes at specified location (before building a wall) More... | |
This file handles all ingame construction functions: builders, destroyers, building materials.
Basically, those enable a player to alter in real-time a map.
Definition in file build_map.cpp.
Make the built object inherit the msg of books that are used with it.
For objects already invisible (i.e. magic mouths & ears), also make it it inherit the face and the name with "talking " prepended.
The book is removed during the operation.
pl | player building. |
x | |
y | building coordinates. |
tmp | object that is being built. |
Definition at line 184 of file build_map.cpp.
References add_string(), buf, CUSTOM_NAME_FIELD, draw_ext_info, object::face, free_string(), get_msg_book(), object::invisible, MAX_BUF, object::msg, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, object::name, object::name_pl, NDI_UNIQUE, object_free_drop_inventory(), object_get_value(), object_remove(), object_set_msg(), and sstring.
Referenced by apply_builder_item().
Floor building function.
Floors can be built:
pl | player building. |
new_floor | new floor object |
x | |
y | where to build. |
Definition at line 507 of file build_map.cpp.
References object::arch, arch_to_object(), draw_ext_info, fix_walls(), FLAG_IS_BUILDABLE, FLAG_IS_FLOOR, FLAG_UNIQUE, floor, FLOOR, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, GET_MAP_OB, INS_BELOW_ORIGINATOR, INS_ON_TOP, object::map, MAX_BUF, message, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, NDI_UNIQUE, object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), OUT_OF_REAL_MAP, QUERY_FLAG, SET_FLAG, object::type, and WALL.
Referenced by apply_map_builder().
Generic item builder.
Item must be put on a square with a floor, you can have something under.
Type of inserted item is tested for specific cases (doors & such).
Item is inserted above the floor.
Note that it is the responsability of the caller to check whether the space is buildable or not.
pl | player building. |
new_item | new item being built |
x | |
y | where to build. |
Definition at line 797 of file build_map.cpp.
References add_button_link(), adjust_sign_msg(), object::arch, BUTTON, CF_HANDLE, DETECTOR, DOOR, draw_ext_info, draw_ext_info_format(), find_or_create_connection_for_map(), FLAG_IS_FLOOR, FLAG_NO_PICK, floor, FLOOR, FOR_OB_AND_ABOVE_FINISH, FOR_OB_AND_ABOVE_PREPARE, GATE, get_connection_rune(), GET_MAP_OB, INS_ABOVE_FLOOR_ONLY, MAGIC_EAR, object::map, MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, name, archetype::name, NDI_UNIQUE, object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), PEDESTAL, QUERY_FLAG, query_name(), SET_FLAG, SIGN, TIMED_GATE, and object::type.
Referenced by apply_map_builder().
void apply_builder_remove | ( | object * | pl, |
int | dir | ||
) |
Item remover.
Removes first buildable item, either under or above the floor
pl | player removing an item. |
dir | direction the player is trying to remove. |
Definition at line 890 of file build_map.cpp.
References object::above, BUTTON, CF_HANDLE, DETECTOR, DOOR, draw_ext_info, draw_ext_info_format(), FLAG_IS_FLOOR, FLAG_IS_LINKED, FLOOR, freearr_x, freearr_y, GATE, GET_MAP_OB, llevError, LOG(), MAGIC_EAR, object::map, MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, name, NDI_UNIQUE, object_free_drop_inventory(), object_remove(), mapstruct::path, PEDESTAL, QUERY_FLAG, query_name(), remove_button_link(), SIGN, TIMED_GATE, object::type, WALL, object::x, and object::y.
Referenced by apply_map_builder().
Wall building function.
Walls can be built:
pl | player building. |
new_wall | new wall object |
x | |
y | where to build. |
Definition at line 627 of file build_map.cpp.
References object::arch, draw_ext_info, fix_walls(), get_wall(), INS_ABOVE_FLOOR_ONLY, object::map, MAX_BUF, message, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, archetype::name, NDI_UNIQUE, object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), OUT_OF_REAL_MAP, remove_marking_runes(), object::type, and WALL.
Referenced by apply_map_builder().
Window building function.
Windows can be built only on top of existing vertical or horizontal walls (*wall_2_1_1 or *wall_2_1_2).
pl | player building. |
new_wall_win | new windowed wall object |
x | |
y | where to build. |
Definition at line 707 of file build_map.cpp.
References object::arch, arch_to_object(), archetype, draw_ext_info, find_archetype(), object::flags, get_wall(), INS_ABOVE_FLOOR_ONLY, object::map, MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, archetype::name, NDI_UNIQUE, object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), object::type, and WALL.
Referenced by apply_map_builder().
void apply_map_builder | ( | object * | pl, |
int | dir | ||
) |
Global building function.
This is the general map building function. Called when the player 'fires' a builder or remover object.
pl | player building or removing. |
dir | building direction. |
Definition at line 960 of file build_map.cpp.
References apply_builder_floor(), apply_builder_item(), apply_builder_remove(), apply_builder_wall(), apply_builder_window(), object::arch, can_build_over(), object::contr, draw_ext_info, find_archetype(), find_marked_object(), FLAG_IS_BUILDABLE, FLAG_UNPAID, FOR_OB_AND_ABOVE_FINISH, FOR_OB_AND_ABOVE_PREPARE, freearr_x, freearr_y, GET_MAP_OB, IS_PLAYER(), llevError, LOG(), object::map, MAP_HEIGHT, MAP_WIDTH, MATERIAL, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, archetype::name, NDI_UNIQUE, object_create_arch(), object_decrease_nrof_by_one, mapstruct::path, QUERY_FLAG, range_builder, player::ranges, SET_FLAG, SIGN, object::slaying, ST_BD_BUILD, ST_BD_REMOVE, ST_MAT_FLOOR, ST_MAT_ITEM, ST_MAT_WALL, ST_MAT_WINDOW, object::subtype, object::type, object::x, and object::y.
Referenced by fire().
Check if objects on a square interfere with building.
map | map we're building on. |
new_item | item the player is trying to build, must not be NULL. |
x | |
y | coordinates where to build. |
Definition at line 48 of file build_map.cpp.
References object::arch, BOOK, BUTTON, CF_HANDLE, archetype::clone, DETECTOR, DOOR, FLAG_IS_BUILDABLE, FOR_MAP_FINISH, FOR_MAP_PREPARE, GATE, HEAD, MAGIC_EAR, object::more, archetype::name, PEDESTAL, QUERY_FLAG, SIGN, object::type, object::x, and object::y.
Referenced by apply_map_builder().
|
static |
Helper function for door/button/connected item building.
Will search the specified spot for a marking rune. If not found, returns -1 Else, searches a force in op's inventory matching the map's name and the rune's text. If found, returns the connection value associated else searches a new connection value, and adds the force to the player.
pl | player building. |
x | |
y | coordinates where to build. |
rune | rune used to indicate the connection value. If NULL, building is searched for one. |
Definition at line 272 of file build_map.cpp.
References add_string(), create_archetype(), draw_ext_info, find_unused_connected_value(), FOR_INV_FINISH, FOR_INV_PREPARE, FORCE, FORCE_NAME, get_connection_rune(), object::map, object::msg, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, NDI_UNIQUE, object_insert_in_ob(), object_set_msg(), object_update_speed(), mapstruct::path, object::path_attuned, object::slaying, and object::speed.
Referenced by apply_builder_item().
|
static |
Returns an unused value for 'connected'.
Tries 1000 random values, then returns -1.
map | map for which to find a value |
Definition at line 234 of file build_map.cpp.
References mapstruct::buttons, oblinkpt::next, and oblinkpt::value.
Referenced by find_or_create_connection_for_map().
|
static |
Fixes walls around specified spot.
Basically it ensures the correct wall is put where needed.
map | |
x | |
y | position to fix. |
Definition at line 336 of file build_map.cpp.
References object::arch, arch_to_object(), archetype, object::flags, get_wall(), INS_ABOVE_FLOOR_ONLY, MAP_HEIGHT, MAP_WIDTH, MAX_BUF, archetype::name, object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), try_find_archetype(), object::type, and WALL.
Referenced by apply_builder_floor(), and apply_builder_wall().
Returns the marking rune on the square, for purposes of building connections.
pl | player trying to build. |
x | |
y | coordinates to search. |
Definition at line 103 of file build_map.cpp.
References FOR_MAP_FINISH, FOR_MAP_PREPARE, object::map, and SIGN.
Referenced by apply_builder_item(), and find_or_create_connection_for_map().
Returns the book/scroll on the current square, for purposes of building.
pl | player trying to build. |
x | |
y | coordinates to search. |
Definition at line 122 of file build_map.cpp.
References BOOK, FOR_MAP_FINISH, FOR_MAP_PREPARE, and object::map.
Referenced by adjust_sign_msg().
Returns first item of type WALL.
map | |
x | |
y | where to search. |
Definition at line 142 of file build_map.cpp.
References FOR_MAP_FINISH, FOR_MAP_PREPARE, and WALL.
Referenced by apply_builder_wall(), apply_builder_window(), and fix_walls().
|
static |
Erases all marking runes at specified location (before building a wall)
map | |
x | |
y | coordinates to erase runes at. |
Definition at line 158 of file build_map.cpp.
References FOR_MAP_FINISH, FOR_MAP_PREPARE, object_free_drop_inventory(), object_remove(), and SIGN.
Referenced by apply_builder_wall().