UGX-Mods

Call of Duty 5: World at War => Downloadable Items for Mappers => Custom Maps, Mods & Tools => Scripts => Topic started by: BluntStuffy on April 28, 2016, 07:19:17 pm

Title: [TUT] Adding achievements to your map
Post by: BluntStuffy on April 28, 2016, 07:19:17 pm
mega.nz

I wasn't sure if i should release this because this tutorial might look a bit complicated, and i'm not sure if people even want to add this to their maps.. But in the end it's really easy to use and i had it laying around anyways, so i decided to post this. Just read carefully step by step and i hope it's understandable. Adding your own achievements just takes 2 or 3 lines of code after you followed this tut!

This script will allow you to put achievements in your map, their stats will save between games. For example when you add an achievement: "Kill 100 zombies" and a player gets 75 kills, then dies and starts a new game and get 25 kills he will earn the achievement.
When a player unlocks an achievement a message shows up on screen, and you can choose to also have an icon appear, a sound play, and have points rewarded.

You can add your own achievements for your map pretty simple, anything like 'Kill X amount of zombies' or 'Kill a boss without jugg' or 'Open 50 doors' or whatever you want.
For now the player will just get the message on screen once, and it will be "unlocked". There's no menu to view your achievements or anything like that ( yet, might do it depending on if people actually use this.. )



1.
Lets get started, first download the files and put them in the correct folder. One goes into your \RAW\mp\ folder, and the other in your \MODS\mapname\maps\ folder.



2.
Open your _zombiemode.gsc and around line 60-70 you'll see similar line's, add this one:
         
Code Snippet
Plaintext
	maps\_blst_achievements::init();


3.
to include the stringtable-csv in your mod, add this line to the mod.csv in your mod-builder-tab on launcher;
   
Code Snippet
Plaintext
	stringtable,mp/my_achievements.csv


4.
if you want to use (custom) shaders for the achievement-notify's, add the materials to a .csv and make sure the images are included in your mod! They will be precached automaticly by the script, so no need to worry about that.


5.
Now how to setup you own achievements: note: i left two examples in the files so its easier to understand. You can just remove / change those as you wish.

First a short explanation to clear things up:
You can add multiple 'levels' for one achievement, for example you can add one for killing 10 zombies and then also one for killing 25 zombies.
Obviously those are 'the same' achievement( ...they are related to the same stat -> zombie kills ) so to tell the game they are the same stat but a different achievement you'll need to add two 'names' for each achievement you add. One is called the 'name' and the other the 'ref'!
 * The achievement NAME, wich should be the same for all achievements that relate to the same stat! So in the example above both could be named: kills_all
 * The achievement REF, wich should be different for all achievements! so in the example above it could be: kills_all_1 and kills_all_2
   
Make sure you pay attention to that, then adding achievements is going to be easy  :)


6.
Open the file you copied to raw\mp\ named: my_achievements.csv it basicly works the same as a soundalias. This just stores stuff like strings. You need to add every achievement you want to use in your map here.
this is an example of a line from that file:
Code Snippet
Plaintext
1,kills_all,kills_all_1,Kill 10 zombies,2105,10,250,specialty_juggernaut_zombies,

In the following order ( the bold text between the braces refers to the example line above )
   0.   Index    ( 1 )
   1.   Achievement NAME ( see explanation in the previous step )   ( kills_all )
   2.   Achievement REF ( see explanation in the previous step )    ( kills_all_1 )
   3.   Achievement description: The line that will show up on screen once the player unlocks the achievement, if you dont want a this fill in: none   ( Kill 10 zombies )
   4.   Stat number: ( 2105 ) THIS ONE IS IMPORTANT: there's a few rules to follow with these
      You make up the numbers yourself, but keep these rules:
      - start counting from 2100
      - increase by 5, so go from 2100 to 2105 to 2110 etc
      - each achievement that has the same achievement NAME should have the same stat number ( ...they are related to the same stat! )
   5.   The amount needed to complete this achievement, so in the example: Kill 10 zombies. The amount will be 10.    ( 10 )
   6.   If you want the players to recieve points for unlocking this achievement, add the amount of points here. Otherwise fill in: none  ( 250 )
   7.   If you want a shader to appear on screen for this achievement add it here ( the material name ). Otherwise fill in: none    ( specialty_juggernaut_zombies )
   


7.
Next open the _blst_achievements.gsc, at the top you'll see the line's to setup the achievements. If you want a sound to play when a player unlocks an achievement, change it in this line:

Code Snippet
Plaintext
level.achievement_sound = "none";

Next to tell the script wich achievements to add, copy this line once for every achievement you added, and edit it: Fill in the correct achievement REF for every achievement you want to add ( "kills_all_1" in the example below )

Code Snippet
Plaintext
	level.custom_achievements[level.custom_achievements.size] = "kills_all_1";


8.

That's everything to setup the script, but now comes the hard part. You need to make the game keep track of the achievements you added. For example if you add an achievement 'Use the mystery box 5 times' you need to edit the box-script, and make the game count the stats.
You can do that by adding the following line in a script:

Code Snippet
Plaintext
	self maps\_blst_achievements::add_to_my_stat( "use_box_5_times", 1 );

In this line 'self' is the player! You need to fill in the correct achievement NAME ( not ref! ). The '1' tells the game to add 1 to the stat. It will automaticly check for achievement-unlocks every time you use that line so no need to add anything else.
   
For some people this will be the hard part to figure out, i'll try to help out if needed in the topic below. In the download i allready made the 'zombie kills' achievement work, the one for opening doors does not work! It's just an example!! If you want to make that work, you need to add the line mentioned above in _zombiemode_blockers_new for each door/debris trigger.



Last thing, in the _blst_achievements.gsc there's one level. var at the top called: level.map_testing    If you set that to true, it will use prints to display your current stats so you can easily test stuff, and at game start you have the option to reset your stats.

Title: Re: [TUT] Adding achievements to your map
Post by: MakeCents on April 28, 2016, 09:21:53 pm
Nice man. I love the idea of growing progress when you play. I'd like to be rewarded for continually playing a map, say better or upgraded starting pistol, or start with qr or jug, or something like that after 5000 kills or something. Maybe a perk you only get by getting the achievement like half price everything... or something that once you get it you use it every game like another player... Anyway, awesome job as always!

Maybe I'll add it and give an upgraded pistol to players at start for like 5000 or 10000 kills, or beating the map on hard or something...
Title: Re: [TUT] Adding achievements to your map
Post by: Dust on April 28, 2016, 09:59:16 pm
Awesome tut man! I am sure I will find some good use for this in the future!
Title: Re: [TUT] Adding achievements to your map
Post by: BluntStuffy on April 29, 2016, 07:34:38 pm
Killer tut man! You're one of the best scripters on the forum hands down :)

Haha, if only that was true


Nice man. I love the idea of growing progress when you play. I'd like to be rewarded for continually playing a map, say better or upgraded starting pistol, or start with qr or jug, or something like that after 5000 kills or something. Maybe a perk you only get by getting the achievement like half price everything... or something that once you get it you use it every game like another player... Anyway, awesome job as always!

Maybe I'll add it and give an upgraded pistol to players at start for like 5000 or 10000 kills, or beating the map on hard or something...

Those are pretty sweet ideas, and way more rewarding for the players then just some points. Would be cool to have some of these achievements in a map!


Awesome tut man! I am sure I will find some good use for this in the future!
Thanks man, not sure if people will find this worth the trouble but if you make up some rewards like MC mentioned it's way cooler allready i suppose. Hope it comes in handy at some point  :)
Title: Re: [TUT] Adding achievements to your map
Post by: Scobalula on April 29, 2016, 09:20:27 pm
hmmm this will be a very nice addition to my map.

Some ideas I have include possibly rewarding players for using a certain gun for x rouns, or x rounds over x round, like if the player keeps the Magnum over Round 20 and uses it for 5-10 rounds, it'll be their starting pistol from now on, and maybe getting x pick ups of Vulture Aid ammo rewards them with temporary infinite ammo or something like that.

This is definitely beast.
Title: Re: [TUT] Adding achievements to your map
Post by: Dust on April 29, 2016, 09:47:30 pm
Some ideas I have include possibly rewarding players for using a certain gun for x rouns, or x rounds over x round, like if the player keeps the Magnum over Round 20 and uses it for 5-10 rounds, it'll be their starting pistol from now on, and maybe getting x pick ups of Vulture Aid ammo rewards them with temporary infinite ammo or something like that.

That sounds like a really cool idea.

There are so many possibilities people can do with these achievements
Title: Re: [TUT] Adding achievements to your map
Post by: Tim Smith on April 30, 2016, 10:11:09 am
And here he's bluntstuffy. Helping the community as he can. Very good tut man. Gonna use that.
Title: Re: [TUT] Adding achievements to your map
Post by: meddle2k on June 09, 2016, 04:51:49 am
Thanks, probably going to use this in my map. Cool idea.
Title: Re: [TUT] Adding achievements to your map
Post by: Fancygamer1738 on March 25, 2018, 07:45:33 pm
Cool tut. Can't wait to see what I can do with this. ;)
Title: Re: [TUT] Adding achievements to your map
Post by: DeletedUser on April 12, 2021, 09:08:46 pm
great stuff man. ik the acheivements can be "saved" when restarting the map. But what about when you quit out of the game to the desktop, then reload waw/map. will they still remain?

Double Post Merge: April 13, 2021, 01:17:39 am

sorry to be a pain but do you think you could add a "remove_from_stat" func? and im not referring to the reset func. my stats will be fluctuating throughout the game so as you have already scripted a "add_to_stat" func, i need a "deduct_from_stat" func. :)

EDIT: nvm i realised i could deduct through the add func aha

EDIT2: great stuff for releasing this mod man you're a life saver!

EDIT3: This is what i managed to do with your mod - https://www.ugx-mods.com/forum/scripting/50/save-feature-for-custom-zombies/19658/msg165280#msg165280 (https://www.ugx-mods.com/forum/scripting/50/save-feature-for-custom-zombies/19658/msg165280#msg165280) :)
Title: Re: [TUT] Adding achievements to your map
Post by: DontGetSeen on March 26, 2024, 09:11:11 pm
This is awesome man!! I decided to use this as a way to make a ranking/level up system in my map.
 
I basically just did
 
1,kills_all,kills_all_1,Rank 1,2105,50,250,specialty_juggernaut_zombies,
2,kills_all,kills_all_2,Rank 2,2110,150,500,specialty_juggernaut_zombies,
3,kills_all,kills_all_3,Rank 3,2115,275,500,specialty_juggernaut_zombies,
4,kills_all,kills_all_4,Rank 4,2120,400,500,specialty_juggernaut_zombies,
5,kills_all,kills_all_5,Rank 5,2125,700,500,specialty_juggernaut_zombies,
6,kills_all,kills_all_6,Rank 6,2130,1150,500,specialty_juggernaut_zombies,
 
etc. etc. etc. etc. etc..
 
I'll be changing the shaders to the WAW ranking icons/shaders of course. And i might edit the kills and stuff, gotta do some tweaking.
 
I also went into your script in *_blst_achievements.gsc* and changed the "Challenge complete" setText to "Rank up:" instead.
 
Now my map seems like it has an actual progression/ranking system that saves between games, i added it since some people enjoy playing with it because it adds a bit of replayability.:D
 
 
I'll be sure to credit you when i publish the map :)
 
 
 
Although, i wish it would show it some how on the hud what "rank" you are. Maybe i can find how to. and edit your script and do it:thumbsup-smiley: