Results 1 to 10 of 10
  1. #1
    FlashFlyyy's Avatar
    Join Date
    Jun 2017
    Gender
    male
    Posts
    141
    Reputation
    10
    Thanks
    19
    My Mood
    Amazed

    How does the killAll command work?

    How does the '/killAll' command work? How are objects assigned the 'enemy' attribute other than using the XML tag?

    Basically can someone explain what this code does?

    Code:
     
        class KillAll : Command
        {
            public KillAll() : base("killAll", Ranks.Admin)
            {
            }
            
            protected override bool Process(Player player, RealmTime time, string[] args)
            {
                var iterations = 0;
                var lastKilled = -1;
                var killed = 0;
    
                var mobName = args.Aggregate((s, a) => string.Concat(s, " ", a));
                while (killed != lastKilled)
                {
                    lastKilled = killed;
                    foreach (var i in player.Owner.Enemies.Values.Where(e =>
                        e.ObjectDesc?.ObjectId != null && e.ObjectDesc.ObjectId.ContainsIgnoreCase(mobName)))
                    {
                        i.Death(time);
                        killed++;
                    }
                    if (++iterations >= 5)
                        break;
                }
    
                player.SendInfo($"{killed} enemy killed!");
                return true;
            }
        }
    I am interested because the object in nexus called 'mb shopkeeper1' is deemed an enemy and is therefore removed when entering '/killAll'. I want to try and remove this.
    Last edited by FlashFlyyy; 07-04-2018 at 08:45 AM.

  2. #2
    TooGoodAtCoding3039's Avatar
    Join Date
    Mar 2018
    Gender
    male
    Posts
    13
    Reputation
    10
    Thanks
    8
    Quote Originally Posted by FlashFlyyy View Post
    How does the '/killAll' command work? How are objects assigned the 'enemy' attribute other than using the XML tag?

    Basically can someone explain what this code does?

    Code:
     
        class KillAll : Command
        {
            public KillAll() : base("killAll", Ranks.Admin)
            {
            }
            
            protected override bool Process(Player player, RealmTime time, string[] args)
            {
                var iterations = 0;
                var lastKilled = -1;
                var killed = 0;
    
                var mobName = args.Aggregate((s, a) => string.Concat(s, " ", a));
                while (killed != lastKilled)
                {
                    lastKilled = killed;
                    foreach (var i in player.Owner.Enemies.Values.Where(e =>
                        e.ObjectDesc?.ObjectId != null && e.ObjectDesc.ObjectId.ContainsIgnoreCase(mobName)))
                    {
                        i.Death(time);
                        killed++;
                    }
                    if (++iterations >= 5)
                        break;
                }
    
                player.SendInfo($"{killed} enemy killed!");
                return true;
            }
        }
    I am interested because the object in nexus called 'mb shopkeeper1' is deemed an enemy and is therefore removed when entering '/killAll'. I want to try and remove this.
    The Killall command inherits form the base class Command.cs. When the command is called using the proper structure, the string is then combined to form a proper name if the name contains more than one word. It gets every entity entance in the players current world, check to see if the name matches the one specified. And for every enemy killed it increases the killed integer by one. After it's done looping through the foreach loop and meeting max iterations , it notifies the player of how much they've killed. Then returns true.
    Last edited by TooGoodAtCoding3039; 07-04-2018 at 03:06 PM.

  3. #3
    FlashFlyyy's Avatar
    Join Date
    Jun 2017
    Gender
    male
    Posts
    141
    Reputation
    10
    Thanks
    19
    My Mood
    Amazed
    Quote Originally Posted by TooGoodAtCoding3039 View Post
    check to see if the name matches the one specified
    What do you mean by this?

    It considers all entity instances in the player's current world, however how does it distinguish that an object is an enemy?
    Could you give an example with data?
    Last edited by FlashFlyyy; 07-04-2018 at 03:34 PM.

  4. #4
    TooGoodAtCoding3039's Avatar
    Join Date
    Mar 2018
    Gender
    male
    Posts
    13
    Reputation
    10
    Thanks
    8
    Quote Originally Posted by FlashFlyyy View Post
    What do you mean by this?

    It considers all entity instances in the player's current world, however how does it distinguish that an object is an enemy?
    Could you give an example with data?
    It checks if any x enemies matches the name you specified in when you initiate your command. /killall medusa, result: killed 999 (meaning there where 999 medusa in your world instance.)

    And yes I'd assume it distinguishes regular objects from enemies, unless who ever made the enemies dictionary is a retard.

  5. #5
    Invader_Zim's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Location
    Atlas 2
    Posts
    546
    Reputation
    10
    Thanks
    300
    My Mood
    Tired
    Objects can possess an enemy tag, it's usually under the object type "Character". You don't need the enemy tag for a nexus shop merchant.

    My weapon is a backpack.

  6. The Following User Says Thank You to Invader_Zim For This Useful Post:

    DevilRotMG (07-04-2018)

  7. #6
    FlashFlyyy's Avatar
    Join Date
    Jun 2017
    Gender
    male
    Posts
    141
    Reputation
    10
    Thanks
    19
    My Mood
    Amazed
    Quote Originally Posted by Invader_Zim View Post
    Objects can possess an enemy tag, it's usually under the object type "Character". You don't need the enemy tag for a nexus shop merchant.
    No no lol. I know the way to make an enemy is to use the tag. But what I am saying is that the /killAll command removes the object (for example) 'mb shopkeep1' from nexus as it is deemed an enemy even when there is no enemy tag in its XML. I go in nexus and type /killAll and the mystery box wizard, some flies on the outside, the alchemist orbs, the rabbits, etc. are all removed and it says '121 enemies killed' even though they aren't enemies! I thought it had something to do with the 'statusimmune' tag but it's not.

    Screen gifs:
    https://gyazo.com/bfb3991a1c2711369a1375076bf5448f
    https://gyazo.com/85d5f75a7bbd967c5782c737125c1947

  8. #7
    DevilRotMG's Avatar
    Join Date
    Jun 2018
    Gender
    male
    Location
    Dust II
    Posts
    364
    Reputation
    -3
    Thanks
    155
    My Mood
    Drunk
    Read:
    Code:
                    foreach (var i in player.Owner.Enemies.Values.Where(e =>
                        e.ObjectDesc?.ObjectId != null && e.ObjectDesc.ObjectId.ContainsIgnoreCase(mobName)))

  9. #8
    FlashFlyyy's Avatar
    Join Date
    Jun 2017
    Gender
    male
    Posts
    141
    Reputation
    10
    Thanks
    19
    My Mood
    Amazed
    Quote Originally Posted by DevilRotMG View Post
    Read:
    Code:
                    foreach (var i in player.Owner.Enemies.Values.Where(e =>
                        e.ObjectDesc?.ObjectId != null && e.ObjectDesc.ObjectId.ContainsIgnoreCase(mobName)))
    Ye, that's why I made it bold lol. But fine I will google parts of it and hopefully it will make sense -_-
    I only started learning c# 2 weeks ago. I know it's some sort of list comprehension. But how is 'mobName' assigned its value? What are the variables 's' and 'a'?

    EDIT: OHHHHHH, it's because I put no argument... that's why it killed everything

    EDIT2: this doesn't help with the fact that some objects in nexus are effected by poison

    EDIT3: is there a 'check_if_object_has_defense_tag' function somewhere? xD

    EDIT4: fixed

    Thanks to all!
    Last edited by FlashFlyyy; 07-05-2018 at 04:26 AM.

  10. The Following User Says Thank You to FlashFlyyy For This Useful Post:

    DevilRotMG (07-05-2018)

  11. #9
    DevilRotMG's Avatar
    Join Date
    Jun 2018
    Gender
    male
    Location
    Dust II
    Posts
    364
    Reputation
    -3
    Thanks
    155
    My Mood
    Drunk
    Quote Originally Posted by FlashFlyyy View Post
    Ye, that's why I made it bold lol. But fine I will google parts of it and hopefully it will make sense -_-
    I only started learning c# 2 weeks ago. I know it's some sort of list comprehension. But how is 'mobName' assigned its value? What are the variables 's' and 'a'?

    EDIT: OHHHHHH, it's because I put no argument... that's why it killed everything

    EDIT2: this doesn't help with the fact that some objects in nexus are effected by poison

    EDIT3: is there a 'check_if_object_has_defense_tag' function somewhere? xD

    EDIT4: fixed

    Thanks to all!
    Very simple, just need to spend sometime and read, xD
    @Nyaro @Luverdark solved.

  12. The Following User Says Thank You to DevilRotMG For This Useful Post:

    FlashFlyyy (07-05-2018)

  13. #10
    Luverdark's Avatar
    Join Date
    Jul 2015
    Gender
    male
    Location
    7,821
    Posts
    4,986
    Reputation
    1386
    Thanks
    2,030
    My Mood
    Yeehaw
    Done closed




     
    Member Since 07-18-2015
    Mpgh Premium 07-17-2016
    Mpgh Premium Seller 08-17-2016
    Mpgh News Force (Gaming News) 02-09-2017
    Mpgh News Resignation 06-08-2017
    Realm Of The Mad God Minion 12-11-2017
    Former Staff 09-25-2018

Similar Threads

  1. How does the reputation system work?
    By $##^$%^%^6456 in forum General
    Replies: 2
    Last Post: 10-04-2016, 08:25 AM
  2. CS:GO How Does The Ranking System Work?
    By OpticFlames in forum General Gaming
    Replies: 6
    Last Post: 12-20-2014, 06:28 PM
  3. How does the vault really work?
    By iAmSquidly in forum Realm of the Mad God Help & Requests
    Replies: 4
    Last Post: 09-29-2013, 03:03 PM
  4. How does the reputation shit work here?
    By unknownartist0 in forum General
    Replies: 58
    Last Post: 06-30-2013, 11:16 AM
  5. How does the report system work?
    By SiickRich in forum Soldier Front Help
    Replies: 4
    Last Post: 09-05-2012, 10:13 PM