private void Shoot(int interval, int count, string method, string id) { IObjectTimerTrigger timerTrigger = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger"); timerTrigger.SetIntervalTime(interval); timerTrigger.SetRepeatCount(count); timerTrigger.SetScriptMethod(method); timerTrigger.CustomId = id; timerTrigger.Trigger(); }
public static IObjectTimerTrigger SetTimer(string met, string id, int times, int delay) { tTrigger = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger"); tTrigger.CustomId = id; tTrigger.SetScriptMethod(met); tTrigger.SetIntervalTime(delay); tTrigger.SetRepeatCount(times); tTrigger.Trigger(); return(tTrigger); }
/// <summary> /// Creates a new trigger /// </summary> /// <param name="interval">The interval at which the trigger will run</param> /// <param name="count">How many times the trigger will round (0 for infinite times)</param> /// <param name="method">The name of the method that is going to be called when the trigger executes</param> /// <param name="id">The id for the trigger</param> private void CreateTrigger(int interval, int count, string method, string id = "") { IObjectTimerTrigger timerTrigger = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger"); timerTrigger.SetIntervalTime(interval); timerTrigger.SetRepeatCount(count); timerTrigger.SetScriptMethod(method); timerTrigger.CustomId = id; timerTrigger.Trigger(); timerTrigger.SetWorldPosition(Game.GetSingleObjectByCustomId("TriggersPosition").GetWorldPosition()); }
private IObjectTimerTrigger CreateTimer(int interval, int count, string method, bool trigger) { IObjectTimerTrigger trig = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger"); trig.SetIntervalTime(interval); trig.SetRepeatCount(count); trig.SetScriptMethod(method); if (trigger) { trig.Trigger(); } return(trig); }
public void OnStartup() { bool success = Int32.TryParse(Game.Data, out GamesPlayed); if (!success) { GamesPlayed = 0; } else { GamesPlayed++; } Game.RunCommand("/MSG This script has been running for " + GamesPlayed + " maps"); IObjectTimerTrigger Timer = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger"); Timer.SetIntervalTime(1000); Timer.SetRepeatCount(0); Timer.SetScriptMethod("ShowGameDotData"); Timer.Trigger(); }
public void OnStartup() { m_rnd = new Random((int)DateTime.Now.Millisecond * (int)DateTime.Now.Minute * 1000); if (Game.IsFirstUpdate) { CheckMessage(); m_minute = DateTime.Now.Minute; if (m_minute >= 30) { m_minute -= 30; } BalanceTeams(false); // after 3 seconds - rebalance teams if anyone left. IObjectTimerTrigger timer = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger"); timer.SetRepeatCount(2); timer.SetIntervalTime(1000); timer.SetScriptMethod("RecheckBalance"); timer.Trigger(); } }
public void OnPlayerKeyInput(IPlayer player, VirtualKeyInfo[] keyEvents) { for (int i = 0; i < keyEvents.Length; i++) { // Game.WriteToConsole(string.Format("Player {0} keyevent: {1}", player.UniqueID, keyEvents[i].ToString())); // TP HALE to some position if HALE presses DOWN + BLOCK and cooldown is gone if (keyEvents[i].Event == VirtualKeyEvent.Pressed && keyEvents[i].Key == VirtualKey.BLOCK && player.KeyPressed(VirtualKey.CROUCH_ROLL_DIVE)) { if (player == HALE && (Game.TotalElapsedGameTime - lastTeleported) > tpCooldown && tpEnabled == true) { lastTeleported = Game.TotalElapsedGameTime; if (HALENAMES[HALETYPE] == "Sin Feaster") { TeleportHaleToPlayers(); HALE.SetInputEnabled(false); HaleMovementStopper.Trigger(); } break; } else if (player == HALE && (Game.TotalElapsedGameTime - lastWarudod) > warudoCooldown && warudoEnabled == true) { lastWarudod = Game.TotalElapsedGameTime; IPlayer[] players = Game.GetPlayers(); foreach (IPlayer plr in players) { if (plr != HALE) { plr.SetInputEnabled(false); Game.PlaySound("ChurchBell1", plr.GetWorldPosition(), 1); } } Game.RunCommand("/SLOMO " + "1"); PlayerMovementStopper.Trigger(); } } } }
private void SetHale() { IPlayer[] players = Game.GetPlayers(); foreach (IPlayer plr in players) { plr.SetTeam(PlayerTeam.Team1); PlayerModifiers plrmodifier = plr.GetModifiers(); plrmodifier.MaxHealth = -2; plrmodifier.MaxEnergy = -2; plrmodifier.CurrentHealth = -2; plrmodifier.EnergyRechargeModifier = -2; plrmodifier.SizeModifier = -2; plrmodifier.SprintSpeedModifier = -2; plrmodifier.RunSpeedModifier = -2; plrmodifier.MeleeForceModifier = -2; plrmodifier.MeleeDamageDealtModifier = -2; plrmodifier.MeleeDamageTakenModifier = -2; plr.SetModifiers(plrmodifier); } // Check if Local Storage contains needed items (halecandidates and last_hale) if (!Game.LocalStorage.ContainsKey("halecandidates")) { Game.RunCommand("/MSG " + "Local storage doesn't contain the 'halecandidates' key, so let's add it."); SetHaleCandidates(); } if (!Game.LocalStorage.ContainsKey("last_hale")) { Game.RunCommand("/MSG " + "Local storage doesn't contain the 'last_hale' key, so let's add it"); Game.LocalStorage.SetItem("last_hale", players[0].Name); } string[] haleCandidates = (string[])Game.LocalStorage.GetItem("halecandidates"); // Synchronize haleCandidates queue to the players currently in server SynchronizeHaleCandidates(players, haleCandidates); string next_hale_name = haleCandidates[(m_rnd.Next(((int)DateTime.Now.Millisecond * (int)DateTime.Now.Minute * 1000)) + (int)DateTime.Now.Millisecond) % haleCandidates.Length]; IPlayer next_hale = players[0]; int next_type = (m_rnd.Next(0, ((int)DateTime.Now.Millisecond * (int)DateTime.Now.Minute * 1000)) + (int)DateTime.Now.Millisecond) % (HALENAMES.Length); int random_index = 0; if (!MODE) { // Check if storage contains last_hale. If it does make sure that same person isn't hale again. bool chooseAgain = false; do { chooseAgain = false; next_hale_name = haleCandidates[(m_rnd.Next(((int)DateTime.Now.Millisecond * (int)DateTime.Now.Minute * 1000) + random_index) + (int)DateTime.Now.Millisecond) % haleCandidates.Length]; if ((string)Game.LocalStorage.GetItem("last_hale") == next_hale_name) { Game.RunCommand("/MSG " + "Sama hale kuin viimeksi --> vaihtoon"); chooseAgain = true; } foreach (IPlayer plr in players) { if (plr.Name == next_hale_name) { next_hale = plr; } } random_index++; } while (chooseAgain & random_index < 10); // Delete new hale from halecandidates and update 'last_hale' in localstorage EraseFromHaleCandidates(next_hale_name); } HALE = next_hale; HALETYPE = next_type; HALETYPE = 4; HALE.SetTeam(PlayerTeam.Team2); // Calculating hale HP based on playeramount and getting the modifier for HALE to apply changes PlayerModifiers modify = HALE.GetModifiers(); int haleHP; int hpConstant = 150; if (MODE) { haleHP = 500; } else { if (players.Length <= 4) { haleHP = (players.Length - 1) * hpConstant; } else { haleHP = 4 * hpConstant + (players.Length - 4) * hpConstant / 2; } } lastHaleHp = haleHP; Game.RunCommand("/MSG " + " - - - Minä olen hirmuinen " + HALENAMES[HALETYPE] + " - - - "); // Setting HALE modifiers switch (HALETYPE) { // SetHaleModifiers( modify, HP, sprintSpeed, runSpeed, meleeForce, meleeDamageDealt, meleeDamageTaken ) // Saxton Fale; case 0: SetHaleClothing(ref HALE); SetHaleModifiers(ref modify, haleHP, 1.5f, 1.5f, 3f, 8f, 2f); HALE.SetModifiers(modify); break; // Sin Feaster case 1: SetSinClothing(ref HALE); tpEnabled = true; tpCooldown = 20000; SetHaleModifiers(ref modify, haleHP, 1.2f, 1.2f, 2f, 5f, 1.5f); HALE.SetModifiers(modify); break; // Speedy Fale case 2: SetSpeedClothing(ref HALE); SetHaleModifiers(ref modify, haleHP, 2f, 2f, 6f, 0.001f, 1f); HALE.SetModifiers(modify); break; // DIO case 3: warudoEnabled = true; warudoCooldown = 10000; SetDIOClothing(ref HALE); SetHaleModifiers(ref modify, haleHP, 1.2f, 1.2f, 3f, 3f, 2f); HALE.SetModifiers(modify); break; // Sick F**k case 4: SetTeam(HALETYPE); zombifyHumansOnDeath = true; SetSickClothing(ref HALE); SetHaleModifiers(ref modify, haleHP / 2, 1.5f, 1.5f, 2f, 3f, 1.5f); HALE.SetModifiers(modify); ReanimateTrigger.Trigger(); break; } // Activate HALE triggers if (MODE) { Game.RunCommand("/INFINITE_AMMO 1"); Game.RunCommand("/GIVE 0 shuriken"); } else { HALE.SetInputEnabled(false); HaleStartCooldown.Trigger(); RemoveHaleItemsTimer.Trigger(); } DisplayHaleStatusTimer.Trigger(); }
public void Fast(TriggerArgs args) { foreach (IObject missile in Game.GetMissileObjects()) { if (missile is IObjectWeaponItem) { float speed = 100; if ((speed > 1 || ((IObjectWeaponItem)missile).WeaponItemType == WeaponItemType.Rifle) && !(missile.CustomId == "ScriptMarkedMissile") && (!(ThrownWeapons.Contains(missile.Name)) || AccelerateThrownWeapons) && !DisableThrowning) { missile.SetLinearVelocity(missile.GetLinearVelocity() * ThrowSpeedMultiply); missile.CustomId = "ScriptMarkedMissile"; if ((CreateFireCircleOnImpact || CreateExplosionOnImpact)) { IObjectTargetObjectJoint targetjoint = (IObjectTargetObjectJoint)Game.CreateObject("TargetObjectJoint", missile.GetWorldPosition(), 0f, missile.GetLinearVelocity(), missile.GetAngularVelocity()); targetjoint.SetTargetObject(missile); targetjoint.CustomId = "destructjoint"; } if (CreateRandomImpact && Rnd.Next(0, RandomProb) == 0) { int x = Rnd.Next(0, 25); IObjectTargetObjectJoint targetjoint = (IObjectTargetObjectJoint)Game.CreateObject("TargetObjectJoint", missile.GetWorldPosition(), 0f, missile.GetLinearVelocity(), missile.GetAngularVelocity()); targetjoint.SetTargetObject(missile); if (x < 25) { targetjoint.CustomId = "Minejoint"; missile.SetLinearVelocity(missile.GetLinearVelocity() * 1.5f); IObjectTimerTrigger Timer = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger"); Timer.SetIntervalTime(500); Timer.SetRepeatCount(1); Timer.SetScriptMethod("Mine"); Timer.Trigger(); } if (x >= 9 && x < 15) { targetjoint.CustomId = "Grenadejoint"; missile.SetLinearVelocity(missile.GetLinearVelocity() * 1.5f); IObjectTimerTrigger Timer = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger"); Timer.SetIntervalTime(250); Timer.SetRepeatCount(1); Timer.SetScriptMethod("grenade"); Timer.Trigger(); } if (x >= 3 && x < 9) { targetjoint.CustomId = "Bazookajoint"; missile.SetLinearVelocity(missile.GetLinearVelocity() * 1.5f); IObjectTimerTrigger Timer = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger"); Timer.SetIntervalTime(250); Timer.SetRepeatCount(1); Timer.SetScriptMethod("bazooka"); Timer.Trigger(); } if (x <= 2) { targetjoint.CustomId = "Electricjoint"; missile.SetLinearVelocity(missile.GetLinearVelocity() * 1.5f); } } if (IncreaseMeleeWeaponMass && ((IObjectWeaponItem)missile).WeaponItemType == WeaponItemType.Melee) { missile.SetMass((float)0.8); } } if ((CreateFireCircleOnImpact || CreateExplosionOnImpact) && speed < 4 && missile.CustomId == "ScriptMarkedMissile") { missile.TrackAsMissile(false); } if (DisableThrownWeaponsCollision || DisableThrowning) { if (ThrownWeapons.Contains(missile.Name)) { missile.TrackAsMissile(false); } } if (DisableThrowning) { missile.TrackAsMissile(false); if (speed > 5) { missile.SetLinearVelocity(missile.GetLinearVelocity() / 3); } } if (SetMissileOnFire && !DisableThrowning && (missile.CustomId == "ScriptMarkedMissile")) { missile.SetMaxFire(); missile.SetHealth(100); } } } }
/// <summary> /// This method is executed when map starts /// </summary> public void OnStartup() { if (CreateFireCircleOnImpact || CreateExplosionOnImpact || CreateRandomImpact) { /* This timer controls fire circles, explosions on impact and/or random impacts */ IObjectTimerTrigger Timer0 = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger"); Timer0.SetIntervalTime(75); Timer0.SetRepeatCount(0); Timer0.SetScriptMethod("VeryFast"); Timer0.Trigger(); } IObjectTimerTrigger Timer = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger"); Timer.SetIntervalTime(100); Timer.SetRepeatCount(0); Timer.SetScriptMethod("Fast"); Timer.Trigger(); IObjectTimerTrigger Timer2 = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger"); Timer2.SetIntervalTime(400); if (CreateRandomImpact) { Timer2.SetIntervalTime(100); } Timer2.SetRepeatCount(0); Timer2.SetScriptMethod("Slow"); Timer2.Trigger(); if (GiveWeaponDefault) { Game.WriteToConsole("Weapon " + GiveWeaponDefault.ToString() + " is going to be given to players!"); IObjectTimerTrigger Timer3 = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger"); Timer3.SetIntervalTime(15000); Timer3.SetRepeatCount(0); if (ThrownWeaponsClass.Contains(DefaultWeapon)) { // Chosen weapon is a thrown weapon. Timer3.SetScriptMethod("MidOne"); } if (RifleWeaponsClass.Contains(DefaultWeapon)) { // Chosen weapon is a rifle. Timer3.SetScriptMethod("MidTwo"); } if (HandWeaponsClass.Contains(DefaultWeapon)) { // Chosen weapon is a hand weapon. Timer3.SetScriptMethod("MidThree"); } if (MeleeWeaponsClass.Contains(DefaultWeapon)) { // Chosen weapon is a melee weapon. Timer3.SetScriptMethod("MidFour"); } if (MakeShiftWeaponsClass.Contains(DefaultWeapon)) { // Chosen weapon is a throwable weak weapon. Timer3.SetScriptMethod("MidFive"); } Timer3.Trigger(); } }