int BrigadeClass::CheckTactic (int tid) { Objective o; if (tid < 1) return 0; if (haveWeaps < 0) { FalconEntity *e; GridIndex x,y,dx,dy; e = GetTarget(); if (Engaged() && !e) SetEngaged(0); if (GetUnitSupply() > 20) haveWeaps = 1; else haveWeaps = 0; GetLocation(&x,&y); o = GetUnitObjective(); ourObjOwner = 0; if (o && o->GetTeam() == GetTeam()) ourObjOwner = 1; if (o) o->GetLocation(&dx,&dy); else GetUnitDestination(&dx,&dy); ourObjDist = FloatToInt32(Distance(x,y,dx,dy)); } if (!CheckUnitType(tid, GetDomain(), GetType())) return 0; if (!CheckTeam(tid,GetTeam())) return 0; if (!CheckEngaged(tid,Engaged())) return 0; if (!CheckCombat(tid,Combat())) return 0; if (!CheckLosses(tid,Losses())) return 0; if (!CheckRetreating(tid,Retreating())) return 0; if (!CheckAction(tid,GetUnitOrders())) return 0; if (!CheckOwned(tid,ourObjOwner)) return 0; if (TeamInfo[GetTeam()]->GetGroundAction()->actionType != GACTION_OFFENSIVE && !CheckRole(tid,0)) return 0; if (!CheckRange(tid,ourObjDist)) return 0; // if (!CheckDistToFront(tid,ourFrontDist)) // return 0; if (!CheckStatus(tid,Broken())) return 0; // if (!CheckOdds(tid,odds)) // return 0; return GetTacticPriority(tid); }
/***************************************************************** * Update() Updates the skeleton behaviour. * * Ins: None * * Outs: None * * Returns: void * * Mod. Date: 08/20/2015 * Mod. Initials: NS *****************************************************************/ void CSkeleton::Update() { if (m_bIsActive) { //CCapsule* tempCapsule = (CCapsule*)GetColliders()[1]->GetBounds(); //DEBUG_UTIL::DrawCapsuleCollider(tempCapsule->GetStart(), tempCapsule->GetEnd(), tempCapsule->GetRadius()); if (m_eCurrState != SPAWN) { float3 target = float3(0.0f, 0.0f, 0.0f); m_f3Velocity = float3(0.0f, m_f3Velocity.y, 0.0f); m_pParticleManager->Update(); if (m_bInvincible) { m_fInvincibilityTimer -= DELTA_TIME(); if (m_fInvincibilityTimer < 0.0f) { m_bInvincible = false; } } UpdateBlockSide(); UpdateDayStatus(); } if (m_bPoweringUp) { if (m_pDayNight->IsDay()) { m_fScale -= DELTA_TIME() * 0.5f; if (m_fScale < 1.0f) { m_fScale = 1.0f; m_bPoweringUp = false; } } else { m_fScale += DELTA_TIME() * 0.5f; if (m_fScale > 1.25f) { m_fScale = 1.25f; m_bPoweringUp = false; } } } if (GetPosition()->y < -900.0f) { m_bHit = true; m_fCurrentHealth = 0; m_bIsGrounded = true; } // Exeute the current action if (m_bIsGrounded) { //AdjustRotation(); CheckState(); switch (m_eCurrState) { case SPAWN: m_eNewState = Spawn(); break; case MANUVERING: m_eNewState = Manuver(); break; case MOVING_IN: m_eNewState = Move(true); break; case BACKING_OUT: m_eNewState = Move(false); break; case SWINGING: m_eNewState = Swinging(); break; /*case BLOCKING: m_eNewState = Blocking(); break;*/ case RETREAT: m_eNewState = Retreating(); break; case DEATH: m_eNewState = Die(); break; case HURT: m_eNewState = Hurt(); break; case FOLLOW: m_eNewState = Follow(); break; default: break; } m_vtPointLights[0].m_fPosition[0] = GetPosition()->x; m_vtPointLights[0].m_fPosition[1] = 150.0f; m_vtPointLights[0].m_fPosition[2] = GetPosition()->z; } else { SetWorldVelocity({ knockBackVelocity.x, m_f3Velocity.y, knockBackVelocity.z }); m_vtPointLights[0].m_fPosition[0] += GetWorldVelocity().x * DELTA_TIME(); m_vtPointLights[0].m_fPosition[1] += GetWorldVelocity().y * DELTA_TIME(); m_vtPointLights[0].m_fPosition[2] += GetWorldVelocity().z * DELTA_TIME(); } if (m_eCurrState != SPAWN) { //m_bIsGrounded = false; // Update the rotation // velocity.x *= DELTA_TIME(); // velocity.y *= DELTA_TIME(); // velocity.z *= DELTA_TIME(); XMFLOAT3 start = ((CCapsule*)m_pvColliders[1]->GetBounds())->GetStart(); XMFLOAT3 end = ((CCapsule*)m_pvColliders[1]->GetBounds())->GetEnd(); m_f3Velocity.y += GRAVITY * DELTA_TIME(); if (m_mWorld.m[3][1] < 0.0f) { m_bIsGrounded = false; } CCapsule* pCapsule = (CCapsule*)m_pvColliders[1]->GetBounds(); XMFLOAT3 f3NewStart = pCapsule->GetStart(); XMFLOAT3 f3NewEnd = pCapsule->GetEnd(); f3NewStart.x = f3NewEnd.x = m_mWorld._41; f3NewStart.z = f3NewEnd.z = m_mWorld._43; pCapsule->SetStart(f3NewStart); pCapsule->SetEnd(f3NewEnd); for (unsigned int collider = 0; collider < m_pvColliders.size(); collider++) { m_pvColliders[collider]->UpdatePosition({ GetWorldVelocity().x * DELTA_TIME(), GetWorldVelocity().y * DELTA_TIME(), GetWorldVelocity().z * DELTA_TIME() }); } #pragma region DebugStuff /*if (m_vPath.size()) { for (size_t i = 0; i < m_vPath.size() - 1; i++) { XMFLOAT3 thisPos = m_vPath[i]; XMFLOAT3 nextPos = m_vPath[i + 1]; GRAPHICS->DrawLine(thisPos, nextPos, { 100, 100, 0 }); } } */ //for (size_t i = 0; i < m_pPathPlanner->GetGraph()->GetNodes().size(); i++) //{ // // XMFLOAT3 start = m_vPath[i]->GetPosition(); // // XMFLOAT3 end = m_vPath[i + 1]->GetPosition(); // // // // GRAPHICS->DrawLine(start, end, XMFLOAT3(100, 100, 0)); // // for (size_t k = 0; k < m_pPathPlanner->GetGraph()->GetNodeAtIndex(i)->GetEdges().size(); k++) // { // CEdge* edge = m_pPathPlanner->GetGraph()->GetNodeAtIndex(i)->GetEdges()[k]; // XMFLOAT3 edgeEnd = m_pPathPlanner->GetGraph()->GetNodeAtIndex(edge->GetAdjNode())->GetPosition(); // // GRAPHICS->DrawLine(m_pPathPlanner->GetGraph()->GetNodeAtIndex(i)->GetPosition(), edgeEnd, XMFLOAT3(0, 200, 0)); // // } //} #pragma endregion } } SnapPosition(m_cDropShadow->GetTransformMatrix(), m_mWorld); m_cDropShadow->GetTransformMatrix().m[3][1] += 10.0f; if (m_mWorld.m[3][1] < -10.0f || !m_bIsActive) m_cDropShadow->GetTransformMatrix().m[3][1] = -20000.0f; }