void CGameContext::ConRescue(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; CCharacter* pChr = pSelf->m_apPlayers[pResult->m_ClientID]->GetCharacter(); if(!g_Config.m_SvRescue) { pSelf->SendChatTarget(pResult->m_ClientID, "Rescue is not activated."); return; } if(!pChr) { pSelf->SendChatTarget(pResult->m_ClientID, "You are not alive!"); return; } if(pChr->m_DeepFreeze) { pSelf->SendChatTarget(pResult->m_ClientID, "You are deepfreezed, undeepfreeze first!"); return; } if(!pChr->IsAlive()) { pSelf->SendChatTarget(pResult->m_ClientID, "You are not alive!"); return; } // unfreeze if pressed second time if(pChr->m_RescueFlags & RESCUEFLAG_CAN_UNFREEZE) { pChr->m_RescueFlags &= ~RESCUEFLAG_CAN_UNFREEZE; if(pChr->m_FreezeTime && pChr->m_TileIndex != TILE_FREEZE && pChr->m_TileFIndex != TILE_FREEZE && pChr->Core()->m_Pos == pChr->m_RescuePos) { pChr->UnFreeze(); return; } } if(pChr->m_FreezeTime == 0) return; if(pChr->m_LastRescue) // sv_rescue_delay return; if(pChr->m_RescueOverride) { pSelf->SendChatTarget(pResult->m_ClientID, "Rescue is disabled by the map."); return; } if(pChr->m_RescuePos == vec2(0,0)) { pSelf->SendChatTarget(pResult->m_ClientID, "No position saved!"); return; } // reset players' hook for(int i = 0; i < MAX_CLIENTS; i++) { if(pSelf->m_apPlayers[i]) { CCharacter* pChr2 = pSelf->m_apPlayers[i]->GetCharacter(); //who hooks me? if(pChr2 && pChr2->Core()->m_HookedPlayer == pResult->m_ClientID) { //Release hook pChr2->Core()->m_HookedPlayer = -1; pChr2->Core()->m_HookState = HOOK_RETRACTED; pChr2->Core()->m_HookPos = pChr2->Core()->m_Pos; } } } if(g_Config.m_SvRescueEffects) { //Blood effect pChr->GameServer()->CreateDeath(pChr->m_Pos, pResult->m_ClientID); //Spawn effect pChr->GameServer()->CreatePlayerSpawn(pChr->m_RescuePos); } //Teleport player pChr->Core()->m_Pos = pChr->m_PrevPos = pChr->m_Pos = pChr->m_RescuePos; pChr->Core()->m_Vel = vec2(0.f, 0.f); // reset momentum if(pChr->m_RescueFlags) { // disarm player if(pChr->m_RescueFlags & RESCUEFLAG_DISARM) { bool disarmed = false; for(int i = WEAPON_SHOTGUN; i < NUM_WEAPONS; i++) { if(pChr->GetWeaponGot(i) && i != WEAPON_NINJA) { pChr->SetWeaponGot(i, false); pChr->SetWeaponAmmo(i, 0); disarmed = true; } } if(disarmed) pChr->GameServer()->SendChatTarget(pResult->m_ClientID, "You have been disarmed"); } // solo fix if(pChr->m_RescueFlags & RESCUEFLAG_SOLOOUT) { pChr->GameServer()->SendChatTarget(pResult->m_ClientID, "You are now in a solo part"); pChr->m_Solo = true; } else if(pChr->m_RescueFlags & RESCUEFLAG_SOLOIN) { pChr->GameServer()->SendChatTarget(pResult->m_ClientID, "You are now out of the solo part"); pChr->m_Solo = false; } // hit fix if(pChr->m_RescueFlags & RESCUEFLAG_NOHIT) { pChr->GameServer()->SendChatTarget(pResult->m_ClientID, "You can hit others"); pChr->m_Hit = CCharacter::HIT_ALL; } else if(pChr->m_RescueFlags & RESCUEFLAG_HIT) { pChr->GameServer()->SendChatTarget(pResult->m_ClientID, "You can't hit others"); pChr->m_Hit = CCharacter::DISABLE_HIT_GRENADE|CCharacter::DISABLE_HIT_HAMMER| CCharacter::DISABLE_HIT_RIFLE|CCharacter::DISABLE_HIT_SHOTGUN; } // endless hook fix if(pChr->m_RescueFlags & RESCUEFLAG_NOEHOOK && !pChr->m_EndlessHook) { pChr->GameServer()->SendChatTarget(pResult->m_ClientID, "Endless hook has been activated"); pChr->m_EndlessHook = true; } else if(pChr->m_RescueFlags & RESCUEFLAG_EHOOK && pChr->m_EndlessHook) { pChr->GameServer()->SendChatTarget(pResult->m_ClientID, "Endless hook has been deactivated"); pChr->m_EndlessHook = false; } pChr->m_RescueFlags = RESCUEFLAG_NONE; } //"save" last rescue time pChr->m_LastRescue = ((float)g_Config.m_SvRescueDelay / 1000) * pSelf->Server()->TickSpeed(); pChr->m_RescueFlags |= RESCUEFLAG_CAN_UNFREEZE; }
void CPickup::Tick() { Move(); /*// wait for respawn if(m_SpawnTick > 0) { if(Server()->Tick() > m_SpawnTick) { // respawn m_SpawnTick = -1; if(m_Type == POWERUP_WEAPON) GameServer()->CreateSound(m_Pos, SOUND_WEAPON_SPAWN); } else return; }*/ // Check if a player intersected us CCharacter *apEnts[MAX_CLIENTS]; int Num = GameWorld()->FindEntities(m_Pos, 20.0f, (CEntity**)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); for(int i = 0; i < Num; ++i) { CCharacter * pChr = apEnts[i]; if(pChr && pChr->IsAlive()) { if(m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[pChr->Team()]) continue; bool sound = false; // player picked us up, is someone was hooking us, let them go switch (m_Type) { case POWERUP_HEALTH: if(pChr->Freeze()) GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH, pChr->Teams()->TeamMask(pChr->Team())); break; case POWERUP_ARMOR: if(pChr->Team() == TEAM_SUPER) continue; for(int i = WEAPON_SHOTGUN; i < NUM_WEAPONS; i++) { if(pChr->GetWeaponGot(i)) { if(!(pChr->m_FreezeTime && i == WEAPON_NINJA)) { pChr->SetWeaponGot(i, false); pChr->SetWeaponAmmo(i, 0); sound = true; } } } pChr->SetNinjaActivationDir(vec2(0,0)); pChr->SetNinjaActivationTick(-500); pChr->SetNinjaCurrentMoveTime(0); if (sound) { pChr->SetLastWeapon(WEAPON_GUN); GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR, pChr->Teams()->TeamMask(pChr->Team())); } if(!pChr->m_FreezeTime && pChr->GetActiveWeapon() >= WEAPON_SHOTGUN) pChr->SetActiveWeapon(WEAPON_HAMMER); break; case POWERUP_WEAPON: if (m_Subtype >= 0 && m_Subtype < NUM_WEAPONS && (!pChr->GetWeaponGot(m_Subtype) || (pChr->GetWeaponAmmo(m_Subtype) != -1 && !pChr->m_FreezeTime))) { pChr->GiveWeapon(m_Subtype); //RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime; if (m_Subtype == WEAPON_GRENADE) GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE, pChr->Teams()->TeamMask(pChr->Team())); else if (m_Subtype == WEAPON_SHOTGUN) GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN, pChr->Teams()->TeamMask(pChr->Team())); else if (m_Subtype == WEAPON_RIFLE) GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN, pChr->Teams()->TeamMask(pChr->Team())); if (pChr->GetPlayer()) GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype); } break; case POWERUP_NINJA: { // activate ninja on target player pChr->GiveNinja(); //RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime; /*// loop through all players, setting their emotes CCharacter *pC = static_cast<CCharacter *>(GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER)); for(; pC; pC = (CCharacter *)pC->TypeNext()) { if (pC != pChr) pC->SetEmote(EMOTE_SURPRISE, Server()->Tick() + Server()->TickSpeed()); }*/ break; } default: break; }; /*if(RespawnTime >= 0) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "pickup player='%d:%s' item=%d/%d", pChr->GetPlayer()->GetCID(), Server()->ClientName(pChr->GetPlayer()->GetCID()), m_Type, m_Subtype); GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); m_SpawnTick = Server()->Tick() + Server()->TickSpeed() * RespawnTime; }*/ } } }