Modding:Basic Modding Examples: Difference between revisions

From Vintage Story Wiki
Updates worldgen example to current version
m (VeryGoodDog moved page Basic Modding Examples to Modding:Basic Modding Examples: clean up main namespace)
(Updates worldgen example to current version)
(3 intermediate revisions by the same user not shown)
Line 14: Line 14:


This should prevent the player from dropping its inventory upon death.
This should prevent the player from dropping its inventory upon death.
== Enable microblock chiseling in survival mode ==
Open the file <code>assets/survival/itemtypes/tool/chisel.json</code>, find the line that writes <code>microBlockChiseling: false,</code>, and set the value to <code>true</code>
This will make it so that you can right click on most solid blocks with a chisel in hands to convert the block into a chisel-able one. Left click with a chisel to remove voxels and right click to add a voxel.


== Changing sleep duration in beds ==
== Changing sleep duration in beds ==


Beds in the Vanilla game are pretty limited, as they let you only sleep 3-5.5 hours every night. More often than not players prefer to skip the whole night. To achieve that open the file <code>assets/blocktypes/wood/generic/bed.json</code>
Beds in the Vanilla game are pretty limited, as they let you only sleep 3-5.5 hours every night. More often than not players prefer to skip the whole night. To achieve that open the file <code>assets/survival/blocktypes/wood/bed.json</code>


Line 7-11 should contain these lines:
Line 8-11 should contain these lines:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
attributesByType: {
sleepEfficiencyByType: {
"bed-wood-*": { sleepEfficiency: 0.375 },
"bed-wood-*": 0.70833333,
"bed-hay-*": { sleepEfficiency: 0.25  },
"bed-hay-*": 0.58333333,
"bed-woodaged-*": { sleepEfficiency: 0.45833  }
"bed-woodaged-*": 0.79166666
},
},
</syntaxhighlight>
</syntaxhighlight>


The <code>sleepEfficiency</code> attribute is specific to the bed. In this case a value of 1 means the player can sleep half the day. The hay bed has a value of 0.25, which means the player can sleep for 12 * 0.25 = 3 in-game hours. Change the value to anything between 0...1 and start the game or leave and re-enter your singleplayer world. Next time you sleep in the bed you will be skipping that amount of time.
The <code>sleepEfficiency</code> attribute is specific to the bed. In this case a value of 1 means the player can sleep half the day. The hay bed has a value of 0.58333333, which means the player can sleep for 12 * 0.58333333 = ~7 in-game hours. Change the value to anything between 0...1 and start the game or leave and re-enter your singleplayer world. Next time you sleep in the bed you will be skipping that amount of time.




Line 40: Line 34:


Our favorite arch enemy the wolf. If you don't like the silent horror of the winterlands, we can tame him with a few tweaks ;-)
Our favorite arch enemy the wolf. If you don't like the silent horror of the winterlands, we can tame him with a few tweaks ;-)
Open the file <code>assets/entities/land/wolf-male.json</code>
Open the file <code>assets/survival/entities/land/wolf-male.json</code>




Line 47-60 should contain this:
Line 108-123 should contain this:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
{
{
code: "meleeattack",
code: "meleeattack",
entityCodes: ["player"],
entityCodes: ["player", "chicken-rooster", "chicken-hen", "chicken-baby", "hare-*"],
priority: 2,
priority: 2,
damage: 10.01,
damage: 8,
damageTier: 2,
damageType: "SlashingAttack",
slot: 1,
slot: 1,
mincooldown: 1500,  
mincooldown: 1500,  
Line 57: Line 53:
animation: "Attack",
animation: "Attack",
animationSpeed: 2.5,
animationSpeed: 2.5,
sound: "creature/wolf/wolf-attack"
sound: "creature/wolf/attack"
},
},
</syntaxhighlight>
</syntaxhighlight>


This is the configuration for the wolves ai task to induce damage to very close by enemies. By default the wolf damages you by 10.01 health points, which means any unprotected player dies in 2 attacks. If you were to change it to 5, the wolf has to attack you up to 4 times before a fully healed player dies.  
This is the configuration for the wolves ai task to induce damage to very close by enemies. By default the wolf damages you by 8 health points, which means any unprotected player dies in 3 attacks. If you were to change it to 5, the wolf has to attack you up to 4 times before a fully healed player dies.  




Line 68: Line 64:
{
{
code: "seekentity",
code: "seekentity",
entityCodes: ["player"],
entityCodes: ["player", "chicken-rooster", "chicken-hen", "chicken-baby", "hare-*"],
priority: 1.5,
priority: 1.5,
movespeed: 0.022,
movespeed: 0.045,
seekingRange: 20,
seekingRange: 15,
belowTempSeekingRange: 25,
belowTempThreshold: -5,
animation: "Run",
animation: "Run",
animationSpeed: 1.5,
leapAtTarget: true,
sound: "creature/wolf/wolf-growl"
leapAnimation: null,
animationSpeed: 2.2,
leapChance: 0.01,
sound: "creature/wolf/growl",
whenNotInEmotionState: "saturated"
},
},
</syntaxhighlight>
</syntaxhighlight>


You can perhaps read out that the wolf has a seeking range of 20 blocks. This means if the wolf finds a player within a radius of 20 blocks, it will start walking towards that player. Changing that to something lower, like 5 blocks, means you can get much closer to a wolf before he begins to chase you.
You can perhaps read out that the wolf has a seeking range of 15 blocks. This means if the wolf finds a player within a radius of 15 blocks, it will start walking towards that player. Changing that to something lower, like 5 blocks, means you can get much closer to a wolf before he begins to chase you.


Be sure to also apply the changes to the female wolf in <code>wolf-female.json</code>!
Be sure to also apply the changes to the female wolf in <code>wolf-female.json</code>!
Line 85: Line 89:
== Playing around with world generation ==
== Playing around with world generation ==


Inside the assets folder, navigate to worldgen/terrain/standard. Copy aside the landforms.json so you have a backup, then open the landforms.json. Remove everything in this file and paste in the following text:
Inside the assets folder, navigate to <code>assets/survival/worldgen/</code>. Copy aside the landforms.json so you have a backup, then open the landforms.json. Remove everything in this file and paste in the following text:
<pre>
<pre>
{
{
Line 95: Line 99:
"comment": "humongous mountains with caverns in them",
"comment": "humongous mountains with caverns in them",
"hexcolor": "#5BC184",
"hexcolor": "#5BC184",
"weight": 2,
"weight": 1.5,
"useClimateMap": false,
"useClimateMap": false,
"terrainOctaves":          [0, 0, 0, 0, 1,  1, 1, 1, 0.6, 0.2],
"terrainOctaves":          [0, 0, 0, 1,  1, 1, 1, 0.6, 0.15],
"terrainOctaveThresholds": [0, 0, 0, 0, 0.5, 0, 0,  0,  0, 0],
"terrainOctaveThresholds": [0, 0, 0, 0.5, 0, 0,  0,  0, 0],
"terrainYKeyPositions":    [0,  0.33, 0.37, 0.42, 0.43, 0.5, 0.6, 0.7, 0.9, 0.97, 1],
"terrainYKeyPositions":    [0.000, 0.330, 0.370, 0.420, 0.430, 0.500, 0.600, 0.700, 1.000],
"terrainYKeyThresholds":  [1,   1, 0.87, 0.84, 0.7, 0.94, 1, 1, 0.1, 0.05, 0]
"terrainYKeyThresholds":  [1.000, 1.000, 0.870, 0.840, 0.700, 0.940, 1.000, 1.000, 0.000]
},
},
]
]
editor
72

edits