Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TSCBaseGuardian extends TSCTeamBase;
- var UnrealTeamInfo Team;
- var int Damage; // damage per seconds that Base Guardian does to enemies
- var int SameTeamCounter; // if nobody of team members are at the base longer than this value, base will be lost
- var TSCGameReplicationInfo TSCGRI;
- var localized string strUseMessage;
- var localized string strUsedMessage;
- var localized string strCarryHintMessage;
- var localized string strITookTheGnome;
- var transient float LastTouchTime;
- replication
- {
- reliable if (bNetDirty && Role == ROLE_Authority)
- Team;
- }
- simulated function PostBeginPlay()
- {
- TSCGRI = TSCGameReplicationInfo(Level.GRI);
- //log("TSCGRI = " $ TSCGRI, 'TSCBaseGuardian');
- super.PostBeginPlay();
- }
- simulated function PostNetReceive()
- {
- if ( Role < ROLE_Authority ) {
- if ( bHeld && Base != none ) {
- // lame replication fix
- SetRelativeLocation(GameObjOffset);
- SetRelativeRotation(GameObjRot);
- }
- }
- }
- function UsedBy( Pawn user )
- {
- if (!ValidHolder(user))
- return;
- SetHolder(user.Controller);
- }
- function SetHolder(Controller C)
- {
- local PlayerController PC;
- super.SetHolder(C);
- PC = PlayerController(C);
- if ( PC != none) {
- //PC.ClientMessage(class'TSCGame'.static.ParseLoadingHintNoColor(strCarryHintMessage, PC));
- PC.ClientMessage(strUsedMessage, 'CriticalEvent');
- PC.TeamSay(strITookTheGnome);
- }
- }
- simulated function vector GetLocation()
- {
- if ( bHeld ) {
- if ( Base != none && !Base.bWorldGeometry )
- return Base.Location;
- else if ( HolderPRI != none && Controller(HolderPRI.Owner).Pawn != none )
- return Controller(HolderPRI.Owner).Pawn.Location;
- }
- return Location;
- }
- singular function Touch(Actor Other)
- {
- if (!ValidHolder(Other))
- return;
- if ( Pawn(Other) != none && PlayerController(Pawn(Other).Controller) != none) {
- if ( Level.TimeSeconds - LastTouchTime > 1 )
- PlayerController(Pawn(Other).controller).ClientMessage(strUseMessage, 'CriticalEvent');
- LastTouchTime = Level.TimeSeconds;
- }
- }
- function bool SameTeam(Controller c)
- {
- if ( c == None || c.PlayerReplicationInfo == none || c.PlayerReplicationInfo.Team != Team )
- return false;
- return true;
- }
- function bool ValidHolder(Actor Other)
- {
- local Pawn p;
- if( bDisabled || bActive || bHome || bHeld )
- return false;
- p = Pawn(other);
- if ( p == None || p.Health <= 0 || !p.bCanPickupInventory || !p.IsPlayerPawn() )
- return false;
- if ( !SameTeam(p.Controller) )
- return false;
- if ( TSCGRI.TeamCarrier[Team.TeamIndex] != none ) {
- if ( TSCGRI.TeamCarrier[Team.TeamIndex].Team != Team )
- TSCGRI.TeamCarrier[Team.TeamIndex] = none; // carrier changed team
- else
- return p.PlayerReplicationInfo == TSCGRI.TeamCarrier[Team.TeamIndex]
- || p.PlayerReplicationInfo == TSCGRI.TeamCaptain[Team.TeamIndex];
- }
- return true;
- }
- function bool ValidPlaceForBase(Vector BaseLocation)
- {
- return !TSCGRI.AtBase(BaseLocation, TSCGRI.Teams[1-Team.TeamIndex].HomeBase);
- }
- // Score() is used for setting up base
- function Score()
- {
- local vector CheckLoc;
- if ( bDisabled || bActive )
- return;
- CheckLoc = Location;
- if ( !ValidPlaceForBase(CheckLoc) )
- return;
- // check for Z difference to prevent vertical intersection
- CheckLoc.Z += TSCGRI.MaxBaseZ + TSCGRI.MinBaseZ;
- if ( !ValidPlaceForBase(CheckLoc) ) {
- if ( Holder != none && PlayerController(Holder.Controller) != none )
- PlayerController(Holder.Controller).ReceiveLocalizedMessage(class'TSCMessages', 210);
- return;
- }
- GotoState('SettingUp');
- }
- function MoveToShop(ShopVolume Shop)
- {
- local int i;
- if ( !Shop.bTelsInit )
- Shop.InitTeleports();
- if ( Shop.TelList.Length == 1 ) {
- // from stupid maps with only 1 player teleport per trader
- if ( Shop.TelList[0].Accept(self, Shop) ) {
- GotoState('Dropped');
- return;
- }
- }
- else {
- for ( i=Team.TeamIndex; i<Shop.TelList.Length; ++i ) {
- if ( Shop.TelList[i].Accept(self, Shop) ) {
- GotoState('Dropped');
- return;
- }
- }
- }
- // foreach AllActors(class'LevelDesigner', LD)
- // if ( LD.MadeThisMap() )
- // LD.CutHisBallsOffAndFeedToZeds();
- // if none of teleporters can accept us, just give me to the closest team member
- GiveToClosestPlayer(Shop.Location);
- }
- function GiveToClosestPlayer(vector Loc)
- {
- local Controller C, Best;
- local float BestDistSqr;
- for ( C = Level.ControllerList; C != none; C = C.nextController ) {
- if ( C.bIsPlayer && C.Pawn != none && ValidHolder(C.Pawn) ) {
- if ( Best == none || VSizeSquared(C.Pawn.Location - Loc) < BestDistSqr )
- Best = C;
- }
- }
- if ( Best != none ) {
- GotoState('Dropped');
- SetHolder(Best);
- }
- }
- function SuddenDeathWipe()
- {
- local TSCGame game;
- game = TSCGame(Level.Game);
- if ( TSCGRI.bSuddenDeath && game != none && game.bWaveInProgress && (game.TotalMaxMonsters > 0 || game.NumMonsters >= 10) )
- game.WipeTeam(Team);
- }
- auto state Home
- {
- function BeginState()
- {
- Disable('Touch');
- SetCollision(false, false);
- bCollideWorld=false;
- bHome = true;
- bHidden = true;
- LightType = LT_None;
- }
- function EndState()
- {
- bHome = false;
- bHidden = false;
- TakenTime = Level.TimeSeconds;
- }
- function CheckTouching() {}
- }
- state Dropped
- {
- function BeginState()
- {
- SetCollision(true, false);
- bCollideWorld=True;
- bHidden = false;
- LightType = LT_Pulse;
- Enable('Touch');
- super.BeginState();
- }
- }
- state Held
- {
- function BeginState()
- {
- super.BeginState();
- Holder.bAlwaysRelevant = true;
- }
- function EndState()
- {
- if ( Holder != none )
- Holder.bAlwaysRelevant = false;
- super.EndState();
- }
- function SendHome() // unignore
- {
- global.SendHome();
- }
- }
- state SettingUp
- {
- ignores Score, Touch, UsedBy;
- function BeginState()
- {
- bActive = true;
- Disable('Touch');
- SetCollision(true, false);
- bCollideWorld=true;
- SetPhysics(PHYS_Falling);
- LightType = LT_Pulse;
- SetTimer(10, false); // just in case
- NetUpdateTime = Level.TimeSeconds - 1; // replicate immediately
- }
- function EndState()
- {
- bActive = false;
- SetTimer(0, false);
- }
- event Landed( vector HitNormal )
- {
- local rotator r;
- r = Rotation;
- r.Pitch = 0;
- r.Roll = 0;
- SetRotation(r);
- SetPhysics(PHYS_Rotating);
- SetTimer(5, false); // activate the base in 5 seconds
- }
- function Timer()
- {
- GotoState('Guarding');
- }
- }
- state Guarding
- {
- ignores Score;
- function BeginState()
- {
- local rotator r;
- bActive = true;
- Disable('Touch');
- SetCollision(false, false);
- bCollideWorld=false;
- r = Rotation;
- r.Pitch = 0;
- r.Roll = 0;
- SetRotation(r);
- SetPhysics(PHYS_Rotating);
- LightType = LT_Steady;
- SameTeamCounter = default.SameTeamCounter;
- SetTimer(1, true);
- BroadcastLocalizedMessage(class'TSCMessages', 1+Team.TeamIndex*100);
- }
- function EndState()
- {
- bActive = false;
- SetTimer(0, false);
- }
- function Timer()
- {
- local Controller C;
- local bool bNobodyAtBase, bNobodyAlive;
- bNobodyAtBase = true;
- bNobodyAlive = true;
- for ( C = Level.ControllerList; C != none; C = C.nextController ) {
- if ( C.bIsPlayer && C.Pawn != none && C.Pawn.Health > 0
- && C.PlayerReplicationInfo != none )
- {
- if ( C.PlayerReplicationInfo.Team != Team && TSCGRI.AtBase(C.Pawn.Location, self) ) {
- C.Pawn.TakeDamage(Damage, none, C.Pawn.Location, vect(0,0,0), class'DamTypeEnemyBase');
- if ( PlayerController(C) != none && ScrnHumanPawn(C.Pawn) != none
- && ScrnHumanPawn(C.Pawn).NextEnemyBaseDamageMsg < Level.TimeSeconds )
- {
- PlayerController(C).ReceiveLocalizedMessage(class'TSCMessages', 212);
- ScrnHumanPawn(C.Pawn).NextEnemyBaseDamageMsg = Level.TimeSeconds + 6.0;
- }
- }
- else if ( bNobodyAtBase && C.PlayerReplicationInfo.Team == Team ) {
- bNobodyAlive = false;
- if ( TSCGRI.AtBase(C.Pawn.Location, self) )
- bNobodyAtBase = false;
- }
- }
- }
- if ( bNobodyAtBase ) {
- if ( bNobodyAlive || --SameTeamCounter <= 0 ) {
- BroadcastLocalizedMessage(class'TSCMessages', 2+Team.TeamIndex*100);
- SendHome();
- // if some of team members are still alive while the base
- // is lost during Sudden Death - kill them
- //if ( TSCGRI.bSuddenDeath && !bNobodyAlive )
- // SuddenDeathWipe();
- }
- else if ( SameTeamCounter % 3 == 0 ) {
- for ( C = Level.ControllerList; C != none; C = C.nextController ) {
- if ( C.bIsPlayer && C.PlayerReplicationInfo != none
- && PlayerController(C) != none
- && C.Pawn != none && C.Pawn.Health > 0
- && C.PlayerReplicationInfo.Team == Team )
- {
- PlayerController(C).ReceiveLocalizedMessage(class'TSCMessages', 211);
- }
- }
- }
- }
- else {
- SameTeamCounter = default.SameTeamCounter;
- }
- }
- }
- defaultproperties
- {
- strUseMessage="Press USE to take the Base Guardian"
- strUsedMessage="You took the Base Guardian"
- strCarryHintMessage="Carry the Base Guarding to the place where you want to set up the base and press %AltFire% key"
- strITookTheGnome="I took our Base Guardian (Gnome)"
- MaxDropTime=0
- GameObjBone="CHR_Spine3"
- GameObjOffset=(X=0,Y=15,Z=0)
- GameObjRot=(Pitch=-16384,Yaw=0,Roll=0)
- Damage=5
- SameTeamCounter=10
- bCanBeDamaged=False
- LightType=LT_Steady
- LightEffect=LE_QuadraticNonIncidence
- LightRadius=25
- LightSaturation=128
- LightBrightness=150 // 220
- LightPeriod=30
- bStatic=False
- bHidden=True
- bDynamicLight=True
- bStasis=False
- NetPriority=3.000000
- bUnlit=True
- bCollideActors=False
- bCollideWorld=False
- CollisionRadius=15
- CollisionHeight=12
- bUseCylinderCollision=True
- bFixedRotationDir=True
- Mass=30.000000
- Buoyancy=20.000000
- RotationRate=(Yaw=25000)
- MessageClass=Class'UnrealGame.CTFMessage'
- Style=STY_Normal
- DrawType=DT_StaticMesh
- StaticMesh=StaticMesh'HillbillyHorror_SM.GardenGnome'
- DrawScale=1.0
- // fucking replication
- bAlwaysRelevant=true
- bNetNotify=true
- /*
- bReplicateMovement=true
- bSkipActorPropertyReplication=false
- RemoteRole=Role_SimulatedProxy
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement