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

[EO 1.X+] Elemental Weapons/NPCs with Weakness


tehl33tjim
 Share

Recommended Posts

Hey guys, this is my first tutorial, and getting everything down pat with much help from Abhi, I present to you:

**Adding Elemental Properties to Weapons, and NPCs that are Weak to those Elements.**

We will be editing both the Client and the Server in this tutorial. It is not all that difficult, but I was surprised that there wasn't a tutorial of this nature to be found on here. What this will ultimately do is add a new variable to items, and to NPCs. Then we will have the server check to see if the weapon you are using and the NPC you are fighting both have the same value for this variable. If they do in fact both match, extra stuff will happen (in this tutorial I use a simple 2x damage modifier). With that being said…

**[Updated marsh 30th, 2013]** ~Fixed a simple bug in ModCombat, where if neither the currently equipped weapon nor the victim have no element, they do not take elemental damage.

Open up your **Client** in VB6-

In the **_ModTypes_** Module;

In:```
Private Type ItemRec
```
At the bottom after the last variable (usually ToolReq), add:

```
Element as Long
```

In:```
Private Type NPCRec
```
At the bottom after the last variable (usually Level), add:

```
Element as Long
```

In the _**ModGameEditors**_ Module;

In```
ItemEditorInit
```
Near the bottom, you will want to add:

```
frmEditor_item.scrlElement.value = .element
```

And then in [codeNpcEditorInit[/code]

Directly after:

```
.txtDamage.text = Npc(EditorIndex).Damage
```
Put:

```
.scrlElement.Value = Npc(EditorIndex).Element
```

In the _**FrmEditor_Item**_ Form;

Create a new _scrollbar_ with the following properties:

* (Name): scrlElement
* Max: 5
* Min: 0

Create a label nearby, with the following properties:

* (Name): lblElement
* Caption: E: None

Double click on the scrlElement and add this to the scrlElement_Change sub:

```
' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If EditorIndex = 0 Or EditorIndex > MAX_ITEMS Then Exit Sub

If scrlElement.Value = 0 Then

lblElement.Caption = "E: None"

ElseIf scrlElement.Value = 1 Then

lblElement.Caption = "E: Fire"

ElseIf scrlElement.Value = 2 Then

lblElement.Caption = "E: Ice"

ElseIf scrlElement.Value = 3 Then

lblElement.Caption = "E: Bolt"

ElseIf scrlElement.Value = 4 Then

lblElement.Caption = "E: Holy"

ElseIf scrlElement.Value = 5 Then

lblElement.Caption = "E: Dark"

End If

Item(EditorIndex).Element = scrlElement.Value

' Error handler

Exit Sub

errorhandler:

HandleError "scrlElement_Change", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub
```

Do the exact same thing in **_frmEditor_NPC_** form. (add the scrollbar, label, and change the subroutine).

Next, we're going to want to open up the **Server** to make some changes.

In the **_ModTypes_** Module;

In:```
Private Type ItemRec
```
At the bottom after the last variable (usually ToolReq), add:

```
Element as Long
```

In:```
Private Type NPCRec
```
At the bottom after the last variable (usually Level), add:

```
Element as Long
```

(this is exactly the same as you did in the Client, nothing difficult here).

In _**ModCombat**_;

Look for the sub:

```
Public Sub TryPlayerAttackNpc(ByVal index As Long, ByVal mapNpcNum As Long)
```
Shortly underneath that you will find a snippet:

```
Damage = GetPlayerDamage(index)
```
Underneath that, paste this:

```

' Double the damage if npc's element matches our weapon's element (i.e., the npc is weak to our weapon)

If GetPlayerEquipment(index, weapon) <> 0 Then

If Item(Player(index).Equipment(Equipment.weapon)).Element <> 0 Then

If Item(Player(index).Equipment(Equipment.weapon)).Element = Npc(npcNum).Element Then

SendActionMsg mapNum, "Super Effective!", BrightCyan, 1, (GetPlayerX(index) * 32), (GetPlayerY(index) * 32)

Damage = Damage * 2

End If

End If

End If

```

What that does is: first it checks to make sure we have a weapon equipped, then it runs the check - to see if the weapon's element matches the enemy's weakness element. And if so, damage is doubled. And I added an annoying SendActionMsg popup - which you should definitely not keep. Just there so you can make sure you did this correctly.

**_-Save_**

**_-Compile_**

**_-Run_**

And that should be it. You can always change the Max limit on both of the scrollbars to however high you want. It doesn't have to be actual elements, you can make them specific weapon types (make an Armored Mob who is weak against piercing spears, or something). If you guys have any questions, or bugs, please let me know. Good luck!
Link to comment
Share on other sites

Just a small mistake I found the code-snippet that multiples the damage should be in PlayerAttackNPC I beleive since the damage should multiply after every check is over. (Can attack, not defendable and stuff) But I might be wrong cuz I have never checked those subs ever.
Link to comment
Share on other sites

I was going to work on that this morning, actually. Theoretically, it should be very similar. Add a new variable to SpellRec, and then add the appropriate code under SpellEditInit in the ModGameEditors module. Add a scrollbar/label to the spell editor, set it up like we did for items and npcs. If the ModCombat sub is similar to regular combat, it should just require that last if-statement [ if spell(player).element = npc(npcnum).element then damage = damage * 2 ]

If I get time to mess around with it, I'll update the main post.
Link to comment
Share on other sites

Well in [at least the early] final fantasy games, there were usually certain weapons that dealt more damage to certain types of monsters, without specifically stating it. Silver weapons could do extra damage to undead, or werewolf types. Stuff like that.

It's not difficult at all to add resistance values as well, or even absorb so that when you cast Fire on that FlameTurtle it will get healed instead. ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png)
Link to comment
Share on other sites

  • 3 weeks later...
This is a great contribution and something I've been looking for.

~~How would I go about making damage double if the npc has a different element?

Example: Earth > Water > Fire > Air > Earth

And: Holy > Dark~~

Edit:

I made a few alterations if someone wants there to be opposing elements for double damage, instead of the same element. Such as: Water beating Fire etc.

Just change the original code pieces above to these:

```

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If EditorIndex = 0 Or EditorIndex > MAX_ITEMS Then Exit Sub

If scrlElement.Value = 0 Then

lblElement.Caption = "E: None"

ElseIf scrlElement.Value = 1 Then

lblElement.Caption = "E: Earth"

ElseIf scrlElement.Value = 2 Then

lblElement.Caption = "E: Air"

ElseIf scrlElement.Value = 3 Then

lblElement.Caption = "E: Fire"

ElseIf scrlElement.Value = 4 Then

lblElement.Caption = "E: Water"

ElseIf scrlElement.Value = 5 Then

lblElement.Caption = "E: Dark"

ElseIf scrlElement.Value = 6 Then

lblElement.Caption = "E: Holy"

End If

Item(EditorIndex).Element = scrlElement.Value

' Error handler

Exit Sub

errorhandler:

HandleError "scrlElement_Change", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

```

```

' Double the damage if npc's element is weak to our weapon's element

If GetPlayerEquipment(index, weapon) <> 0 Then

If Item(Player(index).Equipment(Equipment.weapon)).Element <> 0 Then

If Item(Player(index).Equipment(Equipment.weapon)).Element = 1 And Npc(npcNum).Element = 4 Then

SendActionMsg mapNum, "Super Effective!", BrightCyan, 1, (GetPlayerX(index) * 32), (GetPlayerY(index) * 32)

Damage = Damage * 2

End If

If Item(Player(index).Equipment(Equipment.weapon)).Element = 2 And Npc(npcNum).Element = 1 Then

SendActionMsg mapNum, "Super Effective!", BrightCyan, 1, (GetPlayerX(index) * 32), (GetPlayerY(index) * 32)

Damage = Damage * 2

End If

If Item(Player(index).Equipment(Equipment.weapon)).Element = 3 And Npc(npcNum).Element = 2 Then

SendActionMsg mapNum, "Super Effective!", BrightCyan, 1, (GetPlayerX(index) * 32), (GetPlayerY(index) * 32)

Damage = Damage * 2

End If

If Item(Player(index).Equipment(Equipment.weapon)).Element = 4 And Npc(npcNum).Element = 3 Then

SendActionMsg mapNum, "Super Effective!", BrightCyan, 1, (GetPlayerX(index) * 32), (GetPlayerY(index) * 32)

Damage = Damage * 2

End If

If Item(Player(index).Equipment(Equipment.weapon)).Element = 5 And Npc(npcNum).Element = 6 Then

SendActionMsg mapNum, "Super Effective!", BrightCyan, 1, (GetPlayerX(index) * 32), (GetPlayerY(index) * 32)

Damage = Damage * 2

End If

If Item(Player(index).Equipment(Equipment.weapon)).Element = 6 And Npc(npcNum).Element = 5 Then

SendActionMsg mapNum, "Super Effective!", BrightCyan, 1, (GetPlayerX(index) * 32), (GetPlayerY(index) * 32)

Damage = Damage * 2

End If

End If

End If

```

*Don't forget to change the max for scrlElement to 6 instead of 5.

It's currently set at the typical rpg style for elements:

Earth > Water > Fire > Air > Earth

Holy >< Dark
Link to comment
Share on other sites

  • 1 year later...
> Sorry revive the topic but I have a problem, in item editor he usually saves the weapon element but the npc editor he's not saving the element, save any other changes unless the element but not of any error in compiling etc, did exactly as it is on topic. what could it be?

Check your modGameEditors and see if you forgot to put in:

```
.scrlElement.Value = Npc(EditorIndex).Element

```
Link to comment
Share on other sites

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...