mirror of
https://github.com/MrOkiDoki/BattleBit-Community-Server-API.git
synced 2025-01-09 11:17:30 -03:00
Zombie Example
This commit is contained in:
parent
aa32ced799
commit
aea0de1eb6
1 changed files with 81 additions and 21 deletions
102
Program.cs
102
Program.cs
|
@ -16,38 +16,98 @@ class Program
|
|||
}
|
||||
class MyPlayer : Player<MyPlayer>
|
||||
{
|
||||
public int NumberOfKills;
|
||||
public bool IsZombie;
|
||||
}
|
||||
class MyGameServer : GameServer<MyPlayer>
|
||||
{
|
||||
public WeaponItem[] WeaponList = new WeaponItem[]
|
||||
{
|
||||
new WeaponItem(){ Tool = Weapons.M4A1, MainSight = Attachments._6xScope},
|
||||
new WeaponItem(){ Tool = Weapons.SVD, MainSight = Attachments._6xScope},
|
||||
new WeaponItem(){ Tool = Weapons.SCARH, MainSight = Attachments._6xScope},
|
||||
new WeaponItem(){ Tool = Weapons.ScorpionEVO, MainSight = Attachments._6xScope},
|
||||
new WeaponItem(){ Tool = Weapons.M249, MainSight = Attachments._6xScope},
|
||||
new WeaponItem(){ Tool = Weapons.Groza, MainSight = Attachments._6xScope},
|
||||
new WeaponItem(){ Tool = Weapons.Glock18, MainSight = Attachments._6xScope},
|
||||
};
|
||||
|
||||
public override async Task OnTick()
|
||||
public override async Task OnRoundStarted()
|
||||
{
|
||||
}
|
||||
public override async Task OnRoundEnded()
|
||||
{
|
||||
if (this.RoundSettings.State == GameState.WaitingForPlayers)
|
||||
ForceStartGame();
|
||||
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
|
||||
public override async Task<OnPlayerSpawnArguments> OnPlayerSpawning(MyPlayer player, OnPlayerSpawnArguments request)
|
||||
public override async Task OnPlayerConnected(MyPlayer player)
|
||||
{
|
||||
request.Loadout.PrimaryWeapon = WeaponList[player.NumberOfKills];
|
||||
return request;
|
||||
bool anyZombiePlayer = false;
|
||||
foreach (var item in AllPlayers)
|
||||
{
|
||||
if (item.IsZombie)
|
||||
{
|
||||
anyZombiePlayer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!anyZombiePlayer)
|
||||
{
|
||||
player.IsZombie = true;
|
||||
player.Message("You are the zombie.");
|
||||
player.Kill();
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task OnAPlayerKilledAnotherPlayer(OnPlayerKillArguments<MyPlayer> args)
|
||||
{
|
||||
args.Killer.NumberOfKills++;
|
||||
args.Killer.SetPrimaryWeapon(WeaponList[args.Killer.NumberOfKills], 0);
|
||||
if (args.Victim.IsZombie)
|
||||
{
|
||||
args.Victim.IsZombie = false;
|
||||
args.Victim.Message("You are no longer zombie");
|
||||
|
||||
AnnounceShort("Choosing new zombie in 5");
|
||||
await Task.Delay(1000);
|
||||
AnnounceShort("Choosing new zombie in 4");
|
||||
await Task.Delay(1000);
|
||||
AnnounceShort("Choosing new zombie in 3");
|
||||
await Task.Delay(1000);
|
||||
AnnounceShort("Choosing new zombie in 2");
|
||||
await Task.Delay(1000);
|
||||
AnnounceShort("Choosing new zombie in 1");
|
||||
await Task.Delay(1000);
|
||||
|
||||
args.Killer.IsZombie = true;
|
||||
args.Killer.SetHeavyGadget(Gadgets.SledgeHammer.ToString(), 0, true);
|
||||
|
||||
var position = args.Killer.GetPosition();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override async Task<OnPlayerSpawnArguments> OnPlayerSpawning(MyPlayer player, OnPlayerSpawnArguments request)
|
||||
{
|
||||
if (player.IsZombie)
|
||||
{
|
||||
request.Loadout.PrimaryWeapon = default;
|
||||
request.Loadout.SecondaryWeapon = default;
|
||||
request.Loadout.LightGadget = null;
|
||||
request.Loadout.HeavyGadget = Gadgets.SledgeHammer;
|
||||
request.Loadout.Throwable = null;
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
public override async Task OnPlayerSpawned(MyPlayer player)
|
||||
{
|
||||
if(player.IsZombie)
|
||||
{
|
||||
player.SetRunningSpeedMultiplier(2f);
|
||||
player.SetJumpMultiplier(2f);
|
||||
player.SetFallDamageMultiplier(0f);
|
||||
player.SetReceiveDamageMultiplier(0.1f);
|
||||
player.SetGiveDamageMultiplier(4f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override async Task OnConnected()
|
||||
{
|
||||
await Console.Out.WriteLineAsync("Current state: " + RoundSettings.State);
|
||||
|
||||
}
|
||||
public override async Task OnGameStateChanged(GameState oldState, GameState newState)
|
||||
{
|
||||
await Console.Out.WriteLineAsync("State changed to -> " + newState);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue