• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Best Way to Implement an RPG Stat System

Status
Not open for further replies.
Level 5
Joined
Sep 24, 2015
Messages
33
I have a little spreadsheet here, you can open it in google sheets too and all the formulas should still work. Although the data in the spreadsheet isn't yet complete, the formulas in it are pretty much complete. There are only a few formulas related to the weapon stats that need some tweaking and I might tweak the input data a bit as needed. The one for Weapon Range is messed up.

The output on the Stat Calculator page is what I use to determine what a unit's stats will be for the sandbox maps that I've been making for my own amusement.

I've noticed in Reforged (maybe it's always been there, I didn't know much about code 10-15 years ago), there is a JASS script editor, but I've also seen LUA being discussed (which I'm much more familiar with.)

What I want to do is convert everything in the spreadsheet into a system I can use to modify stats in the Object Editor on units. For input, I figure I could use text in the unit description box. Then I need a few functions to create output that can be applied to a unit-type to determine their stats so I don't have to spend hours tweaking hundreds of units in the object editor every time I change an aspect of a race. I hope a few simple functions could be able to initialize with the map and automatically generate all the unit's stats. I just don't have any ideas as to the best place to start implementing my solution.

I know what I want well enough to write it out in pseudo code, but I figure this spreadsheet is a good example of what I'm trying to do.
 

Attachments

  • Warcraft 3 Sandbox Map Formulas.xlsx
    126.9 KB · Views: 6

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,549
This sort of thing is out of my league but there's some pretty cool stuff going on here:
They have a Constant Generator which will find all of the units in the Object Editor that you've edited (particularly any that you have changed the name of), and generate a constant variable that acts as the rawcode for each of those units. So if something like that exists, where it's reading the Object Editor data and spitting out code, I imagine what you want to do is possible as well.

The Uncle (bad) method would be to write a program that converts that spreadsheet into usable function calls, ie:
Lua:
-- This function stores the data of a unit
function CreateUnitClass(name, unitTypeId, strength, agility, intelligence)
    -- apply the parameters to some kind of unit class
end

-- These function calls would get generated using the info from the spreadsheet
CreateUnitClass("Goblin", FourCC('u000'), 1, 2, 3) -- FourCC() is used to get the Integer from the rawcode
CreateUnitClass("Bandit", FourCC('u001'), 2, 1, 4)
CreateUnitClass("Golem", FourCC('u002'), 5, 5, 5)

-- Now whenever you want to create a unit you would call this function
function CreateUnitFromClass(playerId, unitClass, x, y, face)
    -- load the data from the provided unit class
    -- and apply the loaded data to the newly created unit
    local u = CreateUnit(playerId, unitClass.unitTypeId, x, y, face)
    BlzSetUnitIntegerField(u, UNIT_IF_STRENGTH, unitClass.strength)
    BlzSetUnitIntegerField(u, UNIT_IF_AGILITY, unitClass.agility)
    BlzSetUnitIntegerField(u, UNIT_IF_INTELLIGENCE, unitClass.intelligence)
end
Something like that... Of course my way is limited since there's bound to be a stat or two that you cannot modify outside of the Object Editor. It's also inefficient since I'm applying the changes to the unit the moment it's created instead of modifying the map's Object Editor data.
 
Last edited:
Level 5
Joined
Sep 24, 2015
Messages
33
The Uncle method was the one I was considering; figured that would be bad, but nice to know it might not be my only option.

I'm not what this Constant Generator is or what its limitations are, but that sounds highly preferable to overloading my map with lengthy functions that are called every time a unit is created and are limited to only certain stats.

It sounds like exactly what I was hoping for. If I understand correctly, all the unit data from the object editor can be exported and turned into a variable by this Constant Generator, and then, from there I can just create a set of functions that perform the same role as the ones in my worksheet to automatically adjust the exported object editor data.

If this works, it might allow me to make a tool that could easily be used by others to make RPG-style units.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,549
The Uncle method was the one I was considering; figured that would be bad, but nice to know it might not be my only option.

I'm not what this Constant Generator is or what its limitations are, but that sounds highly preferable to overloading my map with lengthy functions that are called every time a unit is created and are limited to only certain stats.

It sounds like exactly what I was hoping for. If I understand correctly, all the unit data from the object editor can be exported and turned into a variable by this Constant Generator, and then, from there I can just create a set of functions that perform the same role as the ones in my worksheet to automatically adjust the exported object editor data.

If this works, it might allow me to make a tool that could easily be used by others to make RPG-style units.
I would talk to the smarties in that thread I linked, they should be able to point you in the right direction.
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
Years ago you would have used the ObjectMerger for this, but that's no longer possible in the reforged editor because //! external calls no longer work. Here's a relevant tutorial on that: Lua Object Generation.

If you do not need any of the new native functions introduced in the last few years of patches you could always downgrade to the JNGP Lua version (which is afaik no longer directly supported or developed so ymmv) which is the last editor that could run such calls. It would then be a matter of parsing your spreadsheet into the relevant objectmerger calls to create the objects, which probably wouldn't actually be that hard. Not a great solution, unfortunately, and perhaps strictly inferior to what Uncle linked.

It is also likely that you could develop the map on the current patch, use the JNGP Lua version on a separate blank map to generate the object data, and then export that data from the 'blank' map to the real map using the current editor.
 
Status
Not open for further replies.
Top