Saving User made stats (Kill counter example)

Post here about all aspects of D2 mod making whether it's information, problems or whatever. Please specify whether your post is relating to Classic D2 or the Expansion.

Moderator: Nizari

User avatar
SVR
Retired staff
Arch-Angel
Posts: 1449
Joined: Sat Nov 02, 2002 11:04 pm
Location: Texas
United States of America

Hand-picked

Saving User made stats (Kill counter example)

Post by SVR » Thu Jan 29, 2004 8:19 pm

There is a way to make you own stats save in the savefile. It comes in handy for counters and such. I used the technique to create a kill counter but there are endless possibilities.

Normally when adding stats, they are added to the next row & ID. Due to the way D2 handles global character stats, you can only use these as item stats. Problem is, item stats can't be modified easily and require an item.

Solution: Use an "unused" entry that's less than 255. This will create a 'global' stat that can be saved with the characters stats.

As an example, I'll go through how I created the Kill Counter.

First, make a 'kill_counter' stat. This will be saved in savefile and loaded each game.

In itemstatcost.txt...

Code: Select all

Find unused183 entry and change these columns ...

Send Bits = 32    (send this stat to clients )
Saved     = 1     (yes, save this stat)
CSvSigned = 0     (not needed but you may want to save negitive values)
CSvBits   = 32    (could be whatever you need, up to 32)
Devide    = 1024  (I just stuck this here to avoid /zero , maybe not needed.)
Direct    = 1     (must be 1 to allow changes through skill, maxstat not required)
Next, make some way to modify the stat. You may choose elixers,potions,skills etc.
I used a skill.

In Skills.txt ...

Code: Select all

Add a new row & use next ID. Changes these columns ...

skill      = CountKills
Id         = 357
skilldesc  = prayer  (not needed but you can add a skilldesc entry if you want to)
srvdofunc  = 65      (the prayer function, modifies the aurastat over time)
aurafilter = 65795   (not sure here, I think its the right one for player only ?)
aurastate  = prayer  (you can/should make your own state to avoid conflicts)
aurastat1  = unused183 (put your stat to modify here)
aurastatcalc1 = 1    (value to add to your stat, may use the calcs & params to get fancy)
attackrank = 0       (probably not needed)
range      = none    (no range required)
monanim    = xx      (not needed ?? )
itemeffect = 1       (yes, need to use for items)
reqlevel   = 1       (ok)
aura       = 1       (do we need this for an item triggered effect ? )
InGame     = 1       (yes,works in game)
hitshift   = 8       (not needed ?)
Now, you need a way to display the stat. This trick can be used to display *any* stat.

In itemstatcost.txt ...

Code: Select all

Add a new row & use next ID. Create a dummy stat for op function target.

Stat   = dummy      (name doesn't matter, just make it unique)
Id     = next Id


Add a new row & use next ID. Create a display only stat.

Stat      = display_kills
Id        = next Id
Divide    = 1024       (no /zero)
Save Bits = 1          (must have at least one save bit to save item stats)
op        = 2          ( stat * op base >> op param )
op param  = 0          ( no divide, we want to see the real value of "op base" )
op base   = unused183  (the stat to display)
op stat1  = dummy      (we don't want to add the stat to anything, use dummy)
descpriority = 180     (use whatever you want. determines order in which stats are displayed)
descfunc  = 3          (show stat as "number Text". no +/- or % )
descval   = 1          (show number *before* text)
descstrpos = KillCount (string table key, set key to " Kills")
descstrneg ... same
That's it for the basic setup. I used Udie Too to put the skill on a charm using skill_on_kill to fire the skill and count kills. I could have put it in skill on attack,death etc to count those instead. I made another charm with the display_kills stat so I could see how many kills.

To use this in a 'real' mod you need to add a property.txt entry for the display_kills stat so you can have it generate on an item. And add the skill_on_kill with the CountKills parameter to a startup item or Quest reward etc.

It's pretty cool, you can drop the display charm and later pick it up and it shows the right kills. If another player picks it up, it shows their kills ;-)



Other possibilities ... many,many

Instead of the dummy stat, make it 'level'. When holding the charm, number of kills increases your level making very high levels possible.

'Blood Lust' skill. Increase counter on kills. Decrease over time. Apply to Strength and Stamina. If you keep killing you're god, stop and you get weak (as long as the aura is active ;-)

To Do: Need to figure out event functions. Would be nice to use them instead of skills as triggers.

User avatar
kingpin
Retired Admin
Cherub
Posts: 10954
Joined: Sat Jan 11, 2003 12:51 pm
Sweden

Hand-picked

Re: Saving User made stats (Kill counter example)

Post by kingpin » Thu Jan 29, 2004 8:42 pm

This is good news, so the unused rows was more important than we knew first.

For events there are a post somewhere in GMM how they works.

Also, you can look into events.txt for what different of events that exist.
Last edited by kingpin on Thu Jan 29, 2004 8:43 pm, edited 1 time in total.

User avatar
Darque
Retired staff
Arch-Angel
Posts: 1052
Joined: Fri Aug 01, 2003 9:04 am
Location: Poplar Grove, IL

Re: Saving User made stats (Kill counter example)

Post by Darque » Thu Jan 29, 2004 11:52 pm

Is thre any way to make this stat appear in the charactor abilities page?
Diabolic Studios Web Site | Forum
THoC Beta v8.1Download | Feedback

Infinitum Web Site
Read The Forum Terms of Service

User avatar
kingpin
Retired Admin
Cherub
Posts: 10954
Joined: Sat Jan 11, 2003 12:51 pm
Sweden

Hand-picked

Re: Saving User made stats (Kill counter example)

Post by kingpin » Thu Jan 29, 2004 11:59 pm

There is, I'm working currently on a heavy GUI documentation that I will make public when its done. I'm currently up in 27 pages in word and have still a lot left to add. The function you need to use is a D2Win function, for example you can look into SG's killcounter tutorial.

User avatar
pmpch
Forum Legend
Arch-Angel
Posts: 1171
Joined: Thu Dec 19, 2002 12:21 am
Location: Switzerland

Re: Saving User made stats (Kill counter example)

Post by pmpch » Fri Jan 30, 2004 1:54 am

This sounds very interesting. Although I don't get what 'actually' makes the counter know when something is killed.
Bedevere: Well, now, uh, Launcelot, Galahad, and I, uh, wait until nightfall, and then leap out of the RABBIT, taking the French, uh, by surprise. Not only by surprise, but totally unarmed!
King Arthur: Who leaps out?

User avatar
SVR
Retired staff
Arch-Angel
Posts: 1449
Joined: Sat Nov 02, 2002 11:04 pm
Location: Texas
United States of America

Hand-picked

Re: Saving User made stats (Kill counter example)

Post by SVR » Fri Jan 30, 2004 2:21 am

[quote=pmpch";p="151506"]I don't get what 'actually' makes the counter know when something is killed.[/quote]

The skill_on_kill added to an item. It fires the CountKills skill which increments the counter stat using the same function number prayer uses to increase health ;-)

User avatar
pmpch
Forum Legend
Arch-Angel
Posts: 1171
Joined: Thu Dec 19, 2002 12:21 am
Location: Switzerland

Re: Saving User made stats (Kill counter example)

Post by pmpch » Fri Jan 30, 2004 2:32 am

:idea: :idea: :idea:

omg, I can't believe, I even asked this. Time for a break. Vacation coming up :mrgreen:
Bedevere: Well, now, uh, Launcelot, Galahad, and I, uh, wait until nightfall, and then leap out of the RABBIT, taking the French, uh, by surprise. Not only by surprise, but totally unarmed!
King Arthur: Who leaps out?

User avatar
MagicMatze
Junior Member
Champion of the Light
Posts: 324
Joined: Sun Jan 25, 2004 8:53 pm
Location: Good old Germany
Germany

Re: Saving User made stats (Kill counter example)

Post by MagicMatze » Sat Jan 31, 2004 2:19 pm

Yeah, this is really nice!

Now i have a charm with a monstercounter and a playerdeath counter on a charm!

Ive tested the changes with my sorceress and i became frustated! :cry: Because kills with my spells didn't appear on the counter! Only melee Dmg is working.
But for now - i can live with this (i think someone can fix it).

And dont forget to change the "ClientDoFunc" also in the skills to 65!!! (SVR forget it in his guide - i think)

And you should create a new state in state.txt with copy and paste the prayer line and rename it to "moncounter". Then remove the Overlay and Sound entrys so the skill is working "hidden".

And don't give the skill to a charakter, because with this skill on right-mouse icon the skill counts and counts and counts!

It would be nice, if someone checks the maximum value of the counter (is it +32.767 for integer or is it greater?)
If its so and someone kills more monsters (i dont know if this is a "normal" Char1-99 monsterkill) does the game crash?

Now i thank SVR a lot, because he was really fast with his killcounter and beware me from a nervous-breakdown!! Thank you :mrgreen:

edit: Have tested the max value and it is enough! (< 1 Mrd. Monsterkills possible)
Last edited by MagicMatze on Sat Jan 31, 2004 5:00 pm, edited 1 time in total.

User avatar
SVR
Retired staff
Arch-Angel
Posts: 1449
Joined: Sat Nov 02, 2002 11:04 pm
Location: Texas
United States of America

Hand-picked

Re: Saving User made stats (Kill counter example)

Post by SVR » Sat Jan 31, 2004 7:08 pm

MagicMatze";p="151811" wrote:Ive tested the changes with my sorceress and i became frustated! :cry: Because kills with my spells didn't appear on the counter! Only melee Dmg is working.
Hmm, didn't try that ! Maybe range has an effect ? Could be the on_kill event only occurs in melee :(
And dont forget to change the "ClientDoFunc" also in the skills to 65!!! (SVR forget it in his guide - i think)
Nope, didn't even think of it. Why is it needed ? I tend to remove everything I don't notice having an effect ;-)
Have tested the max value and it is enough! (< 1 Mrd. Monsterkills possible)
With 32 bits, it wraps to zero after 4 bil or so;-)

User avatar
ChaosEnergy
Forum Regular
Angel
Posts: 677
Joined: Wed Dec 03, 2003 3:48 pm
Location: NRW

Re: Saving User made stats (Kill counter example)

Post by ChaosEnergy » Sun Feb 01, 2004 4:16 pm

HI

I implemented 5 counters
- monsters killed
- monster attacked
- monster hit
- myself gethit
- my personal death counter

melee attack works fine (all three stats)
bow/throwing weapon (only killed and hit works, attack not)
CasterSpell nothing works
Throwing Potions, behaviour like Caster...nothing counts

- played with eg item_skillonkill in itemstatcost, coloumn damagerelated removed the 1 for all char against monster parts..nothing changes

- changed RANGE in skills.txt to BOTH, no luck


will try more...plz post all what you tried here...so we can find quicke a solution..

tnx
Chaos
Last edited by ChaosEnergy on Thu Feb 05, 2004 3:39 pm, edited 2 times in total.

User avatar
Grave
Posts: 18
Joined: Tue Aug 13, 2002 5:44 pm
Location: Graveyard

Re: Saving User made stats (Kill counter example)

Post by Grave » Fri Feb 06, 2004 3:19 pm

would it be possible to use passive skill as counter?
(available for every char and right from the char creation)

Grave

*eat people, not animals*

User avatar
SVR
Retired staff
Arch-Angel
Posts: 1449
Joined: Sat Nov 02, 2002 11:04 pm
Location: Texas
United States of America

Hand-picked

Re: Saving User made stats (Kill counter example)

Post by SVR » Fri Feb 06, 2004 5:09 pm

[quote=Grave";p="152894"]would it be possible to use passive skill as counter?[/quote]

You have to trigger the count somehow. I haven't done any testing on passives, but there is a passive event function.
I haven't found much info on it.

User avatar
kingpin
Retired Admin
Cherub
Posts: 10954
Joined: Sat Jan 11, 2003 12:51 pm
Sweden

Hand-picked

Re: Saving User made stats (Kill counter example)

Post by kingpin » Fri Feb 06, 2004 5:21 pm

The first that needs to be checked is if the passive event is loaded at all. From my previous testing I couldn't get it work at all. So have no idea if they have added any function to it at all and they havn't used it for any skills either, so we have no hints for it in there.

User avatar
Evil Force
Junior Member
Paladin
Posts: 126
Joined: Tue Jun 11, 2002 10:59 am

Re: Saving User made stats (Kill counter example)

Post by Evil Force » Fri Feb 20, 2004 4:52 pm

how to decrease stat by time, eh? :)

User avatar
HellSpawn
Posts: 96
Joined: Fri Jan 30, 2004 6:06 pm
Location: Where the sun doesn't shine

Re: Saving User made stats (Kill counter example)

Post by HellSpawn » Fri Feb 20, 2004 9:57 pm

OK i've got some serious problems with my kill counter. I did all the things that SVR mentioned; changed the unused183 line and made the dummy and display_kills entries in itemstatcost.txt, created the CountKills skill and created a new state "moncounter".

Then I made a new entry to properties.txt that had this info:
code = kill-display, done = 1, func1 = 1, stat1 = display_kills and eol = 1.

Then I made a new unique charm which had the following mods:
prop1 = kill-skill, par1 = CountKills, min1 = 100
prop2 = kill-display

But now the charm only displays "100% cast lvl 1 prayer on kill".
Now the chance and the skill I know how to change, but it's the missing counter that bugs me. Any ideas what's wrong? I've been experimenting and trying to get this to work with various results but haven't found the problem.

I have this feeling that it something really small and stupid but I just can't figure it out myself. :x
"If the human mind was simple enough to understand, we'd be too simple to understand it."
-Emerson Pugh

User avatar
ChaosEnergy
Forum Regular
Angel
Posts: 677
Joined: Wed Dec 03, 2003 3:48 pm
Location: NRW

Re: Saving User made stats (Kill counter example)

Post by ChaosEnergy » Fri Feb 20, 2004 9:59 pm


User avatar
HellSpawn
Posts: 96
Joined: Fri Jan 30, 2004 6:06 pm
Location: Where the sun doesn't shine

Re: Saving User made stats (Kill counter example)

Post by HellSpawn » Fri Feb 20, 2004 10:10 pm

I knew it! :D Only one number wrong and one missing. :rotf:

The func1 in properties.txt should have been 17 instead of 1 and the kill-display mod in uniqueitems.txt needed a 1 in its parameter field.

Problem solved. Thanks a lot ChaosEnergy :)
"If the human mind was simple enough to understand, we'd be too simple to understand it."
-Emerson Pugh

User avatar
Grave
Posts: 18
Joined: Tue Aug 13, 2002 5:44 pm
Location: Graveyard

Re: Saving User made stats (Kill counter example)

Post by Grave » Sat Feb 28, 2004 5:28 pm

SVR";p="152921" wrote:
Grave";p="152894" wrote:would it be possible to use passive skill as counter?
You have to trigger the count somehow. I haven't done any testing on passives, but there is a passive event function.
I haven't found much info on it.
woldnt it work like critical strike passive skill? (i've been messing around with this, but didnt really had a clue what does what :))
from what i understand if you put the counter on item, it will only count if you have the item in inventory.
so the passive skill would be always on thus always count, even if you dont have the item (which would be used only to display the counter, til someone manages to create a way to display them on character stats page or its own page :))

what about counting other stats like total time spent ingame, in specific areas, efficiency, fph and such :)
fph could be calculated from (kills-deaths)/time (or dph and kph too :))
kills/eff/etc per weapon used? (is it even possible to count which weapon/spell was used to make a kill? if someone managed to make the spellkills work)

Grave

*eat people, not animals*

User avatar
SVR
Retired staff
Arch-Angel
Posts: 1449
Joined: Sat Nov 02, 2002 11:04 pm
Location: Texas
United States of America

Hand-picked

Re: Saving User made stats (Kill counter example)

Post by SVR » Sat Feb 28, 2004 5:49 pm

Grave";p="157658" wrote: woldnt it work like critical strike passive skill?
Exactly like that. It wouldn't 'count'. passive skills activate only once. They increase there related stat then do nothing. On levelup, it kicks in, sets the stat again. Aura's on the other hand are calculated every time tick. If the delay/period is right, the effect is triggered again. Over and over.

what about counting other stats like total time spent ingame, in specific areas, efficiency, fph and such :)
Yes. Lots of posibilities. I was thinking of a pocket watch the other day ;-)
Using the byTime op it would be close to posible. I found an interesting stat also... 328 (pierce_idx). It counts every swing already ;-)

User avatar
Grave
Posts: 18
Joined: Tue Aug 13, 2002 5:44 pm
Location: Graveyard

Re: Saving User made stats (Kill counter example)

Post by Grave » Sat Feb 28, 2004 6:10 pm

passive aura :)

Grave

*eat people, not animals*

User avatar
pmpch
Forum Legend
Arch-Angel
Posts: 1171
Joined: Thu Dec 19, 2002 12:21 am
Location: Switzerland

Re: Saving User made stats (Kill counter example)

Post by pmpch » Thu Mar 04, 2004 5:20 pm

Any success on getting this to work with "events"? The event funtion would be "kill" for killed monsters ... but I don't know how exactly that would count then.
Bedevere: Well, now, uh, Launcelot, Galahad, and I, uh, wait until nightfall, and then leap out of the RABBIT, taking the French, uh, by surprise. Not only by surprise, but totally unarmed!
King Arthur: Who leaps out?

User avatar
ChaosEnergy
Forum Regular
Angel
Posts: 677
Joined: Wed Dec 03, 2003 3:48 pm
Location: NRW

Re: Saving User made stats (Kill counter example)

Post by ChaosEnergy » Thu Mar 04, 2004 5:39 pm

have you already looked into the zip in my last post?
there you get an example on how to get it work

User avatar
SVR
Retired staff
Arch-Angel
Posts: 1449
Joined: Sat Nov 02, 2002 11:04 pm
Location: Texas
United States of America

Hand-picked

Re: Saving User made stats (Kill counter example)

Post by SVR » Thu Mar 04, 2004 8:51 pm

pmpch";p="158474" wrote:Any success on getting this to work with "events"?
Nope. (I'm assuming you mean events in itemstat, I haven't explored event functions in skills much) I haven't found any useful event functions. The functions dont do anything to the stat that I can tell. They are all preprogrammed for specific things like ... cast spell, apply damage, take mana etc.

User avatar
Volf
Retired Admin
Dominion
Posts: 5396
Joined: Thu Jul 31, 2003 8:19 am
Finland

Hand-picked

Re: Saving User made stats (Kill counter example)

Post by Volf » Sat Apr 03, 2004 9:13 pm

Complete stat newbie trying to understand some basics of makeing new stats :D

I was wondering, if i want the counter to reset every time the char exits the game would deleteing the entry in line unused183 for saved be enough.

-----------------------------------------------------

Edit:
Trouble with death conter

I got the kill counter to work perfectly but when i aded a death counter to the same item the death count remains 0 and killcounter saves both deaths and kills, just dont get it, i made new enrtys for both counters in al the files involved, kindof hard to post al lines so il post a zip with the changes i made http://www.volf.biz/TempFiles/Kill%20De ... roblem.zip

Note. between tests i deleted bins and save directory

Edit:
I just tested with death counter on a different item and then both worked fine, but if i have both death counter and kill counter on same then only on of them work.. weird
Last edited by Volf on Sun Apr 04, 2004 1:07 am, edited 3 times in total.

User avatar
SVR
Retired staff
Arch-Angel
Posts: 1449
Joined: Sat Nov 02, 2002 11:04 pm
Location: Texas
United States of America

Hand-picked

Re: Saving User made stats (Kill counter example)

Post by SVR » Sun Apr 04, 2004 1:25 am

Volf";p="165069" wrote:I was wondering, if i want the counter to reset every time the char exits the game would deleteing the entry in line unused183 for saved be enough.
Yep, just clear CSvBits etc.
kindof hard to post al lines so il post a zip with the changes i made http://www.volf.biz/TempFiles/Kill%20De ... roblem.zip
Zip bad ? I d/l'd a couple times and can't open it.
I just tested with death counter on a different item and then both worked fine, but if i have both death counter and kill counter on same then only on of them work.. weird
Weird ;-)
I haven't tried multi-counters but I know some have gotten all events counted on one charm.
Last edited by SVR on Sun Apr 04, 2004 1:26 am, edited 1 time in total.

Return to “General Mod Making”