Zarnick123 Posted June 14, 2009 Author Share Posted June 14, 2009 well is there a way? I have an extremely elaborate skill system which I am writing. But before i go any further i would like to know if its possible Link to comment Share on other sites More sharing options...
balliztik1 Posted June 14, 2009 Share Posted June 14, 2009 Yes. In the OnAttack sub, do a check for the player's weapon. If the weapon is a certain value, don't do damage, else continue normally. Link to comment Share on other sites More sharing options...
Admiral Refuge Posted June 14, 2009 Share Posted June 14, 2009 Like this, as ballie said, OnAttack.```Dim WeaponWeapon = Int(GetPlayerInvItemNum(index, GetPlayerWeaponSlot(index)))If Weapon <> # Then Exit SubEnd If```Replace "#" with the item number you need, that can be the only one to hurt. Link to comment Share on other sites More sharing options...
Pasketi Posted June 15, 2009 Share Posted June 15, 2009 I'd like to use this also. How about:Only a certain weapon can hurt a certain enemyYou'd have to check for Players NPC target oslt. How would you do this? Link to comment Share on other sites More sharing options...
balliztik1 Posted June 15, 2009 Share Posted June 15, 2009 ```Sub OnAttack(Index, Damage) If Int(Damage) > 0 Then If Int(GetPlayerTarget(Index)) > 0 Then Target = GetPlayerTarget(Index) Call DamagePlayer(Index, Target, Damage) Else Target = GetPlayerTargetNPC(Index) Call DamageNPC(Index, Target, Damage) End If End IfEnd Sub```Here's the default OnAttack sub. The first thing you'll need to do is incorporate Admiral's weapon check. This can go at the top of the sub:```If GetPlayerWeaponSlot(index) > 0 Then Weapon = Int(GetPlayerInvItemNum(index, GetPlayerWeaponSlot(index)))Else Weapon = 0End If```Now, NPC damaging comes after the Else in this sub, so start there. The DamageNPC line is the only line you'll need to enclose with If-statements. You'll have two checks to do. The first is a check on the target number, and the second is a check on the weapon. I'll assume you'll be doing checks on targets more, so we'll use the target as our Select Case switch. You'll need to make cases for each target that you'll check on, COMBINED with conditionals for the weapons, like so:```Select Case Target Case 1 and Weapon = 5 'NPC 1 takes only half damage from weapon 5, for example Damage = Int(Damage / 2) Case 5 and (Weapon = 4 or weapon = 7) 'NPC 5 is immune to both weapon 4 and 7 Damage = 0 Case 5 and Weapon = 6 'NPC 5 is weak against weapon 6, though Damage = Damage * 2End Select```This will go above the damage line. I've provided examples of how to use the cases for various things and how to check multiple items for a single NPC, if necessary.All together, your new sub looks something like so:```Sub OnAttack(Index, Damage) If GetPlayerWeaponSlot(index) > 0 Then Weapon = Int(GetPlayerInvItemNum(index, GetPlayerWeaponSlot(index))) Else Weapon = 0 End If If Int(Damage) > 0 Then If Int(GetPlayerTarget(Index)) > 0 Then Target = GetPlayerTarget(Index) Call DamagePlayer(Index, Target, Damage) Else Target = GetPlayerTargetNPC(Index) Select Case Target Case 1 and Weapon = 5 'NPC 1 takes only half damage from weapon 5, for example Damage = Damage 2 Case 5 and (Weapon = 4 or weapon = 7) 'NPC 5 is immune to both weapon 4 and 7 Damage = 0 Case 5 and Weapon = 6 'NPC 5 is weak against weapon 6, though Damage = Damage * 2 End Select Call DamageNPC(Index, Target, Damage) End If End IfEnd Sub```Oddly enough, I think I just wrote _my_ new OnAttack sub. I like what I've done here. :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