tehl33tjim Posted March 25, 2013 Author Share Posted March 25, 2013 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: 0Create a label nearby, with the following properties:* (Name): lblElement* Caption: E: NoneDouble click on the scrlElement and add this to the scrlElement_Change sub:``` ' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf EditorIndex = 0 Or EditorIndex > MAX_ITEMS Then Exit SubIf 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 IfItem(EditorIndex).Element = scrlElement.Value' Error handlerExit Suberrorhandler:HandleError "scrlElement_Change", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit 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 More sharing options...
Matt Posted March 25, 2013 Share Posted March 25, 2013 Looks good! Thank you for sharing ![^_^](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/happy.png) Link to comment Share on other sites More sharing options...
abhi2011 Posted March 25, 2013 Share Posted March 25, 2013 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 More sharing options...
tslusny Posted March 25, 2013 Share Posted March 25, 2013 Nice and simple tut ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Good work Link to comment Share on other sites More sharing options...
Elihu Posted March 26, 2013 Share Posted March 26, 2013 Great, we needed one of these for a long time XD. Is there a way to make it give skills an element too? Basically skills named like " Fire Ball" etc just have the animation of the element right now. Link to comment Share on other sites More sharing options...
tehl33tjim Posted March 26, 2013 Author Share Posted March 26, 2013 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 More sharing options...
hisherwin Posted March 31, 2013 Share Posted March 31, 2013 Hmm , i might create a NPC with Element then use a Weapon As effectiveness Link to comment Share on other sites More sharing options...
abhi2011 Posted March 31, 2013 Share Posted March 31, 2013 > Hmm , i might create a NPC with Element then use a Weapon As effectivenessGive an NPC a weapon? or did I misunderstand that statement? Link to comment Share on other sites More sharing options...
Vince Posted March 31, 2013 Share Posted March 31, 2013 I think, he speaks about the fact that using some Weapon will be more effective versus some type of NPC(depends on their element). Link to comment Share on other sites More sharing options...
tehl33tjim Posted April 1, 2013 Author Share Posted April 1, 2013 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 More sharing options...
Murdoc Posted April 17, 2013 Share Posted April 17, 2013 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 > EarthAnd: 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 outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf EditorIndex = 0 Or EditorIndex > MAX_ITEMS Then Exit SubIf 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 IfItem(EditorIndex).Element = scrlElement.Value' Error handlerExit Suberrorhandler:HandleError "scrlElement_Change", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit 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 IfIf 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 IfIf 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 IfIf 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 IfIf 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 IfIf 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 > EarthHoly >< Dark Link to comment Share on other sites More sharing options...
TheRexion Posted April 17, 2013 Share Posted April 17, 2013 Oh wow, great contribution! I wonder why something like this has not been done already. Link to comment Share on other sites More sharing options...
escfoe2 Posted April 22, 2013 Share Posted April 22, 2013 Nicely done!I'm doing something very similar with my engine. Good to see I'm not the only with great ideas XD (Wizzy gave me the idea lol) Link to comment Share on other sites More sharing options...
gallighanmaker Posted March 31, 2015 Share Posted March 31, 2015 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? Link to comment Share on other sites More sharing options...
SkywardRiver Posted March 31, 2015 Share Posted March 31, 2015 > 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 More sharing options...
gallighanmaker Posted March 31, 2015 Share Posted March 31, 2015 I followed the tutorial as I said already is added, I found it very strange not save the npc and save item ;z![](http://i.imgur.com/5F5lDUj.png) Link to comment Share on other sites More sharing options...
SkywardRiver Posted March 31, 2015 Share Posted March 31, 2015 Hmmmm. Are you sure it's not saving the Element on the NPC and just not _showing_ that it's saved? Does the functionality work? Link to comment Share on other sites More sharing options...
gallighanmaker Posted March 31, 2015 Share Posted March 31, 2015 I believed that it would be but does not work as well, but not of any error in modcombat or elsewhere. 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