New teleport entities

This commit is contained in:
def 2013-08-13 04:59:25 +02:00
parent ed02dbed33
commit bf518df74d
12 changed files with 104 additions and 21 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 KiB

After

Width:  |  Height:  |  Size: 327 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View file

@ -211,7 +211,7 @@ int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *p
return 0;
}
int CCollision::IntersectLineTele(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr, bool AllowThrough)
int CCollision::IntersectLineTeleHook(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr, bool AllowThrough)
{
float Distance = distance(Pos0, Pos1);
int End(Distance+1);
@ -231,7 +231,61 @@ int CCollision::IntersectLineTele(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec
int Nx = clamp(ix/32, 0, m_Width-1);
int Ny = clamp(iy/32, 0, m_Height-1);
*pTeleNr = IsTeleport(Ny*m_Width+Nx);
if (g_Config.m_SvOldTeleportHook)
*pTeleNr = IsTeleport(Ny*m_Width+Nx);
else
*pTeleNr = IsTeleportHook(Ny*m_Width+Nx);
if(*pTeleNr)
{
if(pOutCollision)
*pOutCollision = Pos;
if(pOutBeforeCollision)
*pOutBeforeCollision = Last;
return COLFLAG_TELE;
}
if((CheckPoint(ix, iy) && !(AllowThrough && IsThrough(ix + dx, iy + dy))))
{
if(pOutCollision)
*pOutCollision = Pos;
if(pOutBeforeCollision)
*pOutBeforeCollision = Last;
return GetCollisionAt(ix, iy);
}
Last = Pos;
}
if(pOutCollision)
*pOutCollision = Pos1;
if(pOutBeforeCollision)
*pOutBeforeCollision = Pos1;
return 0;
}
int CCollision::IntersectLineTeleWeapon(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr, bool AllowThrough)
{
float Distance = distance(Pos0, Pos1);
int End(Distance+1);
vec2 Last = Pos0;
int ix = 0, iy = 0; // Temporary position for checking collision
int dx = 0, dy = 0; // Offset for checking the "through" tile
if (AllowThrough)
{
ThroughOffset(Pos0, Pos1, &dx, &dy);
}
for(int i = 0; i < End; i++)
{
float a = i/Distance;
vec2 Pos = mix(Pos0, Pos1, a);
ix = round(Pos.x);
iy = round(Pos.y);
int Nx = clamp(ix/32, 0, m_Width-1);
int Ny = clamp(iy/32, 0, m_Height-1);
if (g_Config.m_SvOldTeleportWeapons)
*pTeleNr = IsTeleport(Ny*m_Width+Nx);
else
*pTeleNr = IsTeleportWeapon(Ny*m_Width+Nx);
if(*pTeleNr)
{
if(pOutCollision)
@ -471,6 +525,29 @@ int CCollision::IsTCheckpoint(int Index)
return 0;
}
int CCollision::IsTeleportWeapon(int Index)
{
if(Index < 0 || !m_pTele)
return 0;
if(m_pTele[Index].m_Type == TILE_TELEINWEAPON)
return m_pTele[Index].m_Number;
return 0;
}
int CCollision::IsTeleportHook(int Index)
{
if(Index < 0 || !m_pTele)
return 0;
if(m_pTele[Index].m_Type == TILE_TELEINHOOK)
return m_pTele[Index].m_Number;
return 0;
}
int CCollision::IsSpeedup(int Index)
{
if(Index < 0 || !m_pSpeedup)

View file

@ -37,7 +37,8 @@ public:
int GetWidth() { return m_Width; };
int GetHeight() { return m_Height; };
int IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, bool AllowThrough);
int IntersectLineTele(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr, bool AllowThrough);
int IntersectLineTeleWeapon(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr, bool AllowThrough);
int IntersectLineTeleHook(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr, bool AllowThrough);
void MovePoint(vec2 *pInoutPos, vec2 *pInoutVel, float Elasticity, int *pBounces);
void MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elasticity);
bool TestBox(vec2 Pos, vec2 Size);
@ -76,6 +77,8 @@ public:
int IsTeleport(int Index);
int IsEvilTeleport(int Index);
int IsCheckTeleport(int Index);
int IsTeleportWeapon(int Index);
int IsTeleportHook(int Index);
int IsTCheckpoint(int Index);
//int IsCheckpoint(int Index);
int IsSpeedup(int Index);

View file

@ -693,6 +693,10 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = TILE_TELECHECKIN;
else if(((CLayerTele*)pTiles)->m_pTeleTile[i].m_Type == TILE_TELECHECKOUT)
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = TILE_TELECHECKOUT;
else if(((CLayerTele*)pTiles)->m_pTeleTile[i].m_Type == TILE_TELEINWEAPON)
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = TILE_TELEINWEAPON;
else if(((CLayerTele*)pTiles)->m_pTeleTile[i].m_Type == TILE_TELEINHOOK)
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = TILE_TELEINHOOK;
else
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = 0;
}

View file

@ -176,7 +176,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
for(int x = 0; x < r.w; x++)
{
pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x] = ((CLayerTele*)this)->m_pTeleTile[(r.y+y)*m_Width+(r.x+x)];
if(pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEIN || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEOUT || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEINEVIL || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECK || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKOUT || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKIN)
if(pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEIN || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEOUT || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEINEVIL || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECK || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKOUT || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKIN || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEINWEAPON || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEINHOOK)
m_pEditor->m_TeleNumber = pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Number;
}
pGrabbed->m_TeleNum = m_pEditor->m_TeleNumber;
@ -756,7 +756,7 @@ void CLayerTele::BrushDraw(CLayer *pBrush, float wx, float wy)
if(fx<0 || fx >= m_Width || fy < 0 || fy >= m_Height)
continue;
if(l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEIN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEINEVIL || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEOUT || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELECHECK || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELECHECKOUT || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELECHECKIN)
if(l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEIN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEINEVIL || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEOUT || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELECHECK || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELECHECKOUT || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELECHECKIN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEINWEAPON || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEINHOOK)
{
if(m_pEditor->m_TeleNumber != l->m_TeleNum)
{

View file

@ -259,11 +259,7 @@ void CCharacterCore::Tick(bool UseInput)
bool GoingToRetract = false;
bool GoingThroughTele = false;
int teleNr = 0;
int Hit;
if (!g_Config.m_SvTeleportHook)
Hit = m_pCollision->IntersectLine(m_HookPos, NewPos, &NewPos, 0, true);
else
Hit = m_pCollision->IntersectLineTele(m_HookPos, NewPos, &NewPos, 0, &teleNr, true);
int Hit = m_pCollision->IntersectLineTeleHook(m_HookPos, NewPos, &NewPos, 0, &teleNr, true);
//m_NewHook = false;

View file

@ -98,6 +98,8 @@ enum
TILE_UNFREEZE,
TILE_DFREEZE,
TILE_DUNFREEZE,
TILE_TELEINWEAPON,
TILE_TELEINHOOK,
TILE_EHOOK_START = 17,
TILE_EHOOK_END,
TILE_HIT_START,

View file

@ -1469,7 +1469,7 @@ void CCharacter::HandleTiles(int Index)
m_Hit |= DISABLE_HIT_RIFLE;
}
int z = GameServer()->Collision()->IsTeleport(MapIndex);
if(!g_Config.m_SvTeleportHook && !g_Config.m_SvTeleportWeapons && z && Controller->m_TeleOuts[z-1].size())
if(!g_Config.m_SvOldTeleportHook && !g_Config.m_SvOldTeleportWeapons && z && Controller->m_TeleOuts[z-1].size())
{
m_Core.m_HookedPlayer = -1;
m_Core.m_HookState = HOOK_RETRACTED;
@ -1485,7 +1485,7 @@ void CCharacter::HandleTiles(int Index)
{
int Num = Controller->m_TeleOuts[evilz-1].size();
m_Core.m_Pos = Controller->m_TeleOuts[evilz-1][(!Num)?Num:rand() % Num];
if (!g_Config.m_SvTeleportHook && !g_Config.m_SvTeleportWeapons)
if (!g_Config.m_SvOldTeleportHook && !g_Config.m_SvOldTeleportWeapons)
{
m_Core.m_HookedPlayer = -1;
m_Core.m_HookState = HOOK_RETRACTED;

View file

@ -91,10 +91,7 @@ void CLaser::DoBounce()
vec2 To = m_Pos + m_Dir * m_Energy;
if (g_Config.m_SvTeleportWeapons)
Res = GameServer()->Collision()->IntersectLineTele(m_Pos, To, &Coltile, &To, &z, false);
else
Res = GameServer()->Collision()->IntersectLine(m_Pos, To, &Coltile, &To, false);
Res = GameServer()->Collision()->IntersectLineTeleWeapon(m_Pos, To, &Coltile, &To, &z, false);
if(Res)
{
@ -123,7 +120,7 @@ void CLaser::DoBounce()
m_Energy -= distance(m_From, m_Pos) + GameServer()->Tuning()->m_LaserBounceCost;
if (g_Config.m_SvTeleportWeapons && Res&CCollision::COLFLAG_TELE && ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1].size())
if (Res&CCollision::COLFLAG_TELE && ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1].size())
{
int Num = ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1].size();
m_TelePos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1][(!Num)?Num:rand() % Num];

View file

@ -157,8 +157,12 @@ void CProjectile::Tick()
}
int x = GameServer()->Collision()->GetIndex(PrevPos, CurPos);
int z = GameServer()->Collision()->IsTeleport(x);
if (g_Config.m_SvTeleportWeapons && z && ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1].size())
int z;
if (g_Config.m_SvOldTeleportWeapons)
z = GameServer()->Collision()->IsTeleport(x);
else
z = GameServer()->Collision()->IsTeleportWeapon(x);
if (z && ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1].size())
{
int Num = ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1].size();
m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1][(!Num)?Num:rand() % Num];

View file

@ -82,8 +82,8 @@ MACRO_CONFIG_INT(SvVoteSpectateRejoindelay, sv_vote_spectate_rejoindelay, 3, 0,
MACRO_CONFIG_INT(SvVoteKick, sv_vote_kick, 1, 0, 1, CFGFLAG_SERVER, "Allow voting to kick players")
MACRO_CONFIG_INT(SvVoteKickMin, sv_vote_kick_min, 0, 0, MAX_CLIENTS, CFGFLAG_SERVER, "Minimum number of players required to start a kick vote")
MACRO_CONFIG_INT(SvVoteKickBantime, sv_vote_kick_bantime, 5, 0, 1440, CFGFLAG_SERVER, "The time to ban a player if kicked by vote. 0 makes it just use kick")
MACRO_CONFIG_INT(SvTeleportWeapons, sv_teleport_weapons, 0, 0, 1, CFGFLAG_SERVER, "Teleporting of all weapons");
MACRO_CONFIG_INT(SvTeleportHook, sv_teleport_hook, 0, 0, 1, CFGFLAG_SERVER, "Hook through teleporter");
MACRO_CONFIG_INT(SvOldTeleportWeapons, sv_old_teleport_weapons, 0, 0, 1, CFGFLAG_SERVER, "Teleporting of all weapons (deprecated, use special entities instead)");
MACRO_CONFIG_INT(SvOldTeleportHook, sv_old_teleport_hook, 0, 0, 1, CFGFLAG_SERVER, "Hook through teleporter (deprecated, use special entities instead)");
// debug
#ifdef CONF_DEBUG // this one can crash the server if not used correctly