Yxxe Posted May 7, 2011 Author Share Posted May 7, 2011 **Lightning's Boss Battle Framework**Hello, and welcome to my next tutorial. When this tutorial is over, you should have created a basic framework for creating boss battles.I will not be providing boss procedures, but this tutorial will tell you how to make one, with a few examples of accompanying attacks. What's a game without bosses?**Compatible with: Eclipse Origins v2**Before you get started, make sure you have the following:* Visual Basic 6 Professional/Enterprise* Client/Server Source Files* Intermediate knowledge of the use of the VB6 IDE and Language**Outcome:**A short video displaying one of the Bosses in Origin: The Legend Reborn. This video was the Alpha version of the boss, without spell effects:http://www.youtube.com/watch?v=RVr3kljoX-4**Server Side:**Most of the boss framework is coded server-side. Open up your server source code, called "server.vbp"![](http://i801.photobucket.com/albums/yy294/Adrammelech_2009/1.png)Once you have loaded the project file, you will need to navigate to "Project > Add Module". Click the "New" tab, then click "Open".![](http://i801.photobucket.com/albums/yy294/Adrammelech_2009/2-1.png)Once this has been created, rename your module to "modBosses" like so:![](http://i801.photobucket.com/albums/yy294/Adrammelech_2009/3.png)Now, load up the modBosses module. The first procedure you will add is the main Boss Logic Handler. This branches out to the correct boss when it is attacked.```Public Sub BossLogic(ByVal Target As Long, ByVal BossNum As Integer, ByVal npcNum As Long)  Select Case BossNum    Case 1      'Your first boss call will be here.    Case Else      Call PlayerMsg(Target, "There seems to be an error with this boss. Please take a screenshot of this and inform an admin.", Red)  End SelectEnd Sub```Now lets make the first boss logic procedure. For the sake of this tutorial, we will call the boss "TestBoss". When creating new bosses, it is essential to name your logic procedures correctly, so you don't get confused.Underneath the sub "BossLogic", create a new procedure like this:```Private Sub TestBossLogic(ByVal Target As Long, ByVal npcNum As Long)  'resume normally attacking the player  Call TryNpcAttackPlayer(3, Target)End Sub```At the moment, all this Boss does it attack the target normally. What's the fun in that? Now we will add a nice attack AI.The special attack is called from the "TestBossLogic" procedure. You see now that everything is branched out easily? This way it is incredibly easy to code new attacks and just call them from the "TestBossLogic" procedure. Let's go and make a simple stunning ability.What this basically does is stuns the player for a pre-determined amount of time, and shows an animation. Copy the code below underneath your "TestBossLogic" procedure.```'Stuns the whole party for three secondsPrivate Sub Stun(ByVal Target As Long)Dim i As Long  'Check if the player is in a party  If TempPlayer(Target).inParty > 0 Then    For i = 1 To TempPlayer(Target).inParty      'Stun the player      TempPlayer(i).StunDuration = 3 'seconds      TempPlayer(i).StunTimer = GetTickCount      'Show animation      Call SendAnimation(#mapnum#, #animation#, GetPlayerX(i), GetPlayerY(i))    Next    Call PartyMsg(TempPlayer(Target).inParty, "The whole party has been stunned for three seconds!", Red)  Else    TempPlayer(Target).StunDuration = 3    TempPlayer(Target).StunTimer = GetTickCount    Call SendAnimation(#mapnum#, #animation#, GetPlayerX(Target), GetPlayerY(Target))    Call PlayerMsg(Target, "You have been stunned for three seconds!", Red)  End IfEnd Sub```This code checks if the player is in a party, and stuns the whole party. If not, it just stuns the player.We now want to go back to out "TestBossLogic" procedure, and add this line below the procedure delaration.```Call Stun(Target)```You could set an if statement to determine at what HP percentage the boss launches this attack, but I can leave that bit to you. You can also set a timer for periodical attacks by adding a new variable to the MapNpc UDT. Still, I'll leave this to you.Next, lets go back to the procedure "BossLogic". Replace the line saying "'Your first boss call will be here." with:```Call TestBossLogic(Target, #npcnum#)```Replace #npcnum# with the slot number of the npc on the map.Thats it for the modBosses! All we need to do server-side now is create a new NPC type, and link its attacking to the BossLogic.Go to modConstants, and search for the NPC behaviours. Underneath them, add this line:```Public Const NPC_BEHAVIOUR_BOSS As Byte = 5```If you have new npc behaviours, change the number accordingly.Finally, we want to make our way to modServerLoop. The specific procedure you are looking for is "Private Sub UpdateMapLogic()". In this procedure, search for this comment:```' Is the target playing and on the same map?```Under that there should be an if statement like this:```If IsPlaying(Target) And GetPlayerMap(Target) = MapNum Then  TryNpcAttackPlayer x, TargetElse  ' Player left map or game, set target to 0      MapNpc(MapNum).Npc(x).Target = 0      MapNpc(MapNum).Npc(x).targetType = 0 ' clearEnd If```Replace it with this:```If IsPlaying(Target) And GetPlayerMap(Target) = MapNum Then  If Npc(MapNpc(MapNum).Npc(x).Num).Behaviour = NPC_BEHAVIOUR_BOSS Then     Call BossLogic(Target, Npc(MapNpc(MapNum).Npc(x).Num).BossNum, MapNpc(MapNum).Npc(x).Num)  Else     TryNpcAttackPlayer x, Target  End IfElse     ' Player left map or game, set target to 0     MapNpc(MapNum).Npc(x).Target = 0     MapNpc(MapNum).Npc(x).targetType = 0 ' clearEnd If```This way it calls the boss logic if the npc's behaviour is a Boss.Finally, go to modTypes, and find the NpcRec UDT. At the bottom of it, above "End Type", add this:```BossNum As Integer```And that's the server-side code done! All that needs to be done now is a quick client-side editor modification.**Client Side**Open up "Client.vbp".Go to modTypes, and find the NpcRec UDT. At the bottom of it, above "End Type", add this:```BossNum As Integer```Navigate to frmEditor_NPC. Once you are there, you need to create a new layout as shown below:![](http://i801.photobucket.com/albums/yy294/Adrammelech_2009/4.png)Name the text box "txtBossNum", and the frame "fraBoss". Then add a new Behaviour to cmbBehavoir, name it "Boss".In the "txtBossNum_Change" event, paste this code in:```Private Sub txtBossNum_Change()If Not IsNumeric(txtBossNum.text) Then Exit SubNpc(EditorIndex).BossNum = txtBossNum.textEnd Sub```This saves the boss number for the server to use. It is the same as what we want to use for our test boss, so enter "1", without the speech marks.Next, go to modGameEditors, and find the procedure "NpcEditorInit". Under the last line where the text boxes etc. are populated, add this:```.txtBossNum.text = Npc(EditorIndex).BossNum```Finally, go to modConstants, and search for the NPC behaviours. Underneath them, add this line:```Public Const NPC_BEHAVIOUR_BOSS As Byte = 5```And there we go! You have just created a nice little framework for your games' bosses!Credit for this framework will be appreciated. If you find anything I may have missed out, send me a PM.Best of luck,Lightning Link to comment Share on other sites More sharing options...
gdog12356 Posted May 7, 2011 Share Posted May 7, 2011 haha thiss is awesome:) thank you for contributing Link to comment Share on other sites More sharing options...
Yxxe Posted May 7, 2011 Author Share Posted May 7, 2011 @gdog12356:> haha thiss is awesome:) thank you for contributingThanks gdog! If you find any errors, please don't hesitate to tell me, so I can get the tutorial fixed ASAP.Regards,Lightning Link to comment Share on other sites More sharing options...
Lavos Posted May 7, 2011 Share Posted May 7, 2011 whoa you released the source. good job mate. Link to comment Share on other sites More sharing options...
Yxxe Posted May 7, 2011 Author Share Posted May 7, 2011 @Miklatov:> whoa you released the source. good job mate.Thanks! I only released the framework, nothing else. I still think there's enough there to make your own bosses successfully. :P Link to comment Share on other sites More sharing options...
Socuine Posted May 7, 2011 Share Posted May 7, 2011 Very nice tutorial! C: Link to comment Share on other sites More sharing options...
erkro1 Posted May 7, 2011 Share Posted May 7, 2011 This is amazing, your the best programmer here after Robin ;) Link to comment Share on other sites More sharing options...
Yxxe Posted May 7, 2011 Author Share Posted May 7, 2011 @Socuine:> Very nice tutorial! C:Thanks Socuine!@Erkro1:> This is amazing, your the best programmer here after Robin ;)You're too kind, thanks! :'] Link to comment Share on other sites More sharing options...
Jeff Posted May 7, 2011 Share Posted May 7, 2011 I could see you making the next version of EO. Also, this is awesome! I'll test it out when I get my game going enough to HAVE boss battles xD Link to comment Share on other sites More sharing options...
schnurman Posted May 8, 2011 Share Posted May 8, 2011 Are you sure you not just robin and trying to hide it to seem nice ;), I am just kidding but this is a great source! Link to comment Share on other sites More sharing options...
gdog12356 Posted May 8, 2011 Share Posted May 8, 2011 @Schnurman:> this is a great source!its a script :p Link to comment Share on other sites More sharing options...
Robin Posted May 8, 2011 Share Posted May 8, 2011 @gdog12356:> its a script :pNo it isn't… -_- Link to comment Share on other sites More sharing options...
schnurman Posted May 8, 2011 Share Posted May 8, 2011 @Robin:> No it isn't… -_-Yeah it is an OBJECT oriented/event driven language. Link to comment Share on other sites More sharing options...
McCull96 Posted May 8, 2011 Share Posted May 8, 2011 Great work Lightning your stuff is always great Link to comment Share on other sites More sharing options...
shado360 Posted May 8, 2011 Share Posted May 8, 2011 I concur! You're such a generous person, Lightning! Link to comment Share on other sites More sharing options...
Yxxe Posted May 8, 2011 Author Share Posted May 8, 2011 Thanks everyone for the great feedback! I've just released another quick tutorial which may make your games look a little less cluttered:[Memory Leak-free Text Rendering](http://www.touchofdeathforums.com/smf/index.php/topic,71691.msg770272.html#new) Link to comment Share on other sites More sharing options...
Yxxe Posted May 8, 2011 Author Share Posted May 8, 2011 I would also like to inform everyone that the damage for all special attacks has to be done by you, it's not handled by the engine already. (If you weren't sure about this) Link to comment Share on other sites More sharing options...
Guest Posted May 17, 2011 Share Posted May 17, 2011 great stuff thanks for this! Link to comment Share on other sites More sharing options...
Yxxe Posted May 18, 2011 Author Share Posted May 18, 2011 @sotvotkong:> great stuff thanks for this!No problem. I can't wait to see what people do with my framework! Post your videos once you have an awesome boss finished! :] Link to comment Share on other sites More sharing options...
Jeff Posted May 19, 2011 Share Posted May 19, 2011 does your example code make a boss that automatically stuns people? If so, how often does it stun people? I have done everything correctly to my knowledge, created NPC, used correct numbers(I think) but the boss still doesn't stun me, it just attacks normally. Link to comment Share on other sites More sharing options...
Yxxe Posted May 19, 2011 Author Share Posted May 19, 2011 @Frosty:> does your example code make a boss that automatically stuns people? If so, how often does it stun people? I have done everything correctly to my knowledge, created NPC, used correct numbers(I think) but the boss still doesn't stun me, it just attacks normally.Make sure you have added the code correctly. Also, the stunning attack takes place every time the server loops the map logic. Of course, you don't want that, so just make a "timer" in the MapNpc UDT for timed events like that. Link to comment Share on other sites More sharing options...
adr990 Posted May 19, 2011 Share Posted May 19, 2011 Woah! Amazing!Really nice.Thanks dude, I will really try and play with it after I'm done with my exams. Link to comment Share on other sites More sharing options...
Yxxe Posted May 21, 2011 Author Share Posted May 21, 2011 @adr990:> Woah! Amazing!> Really nice.> Thanks dude, I will really try and play with it after I'm done with my exams.No problem and thanks! I can't wait to see what you do with it! Link to comment Share on other sites More sharing options...
Grimnnak Posted May 22, 2011 Share Posted May 22, 2011 This is pretty nice :D Link to comment Share on other sites More sharing options...
The New World Posted May 30, 2011 Share Posted May 30, 2011 You forgot to add this:```.txtBossNum.text = Npc(EditorIndex).BossNum```In the NpcEditorInit of modGameEditors. :P Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now