Elemental Weapons Vs Mobs w/ Elemental Weakness

Hey guys, so I’m having a bit of trouble with the syntax of putting this code together. Or perhaps my logic is not the most efficient way of doing this.

The concept is simple: Add a new attribute for weapons that would be considered an “element”. Add those same attributes to NPCs. During combat, it would check to see if player(index).weapon.element.fire (or whatever) is true, then damage = damage x 2, else damage = damage.

First off, I went Server Side:

ModTypes - under ItemRec, below “ToolReq as Long” I added “Element as Long”. From my understanding, this will store data as Item(index).Element, correct?

-under NpcRec, below “Level as Long”, I added “Element as Long” again.

I repeated this in the Client’s ModTypes as well.

Now is where I’m lost with syntax. In FrmEditor_Item, I added a scrollbar (scrlElement), min=0, max=5 (for starters, maybe I’ll add more elements later), I set up a label next to it so it will display the scrollbar value.

I did the same thing in FrmEditor_NPC with a scrollbar and label.

Private Sub scrlElement_Change()

' 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

' Error handler

Exit Sub

errorhandler:

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

Err.Clear

Exit Sub

End Sub

From what I can tell, this doesn’t change anything in the ItemRec’s Element - so how can I do that? AND, what would be the proper syntax of calling that variable again ServerSide under the ModCombat module?

Would it just be GetItem(index).Element? I think I’m going in the right direction, but a little foggy.

I have added Item(EditorIndex).Element = scrlElement.Value - and it compiled with no errors. I’m still having trouble figuring out how exactly do I call that data in ModCombat.


GetPlayerEquipment(index, equipment).element = 3

I think that is correct - but I am having difficulty with grabbing the NPC(index).Element…do I need to add an Element long variable under the MapNpcRec as well?

So till now what you did is correct. Now when the the editor is loaded up or a another item is selected you will have to change the data appropriately in the editor. So in modGameEditors in itemEditorInit and NPCEditorInit add this line of code. This might change to what you are using but the structure is the same.


frmEditor_item.scrlElement.value = .element

' NPCEDITORINIT

frmEditor_NPC.scrlElement.value = .element

VB will do the rest of changing the label.

Now for the modCombat, in PlayerAttackNPC there should be a part that handles damage (or a call to a sub) When this sub is called the following arguments are needed. Player index number, npc index number and some other stuff. With these values you can easily create your syntax. Here is a basic example. Please do not copy paste this but actually understand and try this yourself.


select case item(player(index).equipment(equipment.weapon)).element

case 1 ' fire

damage = damage *2

case n ' n should be a number.

end case

This is a rough code structure. If you have further questions please do ask cause this was really interesting to type out. :D

For some reason when I go to compile the Client, after adding the frmEditor_item.scrlElement.value = .element to the ItemEditorInit, and adding the frmEditor_NPC.scrlElement.value = .element to the NPCEditorInit, VB highlights the .Element part of the NPCInit code, and gives me an “invalid or unqualified reference”.

I do have a scrlElement scrollbar present on frmEditor_NPC, so wtf?

[Edit]SO, I got it to work. Client compiled![/edit]

–In the PlayerAttackNpc Sub (in ModCombat) - how exactly am I supposed to pull the data from the attacking Npc?

In the sub, from what I understand, is pulling the variables from MapNpc.

On a side note, not important to what I want to do, but where does “attacker” get defined? Throughout this entire module, it is only ever referenced, never created.

[Final Edit] Figured it out. Now to make a tutorial.[/Final Edit]

If you figured it out plz set the tag of the topic to resolved.

How, uh…do I do that? Nevermind. Didn’t realize I had to pop into full editor.

Log in to reply