Merge pull request #1363 from Ryozuki/pr_improve_telegun

Improve telegun
This commit is contained in:
Dennis Felsing 2018-11-15 09:24:17 +01:00 committed by GitHub
commit 9bf9ed4838
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 97 additions and 13 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 KiB

After

Width:  |  Height:  |  Size: 344 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 KiB

After

Width:  |  Height:  |  Size: 350 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 KiB

After

Width:  |  Height:  |  Size: 323 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 177 KiB

View file

@ -104,7 +104,9 @@ void CCollision::Init(class CLayers *pLayers)
if(Index <= TILE_NPH_START)
{
if(Index >= TILE_JUMP && Index <= TILE_BONUS)
if((Index >= TILE_JUMP && Index <= TILE_BONUS)
|| Index == TILE_ALLOW_TELE_GUN
|| Index == TILE_ALLOW_BLUE_TELE_GUN)
m_pSwitch[i].m_Type = Index;
else
m_pSwitch[i].m_Type = 0;

View file

@ -953,7 +953,9 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
TILE_HIT_END,
TILE_JUMP,
TILE_PENALTY,
TILE_BONUS
TILE_BONUS,
TILE_ALLOW_TELE_GUN,
TILE_ALLOW_BLUE_TELE_GUN
};
CSwitchTile *pLayerSwitchTiles = ((CLayerSwitch *)pTiles)->m_pSwitchTile;
mem_copy(((CLayerSwitch *)pTiles)->m_pSwitchTile, pSwitchData, pTiles->m_Width*pTiles->m_Height*sizeof(CSwitchTile));

View file

@ -271,7 +271,21 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
for(int x = 0; x < r.w; x++)
{
pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x] = ((CLayerSwitch*)this)->m_pSwitchTile[(r.y+y)*m_Width+(r.x+x)];
if(pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == ENTITY_DOOR + ENTITY_OFFSET || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_HIT_START || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_HIT_END || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_SWITCHOPEN || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_SWITCHCLOSE || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_SWITCHTIMEDOPEN || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_SWITCHTIMEDCLOSE || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == ENTITY_LASER_LONG + ENTITY_OFFSET || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == ENTITY_LASER_MEDIUM + ENTITY_OFFSET || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == ENTITY_LASER_SHORT + ENTITY_OFFSET || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_JUMP || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_PENALTY || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_BONUS)
if(pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == ENTITY_DOOR + ENTITY_OFFSET
|| pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_HIT_START
|| pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_HIT_END
|| pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_SWITCHOPEN
|| pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_SWITCHCLOSE
|| pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_SWITCHTIMEDOPEN
|| pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_SWITCHTIMEDCLOSE
|| pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == ENTITY_LASER_LONG + ENTITY_OFFSET
|| pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == ENTITY_LASER_MEDIUM + ENTITY_OFFSET
|| pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == ENTITY_LASER_SHORT + ENTITY_OFFSET
|| pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_JUMP
|| pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_PENALTY
|| pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_BONUS
|| pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_ALLOW_TELE_GUN
|| pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == TILE_ALLOW_BLUE_TELE_GUN)
{
m_pEditor->m_SwitchNum = pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Number;
m_pEditor->m_SwitchDelay = pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Delay;
@ -1509,7 +1523,21 @@ void CLayerSwitch::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 >= (ENTITY_ARMOR_1 + ENTITY_OFFSET) && l->m_pTiles[y*l->m_Width+x].m_Index <= (ENTITY_DOOR + ENTITY_OFFSET)) || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_HIT_START || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_HIT_END || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHOPEN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHCLOSE || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHTIMEDOPEN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHTIMEDCLOSE || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_FREEZE || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_DFREEZE || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_DUNFREEZE || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_JUMP || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_PENALTY || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_BONUS)
if((l->m_pTiles[y*l->m_Width+x].m_Index >= (ENTITY_ARMOR_1 + ENTITY_OFFSET) && l->m_pTiles[y*l->m_Width+x].m_Index <= (ENTITY_DOOR + ENTITY_OFFSET))
|| l->m_pTiles[y*l->m_Width+x].m_Index == TILE_HIT_START
|| l->m_pTiles[y*l->m_Width+x].m_Index == TILE_HIT_END
|| l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHOPEN
|| l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHCLOSE
|| l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHTIMEDOPEN
|| l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHTIMEDCLOSE
|| l->m_pTiles[y*l->m_Width+x].m_Index == TILE_FREEZE
|| l->m_pTiles[y*l->m_Width+x].m_Index == TILE_DFREEZE
|| l->m_pTiles[y*l->m_Width+x].m_Index == TILE_DUNFREEZE
|| l->m_pTiles[y*l->m_Width+x].m_Index == TILE_JUMP
|| l->m_pTiles[y*l->m_Width+x].m_Index == TILE_PENALTY
|| l->m_pTiles[y*l->m_Width+x].m_Index == TILE_BONUS
|| l->m_pTiles[y*l->m_Width+x].m_Index == TILE_ALLOW_TELE_GUN
|| l->m_pTiles[y*l->m_Width+x].m_Index == TILE_ALLOW_BLUE_TELE_GUN)
{
if(m_pEditor->m_SwitchNum != l->m_SwitchNumber || m_pEditor->m_SwitchDelay != l->m_SwitchDelay)
{

View file

@ -13,7 +13,7 @@ bool IsValidGameTile(int Index)
|| (Index >= TILE_CP && Index <= TILE_THROUGH_DIR)
|| (Index >= TILE_OLDLASER && Index <= TILE_UNLOCK_TEAM)
|| (Index >= TILE_NPC_END && Index <= TILE_NPH_END)
|| (Index >= TILE_TELE_GUN_ENABLE && Index <= TILE_NO_TELE_GUN)
|| (Index >= TILE_TELE_GUN_ENABLE && Index <= TILE_TELE_GUN_DISABLE)
|| (Index >= TILE_TELE_GRENADE_ENABLE && Index <= TILE_TELE_GRENADE_DISABLE)
|| (Index >= TILE_TELE_LASER_ENABLE && Index <= TILE_TELE_LASER_DISABLE)
|| (Index >= TILE_NPC_START && Index <= TILE_NPH_START)
@ -35,7 +35,7 @@ bool IsValidFrontTile(int Index)
|| (Index >= TILE_CP && Index <= TILE_THROUGH_DIR)
|| (Index >= TILE_OLDLASER && Index <= TILE_UNLOCK_TEAM)
|| (Index >= TILE_NPC_END && Index <= TILE_NPH_END)
|| (Index >= TILE_TELE_GUN_ENABLE && Index <= TILE_NO_TELE_GUN)
|| (Index >= TILE_TELE_GUN_ENABLE && Index <= TILE_ALLOW_BLUE_TELE_GUN)
|| (Index >= TILE_TELE_GRENADE_ENABLE && Index <= TILE_TELE_GRENADE_DISABLE)
|| (Index >= TILE_TELE_LASER_ENABLE && Index <= TILE_TELE_LASER_DISABLE)
|| (Index >= TILE_NPC_START && Index <= TILE_NPH_START)
@ -75,6 +75,8 @@ bool IsValidSwitchTile(int Index)
|| (Index >= TILE_SWITCHTIMEDOPEN && Index <= TILE_SWITCHCLOSE)
|| Index == TILE_PENALTY
|| Index == TILE_BONUS
|| Index == TILE_ALLOW_TELE_GUN
|| Index == TILE_ALLOW_BLUE_TELE_GUN
|| IsValidEntity(Index)
);
}

View file

@ -154,7 +154,8 @@ enum
TILE_BONUS = 95,
TILE_TELE_GUN_ENABLE = 96,
TILE_TELE_GUN_DISABLE = 97,
TILE_NO_TELE_GUN = 98,
TILE_ALLOW_TELE_GUN = 98,
TILE_ALLOW_BLUE_TELE_GUN = 99,
TILE_NPC_START = 104,
TILE_SUPER_START,
TILE_JETPACK_START,

View file

@ -46,6 +46,7 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
m_HasTeleLaser = false;
m_HasTeleGrenade = false;
m_TeleGunTeleport = false;
m_IsBlueTeleGunTeleport = false;
m_pPlayer = pPlayer;
m_Pos = Pos;
@ -2137,10 +2138,12 @@ void CCharacter::DDRacePostCoreTick()
{
GameServer()->CreateDeath(m_Pos, m_pPlayer->GetCID(), Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID()));
m_Core.m_Pos = m_TeleGunPos;
m_Core.m_Vel = vec2(0, 0);
if(!m_IsBlueTeleGunTeleport)
m_Core.m_Vel = vec2(0, 0);
GameServer()->CreateDeath(m_TeleGunPos, m_pPlayer->GetCID(), Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID()));
GameServer()->CreateSound(m_TeleGunPos, SOUND_WEAPON_SPAWN, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID()));
m_TeleGunTeleport = false;
m_IsBlueTeleGunTeleport = false;
}
HandleBroadcast();

View file

@ -256,6 +256,7 @@ public:
bool m_HasTeleLaser;
vec2 m_TeleGunPos;
bool m_TeleGunTeleport;
bool m_IsBlueTeleGunTeleport;
// Setters/Getters because i don't want to modify vanilla vars access modifiers
int GetLastWeapon() { return m_LastWeapon; };

View file

@ -21,6 +21,7 @@ CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEner
m_WasTele = false;
m_Type = Type;
m_TeleportCancelled = false;
m_IsBlueTeleport = false;
m_TuneZone = GameServer()->Collision()->IsTune(GameServer()->Collision()->GetMapIndex(m_Pos));
m_TeamMask = GameServer()->GetPlayerChar(Owner) ? GameServer()->GetPlayerChar(Owner)->Teams()->TeamMask(GameServer()->GetPlayerChar(Owner)->Team(), -1, m_Owner) : 0;
GameWorld()->InsertEntity(this);
@ -191,16 +192,40 @@ void CLaser::DoBounce()
{
pOwnerChar->m_TeleGunPos = PossiblePos;
pOwnerChar->m_TeleGunTeleport = true;
pOwnerChar->m_IsBlueTeleGunTeleport = m_IsBlueTeleport;
}
}
else if(m_Owner >= 0 && m_Pos)
{
int MapIndex = GameServer()->Collision()->GetPureMapIndex(Coltile);
int TileIndex = GameServer()->Collision()->GetTileIndex(MapIndex);
int TileFIndex = GameServer()->Collision()->GetFTileIndex(MapIndex);
bool IsSwitchTeleGun = GameServer()->Collision()->IsSwitch(MapIndex) == TILE_ALLOW_TELE_GUN;
bool IsBlueSwitchTeleGun = GameServer()->Collision()->IsSwitch(MapIndex) == TILE_ALLOW_BLUE_TELE_GUN;
int IsTeleInWeapon = GameServer()->Collision()->IsTeleportWeapon(MapIndex);
if (m_Type == WEAPON_RIFLE && (TileIndex == TILE_NO_TELE_GUN || TileFIndex == TILE_NO_TELE_GUN))
m_TeleportCancelled = true;
if(!IsTeleInWeapon)
{
if(IsSwitchTeleGun || IsBlueSwitchTeleGun) {
// Delay specifies which weapon the tile should work for.
// Delay = 0 means all.
int delay = GameServer()->Collision()->GetSwitchDelay(MapIndex);
if((delay != 3 && delay != 0) && m_Type == WEAPON_RIFLE) {
IsSwitchTeleGun = IsBlueSwitchTeleGun = false;
}
}
m_IsBlueTeleport = TileFIndex == TILE_ALLOW_BLUE_TELE_GUN || IsBlueSwitchTeleGun;
// Teleport is canceled if the last bounce tile is not a TILE_ALLOW_TELE_GUN.
// Teleport also works if laser didn't bounce.
m_TeleportCancelled =
m_Type == WEAPON_RIFLE
&& (TileFIndex != TILE_ALLOW_TELE_GUN
&& TileFIndex != TILE_ALLOW_BLUE_TELE_GUN
&& !IsSwitchTeleGun
&& !IsBlueSwitchTeleGun);
}
}
//m_Owner = -1;

View file

@ -36,6 +36,7 @@ private:
int m_Type;
int m_TuneZone;
bool m_TeleportCancelled;
bool m_IsBlueTeleport;
};
#endif

View file

@ -175,10 +175,28 @@ void CProjectile::Tick()
((m_Type == WEAPON_GRENADE && pOwnerChar->m_HasTeleGrenade) || (m_Type == WEAPON_GUN && pOwnerChar->m_HasTeleGun)))
{
int MapIndex = GameServer()->Collision()->GetPureMapIndex(pTargetChr ? pTargetChr->m_Pos : ColPos);
int TileIndex = GameServer()->Collision()->GetTileIndex(MapIndex);
int TileFIndex = GameServer()->Collision()->GetFTileIndex(MapIndex);
bool IsSwitchTeleGun = GameServer()->Collision()->IsSwitch(MapIndex) == TILE_ALLOW_TELE_GUN;
bool IsBlueSwitchTeleGun = GameServer()->Collision()->IsSwitch(MapIndex) == TILE_ALLOW_BLUE_TELE_GUN;
if (TileIndex != TILE_NO_TELE_GUN && TileFIndex != TILE_NO_TELE_GUN)
if(IsSwitchTeleGun || IsBlueSwitchTeleGun) {
// Delay specifies which weapon the tile should work for.
// Delay = 0 means all.
int delay = GameServer()->Collision()->GetSwitchDelay(MapIndex);
if(delay == 1 && m_Type != WEAPON_GUN)
IsSwitchTeleGun = IsBlueSwitchTeleGun = false;
if(delay == 2 && m_Type != WEAPON_GRENADE)
IsSwitchTeleGun = IsBlueSwitchTeleGun = false;
if(delay == 3 && m_Type != WEAPON_RIFLE)
IsSwitchTeleGun = IsBlueSwitchTeleGun = false;
}
if (TileFIndex == TILE_ALLOW_TELE_GUN
|| TileFIndex == TILE_ALLOW_BLUE_TELE_GUN
|| IsSwitchTeleGun
|| IsBlueSwitchTeleGun
|| pTargetChr)
{
bool Found;
vec2 PossiblePos;
@ -192,6 +210,7 @@ void CProjectile::Tick()
{
pOwnerChar->m_TeleGunPos = PossiblePos;
pOwnerChar->m_TeleGunTeleport = true;
pOwnerChar->m_IsBlueTeleGunTeleport = TileFIndex == TILE_ALLOW_BLUE_TELE_GUN || IsBlueSwitchTeleGun;
}
}
}