void AIEnemyZombie::UseBrain() { xtile = aiinput->GetXTilePos(); ytile = aiinput->GetYTilePos(); xpos = aiinput->GetXLoc(); ypos = aiinput->GetYLoc(); if(new_enemy){ new_enemy=false; //if( (aiinput->lower_patrol_x > 0) && (aiinput->upper_patrol_x > 0)) use_patrol_bounds = true; } switch(GetState()) { case AIS_CHASE: Chase(); break; case AIS_ATTACK: Attack(); break; case AIS_PATROL: Patrol(); break; case AIS_MOVE: MoveToXTile(movetoxtile); break; case AIS_WAIT: Wait(); break; } }
void Moose::Mating() { if (mHunger < 50) { mTargetType = ET_GRASS; SetPrey((Entity **)((BaseApp*)mApp)->mGameState->mGrass); mWanderStep = 300; SetState(ES_HUNTING); } int ChaseResult = Chase(); if (ChaseResult == 2) { mCurTarget = 0; mMoveSpeed = 0.5; mWanderStep = 50; SetPrey(0); mSterile = true; mTargetType = ET_NONE; mCurrentStep = 0; SetAnimationSpeed(200); SetState(ES_IDLE); } else if (ChaseResult == 0) { //mate got killed or ran away. mCurTarget = 0; mMoveSpeed = 0.5; mCurrentStep = 0; SetAnimationSpeed(200); SetState(ES_STALKING); } }
void Moose::Charging() { int ChaseResult = Chase(); if (ChaseResult == 2) { //caught prey mCurTarget = 0; mMoveSpeed = 0.5; mWanderStep = 50; SetPrey(0); mCurrentStep = 0; mHunger = 100; mTargetType = ET_NONE; SetAnimationSpeed(200); SetState(ES_IDLE); } else if (ChaseResult == 0) { //caught prey mCurTarget = 0; mMoveSpeed = 0.5; mWanderStep = 50; SetPrey(0); mCurrentStep = 0; mHunger = 100; mTargetType = ET_NONE; SetAnimationSpeed(200); SetState(ES_IDLE); } }
void Moose::Attack() { // Calls chase every update loop // Chase() attempts to move after a target // Returns 2 if it caught the target // Returns 1 if it didnt catch the target but is still chasing it // Returns 0 if the target dies before it can catch it, or runs away. int ChaseResult = Chase(); if (ChaseResult == 2) { //caught prey mCurTarget = 0; mMoveSpeed = 0.5; mWanderStep = 50; SetPrey(0); mCurrentStep = 0; mHunger = 100; mTargetType = ET_NONE; SetAnimationSpeed(200); SetState(ES_IDLE); } else if (ChaseResult == 0) { //prey got killed or ran away. mCurTarget = 0; mMoveSpeed = 0.5; mCurrentStep = 0; SetAnimationSpeed(200); SetState(ES_HUNTING); } }
void T_Troll (objtype *ob) { if (Chase (ob,true)) { ob->state = &s_trollattack1; ob->ticcount = ob->state->tictime; return; } }
void T_Orc (objtype *ob) { if (Chase (ob,true)) { ob->state = &s_orcattack1; ob->ticcount = ob->state->tictime; return; } }
void T_Demon (objtype *ob) { if (Chase (ob,true)) { ob->state = &s_demonattack1; ob->ticcount = ob->state->tictime; return; } }
void AIEnemyAdvancedGeneticMonster2::UseBrain() { xtile = aiinput->GetXTilePos(); ytile = aiinput->GetYTilePos()-1; xpos = aiinput->GetXLoc(); ypos = aiinput->GetYLoc(); int pyt = aio->player_input->GetYTilePos(); int th = abs(ytile - pyt); if(aiinput->GetStateFlags()->S_DEAD) return; if(new_enemy) { new_enemy = false; cur_health = aiinput->GetCurLife(); } prev_health = cur_health; cur_health = aiinput->GetCurLife(); if( (prev_health - cur_health) >0 ) damaged = true; else damaged = false; /*#ifdef _DEBUG char temp[256]; sprintf(temp, "{AI}[AGM] (th:%d)", th); OutputDebugString(temp); #endif*/ switch(GetState()) { case AIS_CHASE: Chase(); break; case AIS_ATTACK: Attack(); break; case AIS_PATROL: Patrol(); break; case AIS_MOVE: MoveToXTile(movetoxtile); break; case AIS_WAIT: Wait(); break; /* case AIS_NAVIGATE_DOWN: break; case AIS_NAVIGATE_UP: break;*/ } }
void Stag::Update(sf::Vector2f target) { frameTime = frameClock.restart(); m_injuredSound.setPosition(m_position.x, m_position.y, 0); m_deathSound.setPosition(m_position.x, m_position.y, 0); if (!m_dead) { if (smellDetected) { m_emitter.SetAlive(true); m_emitter.SetPosition(m_position); } m_emitter.Update(target); if (Player::GetInstance()->m_selected == false) { m_selected = false; } if (m_health <= 0) { m_selected = false; m_dead = true; } else if (m_health < 70 && m_health >= 20) // If the player attacked the Stag { Chase(target); } else if (m_health < 20 && m_health > 0) { Flee(target); } else { Move(); } if (m_health == 0) { m_deathSound.setMinDistance(500); m_deathSound.setPosition(m_position.x, m_position.y, 0); m_deathSound.play(); Player::GetInstance()->IncreaseHealth(20); Player::GetInstance()->SetMaxHealth(Player::GetInstance()->GetMaxHealth() + 3); Player::GetInstance()->SetMaxStamina(Player::GetInstance()->GetMaxStamina() + 3); } } }
void T_Nemesis (objtype *ob) { Chase (ob,false); // // check for line up with player // if (ob->tilex == player->tilex) { ob->temp1 = 1; ob->state = &s_grelattack1; } else if (ob->tiley == player->tiley) { ob->temp1 = 0; ob->state = &s_grelattack1; } }
void BaseEnemy::UseBrain() { xtile = aiinput->GetXTilePos(); ytile = aiinput->GetYTilePos(); xpos = aiinput->GetXLoc(); ypos = aiinput->GetYLoc(); // _ftprintf(debug, _T("%i %i\n"), xtile, ytile); // _ftprintf(debug, _T("%i\n"), GetAIMapCord(xtile, ytile)); // aioutput->moveButton4(); /* FILE *temp = _tfopen(_T("greenninja.txt"), _T("a")); _ftprintf(temp, _T("th%d xt%d yt%d xp%f yp%f\n"), aiinput->GetTileHeight(), xtile, ytile, xpos, ypos); fclose(temp);*/ // StateManager(); /* FILE *fp; fp = fopen("ailog.txt", "w"); fprintf(fp, "%i %i %i %i", aiinput->lower_patrol_x, aiinput->lower_patrol_y, aiinput->upper_patrol_x, aiinput->upper_patrol_y); fclose(fp);*/ switch(GetState()) { case AIS_CHASE: Chase(); break; case AIS_ATTACK: Attack(); break; case AIS_PATROL: Patrol(); break; case AIS_MOVE: MoveToXTile(movetoxtile); break; case AIS_WAIT: Wait(); break; /* case AIS_NAVIGATE_DOWN: break; case AIS_NAVIGATE_UP: break;*/ } }
void CMonster::AI(float nLoopTime) { // m_pMonsterMesh->SetAnimationNum(4); // m_nCurAction=4; if (CalculateTagDistanceSquece()<80*80&&g_pPlayer->m_nState!=14) { //¹¥»÷ Attack(); } else if (CalculateTagDistanceSquece()<300*300&&g_pPlayer->m_nState!=14) { //×·»÷ Chase(); } else { m_pMonsterMesh->SetAnimationNum(0); m_nCurAction=0; } }
void T_Mage (objtype *ob) { Chase (ob,false); // // check for line up with player // if (ob->x-PIXRADIUS*14 < player->xh && ob->x+PIXRADIUS > player->xl) { ob->temp1 = 1; ob->state = &s_mageattack1; } else if (ob->y-PIXRADIUS*14 < player->yh && ob->y+PIXRADIUS > player->yl) { ob->temp1 = 0; ob->state = &s_mageattack1; } }
void AIEnemyJunkbotTrack::UseBrain() { xtile = aiinput->GetXTilePos(); ytile = aiinput->GetYTilePos(); xpos = aiinput->GetXLoc(); ypos = aiinput->GetYLoc(); /*#ifdef _DEBUG char temp[256]; sprintf(temp, "{AI}[JunkbotTrack] (xt:%d) (yt%d) (stopblock:%d)", xtile, ytile, IsStopBlock()); OutputDebugString(temp); #endif*/ if(new_enemy){ new_enemy=false; if( (aiinput->lower_patrol_x > 0) && (aiinput->upper_patrol_x > 0)) use_patrol_bounds = true; } switch(GetState()) { case AIS_CHASE: Chase(); break; case AIS_ATTACK: Attack(); break; case AIS_PATROL: Patrol(); break; case AIS_MOVE: MoveToXTile(movetoxtile); break; case AIS_WAIT: Wait(); break; } }
void Small::Update(int mousex, int mousey) { //XMVECTOR playerlocation = {playerx, playery, 0, 0}; //float displacement = XMVectorGetX(XMVector2Length(playerlocation - Location)); //if (displacement <= 130.0f) //{ //Separation(0.000f); //Cohesion(0.000f); //Alignment(0.0f); //Chase(0.03f); //} //else //{ if (Flocking) { Separation(0.04f); Cohesion(0.01f); Alignment(0.01f); } else { //Wander } if (Chasing) { Chase(0.05f); } BorderRestrict(); if (Chasing) { Location += (Direction * 3.3f); } PointingTwoLocation = Location + (Direction * 10.0f); }
void AIEnemyFlyingSentryB::UseBrain() { xtile = aiinput->GetXTilePos(); ytile = aiinput->GetYTilePos(); xpos = aiinput->GetXLoc(); ypos = aiinput->GetYLoc(); if(new_enemy){ new_enemy=false; //if( (aiinput->lower_patrol_x > 0) && (aiinput->upper_patrol_x > 0)) use_patrol_bounds=true; } /*#ifdef _DEBUG char temp[256]; sprintf(temp, "{AI}[SentryB] (cstate:%d)(use_patrol_bounds:%d)(lxb:%d)(uxb:%d)", current_state, use_patrol_bounds, aiinput->lower_patrol_x, aiinput->upper_patrol_x); OutputDebugString(temp); #endif*/ switch(GetState()) { case AIS_CHASE: Chase(); break; case AIS_ATTACK: Attack(); break; case AIS_PATROL: Patrol(); break; case AIS_MOVE: MoveToXTile(movetoxtile); break; case AIS_WAIT: Wait(); break; } }
void AIEnemyFlyingSentryA::UseBrain() { xtile = aiinput->GetXTilePos(); ytile = aiinput->GetYTilePos(); xpos = aiinput->GetXLoc(); ypos = aiinput->GetYLoc(); if(new_enemy){ new_enemy=false; //use_patrol_bounds=true; //if( (aiinput->lower_patrol_y == 0) && (aiinput->upper_patrol_y == 0)) //{/*no bounds were set -- make some*/ // aiinput->lower_patrol_y = aiinput->GetYTilePos()+6; // aiinput->upper_patrol_y = aiinput->GetYTilePos()-6; //} } switch(GetState()) { case AIS_CHASE: Chase(); break; case AIS_ATTACK: Attack(); break; case AIS_PATROL: Patrol(); break; case AIS_MOVE: MoveToXTile(movetoxtile); break; case AIS_WAIT: Wait(); break; } }
void Prey::ChaseLeader() { try { mCurTarget = MyLeader; if (GetLeaderDistance()>(LeaderRadius - LeaderBuffer)) { //cout<<"Chasing Leader"<<endl; Chase(); } else { //cout<<"Within Normal range"<<endl; FSTATE = FS_NORMAL; PatrolMode(); ResetTarget(); } } catch (...) { MessageBox(NULL, "ChaseLeader", "something happened", MB_OK); } }
int main(void) { char *currenttime; /* current time/date string */ int old_sec = 0; // int cur_hour = 0; /* current hour */ // int cur_day = 0; /* current current day */ int result = 0; int key = 0; Initialise(); // turn outputs on and off for 1 second InitDisplay(); int keepgoing = 1; /* tells program to keep running until ESC pressed */ while ( keepgoing == 1 ) { currenttime = thetime(); /* get the current time */ cur_sec = extract_num(currenttime, 18, 2); /* extract minute */ cur_min = extract_num(currenttime, 15, 2); /* extract minute */ cur_hour = extract_num(currenttime, 12,2); /* extract hour */ //cur_day = extract_num(currenttime, 9, 2); /* extract day */ if(old_sec != cur_sec) { /* only update screen once per second */ ReadAnalogInputs(3); DisplayAnalogValues(3); ReadDigitalInputs(3); DisplayDigitalInputs(3); locate( 25, 56); color(CF_SETTINGS,CB_SETTINGS); cprintf(currenttime); /* update current time on screen */ //locate(20,1);cprintf("cur_min=%d",cur_min); old_sec = cur_sec; // EVENTS (new function) //OutputBit(0,valueInput[0]); //OutputBit(1,valueInput[1]); //OutputBit(2,valueInput[2]); //OutputBit(3,valueInput[3]); if (valueInput[1] == 1) { WritePort(1); DisplayPort(1,XOUTPUT,YOUTPUT); } if (valueAnalog[0] < 50) { WritePort(16); DisplayPort(16,XOUTPUT,YOUTPUT); } Log("e:\\user\\c\\a_pcio\\logfile.log", currenttime); } if( kbhit() ) { result = getkeypressed(); /* get a single keypress */ switch (result) { /* perform task user pressed */ case 27: { /* ESC */ Message( "Do you really want to quit? (Y/n) " , 0); key = getch(); if( ( key == 'Y') || (key =='y') || (key == 13) ) keepgoing = 0; /* stop program execution */ Message("", 0); } break; case 59: { /* F1 */ Message("Initialising",0); Message("Fast Pulse", 0); Pulse(255, gPulse_fast); } break; case 60: { /* F2 */ Message("Storage CRO - enter settings", 0); //getch(); gotoHiResMode(); DrawOscilliscopeScreen(50,0,550,255,50,51); StorageOscilliscope("waiting for trigger", 1, 0, 220, 40, 0, 499); InitDisplay(); } break; case 61: { /* F3 */ gotoHiResMode(); DrawOscilliscopeScreen(100,100,355,355,20,32); Oscilliscope(); InitDisplay(); Message("Oscilliscope", 0); Pulse(255, gPulse_slow); } break; case 62: { /* F4 */ Message("BinaryCount", 0); BinaryCount(gCounter); } break; case 63: { /* F5 */ Message("Chase Multiple", 0); ChaseMultiple(gIterations, gSpeed); } break; case 64: { /* F6 */ Message("Chase Up", 0); Chase(gSpeed, 0, 7); } break; case 65: { /* F7 */ Message("Chase Down", 0); Chase(gSpeed, 7,0); } break; case 66: { /* F8 */ Message("Reading Analog inputs", 0); ReadAnalogInputs(3); DisplayAnalogValues(3); ReadDigitalInputs(3); DisplayDigitalInputs(3); } break; case 67: { /* F9 */ Message("Logging - PRESS A KEY TO STOP", 0); FastAcquisition("e:\\user\\c\\a_pcio\\fastlog.log", currenttime); Message("Done Logging to e:\user\c\a_pcio\fastlog.log", 0); } break; case 68: { /* F10 */ Message("Setup", 0); //locate(12,65); scanf("%d", &gPORT); // port change locate(11, 62); color(CF_SETTINGS,CB_SETTINGS); // color(YELLOW,BLACK); cprintf("Enter new settings"); locate(13,75); scanf("%d", &gCounter); // port change if(gCounter<0||gCounter>999) gCounter=10; else fflush(stdin); locate(14,75); scanf("%d", &gSpeed); // port change if(gSpeed<0||gSpeed>999) gSpeed=10; else fflush(stdin); locate(15,75); scanf("%d", &gPulse_fast); // port change if(gPulse_fast<0||gPulse_fast>999) gPulse_fast=10; else fflush(stdin); locate(16,75); scanf("%d", &gPulse_slow); // port change if(gPulse_slow<0||gPulse_slow>999) gPulse_slow=10; else fflush(stdin); locate(17,75); scanf("%d", &gIterations); // port change if(gIterations<0||gIterations>999) gIterations=10; else fflush(stdin); DisplaySettings(XSETTINGS,YSETTINGS); } break; case 48: { OutputBit(0,2); DisplayPort(1,XOUTPUT,YOUTPUT); } break; case 49: { OutputBit(1,2); DisplayPort(2,XOUTPUT,YOUTPUT); } break; case 50: { OutputBit(2,2); DisplayPort(4,XOUTPUT,YOUTPUT); } break; case 51: { OutputBit(3,2); DisplayPort(16,XOUTPUT,YOUTPUT); } break; case 52: { OutputBit(4,2); DisplayPort(32,XOUTPUT,YOUTPUT); } break; case 53: { OutputBit(5,2); DisplayPort(64,XOUTPUT,YOUTPUT); } break; case 54: { OutputBit(6,2); DisplayPort(128,XOUTPUT,YOUTPUT); } break; case 55: { OutputBit(7,2); DisplayPort(255,XOUTPUT,YOUTPUT); } break; case 43: { WritePort(++valueOutput[0]); } break; case 45: { WritePort(--valueOutput[0]); } break; } } } return 0; }
int main(void) { // Stop watchdog timer DoWatchdog(0); // sET UP aclk BCSCTL3 |= LFXT1S_2; // Set all pins to output to stop floating P1DIR = 0xFF; P2DIR = 0xFF; P3DIR = 0xFF; DoPWM(); _EINT(); // Determine pulse direction RX_PORT_DIR &= ~(RX_PIN); // leave two rx inputs P2DIR = (BIT1 | BIT3 | BIT4 | BIT5 | BIT6 | BIT7); P2OUT = 0xff; // red light P3OUT = BIT2; nR = nG = nB = 0x2FFF; // green light P3OUT = BIT3; while (1) { DelayMS(90); DoWatchdog(1); unsigned int nSig = GetWidth(); if (nSig == 1) { P3OUT = BIT2; if (nCount > 10) { nMode++; if (nCount > 140) { nMode = 0; } } nCount = 0; } else { P3OUT = BIT3; nCount++; } if (nMode > 11) { nMode = 1; } switch (nMode) { case 0: nR = nG = nB = 50; Headlight(0); break; case 1: Light(0xfe00, 0xfe00, 0xfe00, 1); break; case 2: Light(0xfe00, 50, 50, 0); break; case 3: Light(50, 0xfe00, 50, 0); break; case 4: Light(50, 50, 0xfe00, 0); break; case 5: LoopColour(); break; case 6: ColourChange(); break; case 7: Police(); break; case 8: Strobe(); break; case 9: Strobe2(); break; case 10: GoMental(); break; case 11: Chase(); break; } } }
void CameraDirector::Threat(double seconds) { Chase(seconds); }
void CameraDirector::ExecFrame(double seconds) { if (!ship) return; hud = HUDView::GetInstance(); int flight_phase = ship->GetFlightPhase(); if (flight_phase < Ship::LOCKED) SetMode(MODE_DOCKING); if (ship->IsAirborne()) { if (flight_phase >= Ship::DOCKING) SetMode(MODE_DOCKING); } else { if (flight_phase >= Ship::RECOVERY) SetMode(MODE_DOCKING); } if (flight_phase >= Ship::LOCKED && flight_phase < Ship::ACTIVE) { int m = GetMode(); if (m != MODE_COCKPIT && m != MODE_VIRTUAL) SetMode(MODE_COCKPIT); } if (ship->InTransition()) { SetMode(MODE_DROP); } // automatically restore mode after transition: else if (old_mode != MODE_NONE) { mode = old_mode; requested_mode = old_mode; old_mode = MODE_NONE; } int op_mode = mode; if (requested_mode > mode) op_mode = requested_mode; Starshatter* stars = Starshatter::GetInstance(); // if we are in padlock, and have not locked a ship // try to padlock the current target: if (op_mode == MODE_TARGET && !external_ship) { SimObject* tgt = ship->GetTarget(); if (tgt && tgt->Type() == SimObject::SIM_SHIP) SetViewObject((Ship*) tgt); } // if in an external mode, check the external ship: else if (op_mode >= MODE_TARGET && op_mode <= MODE_ZOOM) { if (external_ship && external_ship != ship && !stars->InCutscene()) { Contact* c = ship->FindContact(external_ship); if (!c || !c->ActLock()) { SetViewObject(ship); } } } if (ship->Rep()) { if (op_mode == MODE_COCKPIT) { ship->HideRep(); ship->HideCockpit(); } else if (op_mode == MODE_VIRTUAL || op_mode == MODE_TARGET) { if (ship->Cockpit()) { ship->HideRep(); ship->ShowCockpit(); } else { ship->ShowRep(); } } else { ship->Rep()->SetForeground(op_mode == MODE_DOCKING); ship->ShowRep(); ship->HideCockpit(); } } if (hud && hud->Ambient() != Color::Black) sim->GetScene()->SetAmbient( hud->Ambient() ); else sim->GetScene()->SetAmbient( sim->GetStarSystem()->Ambient() ); switch (op_mode) { default: case MODE_COCKPIT: Cockpit(seconds); break; case MODE_CHASE: Chase(seconds); break; case MODE_TARGET: Target(seconds); break; case MODE_THREAT: Threat(seconds); break; case MODE_VIRTUAL: Virtual(seconds); break; case MODE_ORBIT: case MODE_TRANSLATE: case MODE_ZOOM: Orbit(seconds); break; case MODE_DOCKING: Docking(seconds); break; case MODE_DROP: Drop(seconds); break; } if (ship->Shake() > 0 && (op_mode < MODE_ORBIT || (op_mode == MODE_VIRTUAL && ship->Cockpit()))) { Point vib = ship->Vibration() * 0.2; camera.MoveBy(vib); camera.Aim(0, vib.y, vib.z); } Transition(seconds); DetailSet::SetReference(region, camera.Pos()); }
void T_ShooterObj(objtype *ob) { fixed tempx,tempy; id0_unsigned_t temp_tilex,temp_tiley; id0_int_t angle; shooter_delay -= realtics; if (shooter_delay < 0) { shooter_mode = BE_Cross_Brandom(sm_dummy); // REFKEEN - Force a specific order of calls to random function // (same as original EXEs for DOS), don't introduce undefined behaviors shooter_delay = BE_Cross_Brandom(10*60); shooter_delay += BE_Cross_Brandom(50); //shooter_delay = random(10*60)+random(50); } tempx = player->x; tempy = player->y; temp_tilex = player->tilex; temp_tiley = player->tiley; switch (shooter_mode) { case sm_other1: case sm_other2: case sm_other3: case sm_other4: player->x = ((id0_long_t)other_x[shooter_mode]<<TILESHIFT)+TILEGLOBAL/2; player->y = ((id0_long_t)other_y[shooter_mode]<<TILESHIFT)+TILEGLOBAL/2; player->tilex = other_x[shooter_mode]; player->tiley = other_y[shooter_mode]; break; } if (Chase(ob,true)) shooter_delay = 0; player->x = tempx; player->y = tempy; player->tilex = temp_tilex; player->tiley = temp_tiley; angle = AngleNearPlayer(ob); // Handle shooting for the different characters controlled by this think. switch (ob->obclass) { case ramboneobj: if (!BE_Cross_Brandom(2) && (angle != -1)) { ob->state = &s_skel_attack1; ob->ticcount = ob->state->tictime; } break; case fmageobj: if (!BE_Cross_Brandom(8) && (angle != -1)) { ob->state = &s_fmageattack1; ob->ticcount = ob->state->tictime; } break; case robotankobj: if (!BE_Cross_Brandom(15) && (angle != -1)) { ob->state = &s_robotank_attack1; ob->ticcount = ob->state->tictime; } break; case stompyobj: if (angle != -1) { ob->state = &s_stompy_attack1; ob->ticcount = ob->state->tictime; } break; case bugobj: if (!BE_Cross_Brandom(5) && (angle != -1)) { ob->state = &s_bug_attack1; ob->ticcount = ob->state->tictime; } break; case eyeobj: if (!BE_Cross_Brandom(2) && (angle != -1)) { ob->state = &s_eye_shootplayer_1; ob->ticcount = ob->state->tictime; } break; } }
/* ==================== = = T_RunningEye = ==================== */ void T_RunningEye(objtype *ob) { id0_int_t /*x, y, */dir_num, switch_num; fixed tempx,tempy; id0_unsigned_t temp_tilex,temp_tiley; dir_num = *(mapsegs[2]+farmapylookup[ob->tiley]+ob->tilex); dir_num = dir_num>>8; if (!dir_num) dir_num = ob->temp2; if (dir_num == 5) { if (ob->temp1) { ob->temp1--; } else { ob->temp1 = 2; actorat[ob->tilex][ob->tiley] = 0; switch (ob->temp2) { case 1: ob->tiley = ob->tiley-1; ob->y = ((id0_long_t)(ob->tiley)<<TILESHIFT)+TILEGLOBAL/2; break; case 2: ob->tilex = ob->tilex+1; ob->x = ((id0_long_t)(ob->tilex)<<TILESHIFT)+TILEGLOBAL/2; break; case 3: ob->tiley = ob->tiley+1; ob->y = ((id0_long_t)(ob->tiley)<<TILESHIFT)+TILEGLOBAL/2; break; case 0: case 4: ob->tilex = ob->tilex-1; ob->x = ((id0_long_t)(ob->tilex)<<TILESHIFT)+TILEGLOBAL/2; break; } CalcBounds (ob); ChaseThink(ob,false); actorat[ob->tilex][ob->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(ob); //actorat[ob->tilex][ob->tiley] = ob; return; } } tempx = player->x; tempy = player->y; temp_tilex = player->tilex; temp_tiley = player->tiley; if (dir_num == 5) switch_num = ob->temp2; else switch_num = dir_num; switch (switch_num) { case 1: player->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2; player->y = ((id0_long_t)(ob->tiley-2)<<TILESHIFT)+TILEGLOBAL/2; player->tilex = ob->tilex; player->tiley = ob->tiley-2; break; case 2: player->x = ((id0_long_t)(ob->tilex+2)<<TILESHIFT)+TILEGLOBAL/2; player->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2; player->tilex = ob->tilex+2; player->tiley = ob->tiley; break; case 3: player->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2; player->y = ((id0_long_t)(ob->tiley+2)<<TILESHIFT)+TILEGLOBAL/2; player->tilex = ob->tilex; player->tiley = ob->tiley+2; break; case 0: case 4: player->x = ((id0_long_t)(ob->tilex-2)<<TILESHIFT)+TILEGLOBAL/2; player->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2; player->tilex = ob->tilex-2; player->tiley = ob->tiley; break; } Chase(ob, false); player->x = tempx; player->y = tempy; player->tilex = temp_tilex; player->tiley = temp_tiley; if (dir_num != 5) ob->temp2 = dir_num; }
void CMoveTask::doAction(float ElapsedTime) { if(m_ApropiateCover < 0) { if(m_bChasing) { if(!Chase(ElapsedTime)) { m_bChasing = false; //m_bCoverReached = false; //m_bCovered = false; m_Path.clear(); } else{ return; } } int l_apropiate = MostApropiateCover(); m_ApropiateCover = l_apropiate; ((CSoldier*)m_Owner)->SetCover(m_ApropiateCover); if(l_apropiate == -1) { m_bChasing = true; m_TimeUncover =1.0f; m_bReady = true; } m_TimeWait = 0.0f; return; } else{ if(m_bCoverReached && !isNotBlockedEyeLine(CORE->GetCoverManager()->GetExt(m_ApropiateCover))) { m_TimeWait +=ElapsedTime; if(m_TimeWait > 8.0f) { m_ApropiateCover = -2; ((CSoldier*)m_Owner)->SetCover(m_ApropiateCover); m_bChasing = false; m_bCoverReached = false; m_bCovered = false; m_TimeUncover = 0.0f; m_TimeWait=0.0f; m_Time=0.0f; return; } } else{ m_TimeWait = 0.0f; } if(!m_bCoverReached) { reachCover(m_ApropiateCover, ElapsedTime); if(!m_bCoverReached) { //m_ApropiateCover = MostApropiateCover(); return; } } if(!m_bCovered) { Covered(m_ApropiateCover, ElapsedTime); m_Time = CORE->GetRandom()->getRandFloat(2.0f, 4.0f); return; } m_Time -=ElapsedTime; if(m_Time < 0.0f) { if(!reachCover(m_ApropiateCover, ElapsedTime)) { return; } } else{ m_Owner->ChangeCharacterAnimation(WAIT_ANIM, 0.3f); return; } m_TimeUncover = CORE->GetRandom()->getRandFloat(3.0f, 7.0f); m_bReady=true; return; } }