/** * @brief Creates a movement of type CircleMovement that will be accessible from the script. * * - Argument 1 (integer): type of the center entity * (must match the enumeration EntityType) * - Argument 2 (string): name of the center entity * - Argument 3 (int): the radius of the circle in pixels * - Return value (movement): a handle to the movement created * * @param l the Lua context that is calling this function */ int Script::main_api_circle_movement_create(lua_State *l) { Script *script; called_by_script(l, 3, &script); int center_type = luaL_checkinteger(l, 1); const std::string& center_name = luaL_checkstring(l, 2); int radius = luaL_checkinteger(l, 3); MapEntity* center_entity = script->get_map().get_entities(). get_entity(EntityType(center_type), center_name); CircleMovement *movement = new CircleMovement(); movement->set_center(center_entity); movement->set_radius(radius); int movement_handle = script->create_movement_handle(*movement); lua_pushinteger(l, movement_handle); return 1; }
/** * @brief Starts this state. * @param previous_state the previous state */ void Hero::SpinAttackState::start(State* previous_state) { State::start(previous_state); // play the sound play_spin_attack_sound(); // start the animation if (get_equipment().has_ability("sword_knowledge")) { get_sprites().set_animation_super_spin_attack(); CircleMovement* movement = new CircleMovement(false); movement->set_center(hero.get_xy()); movement->set_radius_speed(128); movement->set_radius(24); movement->set_angle_speed(540); movement->set_max_rotations(3); movement->set_clockwise(true); hero.set_movement(movement); } else { get_sprites().set_animation_spin_attack(); } }