// called when a monster is attacked [attack/use atk skill/use buff/run/summon] bool CMonster::OnBeAttacked( CCharacter* Enemy ) { Battle->hitby = Enemy->clientid; if(!IsOnBattle( )) { //LMA: yeah hurt me (used for Santa Rudolph). if(thisnpc->helpless==1) { StartAction( Enemy, STAY_STILL_ATTACK, 0 ); return true; } //Some monsters do not attack and stay still (mc) if(!stay_still) { StartAction( Enemy, NORMAL_ATTACK, 0 ); } else { Log(MSG_INFO,"Stay still attack"); StartAction( Enemy, STAY_STILL_ATTACK, 0 ); } } return true; }
// called when a enemy is on sight bool CMonster::OnEnemyOnSight( CPlayer* Enemy ) { clock_t etime = clock() - lastSighCheck; if(etime<5000) return true; if(!IsOnBattle( )) { if(thisnpc->aggresive>1) { UINT aggro = GServer->RandNumber(2,15); if(thisnpc->aggresive>=aggro && !IsGhostSeed( )) { //osprose. /* Enemy->ClearObject( this->clientid ); SpawnMonster(Enemy, this ); */ StartAction( (CCharacter*) Enemy, NORMAL_ATTACK, 0 ); } else if(IsGhostSeed( ) || thisnpc->aggresive>5) MoveTo( Enemy->Position->current, true ); } lastSighCheck = clock(); } return true; }
// called when a monster is attacked [attack/use atk skill/use buff/run/summon] bool CMonster::OnBeAttacked( CCharacter* Enemy ) { if(!IsOnBattle( )) { //Some monsters do not attack and stay still (mc) if(!stay_still) { StartAction( Enemy, NORMAL_ATTACK, 0 ); } else { StartAction( Enemy, STAY_STILL_ATTACK, 0 ); } } return true; }
// called when we create a new monster [attack players?] bool CMonster::OnSpawn( bool Attack ) { lastSighCheck = clock(); if(IsGhost( ) && Attack ) { CPlayer* player = GetNearPlayer( ); if(player==NULL) // no players or too far return true; StartAction( (CCharacter*)player, NORMAL_ATTACK, 0 ); } return true; }
void AARWeapon::InputPressed() { //PrimaryActorTick.bStartWithTickEnabled = true; if (Role < ROLE_Authority) { Execute_ClientOnActionStart(this); //WeaponState->StartAction(); ServerStartAction(); } else { StartAction(); //we are on server, we just call normal version. } }
/***************************************************************************************** * Function Name: SetWalkingMode * Description: This function Loads the settings for the walking module to a walking mode * the function sets the max walking speed to 13 and -13. * the function stops the motion, and needs to be enabled. * *****************************************************************************************/ void WalkingAndActions::SetWalkingMode(WalkingModes_t walkingMode) { if(m_walkingMode == walkingMode) { return; } StopWalking(); #ifdef DEBUG_SET_WALKING_MODE cout << "[WalkingAndActions::SetWalkingMode]: Toggling walking mode to [" << ConvertWalkingModeToString(walkingMode) << "]\n"; #endif usleep(500 * 1000); switch(walkingMode) { //if changed to walking mode, change the max speed for the axis //and load ini file, and change the walking mode variable case RUNNING: m_walking->LoadINISettings(m_running_ini); m_maxXSpeed = RUNNING_MAX_FORWARD_SPEED; m_minXSpeed = RUNNING_MAX_BACKWARD_SPEED; m_maxYSpeed = MAX_LEFT_SPEED; m_minYSpeed = MAX_RIGHT_SPEED; m_maxLeftTurningAngle = MAX_TURN_LEFT_SPEED; m_maxRightTurningAngle = MAX_TURN_RIGHT_SPEED; m_walkingMode = RUNNING; break; case WALKING: StartAction(STAND_UP_WALKING); m_walking->LoadINISettings(m_walking_ini); m_maxXSpeed = WALKING_MAX_FORWARD_SPEED; m_minXSpeed = WALKING_MAX_BACKWARD_SPEED; m_maxYSpeed = MAX_LEFT_SPEED; m_minYSpeed = MAX_RIGHT_SPEED; m_maxLeftTurningAngle = MAX_TURN_LEFT_SPEED; m_maxRightTurningAngle = MAX_TURN_RIGHT_SPEED; m_walkingMode = WALKING; break; default: printf("No such walkingMode type as [%d]\n",walkingMode); break; } }
bool CAutoDestroyer::EventProcess(const Event &event) { CObject* scrap; Gfx::CPyro* pyro; Math::Vector pos, speed; Math::Point dim; Ui::CWindow* pw; CAuto::EventProcess(event); if ( m_engine->GetPause() ) return true; if (m_main->GetSelect() == m_object) { if ( event.type == EVENT_OBJECT_BDESTROY ) { Error err = StartAction(0); if ( err != ERR_OK ) m_displayText->DisplayError(err, m_object); return false; } } if ( event.type != EVENT_FRAME ) return true; m_progress += event.rTime*m_speed; m_timeVirus -= event.rTime; if ( m_object->GetVirusMode() ) // contaminated by a virus? { if ( m_timeVirus <= 0.0f ) { m_timeVirus = 0.1f+Math::Rand()*0.3f; } return true; } pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); if ( m_phase == ADEP_WAIT ) { if ( m_progress >= 1.0f ) { m_phase = ADEP_WAIT; // still waiting ... m_progress = 0.0f; m_speed = 1.0f/0.5f; if (m_main->GetSelect() == m_object) { scrap = SearchPlastic(); if ( pw != 0 ) EnableInterface(pw, EVENT_OBJECT_BDESTROY, (scrap != 0)); } } } else if ( pw != 0 ) EnableInterface(pw, EVENT_OBJECT_BDESTROY, false); if ( m_phase == ADEP_DOWN ) { if ( m_progress >= 0.3f-0.05f && !m_bExplo ) { scrap = SearchPlastic(); if ( scrap != nullptr ) { pyro = new Gfx::CPyro(); pyro->Create(Gfx::PT_FRAGT, scrap); } m_bExplo = true; } if ( m_progress < 1.0f ) { pos = Math::Vector(0.0f, -10.0f, 0.0f); pos.y = -Math::Bounce(m_progress, 0.3f)*10.0f; m_object->SetPosition(1, pos); } else { m_object->SetPosition(1, Math::Vector(0.0f, -10.0f, 0.0f)); m_sound->Play(SOUND_REPAIR, m_object->GetPosition(0)); m_phase = ADEP_REPAIR; m_progress = 0.0f; m_speed = 1.0f/1.0f; } } if ( m_phase == ADEP_REPAIR ) { if ( m_progress < 1.0f ) { } else { m_sound->Play(SOUND_OPEN, m_object->GetPosition(0), 1.0f, 0.8f); m_phase = ADEP_UP; m_progress = 0.0f; m_speed = 1.0f/3.0f; } } if ( m_phase == ADEP_UP ) { if ( m_progress < 1.0f ) { pos = Math::Vector(0.0f, -10.0f, 0.0f); pos.y = -(1.0f-m_progress)*10.0f; m_object->SetPosition(1, pos); } else { m_object->SetPosition(1, Math::Vector(0.0f, 0.0f, 0.0f)); m_phase = ADEP_WAIT; m_progress = 0.0f; m_speed = 1.0f/0.5f; } } return true; }
// Spawn a monster //LMA: added handling of skill summons. void CMonster::SpawnMonster( CPlayer* player, CMonster* thismon ) { BEGINPACKET( pak, 0x792 ); ADDWORD ( pak, clientid ); ADDFLOAT ( pak, Position->current.x*100 ); ADDFLOAT ( pak, Position->current.y*100 ); ADDDWORD ( pak, 0xcdcdcdcd ); ADDDWORD ( pak, 0xcdcdcdcd ); if(IsDead( )) { ADDWORD ( pak, 0x0003 ); ADDWORD ( pak, 0x0000 ); } else if(IsOnBattle( )) { //LMA: for supportive summons (lucky ghost...) if(Battle->bufftarget==Battle->target) { ADDWORD ( pak, 0x0002 ); ADDWORD ( pak, 0x0000 ); } else { ADDWORD ( pak, 0x0002 ); ADDWORD ( pak, Battle->target ); } } else if(IsMoving( )) { ADDWORD ( pak, 0x0001 ); ADDWORD ( pak, 0x0000 ); } else { ADDWORD ( pak, 0x0000 ); ADDWORD ( pak, 0x0000 ); } if(IsSummon( ) ) { ADDBYTE ( pak, 0x01 ); } else { ADDBYTE ( pak, 0x00 ); } ADDWORD(pak, 0x0000); if(Stats->HP > MAXHPMOB) { Stats->HP = (long long) MAXHPMOB; } ADDDWORD ( pak, Stats->HP ); if(thismon->owner != player->clientid) { CMap* map = GServer->MapList.Index[Position->Map]; if (thismon->team!=0) { ADDDWORD( pak,thismon->team); } else { if(IsSummon( ) && map->allowpvp!=0) { //Hostil ADDDWORD( pak, 0x00000064 ); } else if (IsSummon( ) && map->allowpvp==0) { //Friendly ADDDWORD ( pak, 2 ); } else { //Hostil ADDDWORD( pak, 0x00000064 ); } } } else { //Friendly ADDDWORD( pak, 2 ); } ADDDWORD( pak, GServer->BuildBuffs( this ) ); ADDDWORD ( pak, montype ); if(IsSummon( )) { ADDWORD( pak, owner ); if (thismon->skillid>0) { ADDWORD( pak, thismon->skillid ); //id del skill (si es summon de skill) } else { ADDWORD( pak, 0x0000 ); //id del skill (si es summon de skill) } } player->client->SendPacket( &pak ); //LMA: supportive summons (lucky ghost) if(IsSummon()&&buffid>0&&(player==GetOwner())) { Log(MSG_INFO,"The summon is spawned"); StartAction( player,SUMMON_BUFF,buffid); Log(MSG_INFO,"completly"); buffid=0; //only one buff } }
bool CAutoFactory::EventProcess(const Event &event) { ObjectType type; CObject* fret; CObject* vehicle; Math::Matrix* mat; CPhysics* physics; Math::Vector pos, speed; Math::Point dim; float zoom, angle, prog; int i; CAuto::EventProcess(event); if ( m_engine->GetPause() ) return true; if ( m_object->GetSelect() ) // factory selected? { if ( event.type == EVENT_UPDINTERFACE ) { CreateInterface(true); } type = OBJECT_NULL; if ( event.type == EVENT_OBJECT_FACTORYwa ) type = OBJECT_MOBILEwa; if ( event.type == EVENT_OBJECT_FACTORYta ) type = OBJECT_MOBILEta; if ( event.type == EVENT_OBJECT_FACTORYfa ) type = OBJECT_MOBILEfa; if ( event.type == EVENT_OBJECT_FACTORYia ) type = OBJECT_MOBILEia; if ( event.type == EVENT_OBJECT_FACTORYws ) type = OBJECT_MOBILEws; if ( event.type == EVENT_OBJECT_FACTORYts ) type = OBJECT_MOBILEts; if ( event.type == EVENT_OBJECT_FACTORYfs ) type = OBJECT_MOBILEfs; if ( event.type == EVENT_OBJECT_FACTORYis ) type = OBJECT_MOBILEis; if ( event.type == EVENT_OBJECT_FACTORYwc ) type = OBJECT_MOBILEwc; if ( event.type == EVENT_OBJECT_FACTORYtc ) type = OBJECT_MOBILEtc; if ( event.type == EVENT_OBJECT_FACTORYfc ) type = OBJECT_MOBILEfc; if ( event.type == EVENT_OBJECT_FACTORYic ) type = OBJECT_MOBILEic; if ( event.type == EVENT_OBJECT_FACTORYwi ) type = OBJECT_MOBILEwi; if ( event.type == EVENT_OBJECT_FACTORYti ) type = OBJECT_MOBILEti; if ( event.type == EVENT_OBJECT_FACTORYfi ) type = OBJECT_MOBILEfi; if ( event.type == EVENT_OBJECT_FACTORYii ) type = OBJECT_MOBILEii; if ( event.type == EVENT_OBJECT_FACTORYrt ) type = OBJECT_MOBILErt; if ( event.type == EVENT_OBJECT_FACTORYrc ) type = OBJECT_MOBILErc; if ( event.type == EVENT_OBJECT_FACTORYrr ) type = OBJECT_MOBILErr; if ( event.type == EVENT_OBJECT_FACTORYrs ) type = OBJECT_MOBILErs; if ( event.type == EVENT_OBJECT_FACTORYsa ) type = OBJECT_MOBILEsa; Error err = StartAction(type); if( err != ERR_OK && err != ERR_GENERIC ) m_displayText->DisplayError(err, m_object); if( err != ERR_GENERIC ) return false; } if ( event.type != EVENT_FRAME ) return true; m_progress += event.rTime*m_speed; EventProgress(event.rTime); if ( m_phase == AFP_WAIT ) { if ( m_progress >= 1.0f ) { m_phase = AFP_WAIT; // still waiting ... m_progress = 0.0f; m_speed = 1.0f/2.0f; } } if ( m_phase == AFP_CLOSE_S ) { if ( m_progress < 1.0f ) { for ( i=0 ; i<9 ; i++ ) { zoom = 0.30f+(m_progress-0.5f+i/16.0f)*2.0f*0.70f; if ( zoom < 0.30f ) zoom = 0.30f; if ( zoom > 1.00f ) zoom = 1.00f; m_object->SetZoomZ( 1+i, zoom); m_object->SetZoomZ(10+i, zoom); } } else { for ( i=0 ; i<9 ; i++ ) { m_object->SetZoomZ( 1+i, 1.0f); m_object->SetZoomZ(10+i, 1.0f); } SoundManip(2.0f, 1.0f, 1.2f); m_phase = AFP_CLOSE_T; m_progress = 0.0f; m_speed = 1.0f/2.0f; } } if ( m_phase == AFP_CLOSE_T ) { if ( m_progress < 1.0f ) { for ( i=0 ; i<9 ; i++ ) { angle = -m_progress*(Math::PI/2.0f)+Math::PI/2.0f; m_object->SetAngleZ( 1+i, angle); m_object->SetAngleZ(10+i, -angle); } } else { for ( i=0 ; i<9 ; i++ ) { m_object->SetAngleZ( 1+i, 0.0f); m_object->SetAngleZ(10+i, 0.0f); } m_channelSound = m_sound->Play(SOUND_FACTORY, m_object->GetPosition(0), 0.0f, 1.0f, true); m_sound->AddEnvelope(m_channelSound, 1.0f, 1.0f, 2.0f, SOPER_CONTINUE); m_sound->AddEnvelope(m_channelSound, 1.0f, 1.0f, 11.0f, SOPER_CONTINUE); m_sound->AddEnvelope(m_channelSound, 0.0f, 1.0f, 2.0f, SOPER_STOP); m_phase = AFP_BUILD; m_progress = 0.0f; m_speed = 1.0f/15.0f; } } if ( m_phase == AFP_BUILD ) { if ( m_progress == 0.0f ) { if ( !CreateVehicle() ) { fret = SearchFret(); // transform metal? if ( fret != 0 ) { fret->SetLock(false); // metal usable again } if ( m_channelSound != -1 ) { m_sound->FlushEnvelope(m_channelSound); m_sound->AddEnvelope(m_channelSound, 0.0f, 1.0f, 1.0f, SOPER_STOP); m_channelSound = -1; } m_phase = AFP_OPEN_T; m_progress = 0.0f; m_speed = 1.0f/2.0f; return true; } } if ( m_progress < 1.0f ) { if ( m_type == OBJECT_MOBILErt || m_type == OBJECT_MOBILErc || m_type == OBJECT_MOBILErr || m_type == OBJECT_MOBILErs ) { prog = 1.0f-m_progress*1.5f; if ( prog < 0.0f ) prog = 0.0f; } else { prog = 1.0f-m_progress; } angle = powf(prog*10.0f, 2.0f)+m_object->GetAngleY(0); vehicle = SearchVehicle(); if ( vehicle != 0 ) { vehicle->SetAngleY(0, angle+Math::PI); vehicle->SetZoom(0, m_progress); } fret = SearchFret(); // transform metal? if ( fret != 0 ) { fret->SetZoom(0, 1.0f-m_progress); } if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time ) { m_lastParticle = m_time; #if 0 pos = m_fretPos; pos.x += (Math::Rand()-0.5f)*20.0f; pos.z += (Math::Rand()-0.5f)*20.0f; pos.y += 1.0f; speed.x = (Math::Rand()-0.5f)*12.0f; speed.z = (Math::Rand()-0.5f)*12.0f; speed.y = Math::Rand()*12.0f; dim.x = Math::Rand()*12.0f+10.0f; dim.y = dim.x; m_particle->CreateParticle(pos, speed, dim, PARTIBLUE, 1.0f, 0.0f, 0.0f); #else mat = m_object->GetWorldMatrix(0); pos = Math::Vector(-12.0f, 20.0f, -4.0f); // position of chimney pos = Math::Transform(*mat, pos); pos.y += 2.0f; pos.x += (Math::Rand()-0.5f)*2.0f; pos.z += (Math::Rand()-0.5f)*2.0f; speed.x = 0.0f; speed.z = 0.0f; speed.y = 6.0f+Math::Rand()*6.0f; dim.x = Math::Rand()*1.5f+1.0f; dim.y = dim.x; m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE3, 4.0f); #endif } } else { m_displayText->DisplayError(INFO_FACTORY, m_object); SoundManip(2.0f, 1.0f, 1.2f); fret = SearchFret(); // transform metal? if ( fret != 0 ) { fret->DeleteObject(); // removes the metal delete fret; } m_vehicle = vehicle = SearchVehicle(); if ( vehicle != 0 ) { physics = vehicle->GetPhysics(); if ( physics != 0 ) { physics->SetFreeze(false); // can move } vehicle->SetLock(false); // vehicle useable //? vehicle->GetPhysics()->GetBrain()->StartTaskAdvance(16.0f); vehicle->SetAngleY(0, m_object->GetAngleY(0)+Math::PI); vehicle->SetZoom(0, 1.0f); } m_main->CreateShortcuts(); m_phase = AFP_OPEN_T; m_progress = 0.0f; m_speed = 1.0f/2.0f; } } if ( m_phase == AFP_OPEN_T ) { if ( m_progress < 1.0f ) { for ( i=0 ; i<9 ; i++ ) { angle = -(1.0f-m_progress)*(Math::PI/2.0f)+Math::PI/2.0f; m_object->SetAngleZ( 1+i, angle); m_object->SetAngleZ(10+i, -angle); } if ( m_lastParticle+m_engine->ParticleAdapt(0.1f) <= m_time ) { m_lastParticle = m_time; pos = m_fretPos; pos.x += (Math::Rand()-0.5f)*10.0f; pos.z += (Math::Rand()-0.5f)*10.0f; pos.y += Math::Rand()*10.0f; speed = Math::Vector(0.0f, 0.0f, 0.0f); dim.x = 2.0f; dim.y = dim.x; m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINT, 2.0f, 0.0f, 0.0f); } } else { for ( i=0 ; i<9 ; i++ ) { m_object->SetAngleZ( 1+i, Math::PI/2.0f); m_object->SetAngleZ(10+i, -Math::PI/2.0f); } SoundManip(3.0f, 1.0f, 0.5f); m_phase = AFP_OPEN_S; m_progress = 0.0f; m_speed = 1.0f/3.0f; } } if ( m_phase == AFP_OPEN_S ) { if ( m_progress < 1.0f ) { for ( i=0 ; i<9 ; i++ ) { zoom = 0.30f+((1.0f-m_progress)-0.5f+i/16.0f)*2.0f*0.70f; if ( zoom < 0.30f ) zoom = 0.30f; if ( zoom > 1.00f ) zoom = 1.00f; m_object->SetZoomZ( 1+i, zoom); m_object->SetZoomZ(10+i, zoom); } if ( m_lastParticle+m_engine->ParticleAdapt(0.1f) <= m_time ) { m_lastParticle = m_time; pos = m_fretPos; pos.x += (Math::Rand()-0.5f)*10.0f; pos.z += (Math::Rand()-0.5f)*10.0f; pos.y += Math::Rand()*10.0f; speed = Math::Vector(0.0f, 0.0f, 0.0f); dim.x = 2.0f; dim.y = dim.x; m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINT, 2.0f, 0.0f, 0.0f); } } else { for ( i=0 ; i<9 ; i++ ) { m_object->SetZoomZ( 1+i, 0.30f); m_object->SetZoomZ(10+i, 0.30f); } if ( m_program != nullptr ) { CBrain* brain = m_vehicle->GetBrain(); if ( brain != nullptr ) { brain->SendProgram(0, const_cast<const char*>(m_program)); brain->SetScriptRun(0); brain->RunProgram(0); } } SetBusy(false); UpdateInterface(); m_phase = AFP_WAIT; m_progress = 0.0f; m_speed = 1.0f/2.0f; } } return true; }
// update attack values and destiny position bool CMonster::UpdateValues( ) { //LMA: Some special case where special monsters stay still (mc, bonfires and so on...) if(stay_still&&(!IsBonfire())) return true; if(IsSummon( ) && CanMove( )) { CPlayer* thisclient = GetOwner( ); if(thisclient!=NULL) { if(!IsBonfire()) { if(!IsOnBattle( ) && thisclient->IsAttacking( )) { Battle->target = thisclient->Battle->target; Battle->atktarget = Battle->target; Battle->atktype = NORMAL_ATTACK; Battle->contatk = true; CCharacter* Enemy = GetCharTarget( ); if(Enemy!=NULL) StartAction( Enemy, NORMAL_ATTACK ); } else if(!IsOnBattle( )) { Position->source = thisclient->Position->current; float distance = GServer->distance( Position->destiny , thisclient->Position->current ); if((distance>15 && !IsOnBattle()) || distance>50) Move( ); } } else { //LMA: Let's kill bonfires if owner too far away :). float distance = GServer->distance( Position->current , thisclient->Position->current ); if(distance>25) { UnspawnMonster( ); return false; } return true; } } else { UnspawnMonster( ); return false; } } if(!IsMoving( ) && !IsOnBattle( ) && CanMove( )) { clock_t etime = clock() - Position->lastMoveTime; if(etime > 20*CLOCKS_PER_SEC) Move( ); } if(!IsSummon( )) { CPlayer* player = GetNearPlayer( 10 ); if(player!=NULL) OnEnemyOnSight( player ); } return true; }
void AARWeapon::ServerStartAction_Implementation() { StartAction(); }
bool CAutoFactory::EventProcess(const Event &event) { ObjectType type; CObject* cargo; CObject* vehicle; Math::Matrix* mat; CPhysics* physics; Math::Vector pos, speed; Math::Point dim; float zoom, angle, prog; int i; CAuto::EventProcess(event); if ( m_engine->GetPause() ) return true; if ( m_object->GetSelect() ) // factory selected? { if ( event.type == EVENT_UPDINTERFACE ) { CreateInterface(true); } type = ObjectTypeFromFactoryButton(event.type); Error err = StartAction(type); if( err != ERR_OK && err != ERR_UNKNOWN ) m_main->DisplayError(err, m_object); if( err != ERR_UNKNOWN ) return false; } if ( event.type != EVENT_FRAME ) return true; m_progress += event.rTime*m_speed; EventProgress(event.rTime); if ( m_phase == AFP_WAIT ) { if ( m_progress >= 1.0f ) { m_phase = AFP_WAIT; // still waiting ... m_progress = 0.0f; m_speed = 1.0f/2.0f; } } if ( m_phase == AFP_CLOSE_S ) { if ( m_progress < 1.0f ) { for ( i=0 ; i<9 ; i++ ) { zoom = 0.30f+(m_progress-0.5f+i/16.0f)*2.0f*0.70f; if ( zoom < 0.30f ) zoom = 0.30f; if ( zoom > 1.00f ) zoom = 1.00f; m_object->SetPartScaleZ( 1+i, zoom); m_object->SetPartScaleZ(10+i, zoom); } } else { for ( i=0 ; i<9 ; i++ ) { m_object->SetPartScaleZ( 1+i, 1.0f); m_object->SetPartScaleZ(10+i, 1.0f); } SoundManip(2.0f, 1.0f, 1.2f); m_phase = AFP_CLOSE_T; m_progress = 0.0f; m_speed = 1.0f/2.0f; } } if ( m_phase == AFP_CLOSE_T ) { if ( m_progress < 1.0f ) { for ( i=0 ; i<9 ; i++ ) { angle = -m_progress*(Math::PI/2.0f)+Math::PI/2.0f; m_object->SetPartRotationZ( 1+i, angle); m_object->SetPartRotationZ(10+i, -angle); } } else { for ( i=0 ; i<9 ; i++ ) { m_object->SetPartRotationZ( 1+i, 0.0f); m_object->SetPartRotationZ(10+i, 0.0f); } m_channelSound = m_sound->Play(SOUND_FACTORY, m_object->GetPosition(), 0.0f, 1.0f, true); m_sound->AddEnvelope(m_channelSound, 1.0f, 1.0f, 2.0f, SOPER_CONTINUE); m_sound->AddEnvelope(m_channelSound, 1.0f, 1.0f, 11.0f, SOPER_CONTINUE); m_sound->AddEnvelope(m_channelSound, 0.0f, 1.0f, 2.0f, SOPER_STOP); m_phase = AFP_BUILD; m_progress = 0.0f; m_speed = 1.0f/15.0f; } } if ( m_phase == AFP_BUILD ) { if ( m_progress == 0.0f ) { if ( !CreateVehicle() ) { cargo = SearchCargo(); // transform metal? if ( cargo != nullptr ) { cargo->SetLock(false); // metal usable again } if ( m_channelSound != -1 ) { m_sound->FlushEnvelope(m_channelSound); m_sound->AddEnvelope(m_channelSound, 0.0f, 1.0f, 1.0f, SOPER_STOP); m_channelSound = -1; } m_phase = AFP_OPEN_T; m_progress = 0.0f; m_speed = 1.0f/2.0f; return true; } } if ( m_progress < 1.0f ) { if ( m_type == OBJECT_MOBILErt || m_type == OBJECT_MOBILErc || m_type == OBJECT_MOBILErr || m_type == OBJECT_MOBILErs ) { prog = 1.0f-m_progress*1.5f; if ( prog < 0.0f ) prog = 0.0f; } else { prog = 1.0f-m_progress; } angle = powf(prog*10.0f, 2.0f)+m_object->GetRotationY(); vehicle = SearchVehicle(); if ( vehicle != nullptr ) { vehicle->SetRotationY(angle+Math::PI); vehicle->SetScale(m_progress); } cargo = SearchCargo(); // transform metal? if ( cargo != nullptr ) { cargo->SetScale(1.0f-m_progress); } if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time ) { m_lastParticle = m_time; mat = m_object->GetWorldMatrix(0); pos = Math::Vector(-12.0f, 20.0f, -4.0f); // position of chimney pos = Math::Transform(*mat, pos); pos.y += 2.0f; pos.x += (Math::Rand()-0.5f)*2.0f; pos.z += (Math::Rand()-0.5f)*2.0f; speed.x = 0.0f; speed.z = 0.0f; speed.y = 6.0f+Math::Rand()*6.0f; dim.x = Math::Rand()*1.5f+1.0f; dim.y = dim.x; m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE3, 4.0f); } } else { m_main->DisplayError(INFO_FACTORY, m_object); SoundManip(2.0f, 1.0f, 1.2f); cargo = SearchCargo(); // transform metal? if ( cargo != nullptr ) { CObjectManager::GetInstancePointer()->DeleteObject(cargo); } vehicle = SearchVehicle(); if ( vehicle != nullptr ) { assert(vehicle->Implements(ObjectInterfaceType::Movable)); physics = dynamic_cast<CMovableObject*>(vehicle)->GetPhysics(); physics->SetFreeze(false); // can move vehicle->SetLock(false); // vehicle useable vehicle->SetRotationY(m_object->GetRotationY()+Math::PI); vehicle->SetScale(1.0f); if ( !m_program.empty() ) { if (vehicle->Implements(ObjectInterfaceType::Programmable) && vehicle->Implements(ObjectInterfaceType::ProgramStorage)) { Program* program = dynamic_cast<CProgramStorageObject*>(vehicle)->AddProgram(); if (boost::regex_search(m_program, boost::regex("^[A-Za-z0-9_]+$"))) // Public function name? { std::string code = "extern void object::Start_"+m_program+"()\n{\n\t\n\t//Automatically generated by object.factory()\n\t"+m_program+"();\n\t\n}\n"; program->script->SendScript(code.c_str()); } else if (boost::regex_search(m_program, boost::regex("\\.txt$"))) // File name (with .txt extension)? { program->script->ReadScript(m_program.c_str()); } else // Program code? { program->script->SendScript(m_program.c_str()); } dynamic_cast<CProgrammableObject*>(vehicle)->RunProgram(program); } } } m_main->CreateShortcuts(); m_phase = AFP_OPEN_T; m_progress = 0.0f; m_speed = 1.0f/2.0f; } } if ( m_phase == AFP_OPEN_T ) { if ( m_progress < 1.0f ) { for ( i=0 ; i<9 ; i++ ) { angle = -(1.0f-m_progress)*(Math::PI/2.0f)+Math::PI/2.0f; m_object->SetPartRotationZ( 1+i, angle); m_object->SetPartRotationZ(10+i, -angle); } if ( m_lastParticle+m_engine->ParticleAdapt(0.1f) <= m_time ) { m_lastParticle = m_time; pos = m_cargoPos; pos.x += (Math::Rand()-0.5f)*10.0f; pos.z += (Math::Rand()-0.5f)*10.0f; pos.y += Math::Rand()*10.0f; speed = Math::Vector(0.0f, 0.0f, 0.0f); dim.x = 2.0f; dim.y = dim.x; m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINT, 2.0f, 0.0f, 0.0f); } } else { for ( i=0 ; i<9 ; i++ ) { m_object->SetPartRotationZ( 1+i, Math::PI/2.0f); m_object->SetPartRotationZ(10+i, -Math::PI/2.0f); } SoundManip(3.0f, 1.0f, 0.5f); m_phase = AFP_OPEN_S; m_progress = 0.0f; m_speed = 1.0f/3.0f; } } if ( m_phase == AFP_OPEN_S ) { if ( m_progress < 1.0f ) { for ( i=0 ; i<9 ; i++ ) { zoom = 0.30f+((1.0f-m_progress)-0.5f+i/16.0f)*2.0f*0.70f; if ( zoom < 0.30f ) zoom = 0.30f; if ( zoom > 1.00f ) zoom = 1.00f; m_object->SetPartScaleZ( 1+i, zoom); m_object->SetPartScaleZ(10+i, zoom); } if ( m_lastParticle+m_engine->ParticleAdapt(0.1f) <= m_time ) { m_lastParticle = m_time; pos = m_cargoPos; pos.x += (Math::Rand()-0.5f)*10.0f; pos.z += (Math::Rand()-0.5f)*10.0f; pos.y += Math::Rand()*10.0f; speed = Math::Vector(0.0f, 0.0f, 0.0f); dim.x = 2.0f; dim.y = dim.x; m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINT, 2.0f, 0.0f, 0.0f); } } else { for ( i=0 ; i<9 ; i++ ) { m_object->SetPartScaleZ( 1+i, 0.30f); m_object->SetPartScaleZ(10+i, 0.30f); } SetBusy(false); UpdateInterface(); m_phase = AFP_WAIT; m_progress = 0.0f; m_speed = 1.0f/2.0f; } } return true; }
bool CAutoResearch::EventProcess(const Event &event) { CPowerContainerObject* power; Math::Vector pos, speed; Error message; Math::Point dim; float angle; CAuto::EventProcess(event); if ( m_engine->GetPause() ) return true; if ( event.type == EVENT_UPDINTERFACE ) { if ( m_object->GetSelect() ) CreateInterface(true); } if ( m_object->GetSelect() ) // center selected? { Error err = ERR_UNKNOWN; if ( event.type == EVENT_OBJECT_RTANK ) err = StartAction(RESEARCH_TANK); if ( event.type == EVENT_OBJECT_RFLY ) err = StartAction(RESEARCH_FLY); if ( event.type == EVENT_OBJECT_RTHUMP ) err = StartAction(RESEARCH_THUMP); if ( event.type == EVENT_OBJECT_RCANON ) err = StartAction(RESEARCH_CANON); if ( event.type == EVENT_OBJECT_RTOWER ) err = StartAction(RESEARCH_TOWER); if ( event.type == EVENT_OBJECT_RPHAZER ) err = StartAction(RESEARCH_PHAZER); if ( event.type == EVENT_OBJECT_RSHIELD ) err = StartAction(RESEARCH_SHIELD); if ( event.type == EVENT_OBJECT_RATOMIC ) err = StartAction(RESEARCH_ATOMIC); if( err != ERR_OK && err != ERR_UNKNOWN ) m_main->DisplayError(err, m_object); if( err != ERR_UNKNOWN ) return false; } if ( event.type != EVENT_FRAME ) return true; m_progress += event.rTime*m_speed; m_timeVirus -= event.rTime; if ( m_object->GetVirusMode() ) // contaminated by a virus? { if ( m_timeVirus <= 0.0f ) { m_timeVirus = 0.1f+Math::Rand()*0.3f; } return true; } UpdateInterface(event.rTime); EventProgress(event.rTime); angle = m_time*0.1f; m_object->SetPartRotationY(1, angle); // rotates the antenna angle = (30.0f+sinf(m_time*0.3f)*20.0f)*Math::PI/180.0f; m_object->SetPartRotationZ(2, angle); // directs the antenna if ( m_phase == ALP_WAIT ) { FireStopUpdate(m_progress, false); // extinguished return true; } if ( m_phase == ALP_SEARCH ) { FireStopUpdate(m_progress, true); // flashes if ( m_progress < 1.0f ) { if ( m_object->GetPower() == nullptr || !m_object->GetPower()->Implements(ObjectInterfaceType::PowerContainer) ) // more battery? { SetBusy(false); UpdateInterface(); m_phase = ALP_WAIT; m_progress = 0.0f; m_speed = 1.0f/1.0f; return true; } power = dynamic_cast<CPowerContainerObject*>(m_object->GetPower()); power->SetEnergyLevel(1.0f-m_progress); if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time ) { m_lastParticle = m_time; pos = m_object->GetPosition(); pos.x += (Math::Rand()-0.5f)*6.0f; pos.z += (Math::Rand()-0.5f)*6.0f; pos.y += 11.0f; speed.x = (Math::Rand()-0.5f)*2.0f; speed.z = (Math::Rand()-0.5f)*2.0f; speed.y = Math::Rand()*20.0f; dim.x = Math::Rand()*1.0f+1.0f; dim.y = dim.x; m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIVAPOR); } } else { m_main->MarkResearchDone(m_research, m_object->GetTeam()); // research done m_eventQueue->AddEvent(Event(EVENT_UPDINTERFACE)); UpdateInterface(); m_main->DisplayError(INFO_RESEARCH, m_object); message = ERR_OK; if ( m_research == RESEARCH_TANK ) message = INFO_RESEARCHTANK; if ( m_research == RESEARCH_FLY ) message = INFO_RESEARCHFLY; if ( m_research == RESEARCH_THUMP ) message = INFO_RESEARCHTHUMP; if ( m_research == RESEARCH_CANON ) message = INFO_RESEARCHCANON; if ( m_research == RESEARCH_TOWER ) message = INFO_RESEARCHTOWER; if ( m_research == RESEARCH_PHAZER ) message = INFO_RESEARCHPHAZER; if ( m_research == RESEARCH_SHIELD ) message = INFO_RESEARCHSHIELD; if ( m_research == RESEARCH_ATOMIC ) message = INFO_RESEARCHATOMIC; if ( message != ERR_OK ) { m_main->DisplayError(message, m_object); } SetBusy(false); UpdateInterface(); m_phase = ALP_WAIT; m_progress = 0.0f; m_speed = 1.0f/1.0f; } } return true; }
void CCharacter::DoAttack( ) { //if(Status->Sleep <= 0xff) //{ // ClearBattle( Battle ); // return; // can't take any action while we are asleep can we? //} //Log(MSG_INFO,"skill type %i selected. Chartype = %i",Battle->atktype, CharType); if(Battle->iscasting == 1) { CCharacter* Enemy = GetCharTarget( ); if(Enemy == NULL) { ClearBattle( Battle ); return; } //Log(MSG_DEBUG,"Iscasting detected as true. Reset to false."); if(CanAttack()) { //if(IsPlayer()) //{ // Log(MSG_DEBUG,"Should reach here once on normal attack. iscasting state = %i",Battle->iscasting); //} ClearBattle( Battle ); StartAction(Enemy, NORMAL_ATTACK, 0); } else { return; } return; } if(!CanAttack()) { return; } if(IsSummon()) { CCharacter* Enemy = GetCharTarget( ); if(Enemy == NULL || (Battle->atktype != SKILL_AOE && Battle->atktype != BUFF_AOE)) { //Log(MSG_DEBUG,"No Enemy found"); ClearBattle( Battle ); return; } if(this == Enemy) //summoned monster is attacking itself. It has been observed to happen { //Log(MSG_INFO,"Clearing Battle for this summon"); ClearBattle( Battle ); return; } if(Enemy->IsSummon()) { CMonster* thisMonster = reinterpret_cast<CMonster*>(this); if(thisMonster == NULL) { ClearBattle( Battle ); return; } CMonster* otherMonster = reinterpret_cast<CMonster*>(Enemy); if(otherMonster == NULL) { ClearBattle( Battle ); return; } if(thisMonster->owner == otherMonster->owner) { //Log(MSG_INFO,"Clearing Battle for this summon"); ClearBattle( Battle ); return; } } } CMap* map = GServer->MapList.Index[Position->Map]; //Log(MSG_INFO,"DoAttack Battle Attack type = %i",Battle->atktype); switch(Battle->atktype) { case NORMAL_ATTACK://normal attack { //if(!Status->CanAttack) // return; //can't attack right now. CCharacter* Enemy = GetCharTarget( ); if(Enemy == NULL) { ClearBattle( Battle ); return; } if(Enemy == this) { //Log(MSG_INFO,"WTF?? I AM trying to attack myself"); ClearBattle( Battle ); } if(IsTargetReached( Enemy )) { //if(IsMonster()) // Log(MSG_INFO,"Monster is trying to hit the player"); NormalAttack( Enemy ); if (Enemy->IsMonster()) // do monster AI script when monster is attacked. { CMonster* monster = GServer->GetMonsterByID(Enemy->clientid, Enemy->Position->Map); if(monster == NULL)return; //monster->DoAi(monster->thisnpc->AI, 3); monster->DoAi(monster->monAI, 3); } } } break; case SKILL_ATTACK://skill attack { CCharacter* Enemy = GetCharTarget( ); if(Enemy == NULL) { ClearBattle( Battle ); return; } CSkills* skill = GServer->GetSkillByID( Battle->skillid ); if(skill == NULL) { //ClearBattle( Battle ); return; } if(IsTargetReached( Enemy, skill )) { SkillAttack( Enemy, skill ); if (Enemy->IsMonster()) { CMonster* monster = GServer->GetMonsterByID(Enemy->clientid, Enemy->Position->Map); if(monster == NULL)return; monster->DoAi(monster->monAI, 3); } } } break; case SKILL_BUFF://buffs { CCharacter* Enemy = GetCharTarget( ); if(Enemy == NULL) { //Log(MSG_DEBUG,"this target is NULL"); ClearBattle( Battle ); return; } CSkills* skill = GServer->GetSkillByID( Battle->skillid ); if(skill == NULL) { //Log(MSG_DEBUG,"this skill is NULL"); return; } if(IsTargetReached( Enemy, skill )) { //Log(MSG_DEBUG,"Skill successfully cast"); BuffSkill( Enemy, skill ); } } break; case SKILL_AOE: //case SKILL_SELF: //this is impossible. it can never be set case AOE_TARGET: { //Log(MSG_DEBUG,"Called skill type %i",Battle->atktype); CCharacter* Enemy = NULL; CSkills* skill = GServer->GetSkillByID( Battle->skillid ); if(skill == NULL) { ClearBattle( Battle ); return; } if(Battle->atktype == AOE_TARGET) { float distance = GServer->distance( Position->current, Position->destiny ); if(distance <= skill->range) { Position->destiny = Position->current; AoeSkill( skill, Enemy ); } } else { Position->skilltargetpos = Position->current; AoeSkill( skill, NULL ); } } break; case BUFF_SELF: { // return; // can't cast skills right now CSkills* skill = GServer->GetSkillByID( Battle->skillid ); if(skill == NULL) { //ClearBattle( Battle ); return; } BuffSkill( this, skill ); } break; case BUFF_AOE: { //Log(MSG_INFO,"BUFF AOE selected"); CSkills* skill = GServer->GetSkillByID( Battle->skillid ); if(skill == NULL) { //ClearBattle( Battle ); return; } AoeBuff( skill ); } break; default: return; break; } }
// Spawn a monster //LMA: added handling of skill summons. void CMonster::SpawnMonster( CPlayer* player, CMonster* thismon ) { BEGINPACKET( pak, 0x792 ); //struct tag_ADD_CHAR ADDWORD ( pak, clientid ); ADDFLOAT ( pak, Position->current.x*100 ); ADDFLOAT ( pak, Position->current.y*100 ); //current X and Y position if((thismon->bonushp > 0 || thismon->bonusmp > 0) && (thismon->skillid > 0)) //What is this? It seems to be sending this in place of destination if the monster is not able to move. Bonfires and so on { ADDFLOAT ( pak, 0xcdcdcdcd ); ADDFLOAT ( pak, 0xcdcdcdcd ); } else { ADDFLOAT ( pak, Position->destiny.x*100 ); //Destination position. This should always follow current position ADDFLOAT ( pak, Position->destiny.y*100 ); } // next 2 WORDS are m_wCommand and m_wTargetOBJ if(IsDead( )) { ADDWORD ( pak, 0x0003 ); ADDWORD ( pak, 0x0000 ); } else if(IsOnBattle( )) { //LMA: for supportive summons (lucky ghost...) if(Battle->bufftarget == Battle->target) { ADDWORD ( pak, 0x0002 ); ADDWORD ( pak, 0x0000 ); } else { ADDWORD ( pak, 0x0002 ); ADDWORD ( pak, Battle->target ); } } else if(IsMoving( )) { ADDWORD ( pak, 0x0001 ); ADDWORD ( pak, 0x0000 ); } else { ADDWORD ( pak, 0x0000 ); ADDWORD ( pak, 0x0000 ); } ADDBYTE ( pak, thisnpc->stance ); ADDWORD ( pak, Stats->HP ); ADDWORD ( pak, 0x0000 ); // now Team Number if(thismon->owner != player->clientid) { CMap* map = GServer->MapList.Index[Position->Map]; //LMA: adding team... if (thismon->team!=0) { ADDWORD( pak,thismon->team); } else { if(IsSummon( ) && map->allowpvp!=0) { //Hostil ADDWORD( pak, 0x0064 ); } else if (IsSummon( ) && map->allowpvp==0) { //Friendly ADDWORD ( pak, 0x0000 ); } else { //Hostil ADDWORD( pak, 0x0064 ); } } } else { //Friendly ADDWORD( pak, 0x0000 ); } ADDWORD ( pak, 0x0000 ); //and finally DWORD StatusFlag ADDDWORD( pak, GServer->BuildBuffs( this ) ); //struct gsv_MOB_CHAR ADDWORD ( pak, montype ); ADDWORD ( pak, 0x0000 ); ADDWORD ( pak, thismon->Stats->Level ); ADDWORD ( pak, thismon->Stats->Size ); player->client->SendPacket( &pak ); //LMA: supportive summons (lucky ghost) //PY: Another special case. Will probably need to remove this later if(IsSummon() && buffid > 0 && (player == GetOwner())) { Log(MSG_INFO,"The summon is spawned"); /*CPlayer* player = GetOwner( ); if (ownplayer==NULL) return true;*/ StartAction( player,SUMMON_BUFF,buffid); Log(MSG_INFO,"completly"); buffid=0; //only one buff } }
// Spawn a monster //LMA: added handling of skill summons. void CMonster::SpawnMonster( CPlayer* player, CMonster* thismon ) { BEGINPACKET( pak, 0x792 ); ADDWORD ( pak, clientid ); ADDFLOAT ( pak, Position->current.x*100 ); ADDFLOAT ( pak, Position->current.y*100 ); if((thismon->bonushp>0||thismon->bonusmp>0)&&(thismon->skillid>0)) { ADDFLOAT ( pak, 0xcdcdcdcd ); ADDFLOAT ( pak, 0xcdcdcdcd ); } else { ADDFLOAT ( pak, Position->destiny.x*100 ); ADDFLOAT ( pak, Position->destiny.y*100 ); } if(IsDead( )) { ADDWORD ( pak, 0x0003 ); ADDWORD ( pak, 0x0000 ); } else if(IsOnBattle( )) { //LMA: for supportive summons (lucky ghost...) if(Battle->bufftarget==Battle->target) { ADDWORD ( pak, 0x0002 ); ADDWORD ( pak, 0x0000 ); } else { ADDWORD ( pak, 0x0002 ); ADDWORD ( pak, Battle->target ); } } else if(IsMoving( )) { ADDWORD ( pak, 0x0001 ); ADDWORD ( pak, 0x0000 ); } else { ADDWORD ( pak, 0x0000 ); ADDWORD ( pak, 0x0000 ); } if(IsSummon( ) ) { ADDBYTE ( pak, 0x01 ); } else { ADDBYTE ( pak, 0x00 ); } //LMA: Little check, for now we "only" have a DWORD for monster's HP so there is a limit //broken by some monsters (Turak boss) if(Stats->HP>MAXHPMOB) { LogDebugPriority(3); LogDebug("Too much HP for monster %i (%I64i->%I64i)",thismon->montype,Stats->HP,MAXHPMOB); LogDebugPriority(4); Stats->HP=(long long) MAXHPMOB; } ADDDWORD ( pak, Stats->HP ); if(thismon->owner != player->clientid) { CMap* map = GServer->MapList.Index[Position->Map]; //LMA: adding team... if (thismon->team!=0) { ADDDWORD( pak,thismon->team); } else { if(IsSummon( ) && map->allowpvp!=0) { //Hostil ADDDWORD( pak, 0x00000064 ); } else if (IsSummon( ) && map->allowpvp==0) { //Friendly ADDDWORD ( pak, 0x00000000 ); } else { //Hostil ADDDWORD( pak, 0x00000064 ); } //TODO: LMA, test if necessary or not anymore... /* else if(thismon->montype>=1474&&thismon->montype<=1489) { //LMA: Xmas trees are friendly. ADDDWORD ( pak, 0x00000000 ); } */ } } else { //Friendly ADDDWORD( pak, 0x00000000 ); } ADDDWORD( pak, GServer->BuildBuffs( this ) ); ADDWORD ( pak, montype ); ADDWORD ( pak, 0x0000 ); if(IsSummon( )) { ADDWORD( pak, owner ); if (thismon->skillid>0) { ADDWORD( pak, thismon->skillid ); //id del skill (si es summon de skill) } else { ADDWORD( pak, 0x0000 ); //id del skill (si es summon de skill) } } player->client->SendPacket( &pak ); //LMA: supportive summons (lucky ghost) if(IsSummon()&&buffid>0&&(player==GetOwner())) { Log(MSG_INFO,"The summon is spawned"); /*CPlayer* player = GetOwner( ); if (ownplayer==NULL) return true;*/ StartAction( player,SUMMON_BUFF,buffid); Log(MSG_INFO,"completly"); buffid=0; //only one buff } }
void RPG_ActionHandler::ProcessAction(RPG_ActionData const& actionData, bool const forceAction /*= false*/) { // if we're already doing the requested move, ignore the call except to update flags or interaction entities. if (actionData.m_Action == m_activeAction.m_Action) { // same move, updated flags if (actionData.m_Action != AT_None && actionData.m_flags != m_activeAction.m_flags) { m_activeAction.m_flags = actionData.m_flags; //@todo: if this is happening on the authoritative server, replicate this flag change to clients. if (m_Actions[actionData.m_Action]) { m_Actions[actionData.m_Action]->UpdateFlags(actionData.m_flags); } } // same move, updated interaction entity if(actionData.m_interactionEntity != m_activeAction.m_interactionEntity || !actionData.m_interactionPosition.isIdentical(m_activeAction.m_interactionPosition)) { m_activeAction.m_interactionEntity = actionData.m_interactionEntity; m_activeAction.m_interactionPosition = actionData.m_interactionPosition; if(m_Actions[actionData.m_Action]) { m_Actions[actionData.m_Action]->UpdateInteraction(actionData.m_interactionEntity, actionData.m_interactionPosition); // clear the pending action, as enough data has changed for the pending action to probably not be the desired behavior. m_pendingAction.Clear(); } } // clear the pending action if this was forced if(forceAction) { m_pendingAction.Clear(); } // no further action required, since this isn't a new move. return; } // if we're chaining from an action that needs to complete first, defer this action if (m_endingAction) { m_pendingAction = actionData; return; } // verify that we can do this move if (actionData.m_Action != AT_None && !forceAction && !m_chainingAction && !CanPerformAction(actionData.m_Action)) { Vision::Error.Warning("Cannot perform requested Action."); return; } // ready to go. m_previousAction = m_activeAction; // stop the previous action, if any if (m_activeAction.m_Action != AT_None) { m_endingAction = true; m_activeAction.m_Action = AT_None; RPG_ActionType_e nextAction = actionData.m_Action; if (nextAction == AT_None && m_pendingAction.m_Action != AT_None) { nextAction = m_pendingAction.m_Action; } CleanUpAction(m_previousAction.m_Action, nextAction); m_endingAction = false; } // if we need to start a pending action, do it now if (actionData.m_Action == AT_None && m_pendingAction.m_Action != AT_None) { // Recursively Process the pending action if one exists. m_chainingAction = true; m_activeAction.m_Action = m_previousAction.m_Action; // restore this value, since the pending action call will need it. ProcessAction(m_pendingAction); m_chainingAction = false; if (m_activeAction.m_Action == m_pendingAction.m_Action) { m_pendingAction.Clear(); return; } } // set the new Action m_activeAction = actionData; // @todo: Once the network branch is in, replicate these values. // - m_replicatedAction = m_activeAction; // - force net update if (m_activeAction.m_Action != AT_None) { StartAction(m_activeAction.m_Action, m_previousAction.m_Action, forceAction, m_activeAction.m_interactionEntity, m_activeAction.m_interactionPosition, m_activeAction.m_flags); // if this was a forced action, clear any pending action, as this was an interrupt of the current action if (forceAction) { m_pendingAction.Clear(); } } }