VS plugin mod for Basic Armour
修订版 | d46f62d2b3166fd3e1b8c3ce2b915852b91d46c4 (tree) |
---|---|
时间 | 2019-07-25 10:21:26 |
作者 | melchior <melchior@user...> |
Commiter | melchior |
feature progress on buckler shields
@@ -13,7 +13,7 @@ namespace ArmourMod | ||
13 | 13 | slashingPercent = slash; |
14 | 14 | crushingPercent = crush; |
15 | 15 | firePercent = fire; |
16 | - encumberancePercent = 0; | |
16 | + encumberanceMultiplier = 1f; | |
17 | 17 | } |
18 | 18 | |
19 | 19 | public DamageFilter(float blunt, float pierce, float slash, float crush, float fire, float encP) |
@@ -23,7 +23,7 @@ namespace ArmourMod | ||
23 | 23 | slashingPercent = slash; |
24 | 24 | crushingPercent = crush; |
25 | 25 | firePercent = fire; |
26 | - encumberancePercent = encP; | |
26 | + encumberanceMultiplier = encP; | |
27 | 27 | } |
28 | 28 | |
29 | 29 | public float bluntPercent; |
@@ -31,7 +31,7 @@ namespace ArmourMod | ||
31 | 31 | public float slashingPercent; |
32 | 32 | public float crushingPercent; |
33 | 33 | public float firePercent; |
34 | - public float encumberancePercent; | |
34 | + public float encumberanceMultiplier; | |
35 | 35 | |
36 | 36 | //TODO:Threshold values; |
37 | 37 |
@@ -43,7 +43,7 @@ namespace ArmourMod | ||
43 | 43 | var slashing = armourInSlot.Itemstack.ItemAttributes["SlashingProtection"].AsFloat( ); |
44 | 44 | var crushing = armourInSlot.Itemstack.ItemAttributes["CrushingProtection"].AsFloat( ); |
45 | 45 | var flame = armourInSlot.Itemstack.ItemAttributes["FireProtection"].AsFloat( ); |
46 | - var encumberance = armourInSlot.Itemstack.ItemAttributes["Encumberance"].AsFloat( ); | |
46 | + var encumberance = armourInSlot.Itemstack.ItemAttributes["Encumberance"].AsFloat(1F); | |
47 | 47 | |
48 | 48 | return new DamageFilter(blunt, piercing, slashing, crushing, flame, encumberance); |
49 | 49 | } |
@@ -23,6 +23,9 @@ namespace ArmourMod | ||
23 | 23 | //Pre-compute values; |
24 | 24 | private DamageFilter finalFilter; |
25 | 25 | |
26 | + private const string armourEncumberanceKey = "ArmourEncumberance"; | |
27 | + | |
28 | + | |
26 | 29 | internal ArmourModConfig CachedConfiguration |
27 | 30 | { |
28 | 31 | get |
@@ -267,10 +270,10 @@ namespace ArmourMod | ||
267 | 270 | { |
268 | 271 | DamageFilter dmgFilt = DamageFilter.ConstructFilter( watchedSlot ); |
269 | 272 | #if DEBUG |
270 | - Logger.VerboseDebug( "Armour Filter Props: B{0} P{1} S{2} C{3} F{4}", dmgFilt.bluntPercent, dmgFilt.piercingPercent, dmgFilt.slashingPercent, dmgFilt.crushingPercent, dmgFilt.firePercent ); | |
273 | + Logger.VerboseDebug( "Armour Filter Props: B{0} P{1} S{2} C{3} F{4} E{5}", dmgFilt.bluntPercent, dmgFilt.piercingPercent, dmgFilt.slashingPercent, dmgFilt.crushingPercent, dmgFilt.firePercent, dmgFilt.encumberanceMultiplier ); | |
271 | 274 | #endif |
272 | 275 | DamageFilters[(EnumCharacterDressType)slotId] = dmgFilt; |
273 | - RecomputeDamageFilterPercents( ); | |
276 | + RecomputeDamageFilterProps( ); | |
274 | 277 | } |
275 | 278 | } |
276 | 279 | } else if (watchedSlot.StorageType == EnumItemStorageFlags.Outfit){ |
@@ -279,7 +282,7 @@ namespace ArmourMod | ||
279 | 282 | Logger.VerboseDebug( "Removed a AF item from SlotId:{0}",slotId ); |
280 | 283 | #endif |
281 | 284 | DamageFilters.Remove((EnumCharacterDressType)slotId); |
282 | - RecomputeDamageFilterPercents( ); | |
285 | + RecomputeDamageFilterProps( ); | |
283 | 286 | } |
284 | 287 | } |
285 | 288 |
@@ -302,10 +305,10 @@ namespace ArmourMod | ||
302 | 305 | if (CheckIfItemHasDamageFilter(handSlot)) { |
303 | 306 | DamageFilter dmgFilt = DamageFilter.ConstructFilter(handSlot); |
304 | 307 | #if DEBUG |
305 | - Logger.VerboseDebug("Armour Filter Props: B{0} P{1} S{2} C{3} F{4}", dmgFilt.bluntPercent, dmgFilt.piercingPercent, dmgFilt.slashingPercent, dmgFilt.crushingPercent, dmgFilt.firePercent); | |
308 | + Logger.VerboseDebug("Armour Filter Props: B{0} P{1} S{2} C{3} F{4} E{5}", dmgFilt.bluntPercent, dmgFilt.piercingPercent, dmgFilt.slashingPercent, dmgFilt.crushingPercent, dmgFilt.firePercent, dmgFilt.encumberanceMultiplier); | |
306 | 309 | #endif |
307 | 310 | DamageFilters[EnumCharacterDressType.Arm] = dmgFilt; |
308 | - RecomputeDamageFilterPercents( ); | |
311 | + RecomputeDamageFilterProps( ); | |
309 | 312 | } |
310 | 313 | } |
311 | 314 | } else { |
@@ -314,7 +317,7 @@ namespace ArmourMod | ||
314 | 317 | Logger.VerboseDebug("Removed a AF from SlotId:{0}", slotId); |
315 | 318 | #endif |
316 | 319 | DamageFilters.Remove(EnumCharacterDressType.Arm); |
317 | - RecomputeDamageFilterPercents( ); | |
320 | + RecomputeDamageFilterProps( ); | |
318 | 321 | } |
319 | 322 | } |
320 | 323 | } |
@@ -348,7 +351,9 @@ namespace ArmourMod | ||
348 | 351 | /// <param name="byPlayer">By player.</param> |
349 | 352 | private void HandlePlayerSpawn(IClientPlayer byPlayer) |
350 | 353 | { |
354 | + #if DEBUG | |
351 | 355 | Logger.VerboseDebug("Handling Spawn for: {0}", byPlayer.PlayerName); |
356 | + #endif | |
352 | 357 | |
353 | 358 | if (byPlayer.Entity != null && byPlayer.Entity is EntityArmourPlayer) { |
354 | 359 | EntityArmourPlayer targetPlayer = byPlayer.Entity as EntityArmourPlayer;//CHECK: Cast from - not actual instance? |
@@ -392,10 +397,10 @@ namespace ArmourMod | ||
392 | 397 | |
393 | 398 | |
394 | 399 | private void HandlePlayerDespawn(IClientPlayer byPlayer) |
395 | - { | |
396 | - //Unlink watcher event | |
400 | + { | |
401 | + #if DEBUG | |
397 | 402 | Logger.VerboseDebug("Handling Despawn for: {0}", byPlayer.PlayerName); |
398 | - | |
403 | + #endif | |
399 | 404 | } |
400 | 405 | |
401 | 406 |
@@ -424,7 +429,7 @@ namespace ArmourMod | ||
424 | 429 | DamageFilter dmgFilt = DamageFilter.ConstructFilter( itemSlot); |
425 | 430 | |
426 | 431 | #if DEBUG |
427 | - CoreAPI.World.Logger.VerboseDebug( "Armour Filter Props: B{0} P{1} S{2} C{3} F{4}", dmgFilt.bluntPercent, dmgFilt.piercingPercent, dmgFilt.slashingPercent, dmgFilt.crushingPercent, dmgFilt.firePercent ); | |
432 | + CoreAPI.World.Logger.VerboseDebug( "Armour Filter Props: B{0} P{1} S{2} C{3} F{4} E{5}", dmgFilt.bluntPercent, dmgFilt.piercingPercent, dmgFilt.slashingPercent, dmgFilt.crushingPercent, dmgFilt.firePercent, dmgFilt.encumberanceMultiplier ); | |
428 | 433 | #endif |
429 | 434 | |
430 | 435 | DamageFilters.Add((EnumCharacterDressType)slotId,dmgFilt); |
@@ -435,11 +440,11 @@ namespace ArmourMod | ||
435 | 440 | } |
436 | 441 | |
437 | 442 | if ( DamageFilters.Count > 0 ) { |
438 | - RecomputeDamageFilterPercents( ); | |
443 | + RecomputeDamageFilterProps( ); | |
439 | 444 | } |
440 | 445 | } |
441 | 446 | |
442 | - private void RecomputeDamageFilterPercents() | |
447 | + private void RecomputeDamageFilterProps() | |
443 | 448 | { |
444 | 449 | if (DamageFilters != null && DamageFilters.Count > 0) |
445 | 450 | { |
@@ -461,7 +466,17 @@ namespace ArmourMod | ||
461 | 466 | |
462 | 467 | finalFilter.firePercent = DamageFilters.Sum( df => df.Value.firePercent ); |
463 | 468 | finalFilter.firePercent = Math.Abs( finalFilter.firePercent ); |
464 | - finalFilter.firePercent = Math.Min( 0.95F, finalFilter.firePercent ); | |
469 | + finalFilter.firePercent = Math.Min( 0.95F, finalFilter.firePercent ); | |
470 | + | |
471 | + finalFilter.encumberanceMultiplier = DamageFilters.Min(df => df.Value.encumberanceMultiplier); | |
472 | + //Encumberance needs direct application / removal here; | |
473 | + if (finalFilter.encumberanceMultiplier > 0 && finalFilter.encumberanceMultiplier < 1.0) { | |
474 | + this.SetWalkSpeedModifier(armourEncumberanceKey, finalFilter.encumberanceMultiplier, false); | |
475 | + Logger.VerboseDebug("New Walk Speed Mult: {0}", this.GetWalkSpeedMultiplier( )); | |
476 | + } else { | |
477 | + this.RemoveWalkSpeedModifier(armourEncumberanceKey); | |
478 | + } | |
479 | + | |
465 | 480 | } |
466 | 481 | } |
467 | 482 |
@@ -18,9 +18,15 @@ namespace ArmourMod | ||
18 | 18 | //base.GetHeldItemInfo(stack, dsc, world, withDebugInfo); |
19 | 19 | |
20 | 20 | if (this.Durability > 1) { |
21 | - dsc.AppendLine(Lang.Get("Durability: {0} / {1}", new object[] { | |
22 | - stack.Attributes.GetInt ("durability", this.Durability), | |
23 | - this.Durability})); | |
21 | + | |
22 | + int defDur = stack.Attributes.GetInt("durability", this.Durability); | |
23 | + | |
24 | + //byte greenComponent = (byte)(255 * (float)this.Durability / (float)defDur); | |
25 | + //byte redComponent = (byte)(0xff - greenComponent); | |
26 | + | |
27 | + //dsc.Append($"<font color='#{greenComponent:X2}{redComponent:X2}00'>"); | |
28 | + dsc.AppendLine(Lang.Get("Durability: {0} / {1}", new object[] { defDur, this.Durability})); | |
29 | + //dsc.Append("</font>\n"); | |
24 | 30 | } |
25 | 31 | |
26 | 32 | //Display Protection values & Weight / dissadvantages |
@@ -29,23 +35,18 @@ namespace ArmourMod | ||
29 | 35 | var slashing = stack.ItemAttributes["SlashingProtection"].AsFloat( ); |
30 | 36 | var crushing = stack.ItemAttributes["CrushingProtection"].AsFloat( ); |
31 | 37 | var flame = stack.ItemAttributes["FireProtection"].AsFloat( ); |
32 | - var encumberance = stack.ItemAttributes["Encumberance"].AsFloat( ); | |
38 | + var encumberance = stack.ItemAttributes["Encumberance"].AsFloat(1F ); | |
33 | 39 | |
34 | - dsc.AppendFormat($"Blunt {blunt:P1}\n Piercing {piercing:P1}\n Slashing {slashing:P1}\n Crushing {crushing:P1}\n Flame {flame:P1}\n Encumberance {encumberance:P1}\n"); | |
40 | + dsc.AppendFormat($"Blunt {blunt:P1}\n Piercing {piercing:P1}\n Slashing {slashing:P1}\n Crushing {crushing:P1}\n Flame {flame:P1}\n Encumberance {encumberance:N2}X\n"); | |
35 | 41 | |
36 | 42 | EnumCharacterDressType dresstype; |
37 | 43 | string strdress = stack.ItemAttributes["clothescategory"].AsString( ); |
38 | 44 | |
39 | - if (!Enum.TryParse(strdress, true, out dresstype)) { | |
40 | - dsc.AppendLine(Lang.Get("Cloth Category: Unknown")); | |
41 | - } else { | |
45 | + if (Enum.TryParse(strdress, true, out dresstype)) { | |
42 | 46 | dsc.AppendLine(Lang.Get("Cloth Category: {0}", Lang.Get("clothcategory-" + stack.ItemAttributes["clothescategory"].AsString( )))); |
43 | 47 | } |
44 | - } | |
45 | - | |
46 | - //IDEA: Shackles = "Armour" that has high encumberance - and 'sticks' to player; needs specific key to remove | |
47 | - //TODO: Shackle & Key item, (Closed) Shackle ItemArmour | |
48 | 48 | |
49 | + } | |
49 | 50 | } |
50 | 51 | } |
51 | 52 |
@@ -56,7 +56,8 @@ | ||
56 | 56 | PiercingProtection:0.3, |
57 | 57 | SlashingProtection:0.3, |
58 | 58 | CrushingProtection:0.3, |
59 | - FireProtection:0.14 | |
59 | + FireProtection:0.14, | |
60 | + Encumberance:0.90 | |
60 | 61 | }, |
61 | 62 | "*-lamellar": { |
62 | 63 | clothescategory: "upperbodyover", |
@@ -65,7 +66,8 @@ | ||
65 | 66 | PiercingProtection:0.35, |
66 | 67 | SlashingProtection:0.35, |
67 | 68 | CrushingProtection:0.35, |
68 | - FireProtection:0.14 | |
69 | + FireProtection:0.14, | |
70 | + Encumberance:0.87 | |
69 | 71 | }, |
70 | 72 | "*-platechest": { |
71 | 73 | clothescategory: "upperbodyover", |
@@ -74,7 +76,8 @@ | ||
74 | 76 | PiercingProtection:0.3, |
75 | 77 | SlashingProtection:0.37, |
76 | 78 | CrushingProtection:0.31, |
77 | - FireProtection:0.2 | |
79 | + FireProtection:0.2, | |
80 | + Encumberance:0.85 | |
78 | 81 | }, |
79 | 82 | "*-scale": { |
80 | 83 | clothescategory: "upperbodyover", |
@@ -83,7 +86,8 @@ | ||
83 | 86 | PiercingProtection:0.26, |
84 | 87 | SlashingProtection:0.27, |
85 | 88 | CrushingProtection:0.25, |
86 | - FireProtection:0.1 | |
89 | + FireProtection:0.1, | |
90 | + Encumberance:0.90 | |
87 | 91 | }, |
88 | 92 | "*-chain": { |
89 | 93 | clothescategory: "upperbodyover", |
@@ -92,21 +96,24 @@ | ||
92 | 96 | PiercingProtection:0.25, |
93 | 97 | SlashingProtection:0.25, |
94 | 98 | CrushingProtection:0.2, |
95 | - FireProtection:0.05 | |
99 | + FireProtection:0.05, | |
100 | + Encumberance:0.95 | |
96 | 101 | }, |
97 | 102 | "*-studdedleather": { |
98 | 103 | clothescategory: "upperbodyover", |
99 | 104 | inCharacterCreationDialog: false, |
100 | 105 | SlashingProtection:0.17, |
101 | 106 | BluntProtection:0.2, |
102 | - FireProtection:0.19 | |
107 | + FireProtection:0.19, | |
108 | + Encumberance:0.98 | |
103 | 109 | }, |
104 | 110 | "*-leather": { |
105 | 111 | clothescategory: "upperbodyover", |
106 | 112 | inCharacterCreationDialog: false, |
107 | 113 | BluntProtection:0.12, |
108 | 114 | SlashingProtection:0.15, |
109 | - FireProtection:0.2 | |
115 | + FireProtection:0.2, | |
116 | + Encumberance:0.99 | |
110 | 117 | }, |
111 | 118 | "*":{ |
112 | 119 | clothescategory: "upperbodyover", |
@@ -19,12 +19,12 @@ | ||
19 | 19 | creativeinventory: { "general": ["*"], "items": ["*"], "clothing": ["*"] }, |
20 | 20 | textures: { |
21 | 21 | aged:{ base: "game:block/wood/debarked/aged"}, |
22 | - }, | |
23 | - | |
22 | + }, | |
24 | 23 | fpHandTransform: { |
25 | - translation: { x: 0, y: 0, z: 0 }, | |
26 | - rotation: { x: 17, y: 38, z: -33 }, | |
27 | - scale: 1.5 | |
24 | + translation: { x: 0, y: -0.05, z: -0.6 }, | |
25 | + rotation: { x: -100, y: -180, z: 90 }, | |
26 | + origin: { x: 0.5, y: 0, z: 0.5 }, | |
27 | + scale: 0.8 | |
28 | 28 | }, |
29 | 29 | guiTransform: { |
30 | 30 | translation: { x: 0, y: 1, z: 0 }, |
@@ -34,7 +34,7 @@ | ||
34 | 34 | }, |
35 | 35 | tpHandTransform: { |
36 | 36 | translation: { x: 0, y: -0.05, z: -0.6 }, |
37 | - rotation: { x: -65, y: -180, z: 90 }, | |
37 | + rotation: { x: -90, y: -180, z: 90 }, | |
38 | 38 | origin: { x: 0.5, y: 0, z: 0.5 }, |
39 | 39 | scale: 0.8 |
40 | 40 | }, |