int32 effect::is_chainable(uint8 tp) { if(!(type & EFFECT_TYPE_ACTIONS)) return FALSE; uint32 sp = get_speed(); if((type & EFFECT_TYPE_ACTIVATE) && sp <= 1) return FALSE; if(pduel->game_field->core.current_chain.size()) { if(get_speed() < pduel->game_field->core.current_chain.rbegin()->triggering_effect->get_speed()) return FALSE; } if(pduel->game_field->core.chain_limit) { pduel->lua->add_param(this, PARAM_TYPE_EFFECT); pduel->lua->add_param(pduel->game_field->core.chain_limp, PARAM_TYPE_INT); pduel->lua->add_param(tp, PARAM_TYPE_INT); if(!pduel->lua->check_condition(pduel->game_field->core.chain_limit, 3)) return FALSE; } if(pduel->game_field->core.chain_limit_p) { pduel->lua->add_param(this, PARAM_TYPE_EFFECT); pduel->lua->add_param(pduel->game_field->core.chain_limp_p, PARAM_TYPE_INT); pduel->lua->add_param(tp, PARAM_TYPE_INT); if(!pduel->lua->check_condition(pduel->game_field->core.chain_limit_p, 3)) return FALSE; } return TRUE; }
AIRCRAFT_STATE AircraftStateFilter::get_predicted_state(const fixed &in_time) const { AIRCRAFT_STATE state_next = m_state_last; GeoVector vec(get_speed()*in_time, get_bearing()); state_next.Location = vec.end_point(m_state_last.Location); state_next.NavAltitude = m_state_last.NavAltitude+get_climb_rate()*in_time; state_next.Speed = get_speed(); state_next.Vario = get_climb_rate(); return state_next; }
NPC::NPC(Subsystem& subsystem, const std::string& filename, ZipReader *zip) throw (KeyValueException, MovableException) : Properties(filename + ".npc", zip), Movable(subsystem) { try { read_base_informations(*this); move_init = atoi(get_value("move_init").c_str()); if (move_init == 0) { move_init = 50; } jump_x_impulse = atof(get_value("jump_x_impulse").c_str()); if (jump_x_impulse < Epsilon) { jump_x_impulse = 1.5f; } jump_y_impulse = atof(get_value("jump_y_impulse").c_str()); if (jump_y_impulse < Epsilon) { jump_y_impulse = 1.5f; } max_accel_x = atof(get_value("max_accel_x").c_str()); if (max_accel_x < Epsilon) { max_accel_x = 2.5f; } springiness_x = atof(get_value("springiness_x").c_str()); springiness_y = atof(get_value("springiness_y").c_str()); friction_factor = atof(get_value("friction_factor").c_str()); if (friction_factor < Epsilon) { friction_factor = 1.0f; } idle1_counter = static_cast<double>(atoi(get_value("idle1_counter").c_str())); idle2_counter = static_cast<double>(atoi(get_value("idle2_counter").c_str())); impact = atof(get_value("impact").c_str()); ignore_owner_counter = atof(get_value("ignore_owner_counter").c_str()); if (ignore_owner_counter < 100.0f) { ignore_owner_counter = 100.0f; } create_npc(NPCAnimationStanding, filename + "_standing.png", get_speed(*this, "standing", 30), get_one_shot(*this, "standing", false), zip); create_npc(NPCAnimationIdle1, filename + "_idle1.png", get_speed(*this, "idle1", 30), get_one_shot(*this, "idle1", false), zip); create_npc(NPCAnimationIdle2, filename + "_idle2.png", get_speed(*this, "idle2", 30), get_one_shot(*this, "idle2", false), zip); create_npc(NPCAnimationJumping, filename + "_jumping.png", get_speed(*this, "jumping", 30), get_one_shot(*this, "jumping", false), zip); } catch (const Exception& e) { throw MovableException(std::string(e.what()) + ": " + filename); } }
int main() { int fd = obd_open(OBD_PORT); int avr_fd = avr_open(AVR_PORT); FILE* timelog = open_timing_log(); int RPM = 0; int speed = 0; time_t start, end; obd_setup(fd); printf("Beginning read cycle...\n"); while (true) { start = time(0); RPM = get_rpm(fd); end = time(0); log_time(timelog, end - start); speed = get_speed(fd); if ((RPM != -1) && (speed != -1)) { send_to_avr(avr_fd, speed, RPM); printf("RPM: %d\nSpeed: %d\n", RPM, speed); } //flush buffers just in case tcflush(fd, TCIOFLUSH); } return 0; }
int main(UNUSED int ac, char **av, char **env) { t_config config; t_tetrimino *tetri; char key[10]; int c; struct winsize win; tetri = NULL; if ((tetri = init_main(av, env, &config, tetri)) == NULL) return (-1); c = 0; key[0] = 0; while (compare_key(key, config.quit) == 0) { ioctl(0, TIOCGWINSZ, &win); get_entry(key); if (key[0] != 0) key_control(key, &config, tetri); if (++c >= 100 && config.brek == 0 && (c = -1) == -1) if (game_physics(&config, tetri)) end_game(&config, key); usleep(get_speed(config.speed, config.level)); } endwin(); return (0); }
int monster::dodge_roll() { if (has_effect("bouldering")) { if(one_in(type->sk_dodge)) { return 0; } } int numdice = get_dodge(); switch (type->size) { case MS_TINY: numdice += 6; break; case MS_SMALL: numdice += 3; break; case MS_LARGE: numdice -= 2; break; case MS_HUGE: numdice -= 4; break; case MS_MEDIUM: break; // keep default } numdice += get_speed() / 80; return dice(numdice, 10); }
int32 effect::is_chainable(uint8 tp) { if(!(type & EFFECT_TYPE_ACTIONS)) return FALSE; int32 sp = get_speed(); if((type & EFFECT_TYPE_ACTIVATE) && (sp <= 1) && !(flag & EFFECT_FLAG_COF)) return FALSE; if(pduel->game_field->core.current_chain.size()) { if(!(flag & EFFECT_FLAG_FIELD_ONLY) && (type & EFFECT_TYPE_TRIGGER_O) && (handler->current.location == LOCATION_HAND)) { if(pduel->game_field->core.current_chain.rbegin()->triggering_effect->get_speed() > 2) return FALSE; } else if(sp < pduel->game_field->core.current_chain.rbegin()->triggering_effect->get_speed()) return FALSE; } if(pduel->game_field->core.chain_limit) { pduel->lua->add_param(this, PARAM_TYPE_EFFECT); pduel->lua->add_param(pduel->game_field->core.chain_limp, PARAM_TYPE_INT); pduel->lua->add_param(tp, PARAM_TYPE_INT); if(!pduel->lua->check_condition(pduel->game_field->core.chain_limit, 3)) return FALSE; } if(pduel->game_field->core.chain_limit_p) { pduel->lua->add_param(this, PARAM_TYPE_EFFECT); pduel->lua->add_param(pduel->game_field->core.chain_limp_p, PARAM_TYPE_INT); pduel->lua->add_param(tp, PARAM_TYPE_INT); if(!pduel->lua->check_condition(pduel->game_field->core.chain_limit_p, 3)) return FALSE; } return TRUE; }
void Creature::reset_stats() { // Reset our stats to normal levels // Any persistent buffs/debuffs will take place in disease.h, // player::suffer(), etc. // repopulate the stat fields process_effects(); str_cur = str_max + get_str_bonus(); dex_cur = dex_max + get_dex_bonus(); per_cur = per_max + get_per_bonus(); int_cur = int_max + get_int_bonus(); // Floor for our stats. No stat changes should occur after this! if (dex_cur < 0) { dex_cur = 0; } if (str_cur < 0) { str_cur = 0; } if (per_cur < 0) { per_cur = 0; } if (int_cur < 0) { int_cur = 0; } // add an appropriate number of moves moves += get_speed(); }
/* Odometer Interrupt routine */ void OdometerIntHandler(void) { int16_t speed; speed = get_speed(); /* Clear interrupt flag */ HWREG(TIMERA2_BASE + TIMER_O_ICR) = 0x1; /* Read odometers */ odo1 = readODO1(); odo2 = readODO2(); /* Keep track of the odometry depending on the motor speed*/ if(odo1 != odo1_old) { if(speed >= 0) odo1_total++; else odo1_total--; } if(odo2 != odo2_old) { if(speed >= 0) odo2_total++; else odo2_total--; } odo1_old = odo1; odo2_old = odo2; }
void Entity::yaw_left(float force) { // 1 unit of force turns 1 weight by M_PI/2 float angular_force = get_speed(force)*RIGHT_ANGLE; turn_angle(fvec3(angular_force, 0, 0)); }
/** * @brief Calculates the direction and the speed of the movement * depending on the target. */ void TargetMovement::recompute_movement() { if (target_entity != NULL) { // the target may be a moving entity target_x = target_entity->get_x(); target_y = target_entity->get_y(); } if (get_x() != target_x || get_y() != target_y) { finished = false; double angle = Geometry::get_angle(get_x(), get_y(), target_x, target_y); int dx = target_x - get_x(); int dy = target_y - get_y(); sign_x = (dx >= 0) ? 1 : -1; sign_y = (dy >= 0) ? 1 : -1; if (std::fabs(angle - get_angle()) > 1E-6 || get_speed() < 1E-6) { set_speed(speed); set_angle(angle); set_max_distance((int) Geometry::get_distance( get_x(), get_y(), target_x, target_y)); } } }
/** * @brief Returns the value of a property of this movement. * * Accepted keys: * - speed * - angle * - max_distance * - ignore_obstacles * - smooth * - displayed_direction * * @param key key of the property to get * @return the corresponding value as a string */ const std::string StraightMovement::get_property(const std::string &key) { std::ostringstream oss; if (key == "speed") { oss << get_speed(); } else if (key == "angle") { oss << get_angle(); } else if (key == "max_distance") { oss << get_max_distance(); } else if (key == "ignore_obstacles") { oss << are_obstacles_ignored(); } else if (key == "smooth") { oss << is_smooth(); } else if (key == "displayed_direction") { oss << get_displayed_direction4(); } else { Debug::die(StringConcat() << "Unknown property of StraightMovement: '" << key << "'"); } return oss.str(); }
int play_game(){ draw_border(); update_position(); draw_snake(); usleep(get_speed()); return 1; }
/* % gcc -DDEBUG_MODULE get_mach_stat.c -I../../.. -g -DUSE_CPU_SPEED */ int main(int argc, char * argv[]) { int error_code; uint16_t sockets, cores, threads; uint16_t block_map_size; uint16_t *block_map, *block_map_inv; struct config_record this_node; char node_name[MAX_SLURM_NAME]; float speed; uint16_t testnumproc = 0; uint32_t up_time = 0; int days, hours, mins, secs; char* _cpuinfo_path = "/proc/cpuinfo"; if (argc > 1) { _cpuinfo_path = argv[1]; testnumproc = 1024; /* since may not match test host */ } debug3("%s:", _cpuinfo_path); error_code = get_mach_name(node_name); if (error_code != 0) exit(1); /* The show is all over without a node name */ error_code += get_procs(&this_node.cpus); error_code += get_cpuinfo(MAX(this_node.cpus, testnumproc), &this_node.sockets, &this_node.cores, &this_node.threads, &block_map_size, &block_map, &block_map_inv); xfree(block_map); /* not used here */ xfree(block_map_inv); /* not used here */ error_code += get_memory(&this_node.real_memory); error_code += get_tmp_disk(&this_node.tmp_disk, "/tmp"); error_code += get_up_time(&up_time); #ifdef USE_CPU_SPEED error_code += get_speed(&speed); #endif debug3(""); debug3("NodeName=%s CPUs=%u Sockets=%u Cores=%u Threads=%u", node_name, this_node.cpus, this_node.sockets, this_node.cores, this_node.threads); debug3("\tRealMemory=%u TmpDisk=%u Speed=%f", this_node.real_memory, this_node.tmp_disk, speed); secs = up_time % 60; mins = (up_time / 60) % 60; hours = (up_time / 3600) % 24; days = (up_time / 86400); debug3("\tUpTime=%u=%u-%2.2u:%2.2u:%2.2u", up_time, days, hours, mins, secs); if (error_code != 0) debug3("get_mach_stat error_code=%d encountered", error_code); exit (error_code); }
struct dce_i2c_hw *acquire_i2c_hw_engine( struct resource_pool *pool, struct ddc *ddc) { uint32_t counter = 0; enum gpio_result result; uint32_t current_speed; struct dce_i2c_hw *dce_i2c_hw = NULL; if (!ddc) return NULL; if (ddc->hw_info.hw_supported) { enum gpio_ddc_line line = dal_ddc_get_line(ddc); if (line < pool->pipe_count) dce_i2c_hw = pool->hw_i2cs[line]; } if (!dce_i2c_hw) return NULL; if (pool->i2c_hw_buffer_in_use) return NULL; do { result = dal_ddc_open(ddc, GPIO_MODE_HARDWARE, GPIO_DDC_CONFIG_TYPE_MODE_I2C); if (result == GPIO_RESULT_OK) break; /* i2c_engine is busy by VBios, lets wait and retry */ udelay(10); ++counter; } while (counter < 2); if (result != GPIO_RESULT_OK) return NULL; dce_i2c_hw->ddc = ddc; current_speed = get_speed(dce_i2c_hw); if (current_speed) dce_i2c_hw->original_speed = current_speed; if (!setup_engine(dce_i2c_hw)) { release_engine(dce_i2c_hw); return NULL; } pool->i2c_hw_buffer_in_use = true; return dce_i2c_hw; }
void Creature::process_turn() { process_effects(); // Call this in case any effects have changed our stats reset_stats(); // add an appropriate number of moves moves += get_speed(); }
void monster::debug(player &u) { debugmsg("monster::debug %s has %d steps planned.", name().c_str(), plans.size()); debugmsg("monster::debug %s Moves %d Speed %d HP %d",name().c_str(), moves, get_speed(), hp); for (size_t i = 0; i < plans.size(); i++) { const int digit = '0' + (i % 10); mvaddch(plans[i].y - SEEY + u.posy, plans[i].x - SEEX + u.posx, digit); } getch(); }
void StraightMovement::set_angle(double angle) { double speed = get_speed(); set_speed_x(speed * std::cos(angle)); set_speed_y(-speed * std::sin(angle)); this->angle = angle; if(get_entity() != NULL) { get_entity()->notify_movement_changed(); } }
/** * @brief Changes the direction of the movement vector, keeping the same speed. * * x_speed and y_speed are recomputed so that the total speed is unchanged. * Warning: if x_speed and y_speed are both equal to zero, this function * stops the program on an error message. * * @param angle the new movement direction in radians */ void StraightMovement::set_angle(double angle) { if (!is_stopped()) { double speed = get_speed(); set_x_speed(speed * std::cos(angle)); set_y_speed(-speed * std::sin(angle)); } this->angle = angle; notify_movement_changed(); }
int main(int argc, char** argv) { init(HOST, PORT); if (argc < 2) { printf("Usage %s filename\n", argv[0]); return -1; } tabel = tabelcrc(CRCCCITT); printf("Speed: %d\n", get_speed(argv[1])); printf("Delay: %d\n", get_delay(argv[2])); printf("Loss: %lf\n", get_loss(argv[3])); printf("Corrupt: %lf\n", get_corrupt(argv[4])); transmit(argv[5], get_speed(argv[1]), get_delay(argv[2]), get_loss(argv[3]), get_corrupt(argv[4]) ); free(tabel); return 0; }
int main(int argc, char *argv[]) { hash_function_t fun; unsigned long databytes = 30000000; unsigned long len, calls; if (argc < 2) die_usage(); fun = get_hashfunc_by_name(argv[1]); if (!fun) die_list(); if (argc == 2) /* only output summary of several get_speed() runs are done */ printf("# %s\n# length calls\ttime\n", argv[1]); if (argc > 2) databytes = atoi(argv[2]); if (argc > 3) { len = atoi(argv[3]); if (len == 0) die_usage(); calls = databytes /= len; get_speed(fun, len, calls); return 0; } calls = databytes /= 4; get_speed(fun, 4, calls); calls /= 10; get_speed(fun, 40, calls); calls /= 10; get_speed(fun, 400, calls); calls /= 10; get_speed(fun, 4000, calls); calls /= 10; get_speed(fun,40000, calls); return 0; }
int monster::get_dodge() const { if (has_effect("downed")) { return 0; } int ret = type->sk_dodge; if (has_effect("beartrap") || has_effect("tied")) { ret /= 2; } if (moves <= 0 - 100 - get_speed()) { ret = rng(0, ret); } return ret + get_dodge_bonus(); }
size_t revolute_joint::initialize_state_value_bindings_(sv_bindings_t& bindings, sv_accessors_t& accessors, state_value_id const& base) const { auto initial_count = bindings.size(); auto bound_id = accessors.size(); auto svid = base + "angle"; bindings[svid] = bound_id++; accessors.push_back([this] { return get_angle(); }); svid = base + "speed"; bindings[svid] = bound_id++; accessors.push_back([this] { return get_speed(); }); svid = base + "applied"; bindings[svid] = bound_id++; accessors.push_back([this] { return gen_as_.applied_torque; }); svid = base + "reaction_Fx"; bindings[svid] = bound_id++; accessors.push_back([this] { return 0.0; //todo: joint_->GetReactionForce(m_sys->get_hertz()).x; }); svid = base + "reaction_Fy"; bindings[svid] = bound_id++; accessors.push_back([this] { return 0.0; //todo: joint_->GetReactionForce(m_sys->get_hertz()).y; }); svid = base + "reaction_T"; bindings[svid] = bound_id++; accessors.push_back([this] { return 0.0; //todo: joint_->GetReactionTorque(m_sys->get_hertz()); }); return bindings.size() - initial_count; }
void Creature::process_turn() { if(is_dead_state()) { return; } reset_bonuses(); process_effects(); // Call this in case any effects have changed our stats reset_stats(); // add an appropriate number of moves moves += get_speed(); }
//************************************************************ // PC // Movement is started here //************************************************************ int ca_run(void) { int ir1=100; int ir2=100; int ir3=100; int ir4=100; int i=0; while (i<5){ direction_filter(get_speed(),get_dir(),ir1, ir2, ir3, ir4); i++; } return 1; }
int monster::turns_to_reach( int x, int y ) { // This function is a(n old) temporary hack that should soon be removed auto path = g->m.route( pos(), tripoint( x, y, posz() ), get_pathfinding_settings() ); if( path.empty() ) { return 999; } double turns = 0.; for( size_t i = 0; i < path.size(); i++ ) { const tripoint &next = path[i]; if( g->m.impassable( next ) ) { // No bashing through, it looks stupid when you go back and find // the doors intact. return 999; } else if( i == 0 ) { turns += double( calc_movecost( pos(), next ) ) / get_speed(); } else { turns += double( calc_movecost( path[i - 1], next ) ) / get_speed(); } } return int( turns + .9 ); // Halve (to get turns) and round up }
/** * @brief Returns the value of a property of this movement. * * Accepted keys: * - speed * - displayed_direction * * @param key key of the property to get * @return the corresponding value as a string */ const std::string RandomPathMovement::get_property(const std::string &key) { std::ostringstream oss; if (key == "speed") { oss << get_speed(); } else if (key == "displayed_direction") { oss << get_displayed_direction4(); } else { Debug::die(StringConcat() << "Unknown property of RandomPathMovement: '" << key << "'"); } return oss.str(); }
//---------------------------------------------------------------------------- void EltOrange::calc_frottements() { // frottements vector_t C1,C2,F; double norme; norme=-1.*simul_info->coeff_frott[mBois][mBois]*masse; F = speed*norme; add_force(G_rot,F); C1=N*rayon; C2=-C1; norme=(get_speed(C1)^N)/rayon*0.0008; F=T*norme; add_force(C1,F); F=-F; add_force(C2,F); }
static turn_command_t player_move(game_t * game, int input) { int x_speed = 0, y_speed = 0; int mob_id; get_speed(input, &x_speed, &y_speed); mob_id = get_mob(game->level, game->player.mob->position.y + y_speed, game->player.mob->position.x + x_speed); if (mob_id != -1) { attack(game, game->player.mob, &(game->level->mobs[mob_id])); return turn_command_complete; } else if (try_move_mob(game, game->level, game->player.mob, y_speed, x_speed)) { explore(game->level, game->player.mob); explore_map(game->level, game->player.mob->position); if (game->level->map[game->player.mob->position.y * game->level->width + game->player.mob->position.x].type == tile_stair && prompt_yn("Go down the stairs?")) { return turn_command_descend; } item_t * item = game->level->map[game->player.mob->position.y * game->level->width + game->player.mob->position.x].item; if (item != NULL) { char item_n[100]; char line[MSGLEN]; item_name(item_n, item); snprintf(line, MSGLEN, "There is %s here.", item_n); print_msg(line); wait(); clear_msg(); } draw_map(game->input_type, game->level); return turn_command_complete; } print_msg("You cannot go there."); return turn_command_void; }
void StraightMovement::update_y() { uint32_t next_move_time_y = delay_y; if(move_y != 0) { //entity wants to move in y direction. next_move_time_y = delay_y; if(!test_collision_with_obstacles(0, move_y) && !test_collision_with_borders(0, move_y)) { translate_y(move_y); //make the move on y if(move_x != 0 && test_collision_with_obstacles(move_x, 0)) { // if there is also a y move and this move is stopped by an obstacles. next_move_time_y = (int) (1000 / get_speed()); update_x(); } } } else { stop(); } next_move_date_y += next_move_time_y; }