teh jimpie Posted December 28, 2009 Author Share Posted December 28, 2009 Im trying to make a random attack dammage. I changed playerhit.ess to this, for a random npc hit.it 'works' but when the npc hits 0 it doesnt show above the head. is it possible to fix that?```'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Module: PlayerHit.ess '' Author: Stephan J.R. van Schaik '' Date: August 30th, 2009. '' Version: 1.0.0 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Function: PlayerHit '' Brief: executes when the player gets hit by a NPC. '' Parameters: '' Index: the index of the player. '' NPCNum: the NPC number. '' Damage: the damage given. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''Sub PlayerHit(Index, NPCNum, Damage) If Damage < 1 Then Exit Sub End If Damage = Rand(-1, 1)If Damage < 0 Then Damage = 0 Call NPCAttack(NPCNum, Index, Damage)End Sub``` Link to comment Share on other sites More sharing options...
xelander Posted December 28, 2009 Share Posted December 28, 2009 This is only a theory but:```Sub PlayerHit(Index, NPCNum, Damage)Dim RandRand = Rand(-1, 1)Damage = Damage + Rand If Damage > 0 then Call NPCAttack(NPCNum, Index, Damage) End IfEnd Sub```Could work Link to comment Share on other sites More sharing options...
teh jimpie Posted December 28, 2009 Author Share Posted December 28, 2009 1\. no sorry :sad:2\. congratelations with ur 500th post XD Link to comment Share on other sites More sharing options...
Ruins of Hell Posted December 28, 2009 Share Posted December 28, 2009 ```Sub PlayerHit(Index, NPCNum, Damage)Damage = Damage + Rand(-1, 1) If Damage > 0 Then Call NPCAttack(NPCNum, Index, Damage) End IfEnd Sub```Try this. Link to comment Share on other sites More sharing options...
teh jimpie Posted December 29, 2009 Author Share Posted December 29, 2009 same function, no hit when npc hit <= 0also tried:```Sub PlayerHit(Index, NPCNum, Damage)Damage = Damage + Rand(-1, 1)If Damage < 0 thendamage = 0end if If Damage > 0 Then Call NPCAttack(NPCNum, Index, Damage) End IfEnd Sub``` Link to comment Share on other sites More sharing options...
cloudwolf00 Posted December 29, 2009 Share Posted December 29, 2009 HelloOk, I have not had the chance to test this, it's just an idea. You say that it doesn't hit damage when the damage is equal to 0 or less. From looking at the script, I think that all you have to do is change your operators. I also changed the "Rand( -1, 1)" to "Rand (0,1)" as in your first script, when the damage was less than 0 e.g. -1, your script set the damage to 0, so just use 0.```Sub PlayerHit(Index, NPCNum, Damage)Damage = Damage + Rand(0, 1) 'If the damage is 0 or greater If Damage >= 0 Then Call NPCAttack(NPCNum, Index, Damage) End IfEnd Sub```Let me know if this works.Yours sincerelycloudwolf00 Link to comment Share on other sites More sharing options...
teh jimpie Posted December 29, 2009 Author Share Posted December 29, 2009 I'm sorry still dont work. the npc's dont even hit 0.i only see the hits if the NPC do dammage above 0but not when 0 or lowerI prefer rand(-1, +1) because you have more '0' hits then. Link to comment Share on other sites More sharing options...
cloudwolf00 Posted December 29, 2009 Share Posted December 29, 2009 HelloI have found the reason your script is not working, it’s not a problem with YOUR script, it’s just the way the NPCAttack function works and this function is contained in the source code of Eclipse, I had a feeling that this would be the problem and so I used my copy of VB6.0 to check:```Sub NPCAttack(ByVal X As Long, ByVal Target As Long, ByVal Damage As Long) Call NpcAttackPlayer(X, Target, Damage)End Sub```This function calls another function "NpcAttackPlayer(X, Target, Damage)" and it is this function that is causing no damage to be dealt.I’ll show you what I mean, read the code below to find the part that prevents the damage.NOTE: I only copy + pasted the top of this function so you can see what causes this error.```Sub NpcAttackPlayer(ByVal MapNpcNum As Long, ByVal Victim As Long, ByVal Damage As Long) Dim Name As String Dim Exp As Long Dim MapNum As Long If MapNpcNum < 1 Or MapNpcNum > MAX_MAP_NPCS Then Exit Sub End If If Not IsPlaying(Victim) Then Exit Sub End If If Damage < 1 Then - HERE IS THE REASON NO DAMAGE IS DEALT! Exit Sub - IT TERMINATES THE FUNCTION IF THE DAMAGE DEALT IS LESS THAN 0 End If```This function is not editable using SadScript as this is a source code based function that is found in the Eclipse source code. As such, unless you have a copy of VB6.0 then you cannot resolve your problem.Best advice, don’t bother dealing 0 damage, just deal damage if its greater than 0, like so:```Sub PlayerHit(Index, NPCNum, Damage)Damage = Damage + Rand(-1, 1) 'If the damage is greater than 0 If Damage > 0 Then Call NPCAttack(NPCNum, Index, Damage) End IfEnd Sub```Yours sincerelyCloudwolf00 Link to comment Share on other sites More sharing options...
teh jimpie Posted December 29, 2009 Author Share Posted December 29, 2009 so its unpossible?but if you re-add```If Damage < 1 Then - HERE IS THE REASON NO DAMAGE IS DEALT! Exit Sub - IT TERMINATES THE FUNCTION IF THE DAMAGE DEALT IS LESS THAN 0 End If```this, is possible to show the hits then? XDin what folder/filename was that exactly. im sorry i dont understand 100% :P Link to comment Share on other sites More sharing options...
cloudwolf00 Posted December 29, 2009 Share Posted December 29, 2009 HelloBasically, it’s impossible for you to change that line of code. This is not in a file or folder that you can access in Eclipse; it is a function that is contained within a Module in the Eclipse source code. This is the code that was used to create Eclipse and is what is compiled to create the Server and Client. Now, you cannot edit this function without the correct IDE (Integrated development environment) which in Eclipse's case is vb6.0\.This means that it is impossible (without Eclipse source edits) to show hits below 1 such as 0.I therefore suggest that you use my script that I provided and perhaps tell the user via a player message that the npc hit 0, for example:```Sub PlayerHit(Index, NPCNum, Damage)Damage = Damage + Rand(-1, 1) 'If the damage is greater than 0 If Damage > 0 Then Call NPCAttack(NPCNum, Index, Damage) 'If the damage was less than or equal to 0 Else Call PlayerMsg(Index, "The npc missed you!", WHITE) End IfEnd Sub```I hope that this helpsYours sincerelycloudwolf00 Link to comment Share on other sites More sharing options...
teh jimpie Posted December 29, 2009 Author Share Posted December 29, 2009 okay thanks now i understand XDgood way to do it while a message. i prefer battlemsg then :azn:```Sub PlayerHit(Index, NPCNum, Damage)Damage = Damage + Rand(-1, 1) If Damage > 0 Then Call NPCAttack(NPCNum, Index, Damage) End If If Damage < 0 Then Call BattleMsg(Index, "The NPC failed to hit you!", BRIGHTGREEN) End IfEnd Sub```ehm this is wrong? XD Link to comment Share on other sites More sharing options...
cloudwolf00 Posted December 29, 2009 Share Posted December 29, 2009 HelloI take it from your statement "ehm this is wrong?" that the script you used is not working, try this:```Sub PlayerHit(Index, NPCNum, Damage)Damage = Damage + Rand(-1, 1) 'If the damage is greater than 0 If Damage > 0 Then Call NPCAttack(NPCNum, Index, Damage) 'If the damage was less than or equal to 0 Else Call BattleMsg(Index, "The NPC failed to hit you!", BRIGHTGREEN, 0) End IfEnd Sub```Yours sincerelycloudwolf00 Link to comment Share on other sites More sharing options...
teh jimpie Posted December 29, 2009 Author Share Posted December 29, 2009 Yes, im sorry i edited my post and deleted that.urs = still not working. :sad: Link to comment Share on other sites More sharing options...
cloudwolf00 Posted December 29, 2009 Share Posted December 29, 2009 HelloSorry about that, I forgot to specify the side of the screen that you want the message to be displayed, I have updated my original post with the new, working script.Yours sincerelycloudwolf00 Link to comment Share on other sites More sharing options...
teh jimpie Posted December 29, 2009 Author Share Posted December 29, 2009 cloudwolf00 = pro :D Link to comment Share on other sites More sharing options...
Ruins of Hell Posted December 29, 2009 Share Posted December 29, 2009 Cloud, did you come from another engine/are a previous member? Because you seem really good at this. Link to comment Share on other sites More sharing options...
cloudwolf00 Posted December 29, 2009 Share Posted December 29, 2009 Hello SoulNope, I have not come from another engine, I have however used Eclipse for a few months in the past but have never had an account on the forums. However, I have finally decided to create an account and give something back to this engine, as it was Eclipse that really got me into game programming. Creating an account and helping members out also means that I can practise my scripting and I am currently working on a few scripts that I'll hopefully be releasing for Eclipse members to use some time in the near future.@teh jimpieGlad it workedYours sincerelycloudwolf00 Link to comment Share on other sites More sharing options...
Ruins of Hell Posted December 29, 2009 Share Posted December 29, 2009 @cloudwolf00:> Hello Soul> > Nope, I have not come from another engine, I have however used Eclipse for a few months in the past but have never had an account on the forums. However, I have finally decided to create an account and give something back to this engine, as it was Eclipse that really got me into game programming. Creating an account and helping members out also means that I can practise my scripting and I am currently working on a few scripts that I'll hopefully be releasing for Eclipse members to use some time in the near future.> > @teh jimpie> Glad it worked> > Yours sincerely> cloudwolf00Nice to see another scripter around. 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