Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Timers;
- using BattleCore;
- using BattleCore.Events;
- using BattleCorePsyOps;
- namespace KenTestModule
- {
- //[Behavior("This is name of Module","(Do you want it to auto-load)","(Version)","(Creator)","(Description)")]
- [Behavior("Main", "true", "0.67", "Kenshin", "My Test Bot.")]
- public class Main : BotEventListener
- {
- public Main()
- {
- //Makes sure spam control is on
- msg.SpamControl = true;
- //Log bot into channel
- msg.SCPubCommand("?chat=specrpg");
- }
- //Psy's Module to help with chat events
- ShortChat msg = new ShortChat();
- //Stores botname and arena
- string BotName, Arena = "";
- //Game Timer
- Timer GameTimer = new Timer();
- //Bot dice Timestamp
- DateTime BotDiceTimeStamp = DateTime.Now;
- //1 Min since GameTimer Interval is 10ms
- double BotDiceInterval = 10000;
- //Random for dice
- Random random = new Random();
- string[] locar = new string[] { " a Beach", " a Desert", " a Forest", " the Plains" };
- string[] weapon = new string[] { "Dagger", "Sword", "Claymore", "Mace" };
- string[] type2 = new string[] { "Wooden", "Bronze", "Iron", "Steel", "Adamantium" };
- string[] type1 = new string[] { "Broken", "Old", "New", "Shining", "Upgraded", "Godly" };
- List<Player> PlayerList = new List<Player>();
- List<Playing> PlayingList = new List<Playing>();
- //Monitor all incoming chat events
- public void MonitorChatEvents(object sender, ChatEvent c)
- {
- //Core sends each bot a pm with its own info 500ms after startup
- //Use it to Initialize Bot
- if (c.ChatType == ChatTypes.Private && c.Message.StartsWith("@BotInfo@"))
- {
- // Catch and store bot info that core sends
- string[] data = c.Message.Split(':');
- BotName = data[1];
- Arena = data[2];
- // Initialize everything needed to get bot started
- InitializeBot();
- }
- }
- public void MonitorPlayerEnter(object sender, PlayerEnteredEvent pe)
- {
- if (PlayerRegistered(pe.PlayerName))
- {
- //Welcomes if player has played already (Could use this to read player profile from data file)
- Game(msg.pm(pe.PlayerName, "Welcome back to SpecRPG " + pe.PlayerName + "!"));
- msg.SCChanMessage(1, "|LOGIN| " + pe.PlayerName + " has spawned into the realm!");
- }
- else
- {
- // Create Player
- Player np = new Player();
- np.PlayerName = pe.PlayerName;
- //Register player first
- PlayerList.Add(np);
- Game(msg.pm(pe.PlayerName,"Welcome " +pe.PlayerName+ "! Type ?chat=SpecRPG to start playing SpecRPG!"));
- //Create Player data file here
- msg.SCChanMessage(1, "|REGISTER| " + pe.PlayerName + " has just been born!");
- }
- //Checks if Player is in spec
- if (pe.ShipType == ShipTypes.Spectator)
- {
- //Sets player to start playing if in spec
- PlayingList.Add(new Playing(pe.PlayerName));
- }
- }
- //Monitor if Player leaves the zone or arena
- public void MonitorPlayerLeave(object sender, PlayerLeftEvent lv)
- {
- //Removes player from playing rpg if he leaves zone or arena
- PlayingList.RemoveAll(a => a.PlayerName == lv.PlayerName);
- msg.SCChanMessage(1, "|LOGOUT| " + lv.PlayerName + " has left the realm! [REASON : Left Zone/Arena]");
- }
- //Checks to see if player left spec
- public void SpecLeave(object sender, ShipChangeEvent sc)
- {
- if (sc.ShipType == ShipTypes.Spectator)
- {
- msg.SCChanMessage(1, "|LOGIN| " + sc.PlayerName + " has joined the realm! [REASON : Joined Spec]");
- PlayingList.Add(new Playing(sc.PlayerName));
- }
- if (PlayingRegistered(sc.PlayerName))
- {
- if (sc.ShipType != ShipTypes.Spectator)
- {
- msg.SCChanMessage(1, "|LOGOUT| " + sc.PlayerName + " has left the realm! [REASON : Left Spec]");
- PlayingList.RemoveAll(a => a.PlayerName == sc.PlayerName);
- }
- }
- }
- public void InitializeBot()
- {
- //Configure and start main game timer
- GameTimer.Elapsed += new ElapsedEventHandler(updateMainTimer);
- GameTimer.Interval = 10;
- GameTimer.Start();
- //update chat with bot initialized msg
- msg.SCChanMessage(1,BotName + " initialized.");
- }
- public void updateMainTimer(object sender, ElapsedEventArgs e)
- {
- if ((DateTime.Now - BotDiceTimeStamp).TotalMilliseconds > BotDiceInterval)
- {
- //Event Dice
- int randomNumber = random.Next(0, 100);
- //Picks a player from spec
- int randomPlayer = random.Next(0,PlayingList.Count);
- //Picks a player from spec to duel
- int randomDuel = random.Next(0, PlayingList.Count);
- //Chance of winning duel
- int randomChance = random.Next(0, 100);
- //Random Area Selection (want to make it Beach <> Forest <> Plains <> Desert later)
- int randomArea = random.Next(0, 3);
- //Random Drop Weapon
- int randomWep = random.Next(0, 3);
- //Random Type 1
- int randomType1 = random.Next(0, 5);
- //Random Type 2
- int randomType2 = random.Next(0, 4);
- BotDiceTimeStamp = DateTime.Now;
- //Retrieves Random players name
- string rPlayer = PlayingList[randomPlayer].PlayerName;
- //Retrieves Random enemy players name
- string rEnemyP = PlayingList[randomDuel].PlayerName;
- //Change Locations
- if (randomNumber <= 10)
- {
- msg.SCChanMessage(1, "|AREA| " +rPlayer+ " has moved to" +locar[randomArea]+ "!");
- }
- //Encounter Duel
- if (randomNumber >= 90)
- {
- if (randomDuel != randomPlayer)
- {
- //Win the duel
- if (randomChance >= 50)
- {
- msg.SCChanMessage(1, "|DUEL| " + rPlayer + " has challenged " + rEnemyP + " to a duel and Won!");
- }
- //Lose the duel
- else if (randomChance < 50)
- {
- msg.SCChanMessage(1, "|DUEL| " + rPlayer + " has challenged " + rEnemyP + " to a duel and Lost!");
- }
- //If Dueler rolled same name as him weird event happens
- else if (randomDuel == randomPlayer)
- {
- msg.SCChanMessage(1, "|ITEM| " + rPlayer + " found " +type1[randomType1]+type2[randomType2]+weapon[randomWep]+ " !");
- }
- }
- }
- //Rolling 69 goes to whore house
- if (randomNumber == 69)
- {
- msg.SCChanMessage(1, "|SEXY| " + rPlayer + " has gone into a whore house!");
- }
- }
- //Check to see if we have any commands in our command chat q
- if (msg.NeedUpdate) Game(msg.sendNextBCommand());
- }
- //Checks if Player has registered before or not (for Welcome message when entering zone or arena)
- bool PlayerRegistered(string PlayerName)
- {
- for (int i = 0; i < PlayerList.Count; i += 1)
- {
- if (PlayerName == PlayerList[i].PlayerName)
- {
- return true;
- }
- }
- return false;
- }
- //Checks if Player is in spec list or not (playing list)
- bool PlayingRegistered(string PlayerName)
- {
- for (int i = 0; i < PlayingList.Count; i += 1)
- {
- if (PlayerName == PlayingList[i].PlayerName)
- {
- return true;
- }
- }
- return false;
- }
- public override void Dispose()
- {
- throw new NotImplementedException();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement