Forums Gallery LOGIN |REGISTER

Community Archive is read-only - Here you can view content recorded up until February 2017. To join the latest discussions visit our new forums


How to create stun/freeze in multiplayer

Please use this forum for questions on C++, Lua, XML, and any other languages used in CryENGINE development.


 

User avatar tanya_grief
Just getting started
Just getting started
 
Posts: 3
Member since: 02.06.2016, 08:19
Likes: 0

How to create stun/freeze in multiplayer

Postby tanya_grief » 07.08.2017, 16:07

Hello! I want to make a weapon, that will freeze vehicle for a time. I try to use ActionMap (node in FG Input:ActionMaps:ActionMap), but it works incorrect, especially in multiplayer. May be someone now the standart ways, like weapon xml..? I registered new hit type "stun" and now I trying to modify cpp function CVehicleComponent::OnHit....But still I haven't good results. Can you give me an advice? ?(
User avatar tanya_grief
Just getting started
Just getting started
 
Posts: 3
Member since: 02.06.2016, 08:19
Likes: 0

Re: How to create stun/freeze in multiplayer

Postby tanya_grief » 11.08.2017, 11:06

In CrySource Vehicle.cpp in function OnHit:

Code: Select all
void CVehicle::OnHit(const HitInfo& hitInfo, IVehicleComponent* pHitComponent)
{
...
if (hitInfo.type == s_stunHitTypeId)
   {
      float time = damage;
      damage = 0;
      const string actionMapName = "vehicle_stun"; //my action map
      //id of target vehicle
      EntityId entityId =GetEntityId();
      IVehicle* pVehicle  = gEnv->pGameFramework->GetIVehicleSystem()->GetVehicle(entityId);
      //id of the pilot seat at the target vehicle
      TVehicleSeatId seatId = pVehicle->GetSeatId("pilot");
      IVehicleSeat* seat = pVehicle->GetSeatById(seatId);
      const char* seatMap = seat->GetActionMap();
      EntityId pilotId = seat->GetPassenger();
      
      IActionMapManager* pActionMapMan = CCryAction::GetCryAction()->GetIActionMapManager();

      if (IActionMap* pActionMap = pActionMapMan->GetActionMap(actionMapName ))
      {
         pActionMap->SetActionListener(pilotId);
         pActionMapMan->EnableActionMap(actionMapName ,1);
      }


This code enable my action map for vehicle driver, but don't disable old. So driver has two action map. Action map of another player dosn't change
Then I try to disable action map, and have fun - the action map disable for all players in level:

Code: Select all
...
      const char* seatMap = seat->GetActionMap();
...
      if (IActionMap* pActionMap = pActionMapMan->GetActionMap(seatMap ))
      {
         pActionMap->SetActionListener(pilotId);
         pActionMapMan->EnableActionMap(seatMap ,0);
      }


But i need to disable only one(


Then i try to use project code. But i can't find something like OnHit..I test it in VehicleClient.cpp CVehicleClient::EnableActionMaps

Code: Select all
void CVehicleClient::EnableActionMaps(IVehicleSeat* pSeat, bool enable)
{
IActionMapManager* pActionMapMan = g_pGame->GetIGameFramework()->GetIActionMapManager();
      
      if (IActionMap* pActionMap = pActionMapMan->GetActionMap("player"))
      {
         pActionMap->SetActionListener(pSeat->GetPassenger());
         
         pActionMapMan->EnableActionMap("player", 0);
      }
}


And this code disable action map only for one player.....but it works when we enter vehicle...
Someone now where we can find OnHit function in sdk code?




the difference between code in crysource and project :
Code: Select all
1) IActionMapManager* pActionMapMan = CCryAction::GetCryAction()->GetIActionMapManager();
2) IActionMapManager* pActionMapMan = g_pGame->GetIGameFramework()->GetIActionMapManager();