Modding => Modding Discussions => Topic started by: DeeZire on November 18, 2015, 12:38:19 am
Title: Perks!
Post by: DeeZire on November 18, 2015, 12:38:19 am
I seem to recall Kva3imoda asking about perks here - http://torchmodders.com/forums/kva3imoda's-playground/perks/
I've revisited this a few times, and after a lot of trial and error (and much head scratching) I am very happy to report that I have managed to get the entire perk system up and working - and it's very cool :)
It works like this - after some pre-defined condition is met, players get awarded perk points. These are similar to skill and stat points, except they are used to 'purchase' perks rather than get assigned to skills or stats. Perks are very special 'abilities' or 'features' not normally accessible to players in the game and work a bit like passive skills that have no costs or player impact - they merely provide benefits that you cannot obtain through effects or affixes. It seems the perk functions are hardcoded to a very specific list (see below).
You can then use these perk points to purchase perks from a number of them in a menu. You can define how many perks are available to the player at any time, and you can even assign tasks to each perk that must be completed before the perk becomes active for the player (even if it has been 'purchased').
As proof of concept, I currently have a perk UI running as an extra menu below the journal menu. I have one perk set up that, once assigned, will give you extra gold each time you gain fame (currently it's 10% of the fame you earn also gets given to you in gold). I have it set up so that there's a list of perks, but you can only have one active at any time - you can select from a list of available perks which one to have active by toggling them on and off. Even when this perk is purchased and assigned, it only works (becomes active for the player) once the task has been completed - in this case, for testing purposes, you only have to kill one monster. And it all works :)
It will need a bit more work to be a decent addition to the game though...
First, I cannot find out how the game engine awards perk points. Despite my best attempts, I cannot find out how and where the game changes the static stat PLAYER PERK PTS TO SPEND (I do know it bears no relation to stat points, skill points, experience or fame). So in light of this, I created my own dynamic stat to substitute it which I can control based on conditions I specify, such as completing a quest, discovering an area, reaching a level or amount of fame etc etc. I even thought about merging this with an achievements mod or linking it up to Steam achievements and awarding perk points based on gaining achievements. So this is a non-issue as we can still access and use the system :) Note that I haven't tried assigning perk points in the player editor as with other starting stats as I'm pretty sure you can only use dynamic stats in that way.
Second, I can currently only make use of one perk - the one Runic conveniently left in the PERKS folder. If you open that file, it represents a good template for creating your own (note that you can only specify one task, TASK0, and one reward for completing that task, REWARD0). I tried porting the perks from TL1 to no avail as they are coded very differently and in a form that TL2 does not parse or recognise.
To complete this, it would be really helpful if somebody with the un-encrypted .exe file (the DRM-free version) could use a hex editor and search for strings that are used in the perk system so we could figure out any other functions that may be coded. A good starting point would be to search for PLAYERKILLS to determine what other task conditions there may be, and FAMETOGOLD to determine if there are more rewards that can be given. In TL1, some of these (unused) perks were also employed to trigger skills, effects and bonuses so if we can figure this out it could become a very powerful addition to the game.
Once I can clean this up a bit and polish the UI I'll upload a compiled mod that shows it all in action, right now it's a mess but works so I'm posting this out of pure excitement! It does look pretty cool, as I have used the skill tree menus from the beta that to me look very fitting for this purpose and are vastly different from the stock released game. In the meantime, any thoughts and input are welcome.
Title: Re: Perks!
Post by: lolesch on November 18, 2015, 05:51:36 am
Hey DeeZire, you totally got my attention! For a mod with advanced content I'll post about soon I'm looking for different extensions like achievements and the Perks would fit in perfectly!
So you can only have 1 Perk at the time or can this be preset somehow? Also did you figured out the conditions a little more? <STRING>TYPE:PLAYERKILLS <INTEGER>COUNT:0 what else is possible? Can they stack/save? like after killing "2" monsters i get double reward etc...
There is a PERK subfolder in the Affixes but i dont understand its content :)
I'm looking forward for your "perktestmod". keep it up!
Title: Re: Perks!
Post by: DeeZire on November 18, 2015, 06:38:54 am
No they don't stack - each perk is exclusive. You can however have as many perks as you like active at any one time (provided you have 'purchased' them and have completed their tasks).
We still have to figure out what else is possible for them - hence my request for somebody to peek through the .exe for any strings that might give us a hint.
What I do know is that there is no limit on how many there can be as the way I have configured everything means that the game simply reads every file in the media\perks directory and adds them to the list of perks you can choose from :)
Here is a template I used for a perk.dat file (comments annotated);-
[PERK] <TRANSLATE>NAME:Any String For The Name Of The Perk // this is what's parsed and displayed in the game <TRANSLATE>DETAILS:Converts each point of Fame earned into gold. // as above, this is the description for the perk <STRING>ICON:skill_slash // having trouble with this, I need to figure out the variable used to parse it <STRING>ICON_DISABLED:skill_slash_gray // same here so I am explicitly stating an icon in the UI file <INTEGER64>GUID:-3134059470467886625 // needed [TASK0] <STRING>TYPE:PLAYERKILLS // we need to figure out what other TYPEs exist for TASK0 <INTEGER>COUNT:10 <STRING>UNIT: Warbeast // kill 10 Warbeasts [/TASK0] [REWARD0] <STRING>TYPE:FAMETOGOLD // we need to figure out what other TYPEs exists for REWARD0 <INTEGER>FAME:1 [/REWARD0] [/PERK]
Title: Re: Perks!
Post by: Phanjam on November 18, 2015, 06:39:41 am
heeyyyy great work Deezire! This is exciting news!
Let's hope Chthon reads this soon and has time to do his hex magic ;)
Title: Re: Perks!
Post by: Kva3imoda on November 18, 2015, 08:20:17 am
heeyyyy great work Deezire! This is exciting news!
Let's hope Chthon reads this soon and has time to do his hex magic ;)
Chthon is traveling. Chthon will attempt hex magic in a few days.
Title: Re: Perks!
Post by: gytfunke on November 18, 2015, 08:31:50 am
Oh snap! This is cool.
Title: Re: Perks!
Post by: Chthon on November 18, 2015, 09:50:56 am
Turns out I had a copy of the exe on my laptop.
PLAYERKILLS and FAMETOGOLD each appear once. Here's the nearby strings:
PERKNOTACTIVE PERKACTIVE PLAYERSTAT MEDIA/PERKS/ PETKILLS MAINPETKILLS PLAYERKILLS GOLDTOFAME FAMETOGOLD MAINPETEFFECT PETSEFFECT PLAYERARMOREFFECT PLAYERWEAPONEFFECT PLAYEREFFECT MAINPETAFFIX PETSAFFIX PLAYERARMORAFFIX PLAYERWEAPONAFFIX PLAYERAFFIX REWARD0 [this might be just REWARD; can't tell if the final 0x03 is part of the string] TASK TASK0 [this might be just TASK; can't tell if the final 0x03 is part of the string] CONDITIONAL ACTIVATIONCONDITIONAL
And these are nearby, but I don't think they're part of the same block:
WEAPONTYPE TIMERUPDATE
Title: Re: Perks!
Post by: DeeZire on November 18, 2015, 12:41:43 pm
Wow, thanks for this, real fast progress already, I can get to work trying that lot!
More good news - I figured how to read the icons from the .dat files properly into the UI, so now all working well.
Title: Re: Perks!
Post by: lolesch on November 18, 2015, 03:33:21 pm
needs testing, but I came across the UI Hud which contains a small ListWindow for the Buff Icons from skills. Under properties the Game system is set to "Effects". The systems dropdown also contains "perks" so I guess it's possible to show Perks as buffs in a second Listwindow?!
Title: Re: Perks!
Post by: DeeZire on November 18, 2015, 04:14:34 pm
Yes, that's the game engine system you use to display perks which I've made use of, there's a fair bit more to it than that though I'll post the workings of it as soon as I can tidy things up and make sure it's all working as it should do. So far so good though!
Title: Re: Perks!
Post by: lolesch on November 20, 2015, 01:16:02 pm
did some research on Static Stats (http://docs.runicgames.com/wiki/Static_Stats) for something else when the "PERK" sprung into my eye...
PLAYER PERK PTS TO SPEND
maybe you have some use for it
Title: Re: Perks!
Post by: DeeZire on November 20, 2015, 03:06:03 pm
OK, so it's a little bit rough round the edges but here's a simple mod that let's you see it in action. Once you get it, you will see where I am going with this;- https://drive.google.com/file/d/0B5w_m-h6MlfvV0V1M25vSVV3R0k/view?usp=sharing
Instructions for use Unpack the mod then open it in GUTS. Set your character to Embermage, don't have a pet, and go into game mode (I've only done the UI for Embermage so far). In the skills menu, you will see a new tab for perks (4th one along) - click this and you will see the perks menu. I have configured this with 5 available perks but only the 'Filthy Lucre' one will actually do anything right now as it's the only one I have configured a reward for.
Perks in blue are available perks - you can choose from any or all of these to be active at any time. Perks in red are your active perks - the ones you have chosen to be active, i.e. you will get the benefits from them provided you have completed the task it needs. The way the system works is that you have to toggle perks between available and active.
Click one to select it (it will go brighter to indicate it is selected) then click the red button at the bottom. The chosen perk will now show in the upper part of the menu in red to indicate it is now active. Any currently chosen perks - whether in the available list or the active list - will always be displayed brighter and only one perk can be selected in this way at any time. To remove an active perk, select it (it will go brighter) then click the red button and it will be removed from your active perks and return to available perks - hope this makes sense, but as I said it is a little rough. Put simply, it has no text label but the red button is the 'toggle this perk' button ;)
Now to the good bit - make sure you have no perks in your active list. Spawn a Warbeast then kill it. In the available perks list, you will now see that you have completed the task for the Filthy Lucre perk. Before you make it active, spawn any champion and kill it. You will see that you get the fame a usual. Now make the Filthy Lucre perk active and spawn another champion and kill that - you will get the fame again, but you will now also get 10% of that fame added to your gold :)
How it all works It's a bit complicated so I'll do my best to explain as it's took me ages to figure all this out! It's mainly all down to the UI handling. The perks UI (my 4th tab here) requires a number of elements to function. First, it needs two list windows - one contains the active perks and must have the widget name ACTIVEPERKLIST to function. The second contains the available perks and must have the widget name PERKLIST to function. You will notice that these lists use the game system PERKS to handle their contents, and are also filtered to contain the unit type PERK only. Finally, it also needs the PerkMenuController which handles the toggling of the perks between those two lists. In turn, the PerkMenuController needs two further UI elements - one UI for an active perk (my red ones) and one UI for an available perk (my blue ones). Those UIs also need another element that handles their tooltips. These are all in the UI folder in this mod.
To function correctly, the available and active perk UI layouts must be toggle buttons. Inside these, several elements must be present in order for them to display the info from your perk .dat files. To display the icon, you must use an image with the widget name PERKICON. To display the name of the perk, you must use a text element with the widget name PERKNAME. To display the perk description you must use a text element with the widget name PERKDETAILS. Finally, to display any effects you assign through REWARD0 (see below) you must again use a text element with the widget name PERKEFFECTS.
To make your own perks, you need a .dat file in the MEDIA\PERKS folder. You can look at the ones in this mod to see their structure. The way the system works is that all of these .dat files are read by the game and the perks defined in this folder will all be listed in the UI list above that has the widget name PERKLIST. In other words, all defined perks in .dat files in the MEDIA\PERKS folder are automatically assigned as available perks (unless there's a conditional on the perk - see below).
The .dat files also need certain elements;- <TRANSLATE>NAME: the name of the perk, read and displayed with the UI widget PERKNAME <TRANSLATE>DETAILS: the perk description, read and displayed with the UI widget PERKDETAILS <STRING>ICON: the icon used for the perk, read and displayed with the UI widget PERKICON <INTEGER64>GUID: each perk is technically a unit type, so each one needs it's own unique ID
Perk .dat files must then define a task (TASK0), a reward (REWARD0) and can also have a condition. Task types can be one of the following but there's only really 3 types - kill something (or a number of somethings), complete a quest or meet a stat value;- PLAYERSTAT - a stat condition must be met PETKILLS - the players pets must kill a number of enemies MAINPETKILLS - the players main pet must kill a number of enemies PLAYERKILLS - the player must kill a number of enemies unaided by any pets QUESTCOMPLETE (to be tested) - the player must complete a quest
Reward types can be one of the following but there are really only 3 types - get an affix, get an effect or do something with gold and fame;- GOLDTOFAME - convert gold collected into fame as well FAMETOGOLD - convert fame gained into gold as well MAINPETEFFECT - apply an effect to the players main pet PETSEFFECT - apply an effect to all of the players pets PLAYERARMOREFFECT - apply an effect to the players armor PLAYERWEAPONEFFECT - apply an effect to the players weapon PLAYEREFFECT - apply an effect to the player MAINPETAFFIX - apply an affix to the players main pet PETSAFFIX - apply an affix to all of the players pets PLAYERARMORAFFIX - apply an affix to the players armor PLAYERWEAPONAFFIX - apply an affix to the players weapon PLAYERAFFIX - apply an affix to the player * by convention, affixes applied by perks should be in the MEDIA\AFFIXES\PERKS folder.
I have not yet figured out the conditional block, but there are two types - CONDITIONAL and ACTIVATIONCONDITIONAL which are used to make the perk available (or not) based on another perk being active (or not) or a stat being met (which I am presuming to be the stat PLAYER PERK PTS TO SPEND). I've also still got to figure out how to make proper use of the other reward types but this shouldn't be too difficult with a bit more trial and error.
So what this very small and simple mod does it enable the whole perks system so you can see how it works and links it to a kind of achievement system too without any of that overly complex mess that I've seen elsewhere. Completing a task earns you an achievement in the form of a perk - a very nice feature for the endgame and beyond, not entirely dissimilar to a Paragon points system or whatever but a lot more engaging.
Let me know what you think so far, and please feel free to play about with the .dat files and let me know how you get on trying to get other tasks, rewards and hopefully conditionals working :)
Title: Re: Perks!
Post by: lolesch on November 20, 2015, 03:25:47 pm
great! will test it soon to give some feedback
Title: Re: Perks!
Post by: Phanjam on November 22, 2015, 02:47:47 pm
Fantastic Deezire! Ima try this one out (by the weekend :( )
Title: Re: Perks!
Post by: lolesch on November 22, 2015, 09:38:35 pm
Hey Dee, I started to mess around with your mod, it feels so great to add a whole new mechanic to the game. excellent work!
Testing: I activated the "filthy Lucre" Perk, killed 1 warbeast and spawed a ZOMBIE_ANCIENT_CHAMP that gave me 150 Fame but 0 gold... As I followed your instructions 1 by 1 it worked. As i killed a warbeast activated the Perk and killed 2 champs, no gold then I de- and activated it again, killed more champs and gained the bonus... Result: The Fametogold isn't the best thing for testing because you cant see if its applied or not. better use playeraffix for testing.
I created a Perk myself using PLAYERSTAT and PLAYERAFFIX as reward but couldnt get it working. I'm using the Player Steps Taken Stat what is a static stat so I created a stat with that name and the Predefined_Int for dynamic use. still so result. I changed back to PLAYERKILL and got the affix applied (PERK_ROLLOVER.LAYOUT stays the same => hard to see if applied or not!)
I modded your PERK for testing and found something interesting: Now the progress showed 0/10, this is the total count 1+2+3+4 = 10 even if there are only 4 tasks and rewards... After killing 1! warbeast I ended up with 3/10 => there are 3 tasks containing kill Warbeast After killing more I ended up 7/10 => 1+2+4 => to get 10/10 I need to kill the 3 champs
This shows you can set up multiple different tasks to get the rewards. TaskX and RewardX are not bound to each other - i.e. for 2 "progressions/counts" you get 2 rewards. I believe the only thing you can set is the order you receive rewards. placing the same task multiple times makes less sense since "progression" will show wrong numbers until u hit the max count of that task. Playerstat needs testing... or I'm just dump setting it up.
this is gettin funky!
Title: Re: Perks!
Post by: DeeZire on November 23, 2015, 10:13:58 am
That's a great find, thanks - brilliant collaboration!
So it seems multiple tasks (and thus rewards) are entirely possible after all. In light of this, it's worth pointing out that each task needs to be exclusive - in your example, you have duplicate tasks that all require you to kill one or more Warbeasts - what you need to do is have 'kill a number of Warbeasts' as just one task. This will marry up the task completion with the tooltip status.
With the player stat task type, it may need something like <INTEGER>VALUE:10 instead of <INTEGER>COUNT:10 - this is where trial and error will be the only way to establish the syntax required to make it all work.
The more I look at this, the more it seems to bear relation to triggerables, so perhaps in some respects the syntax is similar.
Title: Re: Perks!
Post by: lolesch on November 23, 2015, 04:13:37 pm
Any progression on the CONDITIONAL block? I still cant get the PLAYERSTAT working. Here's my setup:
[TASK0] <STRING>TYPE:PLAYERSTAT <INTEGER>COUNT:1 <STRING>NAME:CHARACTER STEPS TAKEN// Statname to refer to// <INTEGER>VALUE:3// Stat Value// testing <FLOAT>VALUE:5// Stat Value// testing <FLOAT>MIN:2// Min Stat value// testing <FLOAT>MAX:2// Max Stat Value// testing <FLOAT>CHANCE:50// Chance// testing <STRING>WATCH_TYPE:GREATER THAN// watch type [/TASK0] none of them applied the reward. I've changed the stat to check if something's wrong with that, no changes. Running out of Ideas
Title: Re: Perks!
Post by: Chthon on November 23, 2015, 05:54:09 pm
Just to make sure, you did make sure that the stat exists in the stats editor and is set to predefined int, right?
Title: Re: Perks!
Post by: lolesch on November 24, 2015, 01:13:02 am
[CONDITIONAL] [/CONDITIONAL] // block to determine if perk can appear available list
[ACTIVATIONCONDITIONAL] [/ACTIVATIONCONDITIONAL] // block to determine if perk can be activated (appear in active list)
Both blocks can use 2 types - check a stat or check PERKNOTACTIVE or PERKACTIVE.
Title: Re: Perks!
Post by: lolesch on November 24, 2015, 04:25:55 pm
so they could be used as a requirement? lets say perk2 has a CONDITIONAL that checks for perk1 is completed/active (whatever) to actually appear in the list? The ACTIVECONDITIONAL could be an outer block for the TASK/REWARD? so after completing the perc automatically gets activated...
no progression over here
Title: Re: Perks!
Post by: Red on December 01, 2015, 11:11:43 am
This is too advanced for me, but I want to say I LOVE the idea of a perk system! This is a really interesting concept!
Title: Re: Perks!
Post by: DeeZire on December 04, 2015, 12:09:36 pm
Well I've spent a ton of time on a brute force technique trying every possible permutation of tags and code in a bid to get the QUESTCOMPLETE and PLAYERSTAT types to work for tasks but to no avail :(
So I've resorted to asking Runic, will keep you posted on what they say but I'm not entirely hopeful. Failing them throwing us a bone here, we're restricted to PLAYERKILLS types of tasks unless more trial and error can get the other types working.
I know Runic abandoned this whole perks thing so it may be that the code is incomplete and simply won't work, but I'd find that hard to swallow given how much of this residual stuff still works just fine plus they re-coded it when going form TL1 to TL2. Fingers crossed!