/* virtual */ void Attack::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; Actor* actor = dynamic_cast<Actor*>(fObject); if (actor == NULL) return; Actor* target = dynamic_cast<Actor*>(Script::FindTargetObject(fObject, fActionParams)); if (target == NULL){ SetCompleted(); return; } if (!Initiated()) { IE::point point = target->NearestPoint(actor->Position()); if (!PointSufficientlyClose(actor->Position(), point)) actor->SetDestination(point); SetInitiated(); } if (actor->Position() != actor->Destination()) { actor->SetAnimationAction(ACT_WALKING); actor->MoveToNextPointInPath(actor->IsFlying()); } else { actor->SetAnimationAction(ACT_ATTACKING); actor->AttackTarget(target); SetCompleted(); } }
/* virtual */ void Dialogue::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; Actor* actor = dynamic_cast<Actor*>(fObject); if (actor == NULL) return; Actor* target = dynamic_cast<Actor*>(Script::FindTargetObject(fObject, fActionParams)); if (target == NULL){ SetCompleted(); return; } // TODO: Some dialogue action require the actor to be near the target, // others do not. Must be able to differentiate /* const IE::point point = fTarget->Target()->NearestPoint(fActor.Target()->Position()); if (!PointSufficientlyClose(fActor.Target()->Destination(), point)) fActor.Target()->SetDestination(point); */ SetInitiated(); /* if (!PointSufficientlyClose(fActor.Target()->Position(), fTarget->Target()->Position())) { fActor.Target()->SetAnimationAction(ACT_WALKING); fActor.Target()->MoveToNextPointInPath(fActor.Target()->IsFlying()); } else { */ actor->SetAnimationAction(ACT_STANDING); SetCompleted(); actor->InitiateDialogWith(target); //} }
/* virtual */ void PlayDeadAction::operator()() { if (!Initiated()) { SetInitiated(); Actor* actor = dynamic_cast<Actor*>(fObject); if (actor == NULL) SetCompleted(); actor->SetAnimationAction(ACT_DEAD); fDuration = fActionParams->integer1 * 15; } if (fDuration-- <= 0) SetCompleted(); }
/* virtual */ void ScreenShake::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; if (!Initiated()) { SetInitiated(); if (fObject != NULL) fObject->SetWaitTime(fDuration); fOffset = fActionParams->where; fDuration = fActionParams->integer1; } GFX::point point = { 0, 0 }; if (fDuration-- == 0) { GraphicsEngine::Get()->SetRenderingOffset(point); SetCompleted(); return; } point.x = fOffset.x; point.y = fOffset.y; GraphicsEngine::Get()->SetRenderingOffset(point); fOffset.x = -fOffset.x; fOffset.y = -fOffset.y; }
/* virtual */ void StartCutsceneModeAction::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; Core::Get()->StartCutsceneMode(); SetCompleted(); }
/* virtual */ void StartCutsceneAction::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; Core::Get()->StartCutscene(fActionParams->string1); SetCompleted(); }
/* virtual */ void SetInterruptableAction::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; fObject->SetInterruptable(fActionParams->integer1 == 1); SetCompleted(); }
/* virtual */ void UnhideGUIAction::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; GUI::Get()->Show(); SetCompleted(); }
/* virtual */ void TriggerActivationAction::operator()() { Region* region = dynamic_cast<Region*>(Script::FindTargetObject(fObject, fActionParams)); if (region != NULL) region->ActivateTrigger(); SetCompleted(); }
/* virtual */ void DestroySelfAction::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; Object* object = Script::FindSenderObject(fObject, fActionParams); object->DestroySelf(); SetCompleted(); }
//----------------------------------------------------------------------------- // Purpose: // Input : id - // priority - // player - // entity - //----------------------------------------------------------------------------- C_TFBaseHint::C_TFBaseHint( int id, int priority, int entity, HINTCOMPLETIONFUNCTION pfn /*=NULL*/ ) : vgui::Panel( NULL, "TFBaseHint" ), m_CursorNone( vgui::dc_none ) { m_pObject = NULL; m_pClearLabel = NULL; m_pCaption = NULL; m_pfnCompletion = pfn; // Child of main panel SetParent( VGui_GetClientDLLRootPanel() ); // Put at top of z-order (happens in Think, too) // MoveToFront(); // No cursor SetCursor( m_CursorNone ); // Set to default size SetSize( TFBASEHINT_DEFAULT_WIDTH, TFBASEHINT_DEFAULT_HEIGHT ); // We'll expressly delete it SetAutoDelete( false ); // Set up default values SetID( id ); SetPriority( priority ); SetEntity( entity ); SetCompleted( false ); // Target panel m_hTarget = NULL; m_bMoving = false; m_flMoveRemaining = 0.0f; m_flMoveTotal = 0.0f; for ( int pt = 0; pt < 2; pt++ ) { m_nMoveStart[ pt ] = 0; m_nMoveEnd[ pt ] = 0; } vgui::ivgui()->AddTickSignal( GetVPanel() ); // Create clear label m_pClearLabel = new vgui::Label( this, "CLEAR", "[Enter] to remove, [Enter] twice quickly to remove all..." ); m_pClearLabel->SetContentAlignment( vgui::Label::a_west ); m_pClearLabel->SetTextInset( 3, 2 ); // Create window caption m_pCaption = new vgui::Label( this, "CAPTION", "" ); m_pCaption->SetContentAlignment( vgui::Label::a_west ); m_pCaption->SetTextInset( 3, 0 ); // See if the hint started out complete! CheckForCompletion(); // Always start out hidden SetVisible( false ); }
void C_TFBaseHint::CheckForCompletion( void ) { if ( m_pfnCompletion ) { bool complete = (*m_pfnCompletion)( this ); if ( complete ) SetCompleted( true ); } }
/* virtual */ void ChangeOrientationExtAction::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; Actor* actor = dynamic_cast<Actor*>(fObject); if (actor != NULL) actor->SetOrientation(fActionParams->integer1); SetCompleted(); }
//----------------------------------------------------------------------------------------------------------------------------------- void AddTextBoxScript::Run(float elapsedSeconds) { Script::Run(elapsedSeconds); if (IsRunning()) { m_textBox->Update(elapsedSeconds); SetCompleted(m_textBox->IsAlive() == false); } }
/* virtual */ void OpenDoor::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; Actor* actor = dynamic_cast<Actor*>(fObject); if (actor == NULL) return; Object* target = Script::FindTargetObject(fObject, fActionParams); if (target == NULL) { SetCompleted(); return; } target->Print(); //if (!target->Opened()) //target->Toggle(); SetCompleted(); }
/* virtual */ void DisplayStringHead::operator()() { if (!Initiated()) { SetInitiated(); fDuration = 100; //?? Actor* actor = dynamic_cast<Actor*>(Script::FindTargetObject(fObject, fActionParams)); if (actor == NULL) SetCompleted(); IE::point point = actor->Position(); point.y -= 100; std::string string = IDTable::GetDialog(fActionParams->integer1); Core::Get()->CurrentRoom()->ConvertFromArea(point); // TODO: Center string // we multiply by 15 because DisplayString() accepts ms, but duration // is specified in AI update times GUI::Get()->DisplayStringCentered(string, point.x, point.y, fDuration * 15); } if (fDuration-- <= 0) { SetCompleted(); } }
/* virtual */ void MoveViewPoint::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; //SetCompleted(); //return; if (!Initiated()) { SetInitiated(); fDestination = fActionParams->where; Core::Get()->CurrentRoom()->SanitizeOffsetCenter(fDestination); switch (fActionParams->integer1) { case 1: fScrollSpeed = 10; break; case 2: fScrollSpeed = 20; break; case 3: fScrollSpeed = 40; break; case 4: fScrollSpeed = 80; break; case 0: default: fScrollSpeed = 10000; break; } } RoomBase* room = Core::Get()->CurrentRoom(); IE::point offset = room->AreaCenterPoint(); const int16 step = fScrollSpeed; if (offset != fDestination) { if (offset.x > fDestination.x) offset.x = std::max((int16)(offset.x - step), fDestination.x); else if (offset.x < fDestination.x) offset.x = std::min((int16)(offset.x + step), fDestination.x); if (offset.y > fDestination.y) offset.y = std::max((int16)(offset.y - step), fDestination.y); else if (offset.y < fDestination.y) offset.y = std::min((int16)(offset.y + step), fDestination.y); room->SetAreaOffsetCenter(offset); std::cout << std::dec; std::cout << "offset: " << offset.x << ", " << offset.y << std::endl; std::cout << "fDestination: " << fDestination.x << ", " << fDestination.y << std::endl; } else SetCompleted(); }
/* virtual */ void MoveBetweenAreasEffect::operator()() { if (!Initiated()) { SetInitiated(); Actor* actor = dynamic_cast<Actor*>(fObject); if (actor != NULL) { std::cout << "area:" << fActionParams->string1 << std::endl; //actor->SetPosition(fActionParams->where); //actor->SetOrientation(fActionParams->integer1); } SetCompleted(); } }
/* virtual */ void Wait::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; if (!Initiated()) { SetInitiated(); fWaitTime = fActionParams->integer1 * 15; // TODO use a constant return; } if (--fWaitTime <= 0) SetCompleted(); }
/* virtual */ void CreateCreatureImpassableAction::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; Actor* actor = new Actor(fActionParams->string1, fActionParams->where, fActionParams->integer1); std::cout << "Created actor " << fActionParams->string1 << " on "; std::cout << fActionParams->where.x << ", " << fActionParams->where.y << std::endl; //actor->SetDestination(fActionParams->where); Core::Get()->AddActorToCurrentArea(actor); SetCompleted(); //core->SetActiveActor(actor); }
/* virtual */ void DisplayString::operator()() { if (!Initiated()) { SetInitiated(); fDuration = fActionParams->integer1; std::string string = IDTable::GetDialog(fActionParams->integer1); GUI::Get()->DisplayString(string, fActionParams->where.x, fActionParams->where.y, fDuration * 15); } if (fDuration-- <= 0) { SetCompleted(); } }
/* virtual */ void WalkTo::operator()() { Actor* actor = dynamic_cast<Actor*>(Script::FindSenderObject(fObject, fActionParams)); if (!Initiated()) { actor->SetDestination(fActionParams->where); SetInitiated(); } if (actor->Position() == actor->Destination()) { SetCompleted(); return; } }
//----------------------------------------------------------------------------------------------------------------------------------- void CheckAccelerateScript::Run(float elapsedGameTime) { Script::Run(elapsedGameTime); if (IsRunning()) { if (m_accelerationPressed) { m_timeSinceAccelerationPressed += elapsedGameTime; SetCompleted(m_timeSinceAccelerationPressed >= 1); } } }
//----------------------------------------------------------------------------------------------------------------------------------- void CheckLeftAndRightTurnScript::Run(float elapsedGameTime) { Script::Run(elapsedGameTime); if (IsRunning()) { if (m_leftTurnPressed && m_rightTurnPressed) { m_timeSinceTurnsPressed += elapsedGameTime; SetCompleted(m_timeSinceTurnsPressed >= 0.6f); } } }
/* virtual */ void RunAwayFrom::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; Actor* actor = dynamic_cast<Actor*>(fObject); if (actor == NULL) return; // TODO: Improve. // TODO: We are recalculating this every time. Is it correct ? Actor* target = dynamic_cast<Actor*>(Script::FindTargetObject(fObject, fActionParams)); if (target == NULL){ SetCompleted(); return; } // TODO: Implement SetCompleted(); return; /* if (Core::Get()->Distance(actor, target) < 200) { IE::point point = PointAway(); if (actor->Destination() != point) { actor->SetDestination(point); } } if (actor->Position() == actor->Destination()) { SetCompleted(); actor->SetAnimationAction(ACT_STANDING); } else { actor->SetAnimationAction(ACT_WALKING); actor->MoveToNextPointInPath(actor->IsFlying()); }*/ }
/* virtual */ void WalkToObject::operator()() { Actor* actor = dynamic_cast<Actor*>(Script::FindSenderObject(fObject, fActionParams)); if (actor == NULL) return; Actor* target = dynamic_cast<Actor*>(Script::FindTargetObject(fObject, fActionParams)); if (target == NULL) { SetCompleted(); return; } //target->Acquire(); IE::point destination = target->NearestPoint(actor->Position()); actor->SetDestination(destination); if (actor->Position() == actor->Destination()) { SetCompleted(); //target->Release(); return; } }
/* virtual */ void SetGlobalAction::operator()() { std::string variableScope; std::string variableName; VariableGetScopeName(fActionParams->string1, variableScope, variableName); if (variableScope.compare("LOCALS") == 0) { if (fObject != NULL) fObject->Vars().Set(variableName.c_str(), fActionParams->integer1); } else { // TODO: Check for AREA variables Core::Get()->Vars().Set(fActionParams->string1, fActionParams->integer1); } SetCompleted(); }
/* virtual */ void SmallWait::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; //Object* object = Script::FindObject(fObject, fActionParams); //if (object != NULL) // object->SetWaitTime(fActionParams->integer1); if (!Initiated()) { SetInitiated(); fWaitTime = fActionParams->integer1; return; } if (--fWaitTime <= 0) SetCompleted(); }
/* virtual */ void FadeFromColorAction::operator()() { if (fObject == NULL) std::cerr << "NULL OBJECT" << std::endl; if (!Initiated()) { SetInitiated(); fCurrentValue = 0; fTargetValue = 255; fStepValue = fTargetValue / fActionParams->where.x; } GraphicsEngine::Get()->SetFade(fCurrentValue); if (fCurrentValue < fTargetValue) fCurrentValue += fStepValue; else SetCompleted(); }
uint32 ObjectiveSprite::ObjectMessageFn(HOBJECT hSender, uint32 messageID, HMESSAGEREAD hRead) { switch(messageID) { case MID_TRIGGER: { const char* szMsg = (const char*)g_pLTServer->ReadFromMessageDWord(hRead); if (stricmp(szMsg, "COMPLETE") == 0) { SetCompleted(); } else if (stricmp(szMsg, "RESET") == 0) { Reset(); } else if (stricmp(szMsg, "ON") == 0) { if (m_hObject) { uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject); g_pLTServer->SetObjectFlags(m_hObject, dwFlags | FLAG_VISIBLE); uint32 dwUsrFlags = g_pLTServer->GetObjectUserFlags(m_hObject); g_pLTServer->SetObjectUserFlags(m_hObject, dwUsrFlags | USRFLG_VISIBLE); } } else if (stricmp(szMsg, "OFF") == 0) { if (m_hObject) { uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject); g_pLTServer->SetObjectFlags(m_hObject, dwFlags & ~FLAG_VISIBLE); uint32 dwUsrFlags = g_pLTServer->GetObjectUserFlags(m_hObject); g_pLTServer->SetObjectUserFlags(m_hObject, dwUsrFlags & ~USRFLG_VISIBLE); } } } default : break; } return GameBase::ObjectMessageFn (hSender, messageID, hRead); }