-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Just a basic example how to add things to the game using sword item.
- XNB Extract
- Chasm Deserializer
- Go to _..\Games\Chasm\Content\databases_ and find weapons.ser
- Use Deserializer to decode it
- Add the item you desire based on other entries.
For example, since we are gonna add a sword, I will add following entry after Long Sword
["Sword", "sword_rapier", "Rapier", "A thin long bladed sword.", "Cut", "Items/ui_icons", "21,17", "15,15", "180", "0", "4", "", "", "weapon_sword_rapier_strike", "weapon_sword_rapier_strike_fx", "weapon_sword_rapier_cooldown", "2", "5", "", "", "0"],
Notice that unlike Long Sword, my newly added weapon does not have windup and downstrike _animations - I specifically removed them since for they are not relevant for a fast Rapier.
- Unpack XNBExtract somewhere
- Copy files atlas__0.xnb, atlas__1.xnb and atlas__2.xnb from *..\Chasm\Content\textures\packed*
into
Packedfolder where XNB tool is - Run
UnPackFiles.bat - Go to
UnPackedand open each of the sheets in your favourite graphical software suite
- Find animations.json.bin and texture_atlas.json.bin
- Unpack them to JSON
- Open for editing
Since we do not use windup and downstrike animations, all we need to find is strike, strike_fx and cooldown animations/frames. CTRL+F and search for the corresponding entries. We used longsword as base for rapier, we gonna search for:
- weapon_sword_longsword_strike
- weapon_sword_longsword_strike_fx
- weapon_sword_longsword_cooldown
There are few values that are important to us. SheetNum represents the id of the atlas file where to look for the frames, so if it says "SheetNum": 1 you want to check atlas_1. "SrcRect" will tell us the exact starting pixel and the height and width of the sheet - so all you need to do is go to X and Y pixel position in atlas_1 and starting from that pixel make a rectangular selection of exact width and height values.
There you go, you have all the frames used for specific animation. Now you can copy and paste on any free space and edit them, draw over. One you are done with each frame sheet you will need to update texture atlas. First of all, change the name of the sheet to be unique for your weapon and (they must correspond to the same values you have in weapons.json for your new item!), then, update the X and Y values to represent starting point for each of your animation sheets. For example, this is what I ended up with for Rapier:
{
"Name": "Entity/Player/Weapons/weapon_sword_rapier_strike",
"SrcRect":{"x":561,"y":1517,"width":336,"height":32},
"SheetNum": 1,
"Key": ""
},
{
"Name": "Entity/Player/Weapons/weapon_sword_rapier_strike_fx",
"SrcRect":{"x":561,"y":1485,"width":336,"height":32},
"SheetNum": 1,
"Key": ""
},
{
"Name": "Entity/Player/Weapons/weapon_sword_rapier_cooldown",
"SrcRect":{"x":561,"y":1453,"width":168,"height":32},
"SheetNum": 1,
"Key": ""
},
and this is how it looks like:
https://i.imgur.com/0pzfC17.png
Okay, now we need to edit animation data for our new item. Repeat the same process as with Texture atals and find 3 relevant entries in animations.json for longsword that are relevant to your sheets. Change the name and update values respectively.
Important variables:
Name - again, dont forget to change to your unique name i.e. from "weapon_sword_longsword_strike" to "weapon_sword_rapier_strike"
AtlasKey - see above
TotalFrames - total frames your specifci sprite sheet for animation has. For example, for strike I went for 6 frames unlike 9 longsword had so I updated to 6
FPS - speed it will be played at.
Example what I ended up with
{
"Hitboxes": {
"0": [
{
"Type": "Attack1",
"Rectangle":{"x":1,"y":-23,"width":38,"height":10}
}
],
"1": [
{
"Type": "Attack1",
"Rectangle":{"x":4,"y":-24,"width":39,"height":11}
}
],
"2": [
{
"Type": "Attack1",
"Rectangle":{"x":10,"y":-23,"width":33,"height":11}
}
],
"3": [
{
"Type": "Attack1",
"Rectangle":{"x":10,"y":-23,"width":32,"height":11}
}
],
"4": [
{
"Type": "Attack1",
"Rectangle":{"x":10,"y":-23,"width":31,"height":11}
}
],
"5": []
},
"Polygones": {},
"ReferencePoints": {},
"Sounds": {},
"ActionFrame": -1,
"AtlasKey": "Entity/Player/Weapons/weapon_sword_rapier_strike",
"DelayedStart": 0.0,
"FlipOffset": "-31,0",
"FPS": 60,
"FrameSize": "56,32",
"IsLoop": false,
"Name": "weapon_sword_rapier_strike",
"Origin":{"X":12.0,"Y":32.0},
"Path": "Entity/Player/Weapons",
"TotalFrames": 6,
"TotalRows": 1,
"LoopMaxElapsed": 0.0,
"RandomFrameStart": false
},
{
"Hitboxes": {},
"Polygones": {},
"ReferencePoints": {},
"Sounds": {},
"ActionFrame": -1,
"AtlasKey": "Entity/Player/Weapons/weapon_sword_rapier_cooldown",
"DelayedStart": 0.0,
"FlipOffset": "-31,0",
"FPS": 12,
"FrameSize": "56,32",
"IsLoop": false,
"Name": "weapon_sword_rapier_cooldown",
"Origin":{"X":12.0,"Y":32.0},
"Path": "Entity/Player/Weapons",
"TotalFrames": 3,
"TotalRows": 1,
"LoopMaxElapsed": 0.0,
"RandomFrameStart": false
},
{
"Hitboxes": {},
"Polygones": {},
"ReferencePoints": {},
"Sounds": {},
"ActionFrame": -1,
"AtlasKey": "Entity/Player/Weapons/weapon_sword_rapier_strike_fx",
"DelayedStart": 0.0,
"FlipOffset": "-31,0",
"FPS": 60,
"FrameSize": "56,32",
"IsLoop": false,
"Name": "weapon_sword_rapier_strike_fx",
"Origin":{"X":12.0,"Y":32.0},
"Path": "Entity/Player/Weapons",
"TotalFrames": 6,
"TotalRows": 1,
"LoopMaxElapsed": 0.0,
"RandomFrameStart": false
}
Go back to part #1 and find the weapon item data in weapons.json. Since it is essentially a CSV format the first top line will be headers (use https://jsonlint.com/ to format it). Find the value corresponding to icon_position, in my case for Rapier you can see it is 21,17 - this is the icon position in Atlas_1 where all icons are located. Each icon is 16x16 pixels and they are all ordered. On the screenshot below, my Rapier is 21th item to the left and 17 from the top:
https://i.imgur.com/paGhVWG.png
It is not a rocket science to figure out. Add your own and update index position accordingly for weapons.json
- Save the atlas*.png and use XNB tool to pack it back and replace game file with yours
- save all edited JSON (BE VERY CAREFUL WITH JSON SYNTAX AND COMMAS)
- use the ChasmDes tool to serialize them back into game compatible format
- replace old files in game directory
Start the game and use console command (press `) "gimme" - this will grant you all items, including yours.