int hit_monster(int y, int x, struct object *weapon, struct thing *thrower) { struct linked_list *mon; coord target; target.y = y; target.x = x; if (thrower == &player) return(fight(&target, weapon, THROWN)); if (ce(target, hero)) { if (good_monster(*thrower)) { if (on(*thrower, ISFAMILIAR)) msg("Please get out of the way, Master! I nearly hit you."); else msg("Get out of the way %s!", whoami); return(FALSE); } return(attack(thrower, weapon, THROWN)); } if ((mon = find_mons(y, x)) != NULL) return(mon_mon_attack(thrower, mon, weapon, THROWN)); else return(FALSE); }
int main() { int cs, tt; int i, l, r, tmp; char cmd[256]; scanf("%d", &tt); for (cs = 1; cs <= tt; cs++) { printf("Case %d:\n", cs); scanf("%d %d %d", &n, &q, &t); memset(cool, 0, sizeof(cool[0])*(1+n)); memset(cnt, 0, sizeof(cnt[0])*(1+n)); while (q--) { scanf("%s", cmd); if (cmd[0] == 'Q') { // Query scanf("%d", &l); printf("%d\n", cnt[l]); } else { // Attack scanf("%d %d", &l, &r); if (l > r) {tmp = l; l = r; r = tmp;} attack(l, r); } } } return 0; }
void st03::play(){ while(getPoint()){ if(getPoint())increaseHealth(); if(getPoint())increaseSpeed(); } int d=(~0U>>1),x,y; for(int i=1;i<=N;++i) for(int j=1;j<=M;++j) if(askWhat(i,j)==EMPTY){ int t1=abs(i-getX())+abs(j-getY()); if(t1>getSp())continue; for(int k=1;k<=N;++k) for(int l=1;l<=M;++l) if(askWhat(k,l)!=EMPTY){ int tmp=abs(i-k)+abs(j-l); if(tmp<d)d=tmp,x=i,y=j; } } move(x,y); for(int i=-1;i<2;++i) for(int j=-1;j<2;++j){ if(i&&j)continue; if((!i)&&(!j))continue; if(askWhat(x+i,y+j)!=EMPTY){ attack(x+i,y+j); return; } } }
//An easy to use, do-everything-in-one-call sort of function commandList GalconAI::update(std::list<Planet> & planets, const std::list<Fleet> & fleets, const std::vector<ShipStats> & shipstats, std::vector<std::list<Building*> > buildRules) { //Set up the list of commands commandList rb; //See if we have waited long enough and the AI is active int time = SDL_GetTicks(); if ((time - updateTime_ < set_.delay && updateTime_ != -1) || !active_) return rb; updateTime_ = time; std::cout << "Update) Attack: " << attTotal_ << " Defense: " << defTotal_ << std::endl; //Compute the best target computeTarget(planets, fleets, shipstats); //Get the commands from rebalancing, attacking, and building rb = rebalance(fleets, shipstats); commandList at = attack(shipstats); commandList bd = build(buildRules, shipstats); //Append at to rb for (commandList::iterator i = at.begin(); i != at.end(); i++) { rb.push_back(*i); } for (commandList::iterator i = bd.begin(); i != bd.end(); i++) { rb.push_back(*i); } //Return the combined list of commands return rb; }
bool Player::moveOrAttack(unsigned int target_x, unsigned int target_y) { if (engine.map->isWall(target_x, target_y)) { return false; } for (const auto& entity : engine.entities) { if ( entity->canDie && !entity->isDead() && entity->x == target_x && entity->y == target_y ) { attack(*entity); return false; } } for (const auto& entity : engine.entities) { if ( entity->canDie && entity->isDead() && entity->x == target_x && entity->y == target_y) { engine.gui->message(TCODColor::white, {"There's a "s, entity->name, " here.\n"s}); } } x = target_x; y = target_y; return true; }
void AttackState::enter(Character* agent) { // agent->getSkeletonNode()->setTimeScale(1.0); // agent->getSkeletonNode()->setToSetupPose(); // agent->getSkeletonNode()->setBonesToSetupPose(); // agent->getSkeletonNode()->setSlotsToSetupPose(); attacking = true; attackNum = 1; if (attackNum % 3 == 0) { bigAttack(agent); }else{ attack(agent); } // spTrackEntry* entry = agent->getSkeletonNode()->setAnimation(0, "attack", true); // agent->getSkeletonNode()->setTrackCompleteListener(entry, [=] (int trackIndex,int loopCount) { // //log("attack complete!"); // BGTWall *wall = agent->getWorld()->getWall(); // MessageDispatcher::getInstance()->dispatchMessage(0, //time delay 1.5 // agent->getID(), //sender ID // wall->getID(), //receiver ID // Msg_WallDamaged, //msg // NULL); // }); }
void SwampMonster::think(const double elapsedTime) { Monster::think(elapsedTime); if(!mIsFrozen && rand() % 750 == 0) attack(); }
void boxboy::update() { if (KEYMANAGER->isOnceKeyDown('Y')) _test = !_test; //플레이어를 찾아온다. for (int i = 0; i < _objectMgr->getVObject().size(); ++i) { if (_objectMgr->getVObject()[i]->getType() != PLAYER) continue; if (_objectMgr->getVObject()[i]->getType() == PLAYER) { _playerX = _objectMgr->getVObject()[i]->getX(); _playerY = _objectMgr->getVObject()[i]->getY(); _saveIdx = i; break; } } _hpBar->update(); _hpBar->setPosition(_enemy.coll.left, _enemy.coll.top - 5); if (_enemy.state != DEAD && _enemy.state != NONE) { move(); if(_objectMgr->getVObject()[_saveIdx]->getState() == IDLE) attack(); } setImage(); }
void UnitMng::issueCommands() { if(conUnit) { //double *inputs,*outputs; //inputs=generateInputs(); generateInputs(); //outputs=generateOutputs(inputs); generateOutputs(); //Keep Last Command incase of CONTINUE lastCommand=act; if(outputs[0]>outputs[1]&&outputs[0]>outputs[2])//&&outputs[0]>=outputs[3]) { act=ATTACK; attack(); } else if(outputs[1]>outputs[0]&&outputs[1]>outputs[2])//&&outputs[1]>=outputs[3]) { act=MOVE; move(); } else if(outputs[2]>outputs[0]&&outputs[2]>outputs[1])//&&outputs[2]>=outputs[3]) { act=HOLD; hold(); } else { Continue(); } } }
void PlayerObject::update(const Ogre::FrameEvent &evt) { if (player->isDead()) { setDeathAnimation(); if (mAnimationState->hasEnded() && updateGraveyard) { player->onDeath(); FileManager::getInstance().addToGraveyard(player); World::getInstance().pauseGame(); updateGraveyard = false; } // if } // if else { lastHealthTick += evt.timeSinceLastEvent * 5.0f; if (lastHealthTick >= 1.0f) { player->regenerateLife(); lastHealthTick = 0.0; } // if move(evt); attack(evt); Ogre::Vector3 campos = camera->getPosition(); campos.x = objectNode->getPosition().x; campos.z = objectNode->getPosition().z + campos.y; camera->setPosition(campos); player->updateTimePlayed(evt.timeSinceLastEvent * 5.0f); GUIManager::getInstance().inGameMenu->updateAttributes(player); GUIManager::getInstance().inGameMenu->updatePlayerScore(player); } // else mAnimationState->addTime(evt.timeSinceLastFrame); } // update
void UnitMng::Continue() { if(lastCommand==NOCOMMMAND) { lastCommand=MOVE; act=lastCommand; move(); } else { act=lastCommand; switch (lastCommand) { case ATTACK: attack(); break; case MOVE: move(); break; case HOLD: hold(); } } }
int ServantAssassin::doAction(int actionNum, vector<Servant *> defenders) { int ret = 0; switch (actionNum) { case 0: ret = attack(defenders, true); break; case 1: ret = poisonStrike(defenders); break; case 2: ret = presenceConcealment(defenders); break; case 3: ret = activateNP1(defenders); break; case 4: ret = activateNP2(defenders); break; case 5: ret = activateNP3(defenders); break; default: return 2; // Not a valid choice break; } return ret; }
void Tank::moveTank() { xtemp=x; ytemp=y; switch(dir) { case U: y-=5;break; case D: y+=5;break; case L: x-=5;break; case R: x+=5;break; case LU: x-=5;y-=5;break; case LD: x-=5;y+=5;break; case RU: x+=5;y-=5;break; case RD: x+=5;y+=5;break; default:break; } if(x<=0)x=0; if(y<=0)y=0; if(x>=MainWindow::WIDTH-w)x=MainWindow::WIDTH-w; if(y>=MainWindow::HEIGHT-h)y=MainWindow::HEIGHT-h; if(!good) { if(qrand()%20>18)attack(); if(step==0) { dir=Direction(qrand()%9); step=qrand()%15+10; } step--; } }
void* solve(void *arg) { thr_param_t param = *((thr_param_t *) arg); int i, j, col; int n; int *hist; hist = param.hist; n = param.n; col = param.col; # define attack(i, j) (hist[j] == i || abs(hist[j] - i) == col - j) for (i = 0, j = 0; i < n; i++) { for (j = 0; j < col && !attack(i, j); j++); if (j < col) continue; hist[col] = i; thr_param_t param1; AnahyJob job; param1.hist = hist; param1.n = n; param1.col = col+1; job.init(solve, ¶m1, NULL); AnahyVM::fork(&job); AnahyVM::join(&job, NULL); } }
void Enemy::move() { if (this->isDead && (sKind != 5 || sNum != 0)) return; switch (status) { case EnemyNS::DIRECTION::ENTER: enterEnemy(); break; case EnemyNS::DIRECTION::BEGINPOS: beginPos(); break; case EnemyNS::DIRECTION::POSITION: position(); break; case EnemyNS::DIRECTION::SYNC: makeSync(); break; case EnemyNS::DIRECTION::ATTACK: attack(); break; case EnemyNS::DIRECTION::BEGINBACK: beginBackPos(); break; case EnemyNS::DIRECTION::BACKPOS: backPosition(); } }
void Monster::moveOrAttack(unsigned int target_x, unsigned int target_y) { int dx = target_x - x; int dy = target_y - y; int step_dx = ( dx > 0 ? 1 : -1 ); int step_dy = ( dy > 0 ? 1 : -1 ); double distance = sqrt(dx*dx + dy*dy); if (distance >= 1.5) { dx = (int)(round(dx / distance)); dy = (int)(round(dy / distance)); if ( engine.map->canWalk(x + dx, y + dy) ) { x += dx; y += dy; } else if (engine.map->canWalk(x + step_dx, y)) { x += step_dx; } else if (engine.map->canWalk(x, y + step_dy)) { y += step_dy; } } else { attack(*(engine.player)); } }
void Characters::Enemy::executeAction() { switch( characterSprite->getCurrentState() ) { case GameCoreStates::STILL: { noAction(); break; } case GameCoreStates::WALKING: { walk(); break; } case GameCoreStates::RUNNING: { run(); break; } case GameCoreStates::JUMPING: case GameCoreStates::DOUBLE_JUMP: { jump(); break; } case GameCoreStates::FAST_ATTACK: { attack(); break; } } }
void emy_moverot::update(){ auto& ply = manager::get().player_; eframe++; move(); attack(); Isdead(); }
void World::touchEnded(int id) { switch(state) { case ST_GAMEPLAY: switch(touchEvent) { case TE_CAN_LINK: case TE_CAN_UNLINK: { Planet *targetPlanet = getPlanet( pointToPos(touchCurrentX[0], touchCurrentY[0]) ); if(targetPlanet) attack(currentRace, sourcePlanet, targetPlanet); } touchEvent = TE_NONE; break; case TE_TRY: case TE_PAN: case TE_ZOOM: touchEvent = TE_NONE; break; } touched[0] = touched[1] = false; if(tutorial) tutorial->onTouch(); break; case ST_WIN: case ST_DEFEAT: break; } }
void Weapon::update() { objSprite.sortLayers(); objHitbox.update(); updateClocks(); attackTimer = attackClock.getElapsedTime(); makeAir(); if(attackTimer.asSeconds() <= front_delay && readyToAttack) { //do nothing readyToAttack = false; } if(attackTimer.asSeconds() > front_delay && attackTimer.asSeconds() <= attackTime + front_delay) { //do the actual attacking if(attacking) { makeSolid(); evolveHitbox(); attack(); } } if(attackTimer.asSeconds() > attackTime + front_delay && attackTime <= attackTime+front_delay+back_delay) { //pause a bit longer } if(attackTimer.asSeconds() > attackTime+front_delay+back_delay) { readyToAttack = true; attacking = false; } evolveMovement(); }
void doBattle(batstat *batstats, bprotocol *aProtocol, int phase) { int attackingShip; int targetShip; group *attackingGroup; group *targetGroup; batstat *attackingSide; batstat *targetSide; int gun; pdebug(DFULL, "doBattle\n"); resetSides(batstats); while (!isDraw(batstats) && !isWon(batstats)) { while (attackersLeft(batstats)) { attackingGroup = selectAttackingGroup(batstats, &attackingSide, &attackingShip); assert(attackingGroup); attackingGroup->flags |= phase; for (gun = 0; gun < attackingGroup->type->attacks; gun++) { targetGroup = selectTargetGroup(attackingSide, &targetSide, &targetShip); if (targetGroup) { targetGroup->flags |= phase; attack(aProtocol, attackingSide, attackingGroup, attackingShip, targetSide, targetGroup, targetShip); } } } resetSides(batstats); } }
void LocalPlayer::nextStep() { // TODO: Fix picking up when reaching target (this method is obsolete) // TODO: Fix holding walking button to keep walking smoothly if (mPath.empty()) { if (mPickUpTarget) pickUp(mPickUpTarget); if (mWalkingDir) walk(mWalkingDir); } // TODO: Fix automatically walking within range of target, when wanted if (mGoingToTarget && mTarget && withinAttackRange(mTarget)) { mAction = Being::STAND; attack(mTarget, true); mGoingToTarget = false; mPath.clear(); return; } else if (mGoingToTarget && !mTarget) { mGoingToTarget = false; mPath.clear(); } #ifdef EATHENA_SUPPORT Player::nextStep(); #endif }
void Satori::update(float deltaTime, Player* player) { if (m_health > 0) attack(player); for (int i = 0; i < MAX_PROJECTILE_AMOUNT; i++) { if (m_Projectiles[i].isActive()) { m_Projectiles[i].update(deltaTime); } } //Check for collision with the projectiles for bosses for (int i = 0; i < MAX_PROJECTILE_AMOUNT; i++) { if (m_Projectiles[i].isActive()) { if (Collision(m_Projectiles[i].getCollisionBox(), player->getCollisionBox()) && m_collisionTimer.getTicks() > 2000) { m_collisionTimer.start(); if (player->getPlayerHealth() > 0) { player->hit(); if (player->getPlayerHealth() <= 0) g_isPlayerDead = true; } } } } }
void Player::fightPlayer(const json &rawJSON) { FightPlayerMessage fightPlayerMessage(rawJSON); auto player = game->findPlayer(fightPlayerMessage.attackingPlayerTag); auto card = board->creatures->findCard(fightPlayerMessage.cardTag); auto creature = std::dynamic_pointer_cast<Creature>(card); // You can't attack yourself! if (player == shared_from_this()) { throw std::runtime_error("You cannot attack yourself"); } creature->attack(player); PlayerAttackedEvent playerAttackedEvent(game, card, player); game->eventHandler(std::make_shared<PlayerAttackedEvent>(playerAttackedEvent)); std::vector<std::shared_ptr<Player>> alive; if (game->isGameOver()) { game->endGame(); } }
/** * \brief Attack an other item. * \param that The item to attack. */ bool tunnel::passive_enemy::attack( bear::engine::base_item& that ) { return attack ( that, bear::universe::zone::find ( that.get_bounding_box(), this->get_bounding_box() ) ); } // passive_enemy::attack()
void LocalPlayer::nextStep() { if (mPath.empty()) { if (mPickUpTarget) pickUp(mPickUpTarget); if (mWalkingDir) walk(mWalkingDir); } if (mGoingToTarget && mTarget && withinAttackRange(mTarget)) { mAction = Being::STAND; attack(mTarget, true); mGoingToTarget = false; mPath.clear(); return; } else if (mGoingToTarget && !mTarget) { mGoingToTarget = false; mPath.clear(); } Player::nextStep(); }
//FUNCIONES PUBLICAS void Particle::animate() { switch (_state) { case search_Goal: calculateObjetive(); _state=calculate_Spin; break; case calculate_Spin: calculateSpin(); _state=spinning; if (_stateObject!=_SCREAMING ) (_type=="wasp")?_stateObject = _FLYING:_stateObject=_NORMAL; break; case spinning: spinningParticle(); break; case walking: moveParticle(); break; case screamed: scream(); break; case attacking: attack(); break; case working: work(); break; default: break; } }
int main( int argc , char * argv[]){ //*************** HASH THE MASSAGE ********************// const unsigned char* message = (const unsigned char * ) "Hello world."; //get the hash_len of sha-1 int hash_len = gcry_md_get_algo_dlen(GCRY_MD_SHA1); unsigned char digest[hash_len]; //calculate the hash in the binary representation //the gcry_sexp_build requires the binary representation of the hash (20 bytes long) //the ascii and the hex representations are 40 bytes long and this broke the HMAC computation when you try to sign your message gcry_md_hash_buffer(GCRY_MD_SHA1, digest, message, strlen(message)); //*************** ATTACK THE CIPHER FOR THE 3 STANDARD DSA KEY LENGTH ********************// int i = 0; puts("\n"); for(i = 0; i<4; i++){ printf("******** ATTACKING %s ******* \n" , files[i]); attack(i,digest,hash_len); printf("\nPRIVATE KEY CRACKED\n "); printf("\n\n"); } }
bool walk( Actor& a, Vec dir ) { auto sgn = [](int x){return x>0? 1 : x<0? -1 : 0;}; Vec newPos = a.pos + Vec( sgn, dir ); ActorList::iterator actorHere = actor_at( newPos ); if( actorHere != actors.end() ) { std::string message( 1, a.image ); bool killed = attack( a, *actorHere ); log( "%c %s %c", a.image, killed? "killed":"hit", actorHere->image ); if( killed ) actors.erase( actorHere ); } else if( map.get(newPos) != '#' ) { a.pos = newPos; } else { return false; } a.cooldown += 25 / a.speed; return true; }
void user_dir_ship (piece_info_t *obj, long loc) { int enemy_killed; enemy_killed = FALSE; if (map[loc].contents == '*') { snprintf (jnkbuf, STRSIZE, "Your %s broke up on shore.", piece_attr[obj->type].name); fatal (obj, loc, "That's never worked before, sir. Do you really want to try? ", jnkbuf); } else if (map[loc].contents == '+') { /* moving ashore? */ if (!getyn ( "Ships need sea to float, sir. Do you really want to go ashore? ")) return; if (user_map[loc].contents == '+') info("Your %s broke up on shore.", piece_attr[obj->type].name); else { /* attack something on shore */ enemy_killed = islower (user_map[loc].contents); attack (obj, loc); if (obj->hits > 0) /* ship won? */ info("Your %s breaks up after its successful assault.", piece_attr[obj->type].name); } if (obj->hits > 0) { kill_obj (obj, loc); if (enemy_killed) scan (comp_map, loc); } } else if (isupper (user_map[loc].contents)) { /* attacking self */ if (!getyn ( "Sir, those are our men! Do you really want to attack them? ")) return; attack (obj, loc); } else attack (obj, loc); }