Jump to content

Achievement System


Jonne

Recommended Posts


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

Preamble

I have written an achievement system I want to share with you. It is not the best way to solve achievement systems nor is it very efficient(though it might be more efficient than NPC scripting) and if you already have an achievement system(src or npc) and it's working for you, please don't change to mine. Mine is rather old(about half a year or more) and back then it was the first time I wrote something completly new for eAthena. What I did today was applying the system to rA and create a working diff.

If you are willing to use this system then I beg you to report any bug found.

Also, if there is enough demand, I might consider re-writing it from scratch, because I am overall unhappy with the system, but not really motivated to further work on it in greater detail. Also the code-style I used back then is totally going against the one I am using nowadays... Don't judge me!

Functions

There are pre-defined types of achievements in this system

Monsterkill Achievements

Itemfind Achievements (Only use this for Items NOT trade/drop/storage-able, or else it will result in abuse)

Itemuse Achievements

Explore Achievements

Quest Achievements

Special Achievements

Let me explain them one after another:

Monsterkill Achievements(0):

Well, name says it mostly, but there is a bit more to it. You can define different types per achievement. The types are counting by ID(0), by size(1), by race(2), by element(3) or for all MvPs(4). And if player A has killed X monsters that meet the requirement, then he gets the achievement.

Itemfind Achievements(1):

Again, name says what it does. If you find certain items, you get the achievement. Make sure you only use it on non tradeable etc. items or it will be abused. It can also be filtered into types. They are the following: ID(0), Equip(1)[see item_db->equip), Type(2)[see item_db->type]. It will count if you drop it and pick it up again, so really, only use it on items not storageable, tradeable and dropable!

Itemuse Achievements(2):

Its porpuse is to count every item used. This achievement might be bugged, report anything you find fishy! It uses the same filtering as Itemfind, so please refer to that.

Explore Achievements(3):

When entering a map, the system checks whether the map is inside the database for explore achievements and if so, it sets the count. If the player visited all maps for one achievement, then he receives the achievement.

Quest Achievements(4):

When finishing certain quests, you are able to gain quest achievements. Simple as that!

Special Achievements(5):

This are achievements in the achievement database. But they are only applicable over @achieve from a GM or with the achieve script_command. This achievement has Event porpuses and is only added for a complete database for your website etc.

Now comes the technical stuff...

How to install the achievement system

1. Download the *.diff and the *.sql file(they are in the *.rar provided).

2. Import the *.sql into your rAthena database.

3. Apply the *.diff onto your rAthena server.

4. Check your ./conf/battle/exp.conf and ./conf/battle/misc.conf: Two new configs have been added: achievement_cutin_duration and achievement_exp_rate. Read the conf files for more information and change it to whatever you wish it to be.

5. Add the two new files ./src/map/achievement.c and ./src/map/achievement.h to your MAKEFILE or to your project solution and recompile!

(^ Up to this point, I won't provide ANY support ^)

How to add achievements

Well, that is mainly why I would like to find another way of solving the achievement system. But currently it is like this:

1. Add your achievement to achievement_db. Here is a brief summary of the columns:

achievement_id: Leave empty, it is set by auto_increment. That is the ID of the achievement. The current max for achievement_ids is 65535. Raise MAX_ACHIEVEMENT in ./src/map/achievement.h for higher values(as if you'd ever need that many). Might slow the system!

type: The type is a integer between 0 and 5. It is an enum. 0=Monsterkill Achievement. 1=Itemfind Achievement. 2=Itemuse Achievement. 3=Explore Achievement. 4=Quest Achievement. 5=Special Achievement.

name: Displayed when finishing the achievement. Also for website porpuses.

cutin: Display when achieving for achievement_cutin_duration ms.

base_exp: Reward EXP for achieving

job_exp: same as base_exp, but for job

nameid: Reward Item for achieving (amount is always 1)

points: Achievement points the achievement is worth

If you chose 5 as type, you are nearly done, skip step 2.

If you chose another type, please read on.

2. Go to the respective table of your chosen type:

0->mob_achievement
1->item_achievement
2->itemuse_achievement
3->explore_achievement
4->quest_achievement

Now add an entry for your newly added achievement.

The columns are rather similiar, but I'll explain in greater detail:

mob_achievement:

achievement_id: Set to ID assigned by achievement_db for your new achievement

type: See description of Mobkill Achievements. There are numbers in brackets for each filtering type

valueX: The value for what to filter. I.e. if you chose ID, then place an ID here. If you chose elements, place a number from the element enum here (see script_commands or src for reference)

amountX: How many to kill

itemfind_achievement:

itemuse_achievement:

achievement_id: Set to ID assigned by achievement_db for your new achievement

type: See description of Itemfind Achievements. There are numbers in brackets for each filtering type

valueX: The value for what to filter. I.e. if you chose ID, then place an ID here.

amountX: How many to find/use

explore_achievement:

achievement_id: Set to ID assigned by achievement_db for your new achievement

mapX: Name of the map. I.e. prontera

quest_achievement:

achievement_id: Set to ID assigned by achievement_db for your new achievement

questX: ID of the quest

3. Last step is to reload the AchievementDB ingame via @reloadachievement or restart your server.

Atcommands

So, I added two atcommands working together with this System:

@achieve <Achievement_ID> <Player_Name>. Give <Player_Name> Achievement with <Achievement_ID> as ID. IT DOES NOT CHECK WHETHER HE MEETS THE REQUIREMENTS! Built in for debugging and special achievements

@reloadachievements. Reload the Achievement DBs. Helpfully if you added new achievements and don't want to restart the server.

Scriptcommands

*Achieve( <AchievementID>{, <Account_ID>});

Same as the Atcommand. If no account_id is given, use attached player. Does also not check if player meets requirements. Intended for special achievements

*GetAchievementInfo(<AchievementID>, <flag>);

Flag determines what to return:

0 = type, 1 = bexp, 2 = jexp, 3 = nameid, 4 = points, 5 = status

5 Only works with attached players and returns 1 if the player finished the achievement and 0 otherwise.

*GetAchievementName(<AchievementID>);

Returns the name of the achievement

*GetAchievementCutin(<AchievementID>);

Returns the name of the cutin of the achievement

I think this is about all you need to know. Please report any bugs and post any suggestions. If you overwhelm me enough, I might rework it to be more user-friendly! Only post bugs and suggestions after you've read through the whole article. I will notive if you haven't.

At last Download

achievement.patch

achievement.sql

€dit:

I really want to stress the following facts again:

  1. Read the whole article!
  2. Only use if you are unable to script/code a system that is suficient to suit your needs or this system matches your needs perfectly(well, w/e)!
  3. Report any found bug!

€dit²:

Forgot to mention. The last achievement is stored within the permanent playervariable "LastAchievement" and it stores the ID of the achievement. So you can check it via NPC script etc.

Changelog:

1.0 FIrst version

1.1 Fixxed bug of not deleting the cutins properly [Thanks Dexter]

1.2 Fixxed cutin bug fully, fixxed typos in config

Edited by Jonne
  • Upvote 10
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

:) Achievement System !!! This is GREAT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Thank for the Release ~
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  392
  • Reputation:   47
  • Joined:  11/18/11
  • Last Seen:  

This is great indeed. I made something similar 3 years ago via scripting. +1

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

This is great indeed. I made something similar 3 years ago via scripting. +1

Where's yours VIA scripting? o_O

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  392
  • Reputation:   47
  • Joined:  11/18/11
  • Last Seen:  

This is great indeed. I made something similar 3 years ago via scripting. +1

Where's yours VIA scripting? o_O

I don't have it anymore, it's been 3 years already xd..

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

This is great indeed. I made something similar 3 years ago via scripting. +1

Where's yours VIA scripting? o_O

I don't have it anymore, it's been 3 years already xd..

Psh.. and you don't save your creations D:!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

Added an edit with a feature I forgot to mention X_x

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  12/31/11
  • Last Seen:  

First of all, great job, although i got a few errors, not while compiling but after, first i tried out @reloadachievement and it didnt work, its like it doesnt exist, and also i got this

[Error]: delete_timer error : function mismatch 0062BF20(pc_invincible_timer) !=00545DA0(achievement_delete_cutin_timer)[Error]: cutin duration timer: 23 != 27[Warning]: Unknown setting 'achievement_cutin_duration' in file conf/battle/misc.conf [Warning]: Unknown setting 'achievement_cutin_duration' in file conf/battle/misc.conf

And yes i have the achievement_cutin_duration in my misc.conf in the battle folder.

If you can help me out i'll really be grateful

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

First of all, great job, although i got a few errors, not while compiling but after, first i tried out @reloadachievement and it didnt work, its like it doesnt exist, and also i got this

[Error]: delete_timer error : function mismatch 0062BF20(pc_invincible_timer) !=00545DA0(achievement_delete_cutin_timer)[Error]: cutin duration timer: 23 != 27[Warning]: Unknown setting 'achievement_cutin_duration' in file conf/battle/misc.conf [Warning]: Unknown setting 'achievement_cutin_duration' in file conf/battle/misc.conf

And yes i have the achievement_cutin_duration in my misc.conf in the battle folder.

If you can help me out i'll really be grateful

My bad, sorry. At first I solved this problem of deleted cutins else, but before releasing I changed to this setting. Uhm, either go to ./src/map/achievement.c line 137 and change to delete_timer(sd->achievement_cutin_timer,achievement_delete_cutin_timer); or download the diff I will by now attach to my original post. Sorry for the trouble.

Wups, the commands name is "reloadachievements" with an s at the end. I only called the function reloadachievement. Sorry for the trouble!

Edited by Jonne
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  12/31/11
  • Last Seen:  

No trouble at all, but... Now its another error

[Error]: delete_timer error : function mismatch 0053CF40(connect_check_clear) !=

00545DA0(achievement_delete_cutin_timer)

[Error]: cutin duration timer: 25 != 29

And this

[Warning]: Unknown setting 'achievement_cutin_duration' in file conf/battle/misc

.conf

And also, i dont know if its related but everytime i relog on one of the explore achievements i complete it again and also get the prizes, also when i use the @achieve command, when i use it i automatically complete the achievment without doing anything ( i only tested explore acheivments and i not at the map on the time, its with any map, lets say the map is prontera, if i give the achievment on lets say morocc, i automatically complete it there)

And just a small thing but when someone completes the achievment it shows ???? on the screen.

And last but not least xD

"See description of Mobkill Achievements. There are numbers in brackets for each filtering type"

Im sorry but no where did i find this and without it i cant set up item or monster achievments :D

Edited by dexter
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

No trouble at all, but... Now its another error

[Error]: delete_timer error : function mismatch 0053CF40(connect_check_clear) !=

00545DA0(achievement_delete_cutin_timer)

[Error]: cutin duration timer: 25 != 29

And this

[Warning]: Unknown setting 'achievement_cutin_duration' in file conf/battle/misc

.conf

And also, i dont know if its related but everytime i relog on one of the explore achievements i complete it again and also get the prizes, also when i use the @achieve command, when i use it i automatically complete the achievment without doing anything ( i only tested explore acheivments and i not at the map on the time, its with any map, lets say the map is prontera, if i give the achievment on lets say morocc, i automatically complete it there)

And just a small thing but when someone completes the achievment it shows ???? on the screen.

@Achieve bypasses all requirement checks. About the explore thing and the error message, I will llook into it this evening or tomorrow, since I currently run out of time and have to go. You can count with a fix tomorrow or the day after.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  12/31/11
  • Last Seen:  

No problem, i dont think you saw my last edit so i'll just leave it here

And last but not least xD
"See description of Mobkill Achievements. There are numbers in brackets for each filtering type"

Im sorry but no where did i find this and without it i cant set up item or monster achievments :D

And like i said, everytime i relog, without even using the @achieve i complete the achievment, i only use it once and keep completing it everytime i relog on the explore map

Once again great job on this, and have a happy new year :D

Edited by dexter
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

No problem, i dont think you saw my last edit so i'll just leave it here

And last but not least xD
"See description of Mobkill Achievements. There are numbers in brackets for each filtering type"

Im sorry but no where did i find this and without it i cant set up item or monster achievments :D

And like i said, everytime i relog, without even using the @achieve i complete the achievment, i only use it once and keep completing it everytime i relog on the explore map

Once again great job on this, and have a happy new year :D

Okay, I forgot to load the achievements already done out of the SQL. I added the function but forgot to call for it. Also the problem with the timer in misc.conf: It was called achievement_cutinduration, with one less underline '_'. I now changed it to achievement_cutin_duration in the new version. But I didn't get the other timer error you got. Please try again and report if it still messes up. I will upload the new diff any moment

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  12/31/11
  • Last Seen:  

Thanks alot, are the changes already updated? and if not asking too much, were do i change so i dont have to do everything all over ( i manually patch)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

Thanks alot, are the changes already updated? and if not asking too much, were do i change so i dont have to do everything all over ( i manually patch)

It's already uploaded. I did changes in pc.c: pc_authok. and battle.c, adding the missing underline

Edited by Jonne
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  12/31/11
  • Last Seen:  

Ok so i updated and all, but now when i complete a achievment, my map-server crashes XD, no errors, and only happens when i complete it, im pretty sure it has to do with the cutin, since i used to use a script to make a cutin with news appear evertime someone logged, and with your mod i kept getting map-server crashes untill i figured that out and disabled my script, do you think its possible to fix it or make the cutin not appear?

Edit:

I think its important to say that before this last update, the cutin from when i completed an achievment was normal, it appeared and i was not getting any map-server crashes

And also did you get to read what i said about those filters? they aren't anywhere and they are needed to setup mob and item achievments

Edited by dexter
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

Filters

Monsterkill Achievements(0):

Well, name says it mostly, but there is a bit more to it. You can define different types per achievement. The types are counting by ID(0), by size(1), by race(2), by element(3) or for all MvPs(4). And if player A has killed X monsters that meet the requirement, then he gets the achievement.

Itemfind Achievements(1):

Again, name says what it does. If you find certain items, you get the achievement. Make sure you only use it on non tradeable etc. items or it will be abused. It can also be filtered into types. They are the following: ID(0), Equip(1)[see item_db->equip), Type(2)[see item_db->type]. It will count if you drop it and pick it up again, so really, only use it on items not storageable, tradeable and dropable!

Why would your server crash? Please post your script. Also, you achieve and then the sever crashes. I think I know the source. Give me a bit of time and I'll fix it. I'll edit this post or BUMP when I'm done.

Did the edit, should now work properly with cutins!

Edited by Jonne
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  12/31/11
  • Last Seen:  

Edit:

Ok, i think i got it now, part of it was my fault, i had 2 entries in the acheivement_db but only one of them was in the other db's (explore,mob etc) and that was making my map-server crash, i deleted the other one and i worked, any other bugs i'll report here. Very great mod Jonne!

Edit2:

I did get this though...

[Error]: delete_timer error : function mismatch 0053CF40(connect_check_clear) !=

00545DA0(achievement_delete_cutin_timer)

Edited by dexter
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

Edit:

Ok, i think i got it now, part of it was my fault, i had 2 entries in the acheivement_db but only one of them was in the other db's (explore,mob etc) and that was making my map-server crash, i deleted the other one and i worked, any other bugs i'll report here. Very great mod Jonne!

It was not your fault, it was mine. If you have forgotten the entries in the other DBs, it just prints a warning in the map-server and leaves out those entries. It was fully my fault with setting up the timer to delete the cutin. Sorry for the circumstances.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  12/31/11
  • Last Seen:  

I see, glad to see its working now xD

Small question, where do the points that are set in the achievement_db go?

And you also forgot to post the sql file in the attachment

Edited by dexter
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

I see, glad to see its working now xD

Small question, where do the points that are set in the achievement_db go?

And you also forgot to post the sql file in the attachment

The points are just kept and can be called via script. Never actually used them since I didn't find it to be of any use, but my old admin wanted to have them in.

Thanks for mentioning the missing SQL file

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  12/31/11
  • Last Seen:  

Yea, i actually want to use those points, thats why i want to know where they are kept xD

Like a way to count how many achievements the player has already done :D

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

Yea, i actually want to use those points, thats why i want to know where they are kept xD

Like a way to count how many achievements the player has already done :D

SQL Command:

SELECT COUNT(*) FROM `achievement_tracker` WHERE `char_id` = 'X' AND `finished` = '1'

This will get the amount.

And in NPC script you can go through every achievement and check with GetAchievementInfo(<ID>, 5) if it is achieved and then count it.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  12/31/11
  • Last Seen:  

I have another question xD

What happens if there are two achievements with the same monster for example, will it count for both when you kill the monster?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

I have another question xD

What happens if there are two achievements with the same monster for example, will it count for both when you kill the monster?

Yes. Even if the system finds a monster for one achievement, it won't stop but still go through every achievement.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...