VS plugin mod for Basic Armour
リビジョン | 719bfd0cacfa7bd9dd4a3a0533b18264062cf01b (tree) |
---|---|
日時 | 2019-06-12 09:16:48 |
作者 | melchior <melchior@user...> |
コミッター | melchior |
Fixed Environmental damage from throwing exception
Prevent heals from decaying armour
Change for possible null-ref by using self as damage source for item decay
@@ -185,12 +185,20 @@ namespace ArmourMod | ||
185 | 185 | /// <param name="damage">Damage.</param> |
186 | 186 | public override bool ReceiveDamage(DamageSource damageSource, float damage) |
187 | 187 | { |
188 | - if (damageSource.Type != EnumDamageType.Heal) | |
188 | + if | |
189 | + ( | |
190 | + damageSource.Type == EnumDamageType.BluntAttack || | |
191 | + damageSource.Type == EnumDamageType.PiercingAttack || | |
192 | + damageSource.Type == EnumDamageType.SlashingAttack || | |
193 | + damageSource.Type == EnumDamageType.Crushing || | |
194 | + damageSource.Type == EnumDamageType.Fire | |
195 | + ) | |
189 | 196 | { |
190 | 197 | float beforeDamage = damage; |
191 | 198 | //TODO: evaluate postion vector of strike to determine WHEN position of armour offers protection |
192 | 199 | |
193 | - if (DamageFilters.Count > 0) { | |
200 | + if (DamageFilters != null && DamageFilters.Count > 0) | |
201 | + { | |
194 | 202 | //Evaluate damge type |
195 | 203 | //Reduce by any applicable filter(s) |
196 | 204 | //Pass along |
@@ -223,23 +231,31 @@ namespace ArmourMod | ||
223 | 231 | |
224 | 232 | default: |
225 | 233 | |
234 | + if (damageSource.Source == EnumDamageSource.Player) { | |
235 | + #if DEBUG | |
236 | + Logger.Warning("Player did unhandled type of damage {0}", damageSource.Type ); | |
237 | + #endif | |
238 | + } | |
239 | + | |
226 | 240 | break; |
227 | 241 | } |
228 | - } | |
229 | 242 | |
230 | - #if DEBUG | |
231 | - Logger.VerboseDebug("Reduced: {0} Dmg from {2}; [{1}]", damage, damageSource.Type.ToString( ), beforeDamage); | |
232 | - #endif | |
243 | + if (damage > 0) { | |
244 | + #if DEBUG | |
245 | + Logger.VerboseDebug("Reduced: {0} Dmg from {2}; [{1}]", damage, damageSource.Type.ToString( ), beforeDamage); | |
246 | + #endif | |
233 | 247 | |
234 | - //All worn Armours adsorb damage themselves... | |
235 | - List<EnumCharacterDressType> slotsList = this.DamageFilters.Keys.ToList(); | |
248 | + //All worn Armours adsorb damage themselves... | |
249 | + List<EnumCharacterDressType> slotsList = this.DamageFilters.Keys.ToList( ); | |
236 | 250 | |
237 | - foreach (var slotId in slotsList) { | |
238 | - ItemSlot slot = this.GearInventory[(int)slotId]; | |
239 | - Item armourItem = slot.Itemstack.Item; | |
251 | + foreach (var slotId in slotsList) { | |
252 | + ItemSlot slot = this.GearInventory[( int )slotId]; | |
253 | + Item armourItem = slot.Itemstack.Item; | |
240 | 254 | |
241 | - armourItem.DamageItem(ServerAPI.World, damageSource.SourceEntity, slot, 1); | |
242 | - } | |
255 | + armourItem.DamageItem(ServerAPI.World, this, slot, 1); | |
256 | + } | |
257 | + } | |
258 | + } | |
243 | 259 | } |
244 | 260 | |
245 | 261 | return base.ReceiveDamage(damageSource, damage); |
@@ -23,14 +23,14 @@ namespace ArmourMod | ||
23 | 23 | this.Durability})); |
24 | 24 | } |
25 | 25 | |
26 | - //Display Protection values | |
26 | + //Display Protection values & Weight / dissadvantages | |
27 | 27 | var blunt = stack.ItemAttributes["BluntProtection"].AsFloat( ); |
28 | 28 | var piercing = stack.ItemAttributes["PiercingProtection"].AsFloat( ); |
29 | 29 | var slashing = stack.ItemAttributes["SlashingProtection"].AsFloat( ); |
30 | 30 | var crushing = stack.ItemAttributes["CrushingProtection"].AsFloat( ); |
31 | 31 | var flame = stack.ItemAttributes["FireProtection"].AsFloat( ); |
32 | 32 | |
33 | - dsc.AppendFormat("Protection:\n Blunt {0:P1}\n Piercing {1:P1}\n Slashing {2:P1}\n Crushing {3:P1}\n Flame {4:P1}", | |
33 | + dsc.AppendFormat("Protection:\n Blunt {0:P1}\n Piercing {1:P1}\n Slashing {2:P1}\n Crushing {3:P1}\n Flame {4:P1}\n", | |
34 | 34 | blunt, |
35 | 35 | piercing, |
36 | 36 | slashing, |
@@ -46,6 +46,10 @@ namespace ArmourMod | ||
46 | 46 | dsc.AppendLine(Lang.Get("Cloth Category: {0}", Lang.Get("clothcategory-" + stack.ItemAttributes["clothescategory"].AsString( )))); |
47 | 47 | } |
48 | 48 | } |
49 | + | |
50 | + //IDEA: Shackles = "Armour" that has high encumberance - and 'sticks' to player; needs specific key to remove | |
51 | + //TODO: Shackle & Key item, (Closed) Shackle ItemArmour | |
52 | + | |
49 | 53 | } |
50 | 54 | } |
51 | 55 |
@@ -3,9 +3,9 @@ | ||
3 | 3 | "name": "Basic Armour Mod", |
4 | 4 | "description" : "Leather, Plate, Scale & More", |
5 | 5 | "authors": ["Melchior", "Bunnyviking"], |
6 | - "version": "0.1.7", | |
6 | + "version": "0.1.8", | |
7 | 7 | "dependencies": { |
8 | - "game": "1.9.7", | |
8 | + "game": "1.9.9", | |
9 | 9 | "survival": "" |
10 | 10 | }, |
11 | 11 | "website": "http://nowebsite.nope" |