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

Custom random resource hp.


Domino_
 Share

Recommended Posts

Hey! This is one of small features from my work on OW project.

You can randomly set from min to max value hp to resource.

Example: scrl health = 4 and healthmax = 100 so the resource can have randomly from 4 to 100 hp every time he spawns. ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)

**Client Side**

frmEditor_Resource =>

Change **lblHealth** caption to " _Health: 0 - 0_ "

**Afther scrlHealth** add one more scroll bar **scrlHealthMax** with min 0 and max 255 value.

Double click on **scrlHealth** and replace this code

```

Private Sub scrlHealth_Change()

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

lblHealth.Caption = "Health: " & scrlHealth.Value

Resource(EditorIndex).health = scrlHealth.Value

' Error handler

Exit Sub

errorhandler:

HandleError "scrlHealth_Change", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

```
With

```

Private Sub scrlHealth_Change()

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

lblHealth.Caption = "Health: " & scrlHealth.value & " - " & scrlHealthMax.value

Resource(EditorIndex).health_min = scrlHealth.value

' Error handler

Exit Sub

errorhandler:

HandleError "scrlHealth_Change", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

```

And add this in Resource form somewhere in bottom of **frmEditor_Resource**

```

Private Sub scrlHealthMax_Change()

lblHealth.Caption = "Health: " & scrlHealth.value & " - " & scrlHealthMax.value

Resource(EditorIndex).health_max = scrlHealthMax.value

End Sub

```

Next, in **ResourceRec** add

```

health_min As Byte

health_max As Byte

```
and delete

```

health As Long

```

In **modGameEditors**

afther

```

.scrlTool.value = Resource(EditorIndex).ToolRequired

```
in **ResourceEditorInit** add

```

.scrlHealthMax.value = Resource(EditorIndex).health_max

.scrlHealth.value = Resource(EditorIndex).health_min

```
and delete

```

.scrlHealth.value = Resource(EditorIndex).health

```

**Server Side**

Do same in **ResourceRec**

Add

```

health_min As Byte

health_max As Byte

```
and delete

```

health As Long

```

Change sub

```

Public Sub CacheResources(ByVal mapnum As Long)

```
In **ModGameLogic** to

```

Public Sub CacheResources(ByVal mapnum As Long)

Dim x As Long, y As Long, Resource_Count As Long

Resource_Count = 0

For x = 0 To Map(mapnum).MaxX

For y = 0 To Map(mapnum).MaxY

If Map(mapnum).Tile(x, y).Type = TILE_TYPE_RESOURCE Then

Resource_Count = Resource_Count + 1

ReDim Preserve ResourceCache(mapnum).ResourceData(0 To Resource_Count)

ResourceCache(mapnum).ResourceData(Resource_Count).x = x

ResourceCache(mapnum).ResourceData(Resource_Count).y = y

ResourceCache(mapnum).ResourceData(Resource_Count).cur_health = rand(Resource(Map(mapnum).Tile(x, y).Data1).health_min, Resource(Map(mapnum).Tile(x, y).Data1).health_max)

End If

Next

Next

ResourceCache(mapnum).Resource_Count = Resource_Count

End Sub

```

and now in **ModServerLoop** replace

```

ResourceCache(mapnum).ResourceData(i).cur_health = Resource(Resource_index).health

```
with

```

ResourceCache(mapnum).ResourceData(i).cur_health = rand(Resource(Resource_index).health_min, Resource(Resource_index).health_max)

```

**DELETE ALL YOUR RESOURCES AFTHER IMPROVING THEM WITH THIS CODE!**

_Report bug's and give credits if you think its needed to. ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)_

**Bit changed tutorial so you dont need to delete old scrl and add scrl min, old scrl will be the small value(scrlMin).** **If I forgot something then report. ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)**
Link to comment
Share on other sites

You forgot to mention that you need to remove scrlHealth and the code that it uses. Rather obvious, especially to those experienced with coding in Eclipse, but I thought I'd point it out anyways. Otherwise, it looks good! I look forward to trying this out. :)
Link to comment
Share on other sites

Ohh , yea sorry. I just looked in my old messy ow project what I started with less skills than I have now, and just added all from it here, and looked for some codes in blank eo to let people who read to understand this bit better. ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)

Ill update 1st post. ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)
Link to comment
Share on other sites

Of course not, although there's more use for this in resources because the damage that's done to the resource is constant, whereas actual NPC damage is somewhat random. The only thing i can think of that needs something like this would be spell damage…

But if you want to put it into npcs, it shouldn't be hard. I did a similar thing. I converted Scott's Multiple Drop and Percentiles to resources.
Link to comment
Share on other sites

> I converted Scott's Multiple Drop and Percentiles to resources.

Yea I did the same xD

Also with this you can make random everything like , player,npc damage, npc health, npc range, or even stats. ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)

p.s. this could be cool for random exp. hmmm, ill make tut tomorrow if I wont forget. xD
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...