Domino_ Posted September 25, 2012 Author Share Posted September 25, 2012 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 outIf Options.Debug = 1 Then On Error GoTo errorhandlerlblHealth.Caption = "Health: " & scrlHealth.ValueResource(EditorIndex).health = scrlHealth.Value' Error handlerExit Suberrorhandler:HandleError "scrlHealth_Change", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```With```Private Sub scrlHealth_Change()' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerlblHealth.Caption = "Health: " & scrlHealth.value & " - " & scrlHealthMax.valueResource(EditorIndex).health_min = scrlHealth.value' Error handlerExit Suberrorhandler:HandleError "scrlHealth_Change", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```And add this in Resource form somewhere in bottom of **frmEditor_Resource**```Private Sub scrlHealthMax_Change()lblHealth.Caption = "Health: " & scrlHealth.value & " - " & scrlHealthMax.valueResource(EditorIndex).health_max = scrlHealthMax.valueEnd Sub```Next, in **ResourceRec** add```health_min As Bytehealth_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 Bytehealth_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 LongResource_Count = 0For 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 NextNextResourceCache(mapnum).Resource_Count = Resource_CountEnd 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 More sharing options...
Matt Posted September 25, 2012 Share Posted September 25, 2012 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 More sharing options...
Domino_ Posted September 25, 2012 Author Share Posted September 25, 2012 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 More sharing options...
or3o Posted September 25, 2012 Share Posted September 25, 2012 This seems like a pretty cool idea, and it doesnt look like it would take too much to change it so npcs could have different hp too ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Link to comment Share on other sites More sharing options...
Matt Posted September 25, 2012 Share Posted September 25, 2012 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 More sharing options...
Domino_ Posted September 25, 2012 Author Share Posted September 25, 2012 > I converted Scott's Multiple Drop and Percentiles to resources.Yea I did the same xDAlso 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 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