Results 1 to 12 of 12
  1. #1
    coolguy950's Avatar
    Join Date
    Oct 2013
    Gender
    male
    Location
    rrrrrrrrrrrrrrrrr
    Posts
    146
    Reputation
    10
    Thanks
    30
    My Mood
    Paranoid

    Lightbulb How to use Behaviors and create custom enemies. [IN-DEPTH, BEGINNER]

    THIS TUTORIAL IS FOR BEGINNERS. DON'T GO AROUND TELLING EVERYONE THAT YOU SHOULD KNOW HOW TO DO THIS.
    I know tutorials on this have been made, but in my opinion, none are very informative or descriptive though that's not to say I guarantee this to be helpful.

    A behavior is made up of a key component: The XML, meant for the purpose of describing what the enemy is: think about it as what a book looks like, rather than the contents of a book, and the behavior code, which is simply a series of C# constructors and properties. The XML interacts through the behavior, thus it is where you will find the stats for the enemy, such as HP, defense, and all the projectiles and their indexes.

    Code:
       <Object type="0x0932" id="Oryx the Mad God 2">
          <DisplayId>Oryx the Mad God</DisplayId>
          <Enemy/>
          <Class>Character</Class>
          <Texture>
             <File>lofiChar16x16</File>
             <Index>0x54</Index>
          </Texture>
          <HitSound>monster/oryx_hit</HitSound>
          <DeathSound>monster/oryx_death</DeathSound>
          <Size>120</Size>
          <MaxHitPoints>75000</MaxHitPoints>
          <Defense>60</Defense>
          <Quest/>
          <God/>
          <Oryx/>
          <StasisImmune/>
          <Level>1</Level>
          <XpMult>1</XpMult>
          <NoArticle/>
          <Projectile id="0">
             <ObjectId>Fire Bolt</ObjectId>
             <Damage>135</Damage>
             <Speed>70</Speed>
             <LifetimeMS>2500</LifetimeMS>
          </Projectile>
          <Projectile id="1">
             <ObjectId>Green Star</ObjectId>
             <Damage>160</Damage>
             <Speed>70</Speed>
             <LifetimeMS>2500</LifetimeMS>
             <ConditionEffect duration="10">Slowed</ConditionEffect>
          </Projectile>
          <Projectile id="2">
             <ObjectId>Blade</ObjectId>
             <Damage>240</Damage>
             <Speed>100</Speed>
             <LifetimeMS>450</LifetimeMS>
          </Projectile>
          <Projectile id="3">
             <ObjectId>Purple Star</ObjectId>
             <Damage>160</Damage>
             <Speed>55</Speed>
             <LifetimeMS>3000</LifetimeMS>
             <ConditionEffect duration="5">Blind</ConditionEffect>
          </Projectile>
          <Projectile id="4">
             <ObjectId>Blue Star</ObjectId>
             <Damage>160</Damage>
             <Speed>105</Speed>
             <LifetimeMS>1200</LifetimeMS>
             <ConditionEffect duration="5">Confused</ConditionEffect>
          </Projectile>
          <Projectile id="5">
             <ObjectId>Grey Star</ObjectId>
             <Damage>160</Damage>
             <Speed>45</Speed>
             <LifetimeMS>3000</LifetimeMS>
             <ConditionEffect duration="3">Quiet</ConditionEffect>
          </Projectile>
          <Projectile id="6">
             <ObjectId>Red Star</ObjectId>
             <Damage>160</Damage>
             <Speed>55</Speed>
             <LifetimeMS>3000</LifetimeMS>
             <ArmorPiercing/>
          </Projectile>
          <Projectile id="13">
             <ObjectId>Dark Gray Spinner</ObjectId>
             <Speed>90</Speed>
             <Size>100</Size>
             <Damage>1</Damage>
             <LifetimeMS>1800</LifetimeMS>
             <ConditionEffect duration="20">Quiet</ConditionEffect>
             <MultiHit/>
          </Projectile>
          <Projectile id="14">
             <ObjectId>Gray Spinner</ObjectId>
             <Speed>90</Speed>
             <Size>100</Size>
             <Damage>1</Damage>
             <LifetimeMS>1800</LifetimeMS>
             <ConditionEffect duration="60">Weak</ConditionEffect>
             <MultiHit/>
          </Projectile>
       </Object>
    I assume you know how the XML works, it should be fairly self-explanatory, much like behaviors themselves. If you need a reference, examine the XML code of "Oryx the Mad God 2". You use that ID in the C# code - when you create a behavior, you have to remember a few key things. 1: Make sure that you copy the 3 using statements located in all the other behavior files. Don't worry about regions, they're simply meant for organization purposes.

    Code:
    #region
    
    using wServer.logic.behaviors;
    using wServer.logic.loot;
    using wServer.logic.transitions;
    
    #endregion
    Change the class to a partial class - assuming you don't, the compiler will not execute the behaviors properly. This essentially means the definitions are split when you use 'partial'.
    Another thing you have to do is change the namespace from 'wServer.logic.db' to 'wServer.logic' - you'll get an error with loading your server if you do!

    Next, add in your main enemy/enemies. Explaining what all of these do will take to long, though I highly suggest that you learn what a "lambda expression" and "class constructor" is in the future. You can enter the class definition by holding CTRL and clicking on it.

    Code:
    private _ Crystal = () => Behav()
                .Init("Mysterious Crystal",
                    new State();
    I like to use the crystal, since it holds examples of things pertinent to creating a behavior that wouldn't normally be found in another behavior, such as size, effects, spawning mobs, etc. Above, where you see .Init(""), the ID that you set in the XML is used. The name "Crystal" can be set to whatever the name of your class is.
    (BehaviorDb._________.cs)

    Inside State();, you add any special things that occur on the death of your enemy, such as a new setpiece(see Malphas), or dropping a portal, which we see in the Crystal behavior.
    Next, you begin to interact with other states through transitions. A timedtransition refers to the amount of time in milliseconds before the next state occurs, which you set via referring states with different names, hence why you see weird names.

    Code:
    new State(
                        new DropPortalOnDeath("Deadwater Docks", 100),
                        new State("Idle",
                            new Taunt(0.1, "Break the crystal for great rewards..."),
                            new Taunt(0.1, "Help me..."),
                            new HpLessTransition(0.9999, "Instructions"),
                            new TimedTransition(10000, "Idle")
                            ),
                        new State("Instructions",
                            new Flash(0xffffffff, 2, 100),
                            new Taunt(0.8, "Fire upon this crystal with all your might for 5 seconds"),
                            new Taunt(0.8, "If your attacks are weak, the crystal magically heals"),
                            new Taunt(0.8, "Gather a large group to smash it open"),
                            new HpLessTransition(0.998, "Evaluation")
                            ),
    And HpLessTransition as seen above refers to how much hp is needed to be depleted for it to continue to the next state. Remember that 1 = 100% HP. Thus, 0.998 = 99.8%!

    Code:
    new State("Daisy_attack",
                            new Prioritize(
                                new StayCloseToSpawn(0.3, 7),
                                new Wander(0.3)
                                ),
    Hopefully, you're getting the hang of this. You should be able to see what's going on here; the enemy will move, but stay close to it's spawn point.

    Code:
     new ConditionalEffect(ConditionEffectIndex.Invulnerable),
                                new Shoot(0, projectileIndex: 0, count: 4, shootAngle: 90, fixedAngle: 0, coolDown: 300),
    Lastly is it's conditional effects and shots. The conditional effect can be changed to whatever you want, such as berserk, statsis, or armored. The new shoot looks a little complicated - but it's quite simple in usage. The projectileindex is simply a reference to the id of the shots you set in your XML! Make sure you don't go out of bounds, otherwise you'll get a bunch of errors in wServer.exe! It's zerobased - so it's common practice to start at 0, though you can theoretically use any number you like.

    There you go. You're set to creating your own behaviors. I presume you'll be able to gather what states contain simply by looking at them. Remember to use other premade behaviors as reference if you're new.

    I bid you the best of luck.

    Oh, by the way; in case you wanted some explanations for the states, here you go.
    https://www.mpgh.net/forum/showthread.php?t=1174922
    Last edited by coolguy950; 10-24-2016 at 07:18 AM.
    faaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaargraarg

  2. The Following 4 Users Say Thank You to coolguy950 For This Useful Post:

    Fightera100 (10-24-2016),FinnishFX (10-25-2016),succboyXD (10-25-2016),The Real DethStrike (12-03-2016)

  3. #2
    FinnishFX's Avatar
    Join Date
    Jun 2015
    Gender
    male
    Location
    Somewhere
    Posts
    203
    Reputation
    16
    Thanks
    48
    My Mood
    Psychedelic
    A lot better than some of the tutorials, Good job!

  4. The Following User Says Thank You to FinnishFX For This Useful Post:

    coolguy950 (10-24-2016)

  5. #3
    Demon's Avatar
    Join Date
    Jul 2015
    Gender
    male
    Location
    Lost
    Posts
    1,095
    Reputation
    86
    Thanks
    316
    My Mood
    Angelic
    Regions Aren't Only Used For Organized Purposes:/ (If You Have Any Thingy Out of The Regions That You Have (Which Is Almost Impossible)Then It Won't Work)

    But then again its better than mine so no spot to complain
    Last edited by Demon; 10-25-2016 at 04:15 AM.

  6. #4
    coolguy950's Avatar
    Join Date
    Oct 2013
    Gender
    male
    Location
    rrrrrrrrrrrrrrrrr
    Posts
    146
    Reputation
    10
    Thanks
    30
    My Mood
    Paranoid
    Quote Originally Posted by DemonLives View Post
    Regions Aren't Only Used For Organized Purposes:/ (If You Have Any Thingy Out of The Regions That You Have (Which Is Almost Impossible)Then It Won't Work)

    But then again its better than mine so no spot to complain
    Are... Are you joking right now? Do you seriously not know what regions are? The whole purpose of the #region and #endregion directives to collapse and expand code so you are able to focus on different parts of the file. Removing the region, or carrying the using statements out of the region will do absolutely nothing. Either way, in your tutorial, you were criticized by many, including me, for omitting information and being unable to explain certain aspects of a behavior properly.
    faaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaargraarg

  7. #5
    Demon's Avatar
    Join Date
    Jul 2015
    Gender
    male
    Location
    Lost
    Posts
    1,095
    Reputation
    86
    Thanks
    316
    My Mood
    Angelic
    Quote Originally Posted by coolguy950 View Post
    Are... Are you joking right now? Do you seriously not know what regions are? The whole purpose of the #region and #endregion directives to collapse and expand code so you are able to focus on different parts of the file. Removing the region, or carrying the using statements out of the region will do absolutely nothing. Either way, in your tutorial, you were criticized by many, including me, for omitting information and being unable to explain certain aspects of a behavior properly.
    sorry about that i was just being stupid forgot that it does nothing...

  8. #6
    coolguy950's Avatar
    Join Date
    Oct 2013
    Gender
    male
    Location
    rrrrrrrrrrrrrrrrr
    Posts
    146
    Reputation
    10
    Thanks
    30
    My Mood
    Paranoid
    Quote Originally Posted by DemonLives View Post
    sorry about that i was just being stupid forgot that it does nothing...
    It's fine <3
    faaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaargraarg

  9. #7
    Queshawn's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Posts
    53
    Reputation
    10
    Thanks
    4
    Quote Originally Posted by coolguy950 View Post
    THIS TUTORIAL IS FOR BEGINNERS. DON'T GO AROUND TELLING EVERYONE THAT YOU SHOULD KNOW HOW TO DO THIS.
    I know tutorials on this have been made, but in my opinion, none are very informative or descriptive though that's not to say I guarantee this to be helpful.

    A behavior is made up of a key component: The XML, meant for the purpose of describing what the enemy is: think about it as what a book looks like, rather than the contents of a book, and the behavior code, which is simply a series of C# constructors and properties. The XML interacts through the behavior, thus it is where you will find the stats for the enemy, such as HP, defense, and all the projectiles and their indexes.

    Code:
       <Object type="0x0932" id="Oryx the Mad God 2">
          <DisplayId>Oryx the Mad God</DisplayId>
          <Enemy/>
          <Class>Character</Class>
          <Texture>
             <File>lofiChar16x16</File>
             <Index>0x54</Index>
          </Texture>
          <HitSound>monster/oryx_hit</HitSound>
          <DeathSound>monster/oryx_death</DeathSound>
          <Size>120</Size>
          <MaxHitPoints>75000</MaxHitPoints>
          <Defense>60</Defense>
          <Quest/>
          <God/>
          <Oryx/>
          <StasisImmune/>
          <Level>1</Level>
          <XpMult>1</XpMult>
          <NoArticle/>
          <Projectile id="0">
             <ObjectId>Fire Bolt</ObjectId>
             <Damage>135</Damage>
             <Speed>70</Speed>
             <LifetimeMS>2500</LifetimeMS>
          </Projectile>
          <Projectile id="1">
             <ObjectId>Green Star</ObjectId>
             <Damage>160</Damage>
             <Speed>70</Speed>
             <LifetimeMS>2500</LifetimeMS>
             <ConditionEffect duration="10">Slowed</ConditionEffect>
          </Projectile>
          <Projectile id="2">
             <ObjectId>Blade</ObjectId>
             <Damage>240</Damage>
             <Speed>100</Speed>
             <LifetimeMS>450</LifetimeMS>
          </Projectile>
          <Projectile id="3">
             <ObjectId>Purple Star</ObjectId>
             <Damage>160</Damage>
             <Speed>55</Speed>
             <LifetimeMS>3000</LifetimeMS>
             <ConditionEffect duration="5">Blind</ConditionEffect>
          </Projectile>
          <Projectile id="4">
             <ObjectId>Blue Star</ObjectId>
             <Damage>160</Damage>
             <Speed>105</Speed>
             <LifetimeMS>1200</LifetimeMS>
             <ConditionEffect duration="5">Confused</ConditionEffect>
          </Projectile>
          <Projectile id="5">
             <ObjectId>Grey Star</ObjectId>
             <Damage>160</Damage>
             <Speed>45</Speed>
             <LifetimeMS>3000</LifetimeMS>
             <ConditionEffect duration="3">Quiet</ConditionEffect>
          </Projectile>
          <Projectile id="6">
             <ObjectId>Red Star</ObjectId>
             <Damage>160</Damage>
             <Speed>55</Speed>
             <LifetimeMS>3000</LifetimeMS>
             <ArmorPiercing/>
          </Projectile>
          <Projectile id="13">
             <ObjectId>Dark Gray Spinner</ObjectId>
             <Speed>90</Speed>
             <Size>100</Size>
             <Damage>1</Damage>
             <LifetimeMS>1800</LifetimeMS>
             <ConditionEffect duration="20">Quiet</ConditionEffect>
             <MultiHit/>
          </Projectile>
          <Projectile id="14">
             <ObjectId>Gray Spinner</ObjectId>
             <Speed>90</Speed>
             <Size>100</Size>
             <Damage>1</Damage>
             <LifetimeMS>1800</LifetimeMS>
             <ConditionEffect duration="60">Weak</ConditionEffect>
             <MultiHit/>
          </Projectile>
       </Object>
    I assume you know how the XML works, it should be fairly self-explanatory, much like behaviors themselves. If you need a reference, examine the XML code of "Oryx the Mad God 2". You use that ID in the C# code - when you create a behavior, you have to remember a few key things. 1: Make sure that you copy the 3 using statements located in all the other behavior files. Don't worry about regions, they're simply meant for organization purposes.

    Code:
    #region
    
    using wServer.logic.behaviors;
    using wServer.logic.loot;
    using wServer.logic.transitions;
    
    #endregion
    Change the class to a partial class - assuming you don't, the compiler will not execute the behaviors properly. This essentially means the definitions are split when you use 'partial'.
    Another thing you have to do is change the namespace from 'wServer.logic.db' to 'wServer.logic' - you'll get an error with loading your server if you do!

    Next, add in your main enemy/enemies. Explaining what all of these do will take to long, though I highly suggest that you learn what a "lambda expression" and "class constructor" is in the future. You can enter the class definition by holding CTRL and clicking on it.

    Code:
    private _ Crystal = () => Behav()
                .Init("Mysterious Crystal",
                    new State();
    I like to use the crystal, since it holds examples of things pertinent to creating a behavior that wouldn't normally be found in another behavior, such as size, effects, spawning mobs, etc. Above, where you see .Init(""), the ID that you set in the XML is used. The name "Crystal" can be set to whatever the name of your class is.
    (BehaviorDb._________.cs)

    Inside State();, you add any special things that occur on the death of your enemy, such as a new setpiece(see Malphas), or dropping a portal, which we see in the Crystal behavior.
    Next, you begin to interact with other states through transitions. A timedtransition refers to the amount of time in milliseconds before the next state occurs, which you set via referring states with different names, hence why you see weird names.

    Code:
    new State(
                        new DropPortalOnDeath("Deadwater Docks", 100),
                        new State("Idle",
                            new Taunt(0.1, "Break the crystal for great rewards..."),
                            new Taunt(0.1, "Help me..."),
                            new HpLessTransition(0.9999, "Instructions"),
                            new TimedTransition(10000, "Idle")
                            ),
                        new State("Instructions",
                            new Flash(0xffffffff, 2, 100),
                            new Taunt(0.8, "Fire upon this crystal with all your might for 5 seconds"),
                            new Taunt(0.8, "If your attacks are weak, the crystal magically heals"),
                            new Taunt(0.8, "Gather a large group to smash it open"),
                            new HpLessTransition(0.998, "Evaluation")
                            ),
    And HpLessTransition as seen above refers to how much hp is needed to be depleted for it to continue to the next state. Remember that 1 = 100% HP. Thus, 0.998 = 99.8%!

    Code:
    new State("Daisy_attack",
                            new Prioritize(
                                new StayCloseToSpawn(0.3, 7),
                                new Wander(0.3)
                                ),
    Hopefully, you're getting the hang of this. You should be able to see what's going on here; the enemy will move, but stay close to it's spawn point.

    Code:
     new ConditionalEffect(ConditionEffectIndex.Invulnerable),
                                new Shoot(0, projectileIndex: 0, count: 4, shootAngle: 90, fixedAngle: 0, coolDown: 300),
    Lastly is it's conditional effects and shots. The conditional effect can be changed to whatever you want, such as berserk, statsis, or armored. The new shoot looks a little complicated - but it's quite simple in usage. The projectileindex is simply a reference to the id of the shots you set in your XML! Make sure you don't go out of bounds, otherwise you'll get a bunch of errors in wServer.exe! It's zerobased - so it's common practice to start at 0, though you can theoretically use any number you like.

    There you go. You're set to creating your own behaviors. I presume you'll be able to gather what states contain simply by looking at them. Remember to use other premade behaviors as reference if you're new.

    I bid you the best of luck.

    Oh, by the way; in case you wanted some explanations for the states, here you go.
    https://www.mpgh.net/forum/showthread.php?t=1174922
    I did all of this and i ended up getting an error in wserver i was wondering what i did wrong?
    Just an average NOOB! Out here trying to make it

  10. #8
    coolguy950's Avatar
    Join Date
    Oct 2013
    Gender
    male
    Location
    rrrrrrrrrrrrrrrrr
    Posts
    146
    Reputation
    10
    Thanks
    30
    My Mood
    Paranoid
    Quote Originally Posted by Queshawn View Post
    I did all of this and i ended up getting an error in wserver i was wondering what i did wrong?
    Can you be more specific about the error?
    faaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaargraarg

  11. #9
    DarkBoodleli's Avatar
    Join Date
    Nov 2016
    Gender
    male
    Posts
    1
    Reputation
    10
    Thanks
    0
    Could u help me code the behavior of the puppets masters encore minions?

  12. #10
    coolguy950's Avatar
    Join Date
    Oct 2013
    Gender
    male
    Location
    rrrrrrrrrrrrrrrrr
    Posts
    146
    Reputation
    10
    Thanks
    30
    My Mood
    Paranoid
    Quote Originally Posted by DarkBoodleli View Post
    Could u help me code the behavior of the puppets masters encore minions?
    Sorry for the late reply, but sure, as long as I can use them too.
    faaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaargraarg

  13. #11
    MikeRaarupBirk's Avatar
    Join Date
    Mar 2016
    Gender
    male
    Posts
    1,583
    Reputation
    38
    Thanks
    3,775
    My Mood
    Stressed
    Quote Originally Posted by coolguy950 View Post
    Sorry for the late reply, but sure, as long as I can use them too.
    you make it, therefor you can use them?????????

  14. #12
    coolguy950's Avatar
    Join Date
    Oct 2013
    Gender
    male
    Location
    rrrrrrrrrrrrrrrrr
    Posts
    146
    Reputation
    10
    Thanks
    30
    My Mood
    Paranoid
    Quote Originally Posted by MikeRaarupBirk View Post
    you make it, therefor you can use them?????????
    ::---DDDDDDD
    faaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaargraarg

Similar Threads

  1. How to use P64 and play SSB :]
    By KingDot in forum Emulator & Rom Hacking
    Replies: 10
    Last Post: 03-08-2011, 08:27 PM
  2. How to use tubebot and triggerbot, i'm playing HCDM
    By OnlySev7n in forum Call of Duty Modern Warfare 2 Help
    Replies: 3
    Last Post: 04-24-2010, 12:59 AM
  3. How To Use PerX And Other Injectors
    By nfitz02 in forum Combat Arms Discussions
    Replies: 14
    Last Post: 09-23-2009, 03:52 AM
  4. [TUT]How to use Stealth and CHeeat Injectors.
    By krishna in forum CrossFire Hacks & Cheats
    Replies: 7
    Last Post: 09-06-2009, 02:18 PM
  5. How to use wallhack and MHS speed hack together.{if you don't already know}
    By neononxxx in forum Combat Arms Hacks & Cheats
    Replies: 16
    Last Post: 07-18-2009, 12:35 AM

Tags for this Thread