Skip to content

Commit

Permalink
fixes and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
duralakun authored and teoman002 committed Jan 11, 2019
1 parent ac8a65e commit 7cfd5b0
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 105 deletions.
2 changes: 1 addition & 1 deletion src/engine/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CSnapIDPool
{
enum
{
MAX_IDS = 16*1024,
MAX_IDS = 16*2048,
};

class CID
Expand Down
7 changes: 3 additions & 4 deletions src/engine/shared/config_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,10 @@ MACRO_CONFIG_INT(InfSlowMotionPercent, inf_slow_motion_percent, 55, 0, 90, CFGFL


//SuperWeapons
MACRO_CONFIG_INT(InfSuperWeaponMinimalKills, inf_super_weapon_minimal_kills, 0, 0, 30, CFGFLAG_SERVER, "Minimal number of kills before super weapons become available")
MACRO_CONFIG_INT(InfSuperWeaponProbability, inf_super_weapon_probability, 99, 0, 100, CFGFLAG_SERVER, "Probability of super weapon being available after MinimalKill requirement")
MACRO_CONFIG_INT(InfSuperWeaponMinimalKills, inf_super_weapon_minimal_kills, 6, 0, 30, CFGFLAG_SERVER, "Minimal number of kills before super weapons become available")
MACRO_CONFIG_INT(InfSuperWeaponProbability, inf_super_weapon_probability, 20, 0, 100, CFGFLAG_SERVER, "Probability of super weapon being available after MinimalKill requirement")
MACRO_CONFIG_INT(InfWhiteHoleLifeSpan, inf_white_hole_life_span, 20, 0, 100, CFGFLAG_SERVER, "White hole life span")
MACRO_CONFIG_INT(InfWhiteHoleRadius, inf_white_hole_radius, 400, 0, 500, CFGFLAG_SERVER, "Radius of white holes")
MACRO_CONFIG_INT(InfWhiteHoleSingularitySize, inf_white_hole_singularity_size, 150, 0, 300, CFGFLAG_SERVER, "Radius of white holes")
MACRO_CONFIG_INT(InfWhiteHoleRadius, inf_white_hole_radius, 430, 0, 500, CFGFLAG_SERVER, "Radius of white holes")


#endif
53 changes: 28 additions & 25 deletions src/game/server/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ m_pConsole(pConsole)
m_NinjaVelocityBuff = 0;
m_NinjaStrengthBuff = 0;
m_NinjaAmmoBuff = 0;
m_HasWhiteHole = true;
m_HasWhiteHole = false;
m_HasIndicator = false;
/* INFECTION MODIFICATION END *****************************************/
}

Expand Down Expand Up @@ -1316,29 +1317,31 @@ void CCharacter::FireWeapon()

void CCharacter::CheckSuperWeaponAccess()
{

// check kills of player
int kills = m_pPlayer->GetNumberKills();


if (m_HasWhiteHole == false) // Can't receive a white hole while having one available
//Only scientists can receive white holes
if(GetClass() == PLAYERCLASS_SCIENTIST)
{
// enable white hole probabilities
if ( kills > g_Config.m_InfSuperWeaponMinimalKills)
// check kills of player
int kills = m_pPlayer->GetNumberKills();

if (m_HasWhiteHole == false) // Can't receive a white hole while having one available
{
if (random_int(0,100)/100 < g_Config.m_InfSuperWeaponProbability/100 )
// enable white hole probabilities
if (kills > g_Config.m_InfSuperWeaponMinimalKills)
{
// Make white hole available
m_HasWhiteHole = true;

//Scientist-laser.cpp will make it unavailable after usage

//create an indicator object
new CSuperWeaponIndicator(GameWorld(), m_Pos, m_pPlayer->GetCID());
if (random_int(0,100) < g_Config.m_InfSuperWeaponProbability )
{
//Scientist-laser.cpp will make it unavailable after usage

//create an indicator object
if (m_HasIndicator == false) {
m_HasIndicator = true;
GameServer()->SendChatTarget_Localization(m_pPlayer->GetCID(), CHATCATEGORY_SCORE, _("white hole found, adjusting scientific parameters..."), NULL);
new CSuperWeaponIndicator(GameWorld(), m_Pos, m_pPlayer->GetCID());
}
}
}
}
}
}

}


Expand Down Expand Up @@ -2708,7 +2711,7 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon, int Mode)
if(From == m_pPlayer->GetCID())
{
if(GetClass() == PLAYERCLASS_HERO || (GetClass() == PLAYERCLASS_SOLDIER && m_ActiveWeapon == WEAPON_GRENADE)
|| (GetClass() == PLAYERCLASS_SCIENTIST && m_ActiveWeapon == WEAPON_RIFLE)
|| (GetClass() == PLAYERCLASS_SCIENTIST && Mode == TAKEDAMAGEMODE_NOINFECTION)
|| (GetClass() == PLAYERCLASS_LOOPER && m_ActiveWeapon == WEAPON_GRENADE))
return false; // no self harm
else
Expand Down Expand Up @@ -2811,12 +2814,12 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon, int Mode)
}
}

// increase number of kills of killer
pKillerPlayer->IncreaseNumberKills();

pKillerChar->CheckSuperWeaponAccess();
if (pKillerChar)
{
pKillerPlayer->IncreaseNumberKills();
pKillerChar->CheckSuperWeaponAccess();
}


return false;
}

Expand Down
1 change: 1 addition & 0 deletions src/game/server/entities/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class CCharacter : public CEntity
bool m_PositionLocked;
bool m_PositionLockAvailable;
bool m_HasWhiteHole; //White hole changes here
bool m_HasIndicator; //White hole changes here
int m_LoveTick;
int m_HallucinationTick;
int m_SlipperyTick;
Expand Down
3 changes: 2 additions & 1 deletion src/game/server/entities/growingexplosion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ void CGrowingExplosion::Tick()
{
int randNb = random_int(0, NumPossibleStartPoint-1);
vec2 StartPoint = PossibleStartPoint[randNb];
GameServer()->CreateLaserDotEvent(StartPoint, EndPoint, Server()->TickSpeed()/6);
if (StartPoint.x > 0 && StartPoint.y > 0) // dirty fix - there is a bug which causes StartPoint to be 0 sometimes, i dont know why
GameServer()->CreateLaserDotEvent(StartPoint, EndPoint, Server()->TickSpeed()/6);
}

if(random_prob(0.1f))
Expand Down
6 changes: 5 additions & 1 deletion src/game/server/entities/scientist-laser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


#include "white-hole.h"
#include "growingexplosion.h"

CScientistLaser::CScientistLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEnergy, int Owner, int Dmg)
: CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
Expand Down Expand Up @@ -71,12 +72,15 @@ void CScientistLaser::DoBounce()
GameServer()->CreateExplosion(m_Pos, m_Owner, WEAPON_RIFLE, false, TAKEDAMAGEMODE_NOINFECTION);

//Create a white hole entity
if(m_OwnerChar->m_HasWhiteHole == true)
if(m_OwnerChar->m_HasWhiteHole)
{
new CGrowingExplosion(GameWorld(), m_Pos, vec2(0.0, -1.0), m_Owner, 5, GROWINGEXPLOSIONEFFECT_BOOM_INFECTED);
new CWhiteHole(GameWorld(), To, m_Owner);

//Make it unavailable
m_OwnerChar->m_HasWhiteHole = false;
m_OwnerChar->m_HasIndicator = false;
m_OwnerChar->GetPlayer()->ResetNumberKills();
}
}

Expand Down
30 changes: 23 additions & 7 deletions src/game/server/entities/superweapon-indicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ CSuperWeaponIndicator::CSuperWeaponIndicator(CGameWorld *pGameWorld, vec2 Pos, i
m_StartTick = Server()->Tick();
m_Owner = Owner;
m_OwnerChar = GameServer()->GetPlayerChar(m_Owner);
m_warmUpCounter = Server()->TickSpeed()*3;
m_IsWarmingUp = true;

m_IDs.set_size(3);
for(int i=0; i<m_IDs.size(); i++)
Expand Down Expand Up @@ -48,21 +50,35 @@ void CSuperWeaponIndicator::Snap(int SnappingClient)
CNetObj_Projectile *pProj = static_cast<CNetObj_Projectile *>(Server()->SnapNewItem(NETOBJTYPE_PROJECTILE, m_IDs[i], sizeof(CNetObj_Projectile)));
pProj->m_X = (int)(m_Pos.x + m_Radius*cos(shiftedAngle));
pProj->m_Y = (int)(m_Pos.y + m_Radius*sin(shiftedAngle));
pProj->m_VelX = (int)(0.0f);
pProj->m_VelY = (int)(0.0f);
pProj->m_VelX = 0;
pProj->m_VelY = 0;
pProj->m_StartTick = Server()->Tick();
pProj->m_Type = WEAPON_HAMMER;
}
}

void CSuperWeaponIndicator::Tick()
{
if (m_OwnerChar->m_HasWhiteHole == false) {
GameServer()->m_World.DestroyEntity(this);
}

//refresh indicator position
m_Pos = m_OwnerChar->m_Core.m_Pos;


if (m_IsWarmingUp)
{
if ( m_warmUpCounter > 0 )
{
m_warmUpCounter--;
} else {
m_IsWarmingUp = false;
m_OwnerChar->m_HasWhiteHole = true;
GameServer()->SendChatTarget_Localization(m_Owner, CHATCATEGORY_SCORE, _("white hole ready, your laser rifle now disrupts space time"), NULL);
}
}
else
{
if (m_OwnerChar->m_HasWhiteHole == false)
{
GameServer()->m_World.DestroyEntity(this);
return; // Do not proceed after destruction
}
}
}
2 changes: 2 additions & 0 deletions src/game/server/entities/superweapon-indicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class CSuperWeaponIndicator : public CEntity

private:
int m_StartTick;
int m_warmUpCounter;
bool m_IsWarmingUp;
array<int> m_IDs;
CCharacter *m_OwnerChar;

Expand Down
Loading

0 comments on commit 7cfd5b0

Please sign in to comment.