void CPlasma::Tick() { if (m_LifeTime == 0) { Reset(); return; } m_LifeTime--; Move(); HitCharacter(); int Res = 0; Res = GameServer()->Collision()->IntersectNoLaser(m_Pos, m_Pos + m_Core, 0, 0); if (Res) { if (m_Explosive) GameServer()->CreateExplosion( m_Pos, -1, WEAPON_GRENADE, true, m_ResponsibleTeam, ((CGameControllerDDRace*) GameServer()->m_pController)->m_Teams.TeamMask( m_ResponsibleTeam)); Reset(); } }
void CLaser::DoBounce() { m_EvalTick = Server()->Tick(); if(m_Energy < 0) { GameWorld()->DestroyEntity(this); return; } vec2 To = m_Pos + m_Dir * m_Energy; if(GameServer()->Collision()->IntersectLine(m_Pos, To, 0x0, &To)) { if(!HitCharacter(m_Pos, To)) { // intersected m_From = m_Pos; m_Pos = To; vec2 TempPos = m_Pos; vec2 TempDir = m_Dir * 4.0f; GameServer()->Collision()->MovePoint(&TempPos, &TempDir, 1.0f, 0); m_Pos = TempPos; m_Dir = normalize(TempDir); m_Energy -= distance(m_From, m_Pos) + GameServer()->Tuning()->m_LaserBounceCost; m_Bounces++; if(m_Bounces > GameServer()->Tuning()->m_LaserBounceNum) m_Energy = -1; tu::CEvent_Sound(GameServer()).World(GameWorld()->m_WorldID) .Send(m_Pos, SOUND_LASER_BOUNCE); } } else { if(!HitCharacter(m_Pos, To)) { m_From = m_Pos; m_Pos = To; m_Energy = -1; } } }
void CMine::Tick() { if (!GameServer()->GetPlayerChar(m_Owner) || GameServer()->m_apPlayers[m_Owner]->GetTeam() == TEAM_BLUE || GameServer()->m_apPlayers[m_Owner]->GetTeam() == TEAM_SPECTATORS) return Reset(); HitCharacter(); }
void CLaserWall::Tick() { CCharacter *OwnerChar = GameServer()->GetPlayerChar(m_Owner); if(!OwnerChar || !OwnerChar->IsAlive()) Reset(); if(m_Active) { HitCharacter(m_WallBody->getStartPoint(), m_WallBody->getEndPoint()); } else { if(time_get() >= m_Delay) { GameWorld()->InsertEntity(m_WallBody); m_Active = true; } } }
void CLaser::DoBounce() { m_EvalTick = Server()->Tick(); if(m_Energy < 0) { GameServer()->m_World.DestroyEntity(this); return; } m_PrevPos = m_Pos; vec2 To = m_Pos + m_Dir * m_Energy; vec2 Coltile; int Res; Res = GameServer()->Collision()->IntersectLine(m_Pos, To, &Coltile, &To,false); if(Res) { if(!HitCharacter(m_Pos, To)) { // intersected m_From = m_Pos; m_Pos = To; vec2 TempPos = m_Pos; vec2 TempDir = m_Dir * 4.0f; int f = 0; if(Res == -1) { f = GameServer()->Collision()->GetTile(round(Coltile.x), round(Coltile.y)); GameServer()->Collision()->SetCollisionAt(round(Coltile.x), round(Coltile.y), CCollision::COLFLAG_SOLID); } GameServer()->Collision()->MovePoint(&TempPos, &TempDir, 1.0f, 0); if(Res == -1) { GameServer()->Collision()->SetCollisionAt(round(Coltile.x), round(Coltile.y), f); } m_Pos = TempPos; m_Dir = normalize(TempDir); m_Energy -= distance(m_From, m_Pos) + GameServer()->Tuning()->m_LaserBounceCost; m_Bounces++; if(m_Bounces > GameServer()->Tuning()->m_LaserBounceNum) m_Energy = -1; GameServer()->CreateSound(m_Pos, SOUND_RIFLE_BOUNCE, m_TeamMask); } } else { if(!HitCharacter(m_Pos, To)) { m_From = m_Pos; m_Pos = To; m_Energy = -1; } } //m_Owner = -1; }
static void HandleGameEvent( GameEvent *e, HUD *hud, ScreenShake *shake, HealthPickups *hp, EventHandlers *eventHandlers) { switch (e->Type) { case GAME_EVENT_SCORE: Score(&gPlayerDatas[e->u.Score.PlayerIndex], e->u.Score.Score); HUDAddScoreUpdate(hud, e->u.Score.PlayerIndex, e->u.Score.Score); break; case GAME_EVENT_SOUND_AT: if (e->u.SoundAt.Sound) { SoundPlayAt( &gSoundDevice, e->u.SoundAt.Sound, e->u.SoundAt.Pos); } break; case GAME_EVENT_SCREEN_SHAKE: *shake = ScreenShakeAdd( *shake, e->u.ShakeAmount, gConfig.Graphics.ShakeMultiplier); break; case GAME_EVENT_SET_MESSAGE: HUDDisplayMessage( hud, e->u.SetMessage.Message, e->u.SetMessage.Ticks); break; case GAME_EVENT_GAME_START: if (eventHandlers->netInput.channel.state == CHANNEL_STATE_CONNECTED) { NetInputSendMsg( &eventHandlers->netInput, SERVER_MSG_GAME_START); } break; case GAME_EVENT_ADD_HEALTH_PICKUP: MapPlaceHealth(e->u.AddPos); break; case GAME_EVENT_TAKE_HEALTH_PICKUP: if (IsPlayerAlive(e->u.PickupPlayer)) { TActor *player = CArrayGet( &gActors, gPlayerIds[e->u.PickupPlayer]); ActorHeal(player, HEALTH_PICKUP_HEAL_AMOUNT); HealthPickupsRemoveOne(hp); HUDAddHealthUpdate( hud, e->u.PickupPlayer, HEALTH_PICKUP_HEAL_AMOUNT); } break; case GAME_EVENT_MOBILE_OBJECT_REMOVE: MobObjDestroy(e->u.MobileObjectRemoveId); break; case GAME_EVENT_ADD_BULLET: BulletAdd( e->u.AddBullet.Bullet, e->u.AddBullet.MuzzlePos, e->u.AddBullet.MuzzleHeight, e->u.AddBullet.Angle, e->u.AddBullet.Direction, e->u.AddBullet.Flags, e->u.AddBullet.PlayerIndex); break; case GAME_EVENT_ADD_MUZZLE_FLASH: AddMuzzleFlash( e->u.AddMuzzleFlash.FullPos, e->u.AddMuzzleFlash.MuzzleHeight, e->u.AddMuzzleFlash.Sprites, e->u.AddMuzzleFlash.Direction, e->u.AddMuzzleFlash.Color, e->u.AddMuzzleFlash.Duration); break; case GAME_EVENT_ADD_FIREBALL: AddFireball(e->u.AddFireball); break; case GAME_EVENT_HIT_CHARACTER: HitCharacter( e->u.HitCharacter.Flags, e->u.HitCharacter.PlayerIndex, CArrayGet(&gActors, e->u.HitCharacter.TargetId), e->u.HitCharacter.Special, e->u.HitCharacter.HasHitSound); break; case GAME_EVENT_ACTOR_IMPULSE: { TActor *a = CArrayGet(&gActors, e->u.ActorImpulse.Id); a->Vel = Vec2iAdd(a->Vel, e->u.ActorImpulse.Vel); } break; case GAME_EVENT_DAMAGE_CHARACTER: DamageCharacter( e->u.DamageCharacter.Power, e->u.DamageCharacter.PlayerIndex, CArrayGet(&gActors, e->u.DamageCharacter.TargetId)); if (e->u.DamageCharacter.Power != 0) { HUDAddHealthUpdate( hud, e->u.DamageCharacter.TargetPlayerIndex, -e->u.DamageCharacter.Power); } break; case GAME_EVENT_TRIGGER: { const Tile *t = MapGetTile(&gMap, e->u.Trigger.TilePos); for (int i = 0; i < (int)t->triggers.size; i++) { Trigger **tp = CArrayGet(&t->triggers, i); if ((*tp)->id == e->u.Trigger.Id) { TriggerActivate(*tp, &gMap.triggers); break; } } } break; case GAME_EVENT_UPDATE_OBJECTIVE: { struct Objective *o = CArrayGet( &gMission.Objectives, e->u.UpdateObjective.ObjectiveIndex); o->done += e->u.UpdateObjective.Update; MissionObjective *mo = CArrayGet( &gMission.missionData->Objectives, e->u.UpdateObjective.ObjectiveIndex); switch (mo->Type) { case OBJECTIVE_COLLECT: { GameEvent e1; e1.Type = GAME_EVENT_SCORE; e1.u.Score.PlayerIndex = e->u.UpdateObjective.PlayerIndex; e1.u.Score.Score = PICKUP_SCORE; HandleGameEvent(&e1, hud, shake, hp, eventHandlers); } break; case OBJECTIVE_DESTROY: { GameEvent e1; e1.Type = GAME_EVENT_SCORE; e1.u.Score.PlayerIndex = e->u.UpdateObjective.PlayerIndex; e1.u.Score.Score = OBJECT_SCORE; HandleGameEvent(&e1, hud, shake, hp, eventHandlers); } break; default: // No other special objective handling break; } // Display a text update effect for the objective HUDAddObjectiveUpdate( hud, e->u.UpdateObjective.ObjectiveIndex, e->u.UpdateObjective.Update); MissionSetMessageIfComplete(&gMission); } break; case GAME_EVENT_MISSION_COMPLETE: HUDDisplayMessage(hud, "Mission complete", -1); hud->showExit = true; MapShowExitArea(&gMap); break; case GAME_EVENT_MISSION_INCOMPLETE: gMission.state = MISSION_STATE_PLAY; break; case GAME_EVENT_MISSION_PICKUP: gMission.state = MISSION_STATE_PICKUP; gMission.pickupTime = gMission.time; SoundPlay(&gSoundDevice, StrSound("whistle")); break; case GAME_EVENT_MISSION_END: gMission.isDone = true; break; default: assert(0 && "unknown game event"); break; } }
void CLaser::DoBounce() { m_EvalTick = Server()->Tick(); if(m_Energy < 0) { if (m_ExtraInfo == DOOMROCKETS) { CSuperexplosion *S = new CSuperexplosion(&GameServer()->m_World, m_Pos, m_Owner, WEAPON_RIFLE, 2); GameServer()->m_World.InsertEntity(S); } GameServer()->m_World.DestroyEntity(this); return; } vec2 To = m_Pos + m_Dir * m_Energy; if(GameServer()->Collision()->IntersectLine(m_Pos, To, 0x0, &To)) { if(!HitCharacter(m_Pos, To)) { if(!HitBuilding(m_Pos, To)) { if(!HitMonster(m_Pos, To)) { // intersected m_From = m_Pos; m_Pos = To; vec2 TempPos = m_Pos; vec2 TempDir = m_Dir * 4.0f; GameServer()->Collision()->MovePoint(&TempPos, &TempDir, 1.0f, 0); m_Pos = TempPos; m_Dir = normalize(TempDir); m_Energy -= distance(m_From, m_Pos) + GameServer()->Tuning()->m_LaserBounceCost; m_Bounces++; if(m_Bounces > 2) m_Energy = -1; GameServer()->CreateSound(m_Pos, SOUND_LASER_BOUNCE); } } } } else { if(!HitCharacter(m_Pos, To)) { if(!HitBuilding(m_Pos, To)) { if(!HitMonster(m_Pos, To)) { m_From = m_Pos; m_Pos = To; m_Energy = -1; } } } } }
void CLaser::DoBounce() { m_EvalTick = Server()->Tick(); if(m_Energy < 0) { GameServer()->m_World.DestroyEntity(this); return; } m_PrevPos = m_Pos; vec2 Coltile; int Res; int z; if (m_WasTele) { m_PrevPos = m_TelePos; m_Pos = m_TelePos; m_TelePos = vec2(0,0); } vec2 To = m_Pos + m_Dir * m_Energy; Res = GameServer()->Collision()->IntersectLineTeleWeapon(m_Pos, To, &Coltile, &To, &z); if(Res) { if(!HitCharacter(m_Pos, To)) { // intersected m_From = m_Pos; m_Pos = To; vec2 TempPos = m_Pos; vec2 TempDir = m_Dir * 4.0f; int f = 0; if(Res == -1) { f = GameServer()->Collision()->GetTile(round_to_int(Coltile.x), round_to_int(Coltile.y)); GameServer()->Collision()->SetCollisionAt(round_to_int(Coltile.x), round_to_int(Coltile.y), TILE_SOLID); } GameServer()->Collision()->MovePoint(&TempPos, &TempDir, 1.0f, 0); if(Res == -1) { GameServer()->Collision()->SetCollisionAt(round_to_int(Coltile.x), round_to_int(Coltile.y), f); } m_Pos = TempPos; m_Dir = normalize(TempDir); if (!m_TuneZone) m_Energy -= distance(m_From, m_Pos) + GameServer()->Tuning()->m_LaserBounceCost; else m_Energy -= distance(m_From, m_Pos) + GameServer()->TuningList()[m_TuneZone].m_LaserBounceCost; if (Res == TILE_TELEINWEAPON && ((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]; m_WasTele = true; } else { m_Bounces++; m_WasTele = false; } int BounceNum = GameServer()->Tuning()->m_LaserBounceNum; if (m_TuneZone) BounceNum = GameServer()->TuningList()[m_TuneZone].m_LaserBounceNum; if(m_Bounces > BounceNum) m_Energy = -1; GameServer()->CreateSound(m_Pos, SOUND_RIFLE_BOUNCE, m_TeamMask); } } else { if(!HitCharacter(m_Pos, To)) { m_From = m_Pos; m_Pos = To; m_Energy = -1; } } //m_Owner = -1; }
void CPlasma::Tick() { if(m_Energy < 0 || GameLayerClipped(m_Pos)) { if (GameServer()->m_apPlayers[m_Owner] && m_Limit) GameServer()->m_apPlayers[m_Owner]->m_Mine -= GameServer()->m_apPlayers[m_Owner]->m_Mine > 0 ? 1 : 0; GameServer()->m_World.DestroyEntity(this); return; } vec2 To = m_Pos + (m_Dir * m_Vel); m_Energy -= distance(m_Pos, To); if ( !GameServer()->m_pEventsGame->IsActualEvent(WEAPON_SLOW) ) m_Vel += 0.5f; else m_Vel += 0.01f; vec2 At; CTeleporter *pTeleporter = (CTeleporter *)GameServer()->m_World.IntersectEntity(m_Pos, To, 12.0f, At, CGameWorld::ENTTYPE_TELEPORTER); if (pTeleporter && pTeleporter->GetNext()) { if(!HitCharacter(m_Pos, To)) m_Pos = pTeleporter->GetNext()->m_Pos + (m_Dir * 20.0f); } else if(!GameServer()->m_pEventsGame->IsActualEvent(BULLET_PIERCING) && !GameServer()->m_pEventsGame->IsActualEvent(BULLET_GLUE) && GameServer()->Collision()->IntersectLine(m_Pos, To, 0x0, &To)) { if(!HitCharacter(m_Pos, To)) { // intersected m_Pos = To; vec2 TempPos = m_Pos; vec2 TempDir = m_Dir * 4.0f; GameServer()->Collision()->MovePoint(&TempPos, &TempDir, 1.0f, 0); m_Pos = TempPos; m_Dir = normalize(TempDir); m_Bounces++; m_Energy -= GameServer()->Tuning()->m_LaserBounceCost; if(m_Bounces > GameServer()->Tuning()->m_LaserBounceNum) m_Energy = -1; GameServer()->CreateSound(m_Pos, SOUND_RIFLE_BOUNCE); GameServer()->CreateExplosion(m_Pos, m_Owner, WEAPON_RIFLE, false, false); } } else if (GameServer()->m_pEventsGame->IsActualEvent(BULLET_GLUE) && GameServer()->Collision()->IntersectLine(m_Pos, To, 0x0, &To)) { if(!HitCharacter(m_Pos, To)) { m_Pos = To; GameServer()->CreateSound(m_Pos, SOUND_RIFLE_BOUNCE); GameServer()->CreateExplosion(m_Pos, m_Owner, WEAPON_RIFLE, false, false); } } else { if(!HitCharacter(m_Pos, To)) { m_Pos = To; } } }