Added Plasma Gun tweaking

made the default 3 plasmas per second more cpu friendly
This commit is contained in:
GreYFoX 2011-04-20 15:47:55 +02:00
parent dca0057bc1
commit 0584f2b7a2
3 changed files with 21 additions and 15 deletions

View file

@ -180,6 +180,8 @@ MACRO_CONFIG_INT(ClShowEntities, cl_show_entities, 0, 0, 1, CFGFLAG_CLIENT, "Che
MACRO_CONFIG_INT(ClPredictOldHookthrough, cl_predict_oldht, 0, 0, 1, CFGFLAG_CLIENT, "Client predicts old Hookthrough", IConsole::CONSOLELEVEL_USER)
MACRO_CONFIG_INT(SvShowOthers, sv_show_others, 1, 0, 1, CFGFLAG_SERVER, "Whether players can user the command showothers or not", IConsole::CONSOLELEVEL_ADMIN)
MACRO_CONFIG_INT(SvMaxAfkTime, sv_max_afk_time, 0, 0, 9999, CFGFLAG_SERVER, "The time in seconds a player is allowed to be afk (0 = disabled)", IConsole::CONSOLELEVEL_ADMIN)
MACRO_CONFIG_INT(SvPlasmaRange, sv_plasma_range, 700, 1, 99999, CFGFLAG_SERVER, "How far will the plasma gun track tees", IConsole::CONSOLELEVEL_ADMIN)
MACRO_CONFIG_INT(SvPlasmaPerSec, sv_plasma_per_sec, 3, 0, 50, CFGFLAG_SERVER, "How many shots does the plasma gun fire per seconds", IConsole::CONSOLELEVEL_ADMIN)
// these might need some fine tuning
MACRO_CONFIG_INT(SvChatPenalty, sv_chat_penalty, 250, 50, 1000, CFGFLAG_SERVER, "chat score will be increased by this on every message, and decremented by 1 on every tick.", IConsole::CONSOLELEVEL_ADMIN)

View file

@ -1,14 +1,11 @@
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
#include <engine/server.h>
#include <engine/config.h>
#include <engine/shared/config.h>
#include <game/generated/protocol.h>
#include <game/server/gamecontext.h>
#include "gun.h"
#include "plasma.h"
const int RANGE=700;
//////////////////////////////////////////////////
// CGun
//////////////////////////////////////////////////
@ -17,7 +14,7 @@ CGun::CGun(CGameWorld *pGameWorld, vec2 Pos, bool Freeze, bool Explosive, int La
{
m_Layer = Layer;
m_Number = Number;
m_Delay = Server()->TickSpeed()*0.3f;
m_LastFire = Server()->Tick();
m_Pos = Pos;
m_EvalTick = Server()->Tick();
m_Freeze = Freeze;
@ -32,20 +29,23 @@ void CGun::Fire()
CCharacter *Ents[16];
int IdInTeam[16];
int LenInTeam[16];
for (int i = 0; i < 16; i++) {
for (int i = 0; i < 16; i++)
{
IdInTeam[i] = -1;
LenInTeam[i] = 0;
}
int Num = -1;
Num = GameServer()->m_World.FindEntities(m_Pos, RANGE, (CEntity**)Ents, 16, CGameWorld::ENTTYPE_CHARACTER);
Num = GameServer()->m_World.FindEntities(m_Pos, g_Config.m_SvPlasmaRange, (CEntity**)Ents, 16, CGameWorld::ENTTYPE_CHARACTER);
for (int i = 0; i < Num; i++)
{
CCharacter *Target = Ents[i];
//now gun doesn't affect on super
if(Target->Team() == TEAM_SUPER) continue;
if(m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Target->Team()]) continue;
if(Target->Team() == TEAM_SUPER)
continue;
if(m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Target->Team()])
continue;
int res = GameServer()->Collision()->IntersectLine(m_Pos, Target->m_Pos,0,0,false);
if (!res)
{
@ -57,10 +57,13 @@ void CGun::Fire()
}
}
}
for (int i = 0; i < 16; i++) {
if(IdInTeam[i] != -1) {
for (int i = 0; i < 16; i++)
{
if(IdInTeam[i] != -1)
{
CCharacter *Target = Ents[IdInTeam[i]];
new CPlasma(&GameServer()->m_World, m_Pos, normalize(Target->m_Pos - m_Pos), m_Freeze, m_Explosive, i);
m_LastFire = Server()->Tick();
}
}
@ -83,8 +86,9 @@ void CGun::Tick()
m_Core=GameServer()->Collision()->CpSpeed(index, Flags);
}
m_Pos+=m_Core;
Fire();
}
if (m_LastFire + Server()->TickSpeed() / g_Config.m_SvPlasmaPerSec <= Server()->Tick())
Fire();
}

View file

@ -13,11 +13,11 @@ class CGun : public CEntity
int m_EvalTick;
vec2 m_Core;
bool m_Freeze;
bool m_Explosive;
bool m_Freeze;
bool m_Explosive;
void Fire();
int m_Delay;
int m_LastFire;
public:
CGun(CGameWorld *pGameWorld, vec2 Pos, bool Freeze, bool Explosive, int Layer = 0, int Number = 0);