Advertisement
Guest User

Untitled

a guest
Nov 15th, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.71 KB | None | 0 0
  1. /**
  2. * Annihilation PvE Co-op GameMode
  3. * Author : is died during the game
  4.  
  5. * "Contact" : follow the road to the bottom of the road, access the cemetery and look for it
  6. */
  7.  
  8.  
  9. // ---------------------------------- //
  10.  
  11. // Requirements
  12.  
  13. // ---------------------------------- //
  14.  
  15. #Extends "Modes/ShootMania/ModeBase.Script.txt"
  16.  
  17.  
  18. #Const CompatibleMapTypes "AnnihilationArena"
  19.  
  20. #Const Version "2100-01-01"
  21.  
  22. #Const ScriptName "Annihilation.Script.txt"
  23.  
  24.  
  25. #Include "MathLib" as MathLib
  26.  
  27. #Include "TextLib" as TextLib
  28.  
  29. #Include "Libs/Nadeo/Message.Script.txt" as Message
  30.  
  31. #Include "Libs/Nadeo/Interface.Script.txt" as Interface
  32.  
  33. #Include "Libs/Nadeo/ShootMania/SM.Script.txt" as SM
  34.  
  35. #Include "Libs/Nadeo/ShootMania/Score.Script.txt" as Score
  36.  
  37. #Include "Libs/Nadeo/ShootMania/SpawnScreen.Script.txt" as SpawnScreen
  38.  
  39.  
  40.  
  41. // ---------------------------------- //
  42.  
  43. // Settings
  44.  
  45. // ---------------------------------- //
  46.  
  47.  
  48. //#Setting S_GameMode 0 as _("GameMode : 0 - Rounds, 1 - Survival, 2 - Custom (Enable option below)")
  49. //
  50.  
  51. #Setting S_NbPlayers 6 as _("Number of max players")
  52. #Setting S_NbBots 30 as _("Number of bots total")
  53.  
  54.  
  55. #Setting S_Saunter_Radius 10. as _("Radius of bots from their spawn")
  56.  
  57.  
  58. #Setting S_AggroRadius 50. as _("Radius vision of bots")
  59.  
  60.  
  61. #Setting S_DisengageDistance 30. as _("Distance of disengage from their start")
  62.  
  63. #Setting S_Accuracy 0.6 as _("Accuracy of bots")
  64.  
  65. #Setting S_WeaponNumber 1 as _("Used weapon (1: Laser, 2: Rocket, 3: Nucleus, 4: Arrow, 6: Missile, else: Random)")
  66.  
  67. #Setting S_ArmorMax 4 as _("Max armor of players") // Max armor of players
  68.  
  69. #Setting S_AmmoMax 1. as _("Max ammunition factor") // Max ammunition factor
  70.  
  71. #Setting S_AmmoGain 1.8 as _("Ammunition gain factor") // Speed of ammunition reload
  72.  
  73.  
  74.  
  75.  
  76. // ---------------------------------- //
  77.  
  78. // Constants
  79.  
  80. // ---------------------------------- //
  81.  
  82.  
  83. #Const C_ImgBase "file://ManiaPlanet/Media/Sounds"
  84. #Const C_KillStreakTime 2000 // Time between hits to perform a consecutive kill streak
  85.  
  86. #Const C_AutoSwitchWeapon False // Automatically switch weapons (tunnels & laser pads) - With rockets => AutoTrue
  87.  
  88. #Const C_StaminaFactor 1.0 // Stamina max & reload factor
  89.  
  90. #Const C_DisplayHitDist True // Enable to display the distance when you hit someone
  91.  
  92. #Const C_NearMissDist 0.7 // Max distance to show NearMiss message (-1 to disable the messages)
  93.  
  94. #Const C_AnnounceHeadshots True // Announce headshots with a headshot sound
  95.  
  96. #Const UITickPeriod 200
  97.  
  98. #Const MaxRounds 6
  99.  
  100.  
  101.  
  102. #Const Description _("TYPE: PvE Co-Op\nOBJECTIVE: Kill all bots before they get angry!\nINFOS\$0f0nGreen bots $g: Rocket\$f0cnPurple bots $g: Nucleus\$9ffnBlue bots $g: Laser\$ff0nYellow bots $g: Arrow")
  103.  
  104.  
  105.  
  106. // ---------------------------------- //
  107.  
  108. // Global var
  109.  
  110. // ---------------------------------- //
  111.  
  112. declare CUILayer SoundLayerFirst;
  113.  
  114. declare CUILayer SoundLayerSecond;
  115.  
  116. declare CUILayer MatchInfo;
  117.  
  118.  
  119.  
  120. declare Integer LastHit;
  121.  
  122. declare Integer KillStreak;
  123.  
  124. declare Integer Score;
  125.  
  126. declare Integer TimeLimit;
  127.  
  128. declare Integer Round;
  129.  
  130.  
  131.  
  132.  
  133.  
  134. declare Text GamePhase;
  135.  
  136. declare Boolean CanPlay;
  137.  
  138.  
  139.  
  140. declare Integer _LatestUITickLayerTeam;
  141.  
  142. declare CUILayer _LayerTeam;
  143.  
  144. declare Text[Ident] _PlayerManialinkLines;
  145.  
  146.  
  147.  
  148. // ---------------------------------- //
  149.  
  150. // Set rules
  151.  
  152. // ---------------------------------- //
  153.  
  154. ***Rules***
  155.  
  156. ***
  157.  
  158. declare ModeName = "Annihilation";
  159.  
  160. declare ModeRules = TextLib::Compose(_("Kill all bots in the map before they get angry\$0f0nGreen bots $g: Rocket\$f0cnPurple bots $g: Nucleus\$9ffnBlue bots $g: Laser\$ff0nYellow bots $g: Arrow"), "$"^SpawnScreen::GetModeColor());
  161.  
  162. SpawnScreen::ResetRulesSection();
  163.  
  164. SpawnScreen::AddSubsection(_("Annihilation - PvE Co-Op Gamemode"), ModeRules, 20.);
  165.  
  166. SpawnScreen::CreatePrettyRules(ModeName);
  167.  
  168. ModeStatusMessage = _("TYPE: PvE Co-Op\nOBJECTIVE: Kill all bots before they get angry!\nINFOS\$0f0nGreen bots $g: Rocket\$f0cnPurple bots $g: Nucleus\$9ffnBlue bots $g: Laser\$ff0nYellow bots $g: Arrow");
  169.  
  170. ***
  171.  
  172.  
  173.  
  174. // ---------------------------------- //
  175.  
  176. // Server start
  177.  
  178. // ---------------------------------- //
  179.  
  180. ***StartServer***
  181.  
  182. ***
  183.  
  184. SoundLayerFirst = UIManager.UILayerCreate();
  185.  
  186. UIManager.UIAll.UILayers.add(SoundLayerFirst);
  187.  
  188. SoundLayerFirst.ManialinkPage = """
  189.  
  190. """;
  191.  
  192.  
  193.  
  194. SoundLayerSecond = UIManager.UILayerCreate();
  195.  
  196. UIManager.UIAll.UILayers.add(SoundLayerSecond);
  197.  
  198. SoundLayerSecond.ManialinkPage = """
  199.  
  200. """;
  201.  
  202.  
  203.  
  204. MatchInfo = UIManager.UILayerCreate();
  205.  
  206. UIManager.UIAll.UILayers.add(MatchInfo);
  207.  
  208. MatchInfo.ManialinkPage = """
  209.  
  210. """;
  211.  
  212.  
  213.  
  214. //Layer Team
  215.  
  216. _LayerTeam = UIManager.UILayerCreate();
  217.  
  218. UIManager.UIAll.UILayers.add(_LayerTeam);
  219.  
  220. _LayerTeam.ManialinkPage = """
  221.  
  222. """;
  223.  
  224. // ---------------------------------- //
  225.  
  226. // Set mode options
  227.  
  228. UseClans = True;
  229.  
  230. UseAllies = True;
  231.  
  232. // ---------------------------------- //
  233.  
  234. // Create the rules
  235.  
  236. ---Rules---
  237.  
  238.  
  239.  
  240. // ---------------------------------- //
  241.  
  242. // Initialize UI
  243.  
  244. SpawnScreen::CreateScores("Score.RoundPoints");
  245.  
  246. SpawnScreen::CreateMapInfo();
  247.  
  248. //Interface::CreateRank();
  249.  
  250.  
  251.  
  252. // ---------------------------------- //
  253.  
  254. // Create the scores table
  255.  
  256. ST2::SetStyle("LibST_SMBaseSolo");
  257.  
  258. ST2::SetStyle("LibST_SMBasePoints");
  259.  
  260. MB_SetScoresTableStyleFromXml(S_ScoresTableStylePath);
  261.  
  262. ST2::Build("SM");
  263.  
  264. ***
  265.  
  266.  
  267.  
  268.  
  269.  
  270. // ---------------------------------- //
  271.  
  272. // Map start
  273.  
  274. // ---------------------------------- //
  275.  
  276. ***StartMap***
  277.  
  278. ***
  279.  
  280. LastHit = Now;
  281.  
  282. KillStreak = 0;
  283.  
  284. Score = 0;
  285.  
  286. Round = 1;
  287.  
  288. GamePhase = "checking";
  289.  
  290.  
  291.  
  292. Score::MatchBegin();
  293.  
  294. SM::SetupDefaultVisibility();
  295.  
  296.  
  297.  
  298. // ---------------------------------- //
  299.  
  300. // Init bases
  301.  
  302. foreach (Base in MapBases) {
  303.  
  304. Base.Clan = 1;
  305.  
  306. Base.IsActive = True;
  307.  
  308. }
  309.  
  310.  
  311.  
  312. // ---------------------------------- //
  313.  
  314. // New map sound
  315.  
  316. UIManager.UIAll.UISequence = CUIConfig::EUISequence::Intro;
  317.  
  318.  
  319.  
  320. ***
  321.  
  322.  
  323.  
  324. // ---------------------------------- //
  325.  
  326. // Play loop
  327.  
  328. // ---------------------------------- //
  329.  
  330. ***PlayLoop***
  331.  
  332. ***
  333.  
  334. if(GamePhase == "checking"){
  335.  
  336. CheckSettings();
  337.  
  338. EndTime = 0;
  339.  
  340. }
  341.  
  342.  
  343.  
  344. if(GamePhase == "newRound"){
  345.  
  346. PlaySound("newRoundIn", -1);
  347.  
  348. declare Msg = "";
  349.  
  350.  
  351.  
  352. Msg = TextLib::Compose(_("$s$i$o$af0Round $f00%1$fff-$f00%2"), TextLib::ToText(Round), TextLib::ToText(MaxRounds));
  353.  
  354. Message::SendBigMessage(Msg, 2000, 3, CUIConfig::EUISound::PhaseChange, 0);
  355.  
  356.  
  357.  
  358. sleep(2000);
  359.  
  360.  
  361.  
  362. CreateBots();
  363.  
  364. SpawnPlayers();
  365.  
  366. UIManager.UIAll.UISequence = CUIConfig::EUISequence::Playing;
  367.  
  368.  
  369.  
  370.  
  371.  
  372. StartTime = Now;
  373.  
  374. TimeLimit = 50 - 5 * Players.count;
  375.  
  376. if (TimeLimit > 0) EndTime = StartTime + (TimeLimit * 1000) + 2500;
  377.  
  378. else EndTime = -1;
  379.  
  380. Score = 1;
  381.  
  382.  
  383.  
  384. sleep(1000);
  385.  
  386. PlaySound("play", 0);
  387.  
  388.  
  389.  
  390.  
  391.  
  392. Msg = TextLib::Compose(_("$s$i$o$f00|||"), TextLib::ToText(Round));
  393.  
  394. Message::SendBigMessage(Msg, 2000, 3, CUIConfig::EUISound::Silence, 0);
  395.  
  396.  
  397.  
  398. sleep(500);
  399.  
  400.  
  401.  
  402. Msg = TextLib::Compose(_("$s$i$o$f00||"), TextLib::ToText(Round));
  403.  
  404. Message::SendBigMessage(Msg, 2000, 3, CUIConfig::EUISound::Silence, 0);
  405.  
  406.  
  407.  
  408. sleep(500);
  409.  
  410.  
  411.  
  412. Msg = TextLib::Compose(_("$s$i$o$f00|"), TextLib::ToText(Round));
  413.  
  414. Message::SendBigMessage(Msg, 2000, 3, CUIConfig::EUISound::Silence, 0);
  415.  
  416.  
  417.  
  418. sleep(500);
  419.  
  420.  
  421.  
  422. Msg = TextLib::Compose(_("$s$i$o$af0Play!"), TextLib::ToText(Round));
  423.  
  424. Message::SendBigMessage(Msg, 2000, 3, CUIConfig::EUISound::Silence, 0);
  425.  
  426.  
  427.  
  428. MatchInfo(True);
  429.  
  430.  
  431.  
  432. GamePhase = "play";
  433.  
  434. } else if(GamePhase == "play"){
  435.  
  436. ShowLayerTeam(True);
  437.  
  438. foreach (Event, PendingEvents) {
  439.  
  440. // ---------------------------------- //
  441.  
  442. // On armor empty
  443.  
  444. if (Event.Type == CSmModeEvent::EType::OnArmorEmpty) {
  445.  
  446. if(Event.Victim.IsFakePlayer){
  447.  
  448. Score += 1;
  449.  
  450. declare Msg = "";
  451.  
  452. declare Gap = BotPlayers.count - Score;
  453.  
  454. declare Variant = 3 - Gap;
  455.  
  456. if (Gap > 0 && Gap <= 3) {
  457.  
  458. if (Gap > 1) {
  459.  
  460. Msg = TextLib::Compose(_("%1 $s$i$o$f90bots around..."), TextLib::ToText(Gap));
  461.  
  462. } else {
  463.  
  464. Msg = TextLib::Compose(_("$s$i$o$f00Pulverize the last bot!!!"));
  465.  
  466. }
  467.  
  468. Message::SendStatusMessage(Msg, 2000, 3, CUIConfig::EUISound::TieBreakPoint, Variant);
  469.  
  470. }
  471.  
  472. else if (Gap <= 0) {
  473.  
  474. Msg = TextLib::Compose(_("$s$i$o$f00All bots are powdered, good job!!!"));
  475.  
  476. Message::SendStatusMessage(Msg, 2000, 3, CUIConfig::EUISound::VictoryPoint, 0);
  477.  
  478. EndTime = 0;
  479.  
  480. GamePhase = "roundEnd";
  481.  
  482. } else {
  483.  
  484. Message::SendStatusMessage(TextLib::Compose("$af0%1 : %2 / %3", _("$s$i$o$af0Kills"), TextLib::ToText(Score), TextLib::ToText(BotPlayers.count)), 2000, 3, CUIConfig::EUISound::ScoreProgress, MathLib::Rand(0,3));
  485. }
  486.  
  487. MatchInfo(True);
  488.  
  489. XmlRpc::OnArmorEmpty(Event);
  490.  
  491. PassOn(Event);
  492.  
  493. } else{
  494.  
  495. declare statusMsg = TextLib::Compose(_("%1 $m$s$i$o$f00is dead!"), Event.Victim.Name);
  496.  
  497. ChangePlayerState(Event.Victim, False);
  498.  
  499. Message::SendStatusMessage(statusMsg, 2000, 3, CUIConfig::EUISound::EndMatch, 0);
  500.  
  501. XmlRpc::OnArmorEmpty(Event);
  502.  
  503. PassOn(Event);
  504.  
  505. }
  506.  
  507. }
  508.  
  509. // ---------------------------------- //
  510.  
  511. // On hit
  512.  
  513. else if (Event.Type == CSmModeEvent::EType::OnHit) {
  514.  
  515. if (Event.Victim == Null || Event.Shooter == Event.Victim) {
  516.  
  517. Discard(Event);
  518.  
  519. } else {
  520.  
  521. if(Event.Shooter.IsFakePlayer && !Event.Victim.IsFakePlayer){ //Bots shoots Players
  522.  
  523.  
  524.  
  525. Event.Damage = 100;
  526.  
  527. XmlRpc::OnHit(Event);
  528.  
  529. PassOn(Event);
  530.  
  531.  
  532.  
  533. } else if(!Event.Shooter.IsFakePlayer && Event.Victim.IsFakePlayer){ //Players shoots Bots
  534.  
  535. declare Points = 1;
  536.  
  537. Score::AddPoints(Event.Shooter, Points);
  538.  
  539. Event.ShooterPoints = Points;
  540.  
  541. declare Distance = SendHitDistanceMessage(Event);
  542.  
  543.  
  544.  
  545. SetPlayerAmmo(Event.Shooter, CSmMode::EWeapon::Laser, 1);
  546.  
  547.  
  548.  
  549. declare HitInterval = 700;
  550.  
  551. if(Now < LastHit + HitInterval){
  552.  
  553. KillStreak += 1;
  554.  
  555. LastHit = Now;
  556.  
  557. DoKillStreakAnnounce();
  558.  
  559. } else {
  560.  
  561. KillStreak = 0;
  562.  
  563. LastHit = Now;
  564.  
  565. }
  566.  
  567.  
  568.  
  569. declare lifeStealChance = MathLib::Rand(0,1);
  570.  
  571.  
  572.  
  573. if(lifeStealChance == 1){
  574.  
  575. Event.Shooter.Armor += 100;
  576.  
  577. declare UI <=> UIManager.GetUI(Event.Shooter);
  578.  
  579. UI.SendNotice(TextLib::Compose(_("$s$o$af0+1 Life!")), CUIConfig::ENoticeLevel::Default, Null, CUIConfig::EAvatarVariant::Default, CUIConfig::EUISound::Silence, 0);
  580.  
  581. }
  582.  
  583.  
  584.  
  585. if(Event.Victim.Armor == 100){
  586.  
  587. declare bonusTime = 0;
  588.  
  589.  
  590.  
  591. switch (Players.count){
  592.  
  593. case 1:
  594.  
  595. bonusTime = MathLib::Rand(3,4);
  596.  
  597. case 2:
  598.  
  599. bonusTime = MathLib::Rand(2,4);
  600.  
  601. case 3:
  602.  
  603. bonusTime = MathLib::Rand(2,3);
  604.  
  605. case 4:
  606.  
  607. bonusTime = MathLib::Rand(1,2);
  608.  
  609. default:
  610.  
  611. bonusTime = MathLib::Rand(3,4);
  612.  
  613. }
  614.  
  615.  
  616.  
  617. EndTime += (bonusTime * 1000);
  618.  
  619.  
  620.  
  621. if(KillStreak == 0){
  622.  
  623. if(bonusTime == 1){
  624.  
  625. Message::SendBigMessage(TextLib::Compose(_("$s$i$o$fff+%1 $af0second $fff!"), TextLib::ToText(bonusTime)), 3000, 0);
  626.  
  627. } else {
  628.  
  629. Message::SendBigMessage(TextLib::Compose(_("$s$i$o$fff+%1 $af0seconds $fff!"), TextLib::ToText(bonusTime)), 3000, 0);
  630.  
  631. }
  632.  
  633. } else {
  634.  
  635. if(bonusTime == 1){
  636.  
  637. Message::SendBigMessage(TextLib::Compose(_("$s$i$o$fff+%1 $af0second $fff! ($f00+%2!$fff)"), TextLib::ToText(bonusTime+1), TextLib::ToText(1)), 3000, 0);
  638. } else {
  639.  
  640. Message::SendBigMessage(TextLib::Compose(_("$s$i$o$fff+%1 $af0seconds $fff! ($f00+%2!$fff)"), TextLib::ToText(bonusTime+1), TextLib::ToText(1)), 3000, 0);
  641.  
  642. }
  643.  
  644. EndTime += 1000;
  645.  
  646. }
  647.  
  648.  
  649.  
  650. Event.Damage = 100;
  651.  
  652. }
  653.  
  654. XmlRpc::OnHit(Event);
  655.  
  656. PassOn(Event);
  657.  
  658. } else {
  659.  
  660. Discard(Event);
  661.  
  662. }
  663.  
  664. }
  665.  
  666. }
  667.  
  668. // ---------------------------------- //
  669.  
  670. // On player request respawn
  671.  
  672. else if (Event.Type == CSmModeEvent::EType::OnPlayerRequestRespawn) {
  673.  
  674. if(Event.Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned) {
  675.  
  676. declare statusMsg = TextLib::Compose(_("%1 $m$s$i$o$f00is dead!"), Event.Player.Name);
  677.  
  678. Message::SendStatusMessage(statusMsg, 2000, 3, CUIConfig::EUISound::EndMatch, 0);
  679.  
  680. ChangePlayerState(Event.Player, False);
  681.  
  682. }
  683.  
  684. XmlRpc::OnPlayerRequestRespawn(Event);
  685.  
  686. PassOn(Event);
  687.  
  688. } else {
  689.  
  690. Discard(Event);
  691.  
  692. }
  693.  
  694. }
  695.  
  696. TimerSound();
  697.  
  698.  
  699.  
  700. if(EndTime < Now || Players.count == 0 || ClansNbPlayersAlive[1] == 0){
  701.  
  702. sleep(1000);
  703.  
  704. GamePhase = "roundEnd";
  705.  
  706.  
  707.  
  708. }
  709.  
  710.  
  711.  
  712. } else if (GamePhase == "roundEnd") {
  713.  
  714. ShowLayerTeam(False);
  715.  
  716. sleep(2000);
  717.  
  718. MatchInfo.ManialinkPage = "";
  719.  
  720. DestroyAllBotPlayers();
  721.  
  722. MatchInfo(False);
  723.  
  724. EndTime = 0;
  725.  
  726. declare Msg = "";
  727.  
  728. if(Score == BotPlayers.count) {
  729.  
  730. if(Round >= MaxRounds){
  731.  
  732. UnspawnPlayers();
  733.  
  734. Msg = TextLib::Compose(_("$m$s$i$o$af0You are the best pulverizer!!!"));
  735.  
  736. PlaySound("win", 0);
  737.  
  738. Message::SendBigMessage(Msg, 2000, 3, CUIConfig::EUISound::EndRound, 0);
  739.  
  740. UIManager.UIAll.ScoreTableVisibility = CUIConfig::EVisibility::ForcedVisible;
  741.  
  742. UIManager.UIAll.UISequence = CUIConfig::EUISequence::PlayersPresentation;
  743.  
  744. sleep(3000);
  745.  
  746. Message::CleanBigMessages();
  747.  
  748. Message::CleanStatusMessages();
  749.  
  750. Score::MatchEnd(True);
  751.  
  752. Round = 1;
  753.  
  754. PlaySound("nextMap", 0);
  755.  
  756. MatchEndRequested = True;
  757.  
  758. sleep(8000);
  759.  
  760.  
  761.  
  762. } else {
  763.  
  764. Msg = TextLib::Compose(_("$s$i$o$af0Round $f00%1 $af0terminated!"), TextLib::ToText(Round));
  765.  
  766. Message::SendBigMessage(Msg, 2000, 3, CUIConfig::EUISound::EndRound, 0);
  767.  
  768. Score::RoundEnd();
  769.  
  770. PlaySound("excellent", 0);
  771.  
  772. Round += 1;
  773.  
  774. sleep(1000);
  775.  
  776. GamePhase = "checking";
  777.  
  778. }
  779.  
  780. } else {
  781.  
  782. UnspawnPlayers();
  783.  
  784. Msg = TextLib::Compose(_("$s$i$o$af0Terminated!"));
  785.  
  786. Score::RoundEnd();
  787.  
  788. PlaySound("lost", 0);
  789.  
  790. Message::SendBigMessage(Msg, 2000, 3, CUIConfig::EUISound::EndRound, 0);
  791.  
  792. UIManager.UIAll.ScoreTableVisibility = CUIConfig::EVisibility::ForcedVisible;
  793.  
  794. UIManager.UIAll.UISequence = CUIConfig::EUISequence::PlayersPresentation;
  795.  
  796. Round = 1;
  797.  
  798. sleep(2000);
  799.  
  800. Score::MatchEnd();
  801.  
  802. Score::MatchBegin();
  803.  
  804. }
  805.  
  806. sleep(2000);
  807.  
  808. GamePhase = "checking";
  809.  
  810.  
  811. }
  812.  
  813. Message::Loop();
  814.  
  815. ***
  816.  
  817.  
  818.  
  819.  
  820.  
  821. // ---------------------------------- //
  822.  
  823. // Map end
  824.  
  825. // ---------------------------------- //
  826.  
  827. /****EndMap***
  828.  
  829. ***
  830.  
  831. ****/
  832.  
  833. // ---------------------------------- //
  834.  
  835. // Server end
  836.  
  837. // ---------------------------------- //
  838.  
  839. ***EndServer***
  840.  
  841. ***
  842.  
  843. UIManager.UILayerDestroyAll();
  844.  
  845. Interface::DestroyRank();
  846.  
  847. SpawnScreen::DestroyRules();
  848.  
  849. SpawnScreen::DestroyScores();
  850.  
  851. SpawnScreen::DestroyMapInfo();
  852.  
  853. ***
  854.  
  855.  
  856.  
  857. // ---------------------------------- //
  858.  
  859. // Functions
  860.  
  861. // ---------------------------------- //
  862.  
  863.  
  864.  
  865.  
  866.  
  867. Void ChangePlayerState(CSmPlayer Player, Boolean IsFree){
  868.  
  869. if(Player.CurrentClan==0) return;
  870.  
  871. if(IsFree){
  872.  
  873. _PlayerManialinkLines[Player.Id] = """<player login="{{{Player.Login}}}"/>""";
  874.  
  875. }else{
  876.  
  877. _PlayerManialinkLines[Player.Id] = """<player isalive="false" nickname="{{{TextLib::MLEncode(Player.Name)}}}"/>""";
  878.  
  879. }
  880.  
  881.  
  882.  
  883. }
  884.  
  885.  
  886. // Play sound
  887.  
  888. Sound::PlaySound(C_ImgBase^"Sounds/30_seconds_remain.ogg");
  889.  
  890. Sound::PlaySound(C_ImgBase^"Sounds/Play.ogg");
  891.  
  892. Sound::PlaySound(C_ImgBase^"Sounds/You_Have_Lost_the_Match.ogg");
  893.  
  894. Sound::PlaySound(C_ImgBase^"Sounds/You_Have_Won_the_Match.ogg");
  895.  
  896. Sound::PlaySound(C_ImgBase^"Sounds/NewRoundIn.ogg");
  897.  
  898.  
  899.  
  900. Void CreateAnniBot(Text _Type, CSmMapLandmark _Spawn){
  901.  
  902. declare newBot = CreateBotPlayer(NullId, 0);
  903.  
  904.  
  905.  
  906. switch(_Type){
  907.  
  908. case "Laser":{
  909.  
  910. SetPlayerWeapon(newBot, CSmMode::EWeapon::Laser, False);
  911.  
  912. newBot.ForceColor = <0.0, 0.5, 0.5>;}
  913.  
  914. case "Rocket":{
  915.  
  916. SetPlayerWeapon(newBot, CSmMode::EWeapon::Rocket, False);
  917.  
  918. newBot.ForceColor = <0.0, 1.0, 0.0>;}
  919.  
  920. case "Nucleus":{
  921.  
  922. SetPlayerWeapon(newBot, CSmMode::EWeapon::Nucleus, False);
  923.  
  924. newBot.ForceColor = <0.5, 0.0, 0.5>;}
  925.  
  926. case "Arrow":{
  927.  
  928. SetPlayerAmmoMax(newBot, CSmMode::EWeapon::Arrow, 2);
  929.  
  930. SetPlayerWeapon(newBot, CSmMode::EWeapon::Arrow, False);
  931.  
  932. newBot.ForceColor = <0.5, 0.5, 0.0>;}
  933.  
  934. case "Special":{
  935.  
  936. SetPlayerWeapon(newBot, CSmMode::EWeapon::Rocket, False);
  937.  
  938. newBot.ForceColor = <1.0, 0.5, 0.0>;}
  939.  
  940. }
  941.  
  942.  
  943.  
  944. newBot.Driver.AttackFilter = CSmPlayerDriver::ESmAttackFilter::OppositePlayers;
  945.  
  946.  
  947.  
  948. if(_Type != "Special"){
  949.  
  950. newBot.Driver.Behaviour = CSmPlayerDriver::ESmDriverBehaviour::Saunter;
  951.  
  952. newBot.Driver.Saunter_AnchorPoint = _Spawn.Position;
  953.  
  954. newBot.Driver.Saunter_Radius = 10.;
  955.  
  956.  
  957.  
  958. newBot.Driver.AggroRadius = 50.;
  959.  
  960. newBot.Driver.DisengageDistance = 30.;
  961.  
  962. newBot.Driver.Accuracy = 0.6;
  963.  
  964. newBot.Driver.ShootPeriodMin = 500;
  965.  
  966. newBot.Driver.ShootPeriodMax = 500;
  967.  
  968. newBot.AmmoGain = 1.0;
  969.  
  970. } else {
  971.  
  972. newBot.Driver.Behaviour = CSmPlayerDriver::ESmDriverBehaviour::Turret;
  973.  
  974. newBot.Driver.AggroRadius = 100.;
  975.  
  976. newBot.Driver.DisengageDistance = 0.;
  977. newBot.Driver.Accuracy = 1.0;
  978.  
  979. newBot.Driver.ShootPeriodMin = 10;
  980.  
  981. newBot.Driver.ShootPeriodMax = 10;
  982.  
  983. newBot.Driver.RocketAnticipation = True;
  984.  
  985. newBot.AmmoGain = 10.0;
  986.  
  987. }
  988.  
  989.  
  990.  
  991.  
  992.  
  993. newBot.Driver.Fov = 400.0;
  994.  
  995. newBot.ArmorMax = 100;
  996.  
  997. newBot.Driver.AggroRadius = S_AggroRadius;
  998.  
  999. newBot.Driver.ShootRadius = newBot.Driver.AggroRadius;
  1000.  
  1001. newBot.Driver.DisengageDistance = newBot.Driver.AggroRadius;
  1002.  
  1003. newBot.Driver.TargetMinDistance = 1.;
  1004.  
  1005.  
  1006.  
  1007. SpawnBotPlayer(newBot, 0, 100, _Spawn.BotPath, Now);
  1008.  
  1009. }
  1010.  
  1011.  
  1012.  
  1013. Void CreateBots(){
  1014.  
  1015. //Bots creation
  1016.  
  1017. declare botCountId = 0;
  1018.  
  1019. while(botCountId < MathLib::Clamp(S_NbBots, 1, 256)) {
  1020.  
  1021. declare Spawn <=> MapLandmarks_BotPath[MathLib::Rand(0, MapLandmarks_BotPath.count-1)];
  1022.  
  1023.  
  1024.  
  1025. declare botsWeapons = 0;
  1026.  
  1027.  
  1028.  
  1029. if(Spawn.Tag == "BotPath"){
  1030.  
  1031. if(Round == 1){
  1032.  
  1033. botsWeapons = 1;
  1034.  
  1035. }
  1036.  
  1037. if(Round == 2){
  1038.  
  1039. botsWeapons = 2;
  1040.  
  1041. }
  1042.  
  1043. if(Round == 3){
  1044.  
  1045. botsWeapons = MathLib::Rand(2,3);
  1046.  
  1047. }
  1048.  
  1049. if(Round == 4){
  1050.  
  1051. botsWeapons = 3;
  1052.  
  1053. }
  1054.  
  1055. if(Round == 5){
  1056.  
  1057. botsWeapons = MathLib::Rand(3,4);
  1058.  
  1059. }
  1060.  
  1061. if(Round == 6){
  1062.  
  1063. botsWeapons = MathLib::Rand(1,4);
  1064.  
  1065. }
  1066.  
  1067.  
  1068.  
  1069. if(botsWeapons == 1){
  1070.  
  1071. CreateAnniBot("Laser",Spawn);
  1072.  
  1073. } else if(botsWeapons == 2){
  1074.  
  1075. CreateAnniBot("Rocket",Spawn);
  1076.  
  1077. } else if(botsWeapons == 3){
  1078.  
  1079. CreateAnniBot("Nucleus",Spawn);
  1080.  
  1081. } else if(botsWeapons == 4){
  1082.  
  1083. CreateAnniBot("Arrow", Spawn);
  1084.  
  1085. }
  1086.  
  1087. botCountId += 1;
  1088.  
  1089. }
  1090.  
  1091. }
  1092.  
  1093. foreach(BotPath, MapLandmarks_BotPath){
  1094.  
  1095. if(BotPath.Tag == "Special"){
  1096.  
  1097. if(Round == MaxRounds){
  1098.  
  1099. CreateAnniBot("Special", BotPath);
  1100.  
  1101. }
  1102.  
  1103. }
  1104.  
  1105. }
  1106.  
  1107. }
  1108.  
  1109.  
  1110.  
  1111.  
  1112. // Get the currently used weapon
  1113.  
  1114. CSmMode::EWeapon GetWeapon() {
  1115.  
  1116. declare WeaponNumber = S_WeaponNumber;
  1117.  
  1118.  
  1119.  
  1120. if (WeaponNumber < 1 || WeaponNumber > 6) {
  1121.  
  1122. // Random weapon
  1123.  
  1124. WeaponNumber = MathLib::Rand(1, 6);
  1125.  
  1126. }
  1127.  
  1128.  
  1129.  
  1130. // Return weapon
  1131.  
  1132. switch (WeaponNumber) {
  1133.  
  1134. case 1: {
  1135.  
  1136. return CSmMode::EWeapon::Laser;
  1137.  
  1138. }
  1139.  
  1140. case 3: {
  1141.  
  1142. return CSmMode::EWeapon::Nucleus;
  1143.  
  1144. }
  1145.  
  1146. case 4: {
  1147.  
  1148. return CSmMode::EWeapon::Arrow;
  1149.  
  1150. }
  1151.  
  1152. case 6: {
  1153.  
  1154. return CSmMode::EWeapon::Missile;
  1155.  
  1156. }
  1157.  
  1158. }
  1159.  
  1160. return CSmMode::EWeapon::Rocket;
  1161.  
  1162. }
  1163.  
  1164.  
  1165.  
  1166. // Get whether weapons should be switched automatically
  1167.  
  1168. Boolean GetAutoSwitchWeapon(CSmMode::EWeapon _Weapon) {
  1169.  
  1170. return (C_AutoSwitchWeapon || _Weapon == CSmMode::EWeapon::Rocket);
  1171.  
  1172. }
  1173.  
  1174.  
  1175.  
  1176. Void SpawnPlayers() {
  1177.  
  1178. foreach (Player in Players) {
  1179.  
  1180. if(Player.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned){
  1181.  
  1182. Player.ArmorMax = MathLib::Max(S_ArmorMax, 1) * 100;
  1183.  
  1184. Player.AmmoGain = MathLib::Clamp(S_AmmoGain, 0., 10.);
  1185.  
  1186. SetPlayerClan(Player, 1);
  1187.  
  1188. ChangePlayerState(Player, True);
  1189.  
  1190.  
  1191. SetPlayerWeapon(Player, GetWeapon(), GetAutoSwitchWeapon(GetWeapon()));
  1192.  
  1193. SpawnPlayer(Player, 1, Player.ArmorMax, MapLandmarks_PlayerSpawn[MathLib::Rand(0, MapLandmarks_PlayerSpawn.count-1)].PlayerSpawn, Now);
  1194.  
  1195. }
  1196.  
  1197. }
  1198.  
  1199. }
  1200.  
  1201.  
  1202.  
  1203.  
  1204. // Set player weapon
  1205.  
  1206. Void SetPlayerWeapon(CSmPlayer _Player) {
  1207.  
  1208. if (_Player.SpawnStatus != CSmPlayer::ESpawnStatus::Spawned) {
  1209.  
  1210. declare Weapon = GetWeapon();
  1211.  
  1212. This.SetPlayerWeapon(_Player, Weapon, GetAutoSwitchWeapon(Weapon));
  1213.  
  1214.  
  1215.  
  1216. // Set weapon depending values
  1217.  
  1218. declare Integer AmmoMax;
  1219.  
  1220. declare Real Accuracy;
  1221.  
  1222. switch (Weapon) {
  1223.  
  1224. case CSmMode::EWeapon::Rocket: {
  1225.  
  1226. AmmoMax = 4;
  1227.  
  1228. Accuracy = 1.0;
  1229.  
  1230. }
  1231.  
  1232. case CSmMode::EWeapon::Laser: {
  1233.  
  1234. AmmoMax = 1;
  1235.  
  1236. Accuracy = 1.0;
  1237.  
  1238. }
  1239.  
  1240. case CSmMode::EWeapon::Nucleus: {
  1241.  
  1242. AmmoMax = 2;
  1243.  
  1244. Accuracy = 1.0;
  1245.  
  1246. }
  1247.  
  1248. case CSmMode::EWeapon::Arrow: {
  1249.  
  1250. AmmoMax = 3;
  1251.  
  1252. Accuracy = 1.0;
  1253.  
  1254. }
  1255.  
  1256. default: {
  1257.  
  1258. AmmoMax = 1;
  1259.  
  1260. Accuracy = 1.0;
  1261.  
  1262. }
  1263.  
  1264. }
  1265.  
  1266. This.SetPlayerAmmoMax(_Player, Weapon, MathLib::NearestInteger(AmmoMax*S_AmmoMax));
  1267.  
  1268. if (_Player.Driver != Null) {
  1269.  
  1270. _Player.Driver.Accuracy = S_Accuracy;
  1271.  
  1272. }
  1273.  
  1274. }
  1275.  
  1276. }
  1277.  
  1278.  
  1279.  
  1280. Void UnspawnPlayers(){
  1281.  
  1282. foreach (Player in Players) {
  1283.  
  1284. if (Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned) {
  1285.  
  1286. UnspawnPlayer(Player);
  1287.  
  1288. }
  1289.  
  1290. }
  1291.  
  1292. }
  1293.  
  1294.  
  1295.  
  1296. Real SendHitDistanceMessage(CSmModeEvent _Event) {
  1297.  
  1298. if (_Event.Type != CSmModeEvent::EType::OnHit) return -1.; // Wrong event type
  1299.  
  1300. if (_Event.Shooter == Null || _Event.Victim == Null || _Event.Shooter == _Event.Victim) return -1.; // Invalid players
  1301.  
  1302. // Get distance
  1303.  
  1304. declare Distance = MathLib::Distance(_Event.Shooter.Position, _Event.Victim.Position);
  1305.  
  1306. Distance = MathLib::NearestInteger(Distance * 10) / 10.0;
  1307.  
  1308.  
  1309.  
  1310. // Save longest hit
  1311.  
  1312. /*
  1313.  
  1314. if (Distance > G_LongestHitDist) {
  1315.  
  1316. G_LongestHitDist = Distance;
  1317.  
  1318. G_LongestHitName = _Event.Shooter.Name;
  1319.  
  1320. SetFooterStats(Null);
  1321.  
  1322. }
  1323.  
  1324. */
  1325.  
  1326. declare UI <=> UIManager.GetUI(_Event.Shooter);
  1327.  
  1328. if (UI == Null) return -1.;
  1329.  
  1330.  
  1331.  
  1332. // Send message
  1333.  
  1334. UI.SendNotice(TextLib::Compose(_("$s$i$o$af0%1m hit!"), TextLib::ToText(Distance)),
  1335.  
  1336. CUIConfig::ENoticeLevel::Default, Null, CUIConfig::EAvatarVariant::Default,
  1337.  
  1338. CUIConfig::EUISound::Silence, 0);
  1339.  
  1340. return Distance;
  1341.  
  1342. }
  1343.  
  1344. //Play sound
  1345. Sound::PlaySound(C_ImgBase^"Sounds/Double_Kill.ogg");
  1346. foreach(Player in Players){
  1347.  
  1348. declare UI <=> UIManager.GetUI(Player);
  1349.  
  1350. UI.SendNotice(TextLib::Compose(_("$f00Double Kill!")), CUIConfig::ENoticeLevel::Default, Null, CUIConfig::EAvatarVariant::Default, CUIConfig::EUISound::Silence, 0);
  1351.  
  1352. }
  1353.  
  1354. Sound::PlaySound(C_ImgBase^"Sounds/MultiKill.ogg");
  1355. foreach(Player in Players){
  1356.  
  1357. declare UI <=> UIManager.GetUI(Player);
  1358.  
  1359. UI.SendNotice(TextLib::Compose(_("$f00Multi Kill!")), CUIConfig::ENoticeLevel::Default, Null, CUIConfig::EAvatarVariant::Default, CUIConfig::EUISound::Silence, 0);
  1360.  
  1361. }
  1362.  
  1363. Sound::PlaySound(C_ImgBase^"Sounds/MegaKill.ogg");
  1364. foreach(Player in Players){
  1365.  
  1366. declare UI <=> UIManager.GetUI(Player);
  1367.  
  1368. UI.SendNotice(TextLib::Compose(_("$f00Mega Kill!")), CUIConfig::ENoticeLevel::Default, Null, CUIConfig::EAvatarVariant::Default, CUIConfig::EUISound::Silence, 0);
  1369.  
  1370. }
  1371.  
  1372. Sound::PlaySound(C_ImgBase^"Sounds/UltraKill.ogg");
  1373. foreach(Player in Players){
  1374.  
  1375. declare UI <=> UIManager.GetUI(Player);
  1376.  
  1377. UI.SendNotice(TextLib::Compose(_("$f00Ultra Kill!")), CUIConfig::ENoticeLevel::Default, Null, CUIConfig::EAvatarVariant::Default, CUIConfig::EUISound::Silence, 0);
  1378.  
  1379. }
  1380.  
  1381. Sound::PlaySound(C_ImgBase^"Sounds/MonsterKill_F.ogg");
  1382. foreach(Player in Players){
  1383.  
  1384. declare UI <=> UIManager.GetUI(Player);
  1385.  
  1386. UI.SendNotice(TextLib::Compose(_("$f00Monster Kill!")), CUIConfig::ENoticeLevel::Default, Null, CUIConfig::EAvatarVariant::Default, CUIConfig::EUISound::Silence, 0);
  1387.  
  1388. }
  1389.  
  1390.  
  1391. Void MatchInfo(Boolean show){
  1392.  
  1393. if(show){
  1394.  
  1395. MatchInfo.ManialinkPage = """
  1396.  
  1397. <frame posn="158 -76 0">
  1398.  
  1399. <label posn="0 0 1" halign="right" style="TextButtonNav" text="{{{_("$s$i$o$af0$oKills")}}} : {{{Score}}}/{{{BotPlayers.count}}}" />
  1400.  
  1401. </frame>
  1402.  
  1403. <frame posn="158 -72 0">
  1404.  
  1405. <label posn="0 0 1" halign="right" style="TextButtonNav" text="{{{_("$s$i$o$af0$oRound")}}} : {{{Round}}}/{{{MaxRounds}}}" />
  1406.  
  1407. </frame>
  1408.  
  1409. <quad posn="165 -80 0" halign= "right" sizen="49 13" bgcolor="FFFA" image="https://dl.dropboxusercontent.com/u/39375802/ATA/logoann.png"/>
  1410.  
  1411. """;
  1412.  
  1413. } else {
  1414.  
  1415. MatchInfo.ManialinkPage = "";
  1416.  
  1417. }
  1418.  
  1419. }
  1420.  
  1421.  
  1422.  
  1423. Void CheckSettings(){
  1424.  
  1425. UIManager.UIAll.ScoreTableVisibility = CUIConfig::EVisibility::Normal;
  1426.  
  1427. if (MapLandmarks_BotPath.count == 0){
  1428.  
  1429. declare Msg = TextLib::Compose(_("This map doesn't have bot spawns. Skipping..."));
  1430.  
  1431. Message::SendBigMessage(Msg, 1000, 3, CUIConfig::EUISound::EndRound, 0);
  1432.  
  1433. sleep(5000);
  1434.  
  1435. GamePhase = "error";
  1436.  
  1437. MatchEndRequested = True;
  1438.  
  1439. } else {
  1440.  
  1441. if(Players.count == 0){
  1442.  
  1443. sleep(1000);
  1444.  
  1445. declare Msg = TextLib::Compose(_("No Players"));
  1446.  
  1447. Message::SendBigMessage(Msg, 1000, 3, CUIConfig::EUISound::Silence, 0);
  1448.  
  1449. } else if (Players.count > 10){
  1450.  
  1451. sleep(1000);
  1452.  
  1453. declare Msg = TextLib::Compose(_("Too much players. Max players script-forced to 10."));
  1454.  
  1455. Message::SendBigMessage(Msg, 1000, 3, CUIConfig::EUISound::Silence, 0);
  1456.  
  1457. } else {
  1458.  
  1459. GamePhase = "newRound";
  1460.  
  1461. }
  1462.  
  1463. }
  1464.  
  1465. }
  1466.  
  1467.  
  1468.  
  1469. Void TimerSound(){
  1470.  
  1471. if((EndTime - Now) == 30000){
  1472.  
  1473. PlaySound("30sec", -1);
  1474.  
  1475. }
  1476.  
  1477. if((EndTime - Now) == 10000){
  1478.  
  1479. PlaySound("cd", 10);
  1480.  
  1481. }
  1482.  
  1483. if((EndTime - Now) == 9000){
  1484.  
  1485. PlaySound("cd", 9);
  1486.  
  1487. }
  1488.  
  1489. if((EndTime - Now) == 8000){
  1490.  
  1491. PlaySound("cd", 8);
  1492.  
  1493. }
  1494.  
  1495. if((EndTime - Now) == 7000){
  1496.  
  1497. PlaySound("cd", 7);
  1498.  
  1499. }
  1500.  
  1501. if((EndTime - Now) == 6000){
  1502.  
  1503. PlaySound("cd", 6);
  1504.  
  1505. }
  1506.  
  1507. if((EndTime - Now) == 5000){
  1508.  
  1509. PlaySound("cd", 5);
  1510.  
  1511. }
  1512.  
  1513. if((EndTime - Now) == 4000){
  1514.  
  1515. PlaySound("cd", 4);
  1516.  
  1517. }
  1518.  
  1519. if((EndTime - Now) == 3000){
  1520.  
  1521. PlaySound("cd", 3);
  1522.  
  1523. }
  1524.  
  1525. if((EndTime - Now) == 2000){
  1526.  
  1527. PlaySound("cd", 2);
  1528.  
  1529. }
  1530.  
  1531. if((EndTime - Now) == 1000){
  1532.  
  1533. PlaySound("cd", 1);
  1534.  
  1535. }
  1536.  
  1537. }
  1538.  
  1539.  
  1540.  
  1541. Void ShowLayerTeam(Boolean show) {
  1542.  
  1543. if(show){
  1544.  
  1545. if(Now > _LatestUITickLayerTeam + UITickPeriod){
  1546.  
  1547. _LatestUITickLayerTeam = Now;
  1548.  
  1549. _LayerTeam.ManialinkPage = """
  1550.  
  1551. <frame posn="-159 88 0">
  1552.  
  1553. <label posn="0 0 0" halign="left" style="TextButtonBig" text="{{{_("$s$i$o$af0Players alive")}}} : {{{ ClansNbPlayersAlive[1]}}}" />
  1554.  
  1555. </frame>
  1556.  
  1557. """;
  1558.  
  1559. declare Integer[Integer] NumberOfLines = [1=>0];
  1560.  
  1561. declare Text[Integer] TextOfPlayers = [1=>""];
  1562.  
  1563. foreach (Player in Players) {
  1564.  
  1565. if(Player.CurrentClan == 1){
  1566.  
  1567. if(NumberOfLines[Player.CurrentClan] < 20 && _PlayerManialinkLines.existskey(Player.Id)) {
  1568.  
  1569. TextOfPlayers[Player.CurrentClan] ^= _PlayerManialinkLines[Player.Id];
  1570.  
  1571. NumberOfLines[Player.CurrentClan] += 1;
  1572.  
  1573. }
  1574.  
  1575. }
  1576.  
  1577. }
  1578.  
  1579. _LayerTeam.ManialinkPage ^= """<playerlist posn="-160 84" halign="left" style="" substyle="Small" lines="20" columns="1" static="true">{{{TextOfPlayers[1]}}}</playerlist>""";
  1580.  
  1581. }
  1582.  
  1583. } else {
  1584.  
  1585. if(_LayerTeam.ManialinkPage != ""){
  1586.  
  1587. _LayerTeam.ManialinkPage = "";
  1588.  
  1589. }
  1590.  
  1591. }
  1592.  
  1593. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement