Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO] Lightning's Boss Battle Framework


Yxxe
 Share

Recommended Posts

**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 Select
End 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 seconds
Private 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 If
End 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, Target
Else
    ' Player left map or game, set target to 0
            MapNpc(MapNum).Npc(x).Target = 0
            MapNpc(MapNum).Npc(x).targetType = 0 ' clear
End 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 If
Else
          ' Player left map or game, set target to 0
          MapNpc(MapNum).Npc(x).Target = 0
          MapNpc(MapNum).Npc(x).targetType = 0 ' clear
End 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 Sub

Npc(EditorIndex).BossNum = txtBossNum.text
End 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

  • Replies 56
  • Created
  • Last Reply

Top Posters In This Topic

@gdog12356:

> haha thiss is awesome:) thank you for contributing

Thanks 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

@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

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

  • 2 weeks later...
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

@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

  • 2 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×
×
  • Create New...