Ejemplo n.º 1
0
bool RPG_Projectile_Healing::ShouldHit(RPG_DamageableEntity* target)
{
  if(!target)
  {
    // pass through non-entities
    return false;
  }

  if(target == m_characterOwner)
  {
    // pass through firing character
    return false;
  }

  if(m_targetToTrack && target != m_targetToTrack)
  {
    // hit only tracked target
    return false;
  }

  if(target->IsFrom(RPG_Character))
  {
    RPG_Character* targetCharacter = static_cast<RPG_Character*>(target);
    if(targetCharacter->GetTeam() == m_characterOwner->GetTeam())
    {
      return true;
    }
  }

  return true;
}
Ejemplo n.º 2
0
void RPG_Pickup::CheckCharacterContact()
{
  VArray<RPG_Character*> const& characters = RPG_GameManager::s_instance.GetCharacters();

  hkvVec3 const& currentPosition = GetPosition();

  for(int index = 0; index < characters.GetSize(); ++index)
  {
    RPG_Character* character = characters.GetAt(index);

    // only target players
    if(!character->IsOfType(V_RUNTIME_CLASS(RPG_PlayerCharacter)))
    {
      continue;
    }

    hkvVec3 const& targetPosition = character->GetPosition();

    float currentRangeSquared = (currentPosition - targetPosition).getLengthSquared();

    if(currentRangeSquared <= m_pickupRadius * m_pickupRadius)
    {
      // call OnPickup for subclasses
      OnPickup(character);

      // play the pickup effect
      CreateEffect(PKFX_Pickup, GetPosition(), GetOrientation());

      // setup this object for deletion
      DisposeObject();
    }
  }
}
Ejemplo n.º 3
0
void PlayerUIDialog::PlayTestEffect()
{
  RPG_Character *characterEntity = static_cast<RPG_Character *>(m_playerController->GetOwner());
  VASSERT(characterEntity);
  const hkvVec3 position = characterEntity->GetPosition();
  RPG_VisionEffectHelper::PlayFmodSoundEvent("Characters/Barbarian", "Melee_Basic_Swing", position);  // first argument refers to event group names in the FMOD project specified by GameManager::FMOD_EVENT_PROJECT
}
Ejemplo n.º 4
0
void RPG_Projectile_Healing::OnHit(RPG_DamageableEntity* target, hkvVec3 const& position, hkvVec3 const& normal)
{
  RPG_Character* targetCharacter = static_cast<RPG_Character*>(target);
  if (targetCharacter)
  {
    targetCharacter->AddHealth(m_characterOwner->GetCharacterStats().GetHealingAmount());
  }
}
Ejemplo n.º 5
0
void RPG_Pickup::UpdateMagnetForces(float const deltaTime)
{
  if(m_usePhysics)
  {
    // find the player
    VArray<RPG_Character*> const& characters = RPG_GameManager::s_instance.GetCharacters();

    hkvVec3 const& currentPosition = GetPosition();

    RPG_PlayerCharacter* player = NULL;

    // find a player in range
    for(int index = 0; index < characters.GetSize(); ++index)
    {
      RPG_Character* character = characters.GetAt(index);

      // only target apparently alive players
      if(!character->IsOfType(V_RUNTIME_CLASS(RPG_PlayerCharacter)) ||
        character->IsDead() ||
        character->IsFeigningDeath())
      {
        continue;
      }

      player = static_cast<RPG_PlayerCharacter*>(character);

      break;
    }

    if(player)
    {
      hkvVec3 targetPosition = player->GetPosition();
      targetPosition.z += 0.5f * player->GetBoundingBox().getSizeZ();

      float distance = (currentPosition - targetPosition).getLength();

      if(distance < m_pickupRadius)
      {
        distance = m_pickupRadius;
      }

      float const distanceSquared = distance * distance;

      if(distanceSquared < m_magnetMaxDistance * m_magnetMaxDistance)
      {
        hkvVec3 direction = targetPosition - GetPosition();
        direction.normalizeIfNotZero();

        float magnitude = m_magnetSpeedMultiplier * (1.0f / distanceSquared - m_magnetMaxDistanceInverseSquared);
        m_currentMagnetSpeed += deltaTime * magnitude * RPG_HEALTH_PICKUP_MAGNET_SPEED_MULTIPLIER_CONVERSION_VALUE;
        m_currentMagnetVelocity = m_currentMagnetSpeed * direction;
      }
    }
  }
}
Ejemplo n.º 6
0
void PlayerUIDialog::CheatToggleUnlimitedMana()
{
  RPG_Character *characterEntity = static_cast<RPG_Character *>(m_playerController->GetOwner());
  VASSERT(characterEntity);
  characterEntity->GetCharacterStats().SetUnlimitedMana(!characterEntity->GetCharacterStats().HasUnlimitedMana());

  VString msg;
  if (characterEntity->GetCharacterStats().HasUnlimitedMana())
  {
    msg = "CHEAT - Unlimited Mana: ON";
  }
  else
  {
    msg = "CHEAT - Unlimited Mana: OFF";
  }
  hkvLog::Info(msg.AsChar());
  Vision::Message.Add(1, msg.AsChar());
}
bool RPG_AiControllerComponent::HasValidTarget() const
{
  if (HasTarget())
  {
    VArray<RPG_DamageableEntity*> const& attackableEntities = RPG_GameManager::s_instance.GetAttackableEntities();
    if(attackableEntities.Find(m_target) < 0)
    {
      return false;
    }

    if(m_target->IsFrom(RPG_Character))
    {
      RPG_Character* targetCharacter = static_cast<RPG_Character*>(m_target);
      return !targetCharacter->IsDead() && !targetCharacter->IsFeigningDeath();
    }
    else
    {
      return true;
    }
  }
  return false;
}
/// Finds and sets a target within range to interact with (usually to attack).
/// @TODO: Implement teams and team relationships, as target must currently be a player.
bool RPG_AiControllerComponent::AcquireTarget()
{
  VArray<RPG_Character*> const& characters = RPG_GameManager::s_instance.GetCharacters();

  hkvVec3 const& currentPosition = m_characterOwner->GetPosition();

  bool returnVal = false;
  for(int index = 0; index < characters.GetSize(); ++index)
  {
    RPG_Character* character = characters.GetAt(index);

    // can't target yourself
    if(character == m_characterOwner)
    {
      continue;
    }

    // only target apparently alive players
    if(!character->IsOfType(V_RUNTIME_CLASS(RPG_PlayerCharacter)) ||
      character->IsDead() ||
      character->IsFeigningDeath())
    {
      continue;
    }

    float const aggroRadius = m_characterOwner->GetAggroRadius();
    hkvVec3 const& targetPosition = character->GetPosition();

    float const currentRangeSquared = (currentPosition - targetPosition).getLengthSquared();

    // check if they are within range
    if(currentRangeSquared <= aggroRadius * aggroRadius)
    {
      m_target = character;
      returnVal = true;
    }
  }
  return returnVal;
}
Ejemplo n.º 9
0
bool RPG_Projectile::ShouldHit(RPG_DamageableEntity* target)
{
  VASSERT_MSG(m_characterOwner, "Please set your projectile's character owner.");
  if(!target || !m_characterOwner) 
  {
    return true;
  }

  if(target->IsFrom(RPG_Character))
  {
    RPG_Character* targetCharacter = static_cast<RPG_Character*>(target);
    if(targetCharacter->GetTeam() != m_characterOwner->GetTeam())
    {
      return true;
    }
  }
  else if(target->Components().GetComponentOfType<RPG_AttackableComponent>())
  {
    return true;
  }

  return false;
}
bool RPG_AiControllerComponent::HasValidTarget() const
{
  if (m_target)
  {
    VArray<RPG_DamageableEntity*> const& attackableEntities = RPG_GameManager::s_instance.GetAttackableEntities();
    if(attackableEntities.Find(GetTarget()) < 0)
    {
      return false;
    }

    if(m_target->IsFrom(RPG_Character))
    {
      float const aggroRadius = GetCharacter()->GetAggroRadius();
      hkvVec3 const& currentPosition = GetCharacter()->GetPosition();

      RPG_Character* targetCharacter = static_cast<RPG_Character*>(GetTarget());
      hkvVec3 const& targetPosition = targetCharacter->GetPosition();

      float const currentRangeSquared = (currentPosition - targetPosition).getLengthSquared();

      // check if target is still within range
      if(currentRangeSquared > aggroRadius * aggroRadius)
      {
        return false;
      }
      else
      {
        return !targetCharacter->IsDead() && !targetCharacter->IsFeigningDeath();
      }
    }
    else
    {
      return true;
    }
  }
  return false;
}
Ejemplo n.º 11
0
//@todo: Temporary placeholder until the legitimate inventory handler goes in.
void RPG_InventoryHandler::AddDefaultInventory(RPG_Character& character)
{
  // @todo: temporary for testing inventory handler. We'll want to create legitimate inventory item classes and specifiers.
  RPG_InventoryHandler& inventoryHandler = character.GetInventoryHandler();
  {
    RPG_InventoryItem* newItem = new RPG_InventoryItem("TestAxe");
    {
      newItem->SetMinDamage(0.8f);
      newItem->SetMaxDamage(1.2f);
      newItem->SetSpeed(1.0f);
      newItem->SetRange(150.0f);
      newItem->SetEquipmentSlot(ES_Weapon);
      //newItem->SetEquippedPrefabFileName("Prefabs\\Editor\\Axis.vprefab");
    }

    int const itemIndex = inventoryHandler.AddInventory(newItem);
    inventoryHandler.EquipWeapon(itemIndex);
  }

  {
    RPG_InventoryItem *newItem = new RPG_InventoryItem("TestHelmet");
    {
      newItem->SetArmorValue(2);
    }

    int const itemIndex = inventoryHandler.AddInventory(newItem);
    inventoryHandler.EquipArmor(ES_Helmet, itemIndex);
  }

  {
    RPG_InventoryItem *newItem = new RPG_InventoryItem("TestChestPiece");
    {
      newItem->SetArmorValue(3);
    }

    int const itemIndex = inventoryHandler.AddInventory(newItem);
    inventoryHandler.EquipArmor(ES_Chest, itemIndex);
  }

  {
    RPG_InventoryItem *newItem = new RPG_InventoryItem("TestGloves");
    {
      newItem->SetArmorValue(2);
    }

    int const itemIndex = inventoryHandler.AddInventory(newItem);
    inventoryHandler.EquipArmor(ES_Gloves, itemIndex);
  }

  {
    RPG_InventoryItem *newItem = new RPG_InventoryItem("TestShoulders");
    {
      newItem->SetArmorValue(2);
    }

    int const itemIndex = inventoryHandler.AddInventory(newItem);
    inventoryHandler.EquipArmor(ES_Shoulder, itemIndex);
  }

  {
    RPG_InventoryItem *newItem = new RPG_InventoryItem("TestBelt");
    {
      newItem->SetArmorValue(1);
    }

    int const itemIndex = inventoryHandler.AddInventory(newItem);
    inventoryHandler.EquipArmor(ES_Belt, itemIndex);
  }

  {
    RPG_InventoryItem *newItem = new RPG_InventoryItem("TestBoots");
    {
      newItem->SetArmorValue(2);
    }

    int const itemIndex = inventoryHandler.AddInventory(newItem);
    inventoryHandler.EquipArmor(ES_Boots, itemIndex);
  }
}
Ejemplo n.º 12
0
void PlayerUIDialog::OnTick(float deltaTime)
{
  VDialog::OnTick(deltaTime);

#if defined (SUPPORTS_MULTITOUCH) && (HAVOK_VISION_RESTRUCTURING) && !defined(_VISION_ANDROID)

  if (m_touchInput != NULL)
  {     
    int count = m_touchInput->GetNumberOfTouchPoints();
    if (count > 1)
      return;
  }

#endif

  RPG_Character *characterEntity = static_cast<RPG_Character *>(m_playerController->GetOwner());
  if (!characterEntity)
  {
    // @todo: handle player death properly
    hkvLog::Warning("Player character has probably died, which isn't yet handled. Set the character's Unlimited Health entity property to true to prevent this.");
    return;
  }

  RPG_PlayerControllerInput input;
  {
    if(m_inputMap->GetTrigger(PI_PrimaryAction) > 0.0f)
    {
      if(m_inputMap->GetTrigger(PI_ShiftModifier) > 0.0f)
      {
        input.m_buttons |= RPG_PlayerControllerInput::B_RANGED;
      }
      else if(m_inputMap->GetTrigger(PI_SecondaryShiftModifier) > 0.0f)
      {
        input.m_buttons |= RPG_PlayerControllerInput::B_POWER;
      }
      else
      {
        input.m_buttons |= RPG_PlayerControllerInput::B_PRIMARY;
      }
    }

    if(m_inputMap->GetTrigger(PI_SecondaryAction) > 0.0f)
    {
      input.m_buttons |= RPG_PlayerControllerInput::B_POWER;
    }

    if(m_inputMap->GetTrigger(PI_SpecialAction01) > 0.0f)
    {
      input.m_buttons |= RPG_PlayerControllerInput::B_AOE;
    }

    GetFirstAttackableEntityUnderCursor(input.m_targetEntity, input.m_targetPoint, characterEntity);
    if(!input.m_targetEntity)
    {
      hkVector4 hitPoint, characterPos;
      RPG_VisionHavokConversion::VisionToHavokPoint(characterEntity->GetPosition(), characterPos);
      if(GetClosestPointOnNavMeshUnderCursor(hitPoint, characterPos))
      {
        RPG_VisionHavokConversion::HavokToVisionPoint(hitPoint, input.m_targetPoint);
      }
    }

    m_playerController->SetInput(input);
  }

  RPG_GuiManager::GetInstance()->OnTick(deltaTime);
}