getting jetpack through remote

This commit is contained in:
BannZay 2016-10-08 20:42:42 +03:00
parent 3b8c17d9d6
commit a96ebde93a
7 changed files with 81 additions and 75 deletions

View file

@ -15,10 +15,12 @@ CONSOLE_COMMAND("removeweapon", "i[weapon-id]", CFGFLAG_SERVER|CMDFLAG_TEST, Con
CONSOLE_COMMAND("shotgun", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConShotgun, this, "Gives a shotgun to you") CONSOLE_COMMAND("shotgun", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConShotgun, this, "Gives a shotgun to you")
CONSOLE_COMMAND("grenade", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConGrenade, this, "Gives a grenade launcher to you") CONSOLE_COMMAND("grenade", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConGrenade, this, "Gives a grenade launcher to you")
CONSOLE_COMMAND("rifle", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConRifle, this, "Gives a rifle to you") CONSOLE_COMMAND("rifle", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConRifle, this, "Gives a rifle to you")
CONSOLE_COMMAND("jetpack","", CFGFLAG_SERVER|CMDFLAG_TEST, ConJetpack, this, "Gives jetpack to you")
CONSOLE_COMMAND("weapons", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConWeapons, this, "Gives all weapons to you") CONSOLE_COMMAND("weapons", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConWeapons, this, "Gives all weapons to you")
CONSOLE_COMMAND("unshotgun", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConUnShotgun, this, "Takes the shotgun from you") CONSOLE_COMMAND("unshotgun", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConUnShotgun, this, "Takes the shotgun from you")
CONSOLE_COMMAND("ungrenade", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConUnGrenade, this, "Takes the grenade launcher you") CONSOLE_COMMAND("ungrenade", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConUnGrenade, this, "Takes the grenade launcher you")
CONSOLE_COMMAND("unrifle", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConUnRifle, this, "Takes the rifle from you") CONSOLE_COMMAND("unrifle", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConUnRifle, this, "Takes the rifle from you")
CONSOLE_COMMAND("unjetpack", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConUnJetpack, this, "Takes the jetpack from you")
CONSOLE_COMMAND("unweapons", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConUnWeapons, this, "Takes all weapons from you") CONSOLE_COMMAND("unweapons", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConUnWeapons, this, "Takes all weapons from you")
CONSOLE_COMMAND("ninja", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConNinja, this, "Makes you a ninja") CONSOLE_COMMAND("ninja", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConNinja, this, "Makes you a ninja")
CONSOLE_COMMAND("super", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConSuper, this, "Makes you super") CONSOLE_COMMAND("super", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConSuper, this, "Makes you super")

View file

@ -166,6 +166,14 @@ void CGameContext::ConRifle(IConsole::IResult *pResult, void *pUserData)
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_RIFLE, false); pSelf->ModifyWeapons(pResult, pUserData, WEAPON_RIFLE, false);
} }
void CGameContext::ConJetpack(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
CCharacter* pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
if (pChr)
pChr->m_Jetpack = true;
}
void CGameContext::ConWeapons(IConsole::IResult *pResult, void *pUserData) void CGameContext::ConWeapons(IConsole::IResult *pResult, void *pUserData)
{ {
CGameContext *pSelf = (CGameContext *) pUserData; CGameContext *pSelf = (CGameContext *) pUserData;
@ -190,6 +198,14 @@ void CGameContext::ConUnRifle(IConsole::IResult *pResult, void *pUserData)
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_RIFLE, true); pSelf->ModifyWeapons(pResult, pUserData, WEAPON_RIFLE, true);
} }
void CGameContext::ConUnJetpack(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
CCharacter* pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
if (pChr)
pChr->m_Jetpack = false;
}
void CGameContext::ConUnWeapons(IConsole::IResult *pResult, void *pUserData) void CGameContext::ConUnWeapons(IConsole::IResult *pResult, void *pUserData)
{ {
CGameContext *pSelf = (CGameContext *) pUserData; CGameContext *pSelf = (CGameContext *) pUserData;
@ -211,10 +227,11 @@ void CGameContext::ConRemoveWeapon(IConsole::IResult *pResult, void *pUserData)
void CGameContext::ModifyWeapons(IConsole::IResult *pResult, void *pUserData, void CGameContext::ModifyWeapons(IConsole::IResult *pResult, void *pUserData,
int Weapon, bool Remove) int Weapon, bool Remove)
{ {
CGameContext *pSelf = (CGameContext *) pUserData; CGameContext *pSelf = (CGameContext *)pUserData;
if (!CheckClientID(pResult->m_ClientID)) CCharacter* pChr = GetPlayerChar(pResult->m_ClientID);
if (!pChr)
return; return;
int ClientID = pResult->m_ClientID;
if (clamp(Weapon, -1, NUM_WEAPONS - 1) != Weapon) if (clamp(Weapon, -1, NUM_WEAPONS - 1) != Weapon)
{ {
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info",
@ -222,47 +239,15 @@ void CGameContext::ModifyWeapons(IConsole::IResult *pResult, void *pUserData,
return; return;
} }
CCharacter* pChr = GetPlayerChar(ClientID);
if (!pChr)
return;
if (Weapon == -1) if (Weapon == -1)
{ {
if (Remove pChr->GiveWeapon(WEAPON_SHOTGUN);
&& (pChr->GetActiveWeapon() == WEAPON_SHOTGUN pChr->GiveWeapon(WEAPON_GRENADE);
|| pChr->GetActiveWeapon() == WEAPON_GRENADE pChr->GiveWeapon(WEAPON_RIFLE);
|| pChr->GetActiveWeapon() == WEAPON_RIFLE))
pChr->SetActiveWeapon(WEAPON_GUN);
if (Remove)
{
pChr->SetWeaponGot(WEAPON_SHOTGUN, false);
pChr->SetWeaponGot(WEAPON_GRENADE, false);
pChr->SetWeaponGot(WEAPON_RIFLE, false);
}
else
pChr->GiveAllWeapons();
}
else if (Weapon != WEAPON_NINJA)
{
if (Remove && pChr->GetActiveWeapon() == Weapon)
pChr->SetActiveWeapon(WEAPON_GUN);
if (Remove)
pChr->SetWeaponGot(Weapon, false);
else
pChr->GiveWeapon(Weapon, -1);
} }
else else
{ {
if (Remove) pChr->GiveWeapon(Weapon, Remove);
{
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info",
"you can't remove ninja");
return;
}
pChr->GiveNinja();
} }
pChr->m_DDRaceState = DDRACE_CHEAT; pChr->m_DDRaceState = DDRACE_CHEAT;

View file

@ -180,11 +180,7 @@ void CCharacter::HandleNinja()
if ((Server()->Tick() - m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000)) if ((Server()->Tick() - m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000))
{ {
// time's up, return // time's up, return
m_Ninja.m_CurrentMoveTime = 0; RemoveNinja();
m_aWeapons[WEAPON_NINJA].m_Got = false;
m_Core.m_ActiveWeapon = m_LastWeapon;
SetWeapon(m_Core.m_ActiveWeapon);
return; return;
} }
@ -650,18 +646,6 @@ void CCharacter::HandleWeapons()
return; return;
} }
bool CCharacter::GiveWeapon(int Weapon, int Ammo)
{
if(m_aWeapons[Weapon].m_Ammo < g_pData->m_Weapons.m_aId[Weapon].m_Maxammo || !m_aWeapons[Weapon].m_Got)
{
m_aWeapons[Weapon].m_Got = true;
if(!m_FreezeTime)
m_aWeapons[Weapon].m_Ammo = min(g_pData->m_Weapons.m_aId[Weapon].m_Maxammo, Ammo);
return true;
}
return false;
}
void CCharacter::GiveNinja() void CCharacter::GiveNinja()
{ {
m_Ninja.m_ActivationTick = Server()->Tick(); m_Ninja.m_ActivationTick = Server()->Tick();
@ -676,6 +660,15 @@ void CCharacter::GiveNinja()
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_NINJA, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); GameServer()->CreateSound(m_Pos, SOUND_PICKUP_NINJA, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID()));
} }
void CCharacter::RemoveNinja()
{
m_Ninja.m_CurrentMoveTime = 0;
m_aWeapons[WEAPON_NINJA].m_Got = false;
m_Core.m_ActiveWeapon = m_LastWeapon;
SetWeapon(m_Core.m_ActiveWeapon);
}
void CCharacter::SetEmote(int Emote, int Tick) void CCharacter::SetEmote(int Emote, int Tick)
{ {
m_EmoteType = Emote; m_EmoteType = Emote;
@ -2121,14 +2114,37 @@ bool CCharacter::UnFreeze()
return false; return false;
} }
void CCharacter::GiveWeapon(int Weapon, bool Remove)
{
if (Weapon == WEAPON_NINJA)
{
if (Remove)
RemoveNinja();
else
GiveNinja();
return;
}
if (Remove)
{
if (GetActiveWeapon()== Weapon)
SetActiveWeapon(WEAPON_GUN);
}
else
{
if (!m_FreezeTime)
m_aWeapons[Weapon].m_Ammo = -1;
}
m_aWeapons[Weapon].m_Got = !Remove;
}
void CCharacter::GiveAllWeapons() void CCharacter::GiveAllWeapons()
{ {
for(int i=WEAPON_GUN;i<NUM_WEAPONS-1;i++) for(int i=WEAPON_GUN;i<NUM_WEAPONS-1;i++)
{ {
m_aWeapons[i].m_Got = true; GiveWeapon(i);
if(!m_FreezeTime) m_aWeapons[i].m_Ammo = -1;
} }
return;
} }
void CCharacter::Pause(bool Pause) void CCharacter::Pause(bool Pause)

View file

@ -75,8 +75,9 @@ public:
bool IncreaseHealth(int Amount); bool IncreaseHealth(int Amount);
bool IncreaseArmor(int Amount); bool IncreaseArmor(int Amount);
bool GiveWeapon(int Weapon, int Ammo); void GiveWeapon(int Weapon, bool Remove = false);
void GiveNinja(); void GiveNinja();
void RemoveNinja();
void SetEmote(int Emote, int Tick); void SetEmote(int Emote, int Tick);

View file

@ -90,22 +90,22 @@ void CPickup::Tick()
case POWERUP_WEAPON: case POWERUP_WEAPON:
if(m_Subtype >= 0 && m_Subtype < NUM_WEAPONS && (!pChr->GetWeaponGot(m_Subtype) || (pChr->GetWeaponAmmo(m_Subtype) != -1 && !pChr->m_FreezeTime))) if (m_Subtype >= 0 && m_Subtype < NUM_WEAPONS && (!pChr->GetWeaponGot(m_Subtype) || (pChr->GetWeaponAmmo(m_Subtype) != -1 && !pChr->m_FreezeTime)))
{ {
if(pChr->GiveWeapon(m_Subtype, -1)) pChr->GiveWeapon(m_Subtype);
{
//RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
if(m_Subtype == WEAPON_GRENADE) //RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE, pChr->Teams()->TeamMask(pChr->Team()));
else if(m_Subtype == WEAPON_SHOTGUN) if (m_Subtype == WEAPON_GRENADE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN, pChr->Teams()->TeamMask(pChr->Team())); GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE, pChr->Teams()->TeamMask(pChr->Team()));
else if(m_Subtype == WEAPON_RIFLE) else if (m_Subtype == WEAPON_SHOTGUN)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN, pChr->Teams()->TeamMask(pChr->Team())); 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);
if(pChr->GetPlayer())
GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype);
}
} }
break; break;

View file

@ -246,10 +246,12 @@ private:
static void ConShotgun(IConsole::IResult *pResult, void *pUserData); static void ConShotgun(IConsole::IResult *pResult, void *pUserData);
static void ConGrenade(IConsole::IResult *pResult, void *pUserData); static void ConGrenade(IConsole::IResult *pResult, void *pUserData);
static void ConRifle(IConsole::IResult *pResult, void *pUserData); static void ConRifle(IConsole::IResult *pResult, void *pUserData);
static void ConJetpack(IConsole::IResult *pResult, void *pUserData);
static void ConWeapons(IConsole::IResult *pResult, void *pUserData); static void ConWeapons(IConsole::IResult *pResult, void *pUserData);
static void ConUnShotgun(IConsole::IResult *pResult, void *pUserData); static void ConUnShotgun(IConsole::IResult *pResult, void *pUserData);
static void ConUnGrenade(IConsole::IResult *pResult, void *pUserData); static void ConUnGrenade(IConsole::IResult *pResult, void *pUserData);
static void ConUnRifle(IConsole::IResult *pResult, void *pUserData); static void ConUnRifle(IConsole::IResult *pResult, void *pUserData);
static void ConUnJetpack(IConsole::IResult *pResult, void *pUserData);
static void ConUnWeapons(IConsole::IResult *pResult, void *pUserData); static void ConUnWeapons(IConsole::IResult *pResult, void *pUserData);
static void ConAddWeapon(IConsole::IResult *pResult, void *pUserData); static void ConAddWeapon(IConsole::IResult *pResult, void *pUserData);
static void ConRemoveWeapon(IConsole::IResult *pResult, void *pUserData); static void ConRemoveWeapon(IConsole::IResult *pResult, void *pUserData);

View file

@ -560,8 +560,8 @@ void IGameController::OnCharacterSpawn(class CCharacter *pChr)
pChr->IncreaseHealth(10); pChr->IncreaseHealth(10);
// give default weapons // give default weapons
pChr->GiveWeapon(WEAPON_HAMMER, -1); pChr->GiveWeapon(WEAPON_HAMMER);
pChr->GiveWeapon(WEAPON_GUN, -1); pChr->GiveWeapon(WEAPON_GUN);
} }
void IGameController::DoWarmup(int Seconds) void IGameController::DoWarmup(int Seconds)