Good job! May I suggest something Gesh:
- Code: Select all
Properties.GAMENPC_CHANCES_TO_STYLE + Styles.Count
This doesnt make sense in the context of Util.Chance(). Potentially I could see this value being greater than 100 - if for example GAMENPC_CHANCES_TO_STYLE = 100. I'm not sure what Chance() does then, probably just ignore it but its still odd logic.
I thought perhaps you may be trying to make it so that NPCs with more styles, style more often. If this is the case, perhaps do something like:
- Code: Select all
int chance = Math.Min(100, Properties.GAMENPC_BASE_STYLE_CHANCE + Styles.Count * Properties.GAMENPC_EXTRA_STYLE_CHANCE);
if (Properties.GAMENPC_BASE_STYLE_CHANCE == 0) chance = 0;
Properties.GAMENPC_EXTRA_STYLE_CHANCE ~ 5 (just so we dont have any magic numbers lying about!)
(Theres a more compact way of writing this using ?, : and ;, but I wanted to illustrate the point clearly.)
mainly because I dont think just 1% difference per style will make a noticeable difference.
Another note: 'StyleProcessor.CanUseStyle(this, style, AttackWeapon)' will always return false for an invalid attack weapon, which most npcs will have. IIRC npc equipment added via npctemplate is purely aesthetic, and swords added in this way will never be used for sword styles. Geshi, can you verify that the patch works for npcs produced by NPCTemplate (which is the primary method I imagine the db team will have access to assigning styles in the first place)?
EDIT: Scratch that last point, just checked the code and its got an override for NPCs:
CanUseStyle:
- Code: Select all
169 if (!CheckWeaponType(style, living, weapon))
170 return false;
- Code: Select all
602 protected static bool CheckWeaponType(Style style, GameLiving living, InventoryItem weapon)
603 {
604 if (living is GameNPC)
605 return true;
The Marvelous Contraption begins to stir...