static int Lua_MonsterType_Enemies_Get(lua_State *L) { int monster_type = Lua_MonsterType_Enemies::Index(L, 1); int enemy_class = Lua_MonsterClass::ToIndex(L, 2); monster_definition *definition = get_monster_definition_external(monster_type); lua_pushboolean(L, definition->enemies & enemy_class); return 1; }
int Lua_MonsterType_Weaknesses_Get(lua_State *L) { int monster_type = Lua_MonsterType_Weaknesses::Index(L, 1); int damage_type = Lua_DamageType::ToIndex(L, 2); monster_definition *definition = get_monster_definition_external(monster_type); lua_pushboolean(L, definition->weaknesses & (1 << damage_type)); return 1; }
static int Lua_MonsterType_Friends_Get(lua_State *L) { int monster_type = Lua_MonsterType_Friends::Index(L, 1); int friend_class = Lua_MonsterClass::ToIndex(L, 2); monster_definition *definition = get_monster_definition_external(monster_type); lua_pushboolean(L, definition->friends & friend_class); return 1; }
int Lua_Monster_Move_By_Path(lua_State *L) { int monster_index = Lua_Monster::Index(L, 1); int polygon_index = 0; if (lua_isnumber(L, 2)) { polygon_index = static_cast<int>(lua_tonumber(L, 2)); if (!Lua_Polygon::Valid(polygon_index)) return luaL_error(L, "move_by_path: invalid polygon index"); } else if (Lua_Polygon::Is(L, 2)) { polygon_index = Lua_Polygon::Index(L, 2); } else return luaL_error(L, "move_by_path: incorrect argument type"); monster_data *monster = get_monster_data(monster_index); if (MONSTER_IS_PLAYER(monster)) return luaL_error(L, "move_by_path: monster is player"); monster_definition *definition = get_monster_definition_external(monster->type); object_data *object = get_object_data(monster->object_index); monster_pathfinding_data path; world_point2d destination; if (!MONSTER_IS_ACTIVE(monster)) activate_monster(monster_index); if (monster->path != NONE) { delete_path(monster->path); monster->path = NONE; } SET_MONSTER_NEEDS_PATH_STATUS(monster, false); path.definition = definition; path.monster = monster; path.cross_zone_boundaries = true; destination = get_polygon_data(polygon_index)->center; monster->path = new_path((world_point2d *) &object->location, object->polygon, &destination, polygon_index, 3 * definition->radius, monster_pathfinding_cost_function, &path); if (monster->path == NONE) { if (monster->action != _monster_is_being_hit || MONSTER_IS_DYING(monster)) { set_monster_action(monster_index, _monster_is_stationary); } set_monster_mode(monster_index, _monster_unlocked, NONE); return 0; } advance_monster_path(monster_index); return 0; }
static int Lua_MonsterType_Set_Flag(lua_State* L) { if (!lua_isboolean(L, 2)) return luaL_error(L, "monster flag: incorrect argument type"); monster_definition* definition = get_monster_definition_external(Lua_MonsterType::Index(L, 1)); if (lua_toboolean(L, 2)) { definition->flags |= flag; } else { definition->flags &= ~flag; } return 0; }
static int Lua_MonsterType_Set_Item(lua_State *L) { int item_type = 0; if (lua_isnumber(L, 2)) { item_type = static_cast<int>(lua_tonumber(L, 2)); } else if (lua_isnil(L, 2)) { item_type = NONE; } else return luaL_error(L, "item: incorrect argument type"); monster_definition *definition = get_monster_definition_external(Lua_MonsterType::ToIndex(L, 1)); definition->carrying_item_type = item_type; return 0; }
void accelerate_player( short monster_index, world_distance vertical_velocity, angle direction, world_distance velocity) { short player_index= monster_index_to_player_index(monster_index); struct player_data *player= get_player_data(player_index); struct physics_variables *variables= &player->variables; struct physics_constants *constants= get_physics_constants_for_model(static_world->physics_model, 0); variables->external_velocity.k+= WORLD_TO_FIXED(vertical_velocity); variables->external_velocity.k= PIN(variables->external_velocity.k, -constants->terminal_velocity, constants->terminal_velocity); if (get_monster_definition_external(_monster_marine)->flags & _monster_can_grenade_climb) { variables->external_velocity.i= (cosine_table[direction]*velocity)>>(TRIG_SHIFT+WORLD_FRACTIONAL_BITS-FIXED_FRACTIONAL_BITS); variables->external_velocity.j= (sine_table[direction]*velocity)>>(TRIG_SHIFT+WORLD_FRACTIONAL_BITS-FIXED_FRACTIONAL_BITS); } else {
static int Lua_MonsterType_Enemies_Set(lua_State *L) { if (!lua_isboolean(L, 3)) return luaL_error(L, "enemies: incorrect argument type"); int monster_type = Lua_MonsterType_Enemies::Index(L, 1); int enemy_class = Lua_MonsterClass::ToIndex(L, 2); bool enemy = lua_toboolean(L, 3); monster_definition *definition = get_monster_definition_external(monster_type); if (enemy) { definition->enemies = definition->enemies | enemy_class; } else { definition->enemies = definition->enemies & ~(enemy_class); } return 0; }
int Lua_MonsterType_Weaknesses_Set(lua_State *L) { if (!lua_isboolean(L, 3)) luaL_error(L, "immunities: incorrect argument type"); int monster_type = Lua_MonsterType_Weaknesses::Index(L, 1); int damage_type = Lua_DamageType::ToIndex(L, 2); bool weakness = lua_toboolean(L, 3); monster_definition *definition = get_monster_definition_external(monster_type); if (weakness) { definition->weaknesses |= (1 << damage_type); } else { definition->weaknesses &= ~(1 << damage_type); } return 0; }
static int Lua_MonsterType_Set_Class(lua_State *L) { monster_definition *definition = get_monster_definition_external(Lua_MonsterType::Index(L, 1)); definition->_class = static_cast<int32>(Lua_MonsterClass::ToIndex(L, 2)); return 0; }
static int Lua_MonsterType_Get_Item(lua_State *L) { monster_definition *definition = get_monster_definition_external(Lua_MonsterType::Index(L, 1)); Lua_ItemType::Push(L, definition->carrying_item_type); return 1; }
static int Lua_MonsterType_Get_Radius(lua_State *L) { monster_definition *definition = get_monster_definition_external(Lua_MonsterType::Index(L, 1)); lua_pushnumber(L, (double) definition->radius / WORLD_ONE); return 1; }
static int Lua_MonsterType_Get_Melee_Impact_Effect(lua_State *L) { monster_definition *definition = get_monster_definition_external(Lua_MonsterType::Index(L, 1)); Lua_EffectType::Push(L, definition->melee_impact_effect); return 1; }
static int Lua_MonsterType_Get_Flag(lua_State* L) { monster_definition* definition = get_monster_definition_external(Lua_MonsterType::Index(L, 1)); lua_pushboolean(L, definition->flags & flag); return 1; }
static int Lua_MonsterType_Get_Class(lua_State *L) { monster_definition *definition = get_monster_definition_external(Lua_MonsterType::Index(L, 1)); Lua_MonsterClass::Push(L, definition->_class); return 1; }