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

NPC combat dammage


teh jimpie
 Share

Recommended Posts

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

Hello

Ok, 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 If
End Sub

```
Let me know if this works.

Yours sincerely
cloudwolf00
Link to comment
Share on other sites

Hello

I 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 If
End Sub

```
Yours sincerely
Cloudwolf00
Link to comment
Share on other sites

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?  XD

in what folder/filename was that exactly. im sorry i dont understand 100%  :P
Link to comment
Share on other sites

Hello

Basically, 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 If
End Sub

```
I hope that this helps

Yours sincerely
cloudwolf00
Link to comment
Share on other sites

okay thanks now i understand  XD

good 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 If
End Sub

```
ehm this is wrong?  XD
Link to comment
Share on other sites

Hello

I 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 If
End Sub

```
Yours sincerely
cloudwolf00
Link to comment
Share on other sites

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
cloudwolf00
Link to comment
Share on other sites

@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
> cloudwolf00

Nice to see another scripter around.
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...