First Machine Age's Mods (Combined repo.)
Révision | de1f838e17628ed460e688f23e26febb59549261 (tree) |
---|---|
l'heure | 2020-08-13 13:08:12 |
Auteur | melchior <melchior@user...> |
Commiter | melchior |
W.I.P. More event processing, tool entries
@@ -19,11 +19,14 @@ namespace ElementalTools | ||
19 | 19 | internal const string malletItemKey = @"ItemMallet"; |
20 | 20 | internal const string sharpeningStoneItemKey = @"ItemSharpening_stone"; |
21 | 21 | |
22 | - internal const string genericSteelItemKey = @"Steel_Item";//Only for tool heads / blades... | |
23 | - internal const string genericSteelSwordKey = @"Steel_ItemSword"; | |
24 | - internal const string genericSteelChiselKey = @"Steel_ItemChisel"; | |
25 | - internal const string genericSteelAxeKey = @"Steel_ItemAxe"; | |
26 | - internal const string genericSteelSpearKey = @"Steel_ItemSpear"; | |
22 | + internal const string genericSteelItemKey = @"Steel_Item";//Only for tool heads / blades... | |
23 | + internal const string genericSteelSwordKey = @"Steel_ItemSword"; | |
24 | + internal const string genericSteelChiselKey = @"Steel_ItemChisel"; | |
25 | + internal const string genericSteelAxeKey = @"Steel_ItemAxe"; | |
26 | + internal const string genericSteelSpearKey = @"Steel_ItemSpear"; | |
27 | + internal const string genericSteelCleaverKey = @"Steel_ItemCleaver"; | |
28 | + internal const string genericSteelHammerKey= @"Steel_ItemHammer"; | |
29 | + | |
27 | 30 | |
28 | 31 | internal const string pack_carburizationBlockKey = @"pack_carburization"; |
29 | 32 | internal const string pack_stateFired = @"fired"; |
@@ -57,7 +60,10 @@ namespace ElementalTools | ||
57 | 60 | CoreAPI.RegisterItemClass(genericSteelChiselKey, typeof(SteelWrap<ItemChisel>)); |
58 | 61 | CoreAPI.RegisterItemClass(genericSteelAxeKey, typeof(SteelWrap<ItemAxe>)); |
59 | 62 | CoreAPI.RegisterItemClass(genericSteelSpearKey, typeof(SteelWrap<ItemSpear>)); |
60 | - | |
63 | + CoreAPI.RegisterItemClass(genericSteelCleaverKey, typeof(SteelWrap<ItemCleaver>)); | |
64 | + CoreAPI.RegisterItemClass(genericSteelHammerKey, typeof(SteelWrap<ItemHammer>)); | |
65 | + | |
66 | + | |
61 | 67 | |
62 | 68 | } |
63 | 69 |
@@ -102,6 +102,7 @@ | ||
102 | 102 | <Folder Include="assets\fma\config\" /> |
103 | 103 | <Folder Include="assets\fma\config\handbook\" /> |
104 | 104 | <Folder Include="assets\fma\entities\" /> |
105 | + <Folder Include="assets\fma\itemtypes\tools\heads\" /> | |
105 | 106 | </ItemGroup> |
106 | 107 | <ItemGroup> |
107 | 108 | <None Include="modinfo.json"> |
@@ -193,8 +194,12 @@ | ||
193 | 194 | <None Include="assets\fma\itemtypes\tools\prospectingpick.json" /> |
194 | 195 | <None Include="assets\fma\itemtypes\tools\scythe.json" /> |
195 | 196 | <None Include="assets\fma\itemtypes\tools\saw.json" /> |
196 | - <None Include="assets\fma\itemtypes\tools\cleaver.json" /> | |
197 | - <None Include="assets\fma\itemtypes\tools\hammer.json" /> | |
197 | + <None Include="assets\fma\itemtypes\tools\cleaver.json"> | |
198 | + <CopyToOutputDirectory>Always</CopyToOutputDirectory> | |
199 | + </None> | |
200 | + <None Include="assets\fma\itemtypes\tools\hammer.json"> | |
201 | + <CopyToOutputDirectory>Always</CopyToOutputDirectory> | |
202 | + </None> | |
198 | 203 | <None Include="assets\fma\itemtypes\tools\shears.json" /> |
199 | 204 | <None Include="assets\fma\itemtypes\tools\hoe.json" /> |
200 | 205 | <None Include="assets\fma\itemtypes\arms\spear.json"> |
@@ -206,6 +211,7 @@ | ||
206 | 211 | <None Include="assets\fma\entities\spears.json"> |
207 | 212 | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
208 | 213 | </None> |
214 | + <None Include="assets\fma\itemtypes\tools\heads\hammer_head.json" /> | |
209 | 215 | </ItemGroup> |
210 | 216 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
211 | 217 | </Project> |
\ No newline at end of file |
@@ -34,7 +34,13 @@ namespace ElementalTools | ||
34 | 34 | SharpnessState Sharpen(IItemStack someStack); |
35 | 35 | |
36 | 36 | /// <summary> |
37 | - /// Read Harness | |
37 | + /// Reduce the sharpness. | |
38 | + /// </summary> | |
39 | + /// <param name="someStack">Some stack.</param> | |
40 | + SharpnessState Dull(IItemStack someStack); | |
41 | + | |
42 | + /// <summary> | |
43 | + /// Read Hardness | |
38 | 44 | /// </summary> |
39 | 45 | /// <param name="someStack">Some stack.</param> |
40 | 46 | HardnessState Hardness(IItemStack someStack); |
@@ -46,6 +52,7 @@ namespace ElementalTools | ||
46 | 52 | /// <param name="set">Value.</param> |
47 | 53 | void Hardness(IItemStack someStack, HardnessState set);//Apply harden - Perhaps translate these to brinell units... |
48 | 54 | |
55 | + | |
49 | 56 | /// <summary> |
50 | 57 | /// Perpetuate Steely attributes from donor to recipient |
51 | 58 | /// </summary> |
@@ -21,6 +21,7 @@ namespace ElementalTools | ||
21 | 21 | private const float quench_min_temperature = 450f;//Celcius |
22 | 22 | |
23 | 23 | private Item WrappedItem;//Special placeholder replica - for calling ancestor class |
24 | + | |
24 | 25 | internal const string hardenableKeyword = @"hardenable"; |
25 | 26 | internal const string sharpenableKeyword = @"sharpenable"; |
26 | 27 | internal const string metalNameKeyword = @"metalName"; |
@@ -181,6 +182,23 @@ namespace ElementalTools | ||
181 | 182 | someStack.Attributes.SetBytes(sharpnessKeyword, bytes); |
182 | 183 | } |
183 | 184 | |
185 | + public virtual SharpnessState Dull(IItemStack someStack) | |
186 | + { | |
187 | + if (someStack.Attributes != null && someStack.Attributes.HasAttribute(sharpnessKeyword)) { | |
188 | + byte[ ] bytes = new byte[1]; | |
189 | + bytes = someStack.Attributes.GetBytes(sharpnessKeyword, bytes); | |
190 | + var state = ( SharpnessState )bytes[0]; | |
191 | + | |
192 | + if (state > SharpnessState.Rough) state--; | |
193 | + | |
194 | + bytes[0] = ( byte )state; | |
195 | + someStack.Attributes.SetBytes(sharpnessKeyword, bytes); | |
196 | + | |
197 | + return state; | |
198 | + } | |
199 | + return SharpnessState.Rough; | |
200 | + } | |
201 | + | |
184 | 202 | public virtual HardnessState Hardness(IItemStack someStack) |
185 | 203 | { |
186 | 204 | if (someStack.Attributes != null && someStack.Attributes.HasAttribute(hardnessKeyword)) { |
@@ -338,9 +356,9 @@ namespace ElementalTools | ||
338 | 356 | public override void OnAttackingWith(IWorldAccessor world, Entity byEntity, Entity attackedEntity, ItemSlot itemslot) |
339 | 357 | { |
340 | 358 | bool edged = this.Tool.EdgedImpliment( ); |
341 | - bool weapon = this.Tool.Weapons( ); | |
359 | + bool weapon = this.Tool.Weapons( ); | |
342 | 360 | float targetArmorFactor = 0.0f; |
343 | - | |
361 | + | |
344 | 362 | /*DETERMINE: |
345 | 363 | * Usage - Edged weapon attack Vs. creature Sc.#1 [What about armored players?] |
346 | 364 | * Non-edged weapon vs. creature Sc. #2 [What about armored players?] |
@@ -362,7 +380,7 @@ namespace ElementalTools | ||
362 | 380 | } |
363 | 381 | */ |
364 | 382 | |
365 | - WrappedItem.OnAttackingWith(world, byEntity, attackedEntity, itemslot); | |
383 | + //WrappedItem.OnAttackingWith(world, byEntity, attackedEntity, itemslot); | |
366 | 384 | } |
367 | 385 | |
368 | 386 |
@@ -374,50 +392,72 @@ namespace ElementalTools | ||
374 | 392 | var targetBlock = api.World.BlockAccessor.GetBlock(blockSel.Position); |
375 | 393 | int targetTier = targetBlock.ToolTier; |
376 | 394 | float targetResistance = targetBlock.Resistance; |
395 | + bool recomendedUsage = this.MiningSpeed.ContainsKey(targetBlock.BlockMaterial); | |
377 | 396 | |
378 | 397 | //Only called for attacks on BLOCKS / Envrionment. Scen# 5 - 6 here. |
379 | - | |
398 | + | |
380 | 399 | //Weapon & Tool applicability: Is rate > 1 ? then - its sorta OK...ish. |
381 | 400 | |
382 | 401 | //Harndess Vs. Block-Resistance... |
402 | + //Tool Specific special damage reduction rate: e.g. scythe, hoe, knife, here... | |
403 | + //By MiningSpeed | |
404 | + | |
383 | 405 | |
384 | 406 | api.World.Logger.VerboseDebug($"OnBlockBrokenWith:: (Weap:{weapon},Edge:{edged}) {byEntity.Code} -> {targetBlock.Code}"); |
385 | 407 | |
386 | 408 | |
387 | 409 | |
388 | 410 | return WrappedItem.OnBlockBrokenWith(world, byEntity, itemslot, blockSel); |
411 | + //Post Damage reduction? or Increase?? | |
412 | + | |
389 | 413 | } |
390 | 414 | |
391 | - | |
415 | + //This Method signature leaves _ALOT_ to be ascertained about the _ACUTAL_ Scenario / REASON of damage... | |
416 | + //Tool/Weapon Vs. What? | |
392 | 417 | public override void DamageItem(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, int amount = 1) |
393 | 418 | { |
394 | - //TODO: too sharp edges...wear down EDGE randomly (extra for 'abuse' ) | |
419 | + //ItemAxe: just repeatedly calls DamageItem....instead of accrued count...lame. | |
420 | + | |
421 | + bool byPlayer = byEntity is EntityPlayer; | |
422 | + bool catasptrophicFailure = false, edgeBlunting = false; | |
423 | + | |
424 | + float resistance = 0.0f; | |
395 | 425 | |
396 | - //Tool Specific special damage reduction rate: e.g. scythe, hoe, knife, here...? | |
397 | - //By MiningSpeed ? | |
398 | 426 | if (!itemslot.Empty) |
399 | 427 | { |
400 | 428 | var hardness = this.Hardness(itemslot.Itemstack); |
401 | 429 | switch (hardness) |
402 | 430 | { |
403 | 431 | case HardnessState.Soft: |
404 | - | |
432 | + resistance = 0.3f; | |
433 | + edgeBlunting = world.Rand.Next(1, 100) >= 99; | |
405 | 434 | break; |
406 | 435 | case HardnessState.Medium: |
407 | - | |
436 | + resistance = -0.1f; | |
437 | + edgeBlunting = world.Rand.Next(1, 200) >= 199; | |
408 | 438 | break; |
409 | 439 | case HardnessState.Hard: |
410 | - | |
440 | + resistance = -0.25f; | |
441 | + edgeBlunting = world.Rand.Next(1, 300) >= 299; | |
411 | 442 | break; |
412 | 443 | case HardnessState.Brittle: |
413 | - | |
414 | - break; | |
415 | - default: | |
444 | + resistance = -0.3f; | |
445 | + edgeBlunting = world.Rand.Next(1, 400) >= 399; | |
446 | + catasptrophicFailure = world.Rand.Next(1, 1000) >= 999; | |
416 | 447 | break; |
417 | 448 | } |
418 | 449 | } |
419 | 450 | |
420 | - WrappedItem.DamageItem(world, byEntity, itemslot, amount); | |
451 | + amount = amount < 1 ? 1 : amount;//Zero or negative damange, possible but WHY? | |
452 | + | |
453 | + float amountFractional = (resistance * amount); | |
454 | + var dmgRandomizer = NatFloat.createUniform(amount, amountFractional); | |
455 | + var actualAmount = ( int )dmgRandomizer.nextFloat( ); | |
456 | + | |
457 | + if (edgeBlunting) this.Dull(itemslot.Itemstack); | |
458 | + if (catasptrophicFailure) actualAmount += 1200; | |
459 | + | |
460 | + base.DamageItem(world, byEntity, itemslot, actualAmount); | |
421 | 461 | } |
422 | 462 | |
423 | 463 |
@@ -685,6 +725,8 @@ namespace ElementalTools | ||
685 | 725 | { |
686 | 726 | return recipient.Attributes.GetInt(durabilityKeyword, recipient.Item.Durability); |
687 | 727 | } |
728 | + | |
729 | + | |
688 | 730 | } |
689 | 731 | } |
690 | 732 |
@@ -1,16 +1,6 @@ | ||
1 | 1 | { |
2 | 2 | code: "axe", |
3 | - class: "Steel_ItemAxe", | |
4 | - attributes: { | |
5 | - handbook: { | |
6 | - groupBy: ["axe-*"] | |
7 | - }, | |
8 | - toolrackTransform: { | |
9 | - rotation: { y: 1, z: -1 }, | |
10 | - translation: { x: -0.3, y: 0.6 }, | |
11 | - scale: 1.25, | |
12 | - } | |
13 | - }, | |
3 | + class: "Steel_ItemAxe", | |
14 | 4 | variantgroups: [ |
15 | 5 | { code: "metal", states: ["blister_steel", "shear_steel" ] }, |
16 | 6 | ], |
@@ -56,7 +46,17 @@ | ||
56 | 46 | metalName:"Shear Steel", |
57 | 47 | sharpenable: true, |
58 | 48 | hardenable: true, |
59 | - } | |
49 | + }, | |
50 | + "*": { | |
51 | + handbook: { | |
52 | + groupBy: ["axe-*"] | |
53 | + }, | |
54 | + toolrackTransform: { | |
55 | + rotation: { y: 1, z: -1 }, | |
56 | + translation: { x: -0.3, y: 0.6 }, | |
57 | + scale: 1.25, | |
58 | + } | |
59 | + }, | |
60 | 60 | }, |
61 | 61 | creativeinventory: { "general": ["*"], "items": ["*"], "tools": ["*"] }, |
62 | 62 |
@@ -1 +1,71 @@ | ||
1 | - | |
1 | +{ | |
2 | + code: "cleaver", | |
3 | + damagedby: ["blockbreaking", "attacking"], | |
4 | + class: "Steel_ItemCleaver", | |
5 | + variantgroups: [ | |
6 | + { code: "metal", states: ["blister_steel", "shear_steel" ] }, | |
7 | + ], | |
8 | + shape: { base: "game:item/tool/cleaver" }, | |
9 | + heldTpHitAnimation: "breaktool", | |
10 | + textures: { | |
11 | + "metal": { base:"fma:metal/{metal}"}, | |
12 | + "toolhandle": { | |
13 | + base: "fma:metal/{metal}", | |
14 | + overlays: [ "game:item/tool/cleaver-overlay" ] | |
15 | + } | |
16 | + }, | |
17 | + durabilitybytype: { | |
18 | + "*-blister_steel": 1100, | |
19 | + "*-shear_steel": 1200, | |
20 | + }, | |
21 | + attackpowerbytype: { | |
22 | + "*-blister_steel": 2.75, | |
23 | + "*-shear_steel": 3.0, | |
24 | + }, | |
25 | + attributesByType: { | |
26 | + "*-blister_steel": { | |
27 | + metalName:"Blister Steel", | |
28 | + sharpenable: true, | |
29 | + hardenable: true, | |
30 | + }, | |
31 | + "*-shear_steel": { | |
32 | + metalName:"Shear Steel", | |
33 | + sharpenable: true, | |
34 | + hardenable: true, | |
35 | + }, | |
36 | + "*": { | |
37 | + handbook: { | |
38 | + groupBy: ["cleaver-*"] | |
39 | + }, | |
40 | + rackable: true, | |
41 | + toolrackTransform: { | |
42 | + rotation: { x: 90 }, | |
43 | + translation: { x: -0.35 }, | |
44 | + scale: 1.25, | |
45 | + }, | |
46 | + } | |
47 | + }, | |
48 | + creativeinventory: { "general": ["*"], "items": ["*"], "tools": ["*"] }, | |
49 | + fpHandTransform: { | |
50 | + translation: { x: -0.34, y: 0, z: 0.4 }, | |
51 | + rotation: { x: -17, y: -93, z: -75 }, | |
52 | + scale: 2.5 | |
53 | + }, | |
54 | + guiTransform: { | |
55 | + translation: { x: 0, y: 0, z: 0 }, | |
56 | + rotation: { x: 0, y: 26, z: 140 }, | |
57 | + origin: { x: 0.55, y: 0.52, z: 0.5 }, | |
58 | + scale: 2.53 | |
59 | + }, | |
60 | + groundTransform: { | |
61 | + translation: { x: 0, y: 0, z: 0 }, | |
62 | + rotation: { x: -90, y: 0, z: 0 }, | |
63 | + origin: { x: 0.5, y: 0.5, z: 0.45 }, | |
64 | + scale: 3.6 | |
65 | + }, | |
66 | + tpHandTransform: { | |
67 | + translation: { x: -0.78, y: -0.44, z: -0.5 }, | |
68 | + rotation: { x: 0, y: 180, z: -10 }, | |
69 | + scale: 1 | |
70 | + } | |
71 | +} | |
\ No newline at end of file |
@@ -1 +1,73 @@ | ||
1 | - | |
1 | +{ | |
2 | + code: "hammer", | |
3 | + class: "Steel_ItemHammer", | |
4 | + variantgroups: [ | |
5 | + { code: "metal", states: ["blister_steel", "shear_steel" ] }, | |
6 | + ], | |
7 | + tool: "hammer", | |
8 | + heldTpHitAnimation: "smithing", | |
9 | + shape: { base: "game:item/tool/hammer" }, | |
10 | + textures: { | |
11 | + "metal": { base:"fma:metal/{metal}"}, | |
12 | + "wood": { base: "game:item/tool/material/wood" } | |
13 | + }, | |
14 | + tooltierbytype: { | |
15 | + "*-blister_steel": 5, | |
16 | + "*-shear_steel": 5, | |
17 | + }, | |
18 | + durabilitybytype: { | |
19 | + "*-blister_steel": 2500, | |
20 | + "*-shear_steel": 2600, | |
21 | + }, | |
22 | + attackpowerbytype: { | |
23 | + "*-blister_steel": 2.5, | |
24 | + "*-shear_steel": 2.5, | |
25 | + }, | |
26 | + attributesByType: { | |
27 | + "*-blister_steel": { | |
28 | + metalName:"Blister Steel", | |
29 | + sharpenable: false, | |
30 | + hardenable: true, | |
31 | + }, | |
32 | + "*-shear_steel": { | |
33 | + metalName:"Shear Steel", | |
34 | + sharpenable: false, | |
35 | + hardenable: true, | |
36 | + }, | |
37 | + "*": | |
38 | + { | |
39 | + handbook: { | |
40 | + groupBy: ["hammer-*"] | |
41 | + }, | |
42 | + toolrackTransform: { | |
43 | + rotation: { y: 1, z: -1 }, | |
44 | + translation: { x: -0.2 }, | |
45 | + scale: 1.5, | |
46 | + } | |
47 | + } | |
48 | + }, | |
49 | + creativeinventory: { "general": ["*"], "items": ["*"], "tools": ["*"] }, | |
50 | + fpHandTransform: { | |
51 | + translation: { x: 0.0468, y: -0.2, z: 0 }, | |
52 | + rotation: { x: 15, y: 15, z: 90 }, | |
53 | + scale: 2.5 | |
54 | + }, | |
55 | + guiTransform: { | |
56 | + rotate: false, | |
57 | + translation: { x: 0, y: 5, z: 0 }, | |
58 | + rotation: { x: -77, y: -135, z: 160 }, | |
59 | + origin: { x: 0.54, y: 0.5, z: 0.48 }, | |
60 | + scale: 2.6 | |
61 | + }, | |
62 | + groundTransform: { | |
63 | + translation: { x: 0, y: 0, z: 0 }, | |
64 | + rotation: { x: 0, y: 0, z: 0 }, | |
65 | + origin: { x: 0.5, y: 0.45, z: 0.5 }, | |
66 | + scale: 4.5 | |
67 | + }, | |
68 | + tpHandTransform: { | |
69 | + translation: { x: -0.75, y: -0.48, z: -0.52 }, | |
70 | + rotation: { x: 90, y: 1, z: 0 }, | |
71 | + scale: 1 | |
72 | + } | |
73 | +} |
@@ -0,0 +1,35 @@ | ||
1 | +{ | |
2 | + code: "hammerhead", | |
3 | + variantgroups: [ | |
4 | + { code: "metal", states: ["blister_steel", "shear_steel" ] }, | |
5 | + ], | |
6 | + shape: { base: "game:item/tool/hammer" }, | |
7 | + textures: { | |
8 | + "metal": { base:"fma:metal/{metal}"}, | |
9 | + "wood": { base: "game:block/transparent" }, | |
10 | + }, | |
11 | + creativeinventory: { "general": ["*"], "items": ["*"] }, | |
12 | + fpHandTransform: { | |
13 | + translation: { x: 0.3, y: -0.4, z: 0 }, | |
14 | + rotation: { x: 15, y: 15, z: 90 }, | |
15 | + scale: 2.5 | |
16 | + }, | |
17 | + guiTransform: { | |
18 | + rotate: false, | |
19 | + translation: { x: 4, y: 1, z: 190 }, | |
20 | + rotation: { x: -52, y: -131, z: -180 }, | |
21 | + origin: { x: 0.37, y: 1.25, z: 0.1 }, | |
22 | + scale: 3.5 | |
23 | + }, | |
24 | + groundTransform: { | |
25 | + translation: { x: 0, y: 0, z: 0 }, | |
26 | + rotation: { x: 0, y: 0, z: 0 }, | |
27 | + origin: { x: 0.8, y: 0.44, z: 0.5 }, | |
28 | + scale: 4.5 | |
29 | + }, | |
30 | + tpHandTransform: { | |
31 | + translation: { x: -0.3, y: -0.8, z: -0.6 }, | |
32 | + rotation: { x: 109, y: -30, z: 5 }, | |
33 | + scale: 1 | |
34 | + } | |
35 | +} | |
\ No newline at end of file |