2424import java .util .Map ;
2525import java .util .Map .Entry ;
2626import java .util .TreeMap ;
27+
2728import org .python .core .Py ;
2829import org .python .core .PyObject ;
30+
2931import resources .objects .creature .CreatureObject ;
3032import main .NGECore ;
3133import engine .resources .objects .SWGObject ;
@@ -50,26 +52,73 @@ public void shutdown() {
5052
5153 }
5254
55+ public void weaponCriticalToDisplay (CreatureObject actor , SWGObject item , boolean add ) {
56+
57+ if (add == true ) {
58+
59+ switch (item .getStringAttribute ("cat_wpn_damage.wpn_category" )) {
60+
61+ case "Rifle" : actor .addSkillMod ("display_only_critical" , actor .getSkillModBase ("expertise_critical_rifle" ) * 100 ); // rifle
62+ case "Carbine" : actor .addSkillMod ("display_only_critical" , actor .getSkillModBase ("expertise_critical_carbine" ) * 100 ); // carbine
63+ case "Pistol" : actor .addSkillMod ("display_only_critical" , actor .getSkillModBase ("expertise_critical_pistol" ) * 100 ); // pistol
64+ case "One-Handed Melee" : actor .addSkillMod ("display_only_critical" , ((actor .getSkillModBase ("expertise_critical_1h" ) + actor .getSkillModBase ("expertise_critical_melee" )) * 100 )); // one-handed
65+ case "Two-Handed Melee" : actor .addSkillMod ("display_only_critical" , ((actor .getSkillModBase ("expertise_critical_2h" ) + actor .getSkillModBase ("expertise_critical_melee" )) * 100 )); // two-handed
66+ case "Unarmed" : actor .addSkillMod ("display_only_critical" , ((actor .getSkillModBase ("expertise_critical_unarmed" ) + actor .getSkillModBase ("expertise_critical_melee" )) * 100 )); // unarmed
67+ case "Polearm" : actor .addSkillMod ("display_only_critical" , ((actor .getSkillModBase ("expertise_critical_polearm" ) + actor .getSkillModBase ("expertise_critical_melee" )) * 100 )); // polearm
68+ case "Free Targeting Heavy Weapon" : actor .addSkillMod ("display_only_critical" , actor .getSkillModBase ("expertise_critical_heavy" ) * 100 ); // Heavy
69+
70+
71+ }
72+
73+ }
74+
75+ if (add == false ) {
76+
77+ switch (item .getStringAttribute ("cat_wpn_damage.wpn_category" )) {
78+
79+ case "Rifle" : actor .deductSkillMod ("display_only_critical" , actor .getSkillModBase ("expertise_critical_rifle" ) * 100 ); // rifle
80+ case "Carbine" : actor .deductSkillMod ("display_only_critical" , actor .getSkillModBase ("expertise_critical_carbine" ) * 100 ); // carbine
81+ case "Pistol" : actor .deductSkillMod ("display_only_critical" , actor .getSkillModBase ("expertise_critical_pistol" ) * 100 ); // pistol
82+ case "One-Handed Melee" : actor .deductSkillMod ("display_only_critical" , ((actor .getSkillModBase ("expertise_critical_1h" ) + actor .getSkillModBase ("expertise_critical_melee" )) * 100 )); // one-handed
83+ case "Two-Handed Melee" : actor .deductSkillMod ("display_only_critical" , ((actor .getSkillModBase ("expertise_critical_2h" ) + actor .getSkillModBase ("expertise_critical_melee" )) * 100 )); // two-handed
84+ case "Unarmed" : actor .deductSkillMod ("display_only_critical" , ((actor .getSkillModBase ("expertise_critical_unarmed" ) + actor .getSkillModBase ("expertise_critical_melee" )) * 100 )); // unarmed
85+ case "Polearm" : actor .deductSkillMod ("display_only_critical" , ((actor .getSkillModBase ("expertise_critical_polearm" ) + actor .getSkillModBase ("expertise_critical_melee" )) * 100 )); // polearm
86+ case "Free Targeting Heavy Weapon" : actor .deductSkillMod ("display_only_critical" , actor .getSkillModBase ("expertise_critical_heavy" ) * 100 ); // Heavy
87+ }
88+ }
89+ }
90+
5391 public void equip (CreatureObject actor , SWGObject item ) {
5492
5593 //if(replacedItem != null)
5694 // unequip(actor, replacedItem);
5795
58- String template = item .getTemplate ();
96+ String template = (( item .getAttachment ( "customServerTemplate" ) == null ) ? item . getTemplate () : ( item . getTemplate (). split ( "shared_" )[ 0 ] + "shared_" + (( String ) item . getAttachment ( "customServerTemplate" )) + ".iff" ) );
5997 String serverTemplate = template .replace (".iff" , "" );
6098 PyObject func = core .scriptService .getMethod ("scripts/" + serverTemplate .split ("shared_" , 2 )[0 ].replace ("shared_" , "" ), serverTemplate .split ("shared_" , 2 )[1 ], "equip" );
6199 if (func != null )
62100 func .__call__ (Py .java2py (core ), Py .java2py (actor ), Py .java2py (item ));
63101
64- // TODO: add health/action bonus from crafted weapon with augmentations
102+ // TODO: add health/action bonus from crafted weapon with augmentations (also seen with cybernetics)
103+ // TODO: faction restrictions
104+ // TODO: Species restrictions?
105+ // TODO: Gender restrictions?
106+ // TODO: crit enhancement from crafted weapons
107+ // TODO: Jedi robes Force Protection Intensity
108+ // TODO: check for armor category in order to add resistance to certain DoT types
109+ // TODO: if weapon, add the weapon specific crit to display_only_critical
110+ // TODO: bio-link
111+
112+ if (actor .getSlotNameForObject (item ).contentEquals ("hold_r" ) == true )
113+ weaponCriticalToDisplay (actor , item , true );
65114
66115 Map <String , Object > attributes = new TreeMap <String , Object >(item .getAttributes ());
67116
68117 for (Entry <String , Object > e : attributes .entrySet ()) {
69118
70119 if (e .getKey ().startsWith ("cat_skill_mod_bonus.@stat_n:" )) {
71120 core .skillModService .addSkillMod (actor , e .getKey ().replace ("cat_skill_mod_bonus.@stat_n:" , "" ), Integer .parseInt ((String ) e .getValue ()));
72- }
121+ }
73122
74123 }
75124
@@ -80,21 +129,22 @@ public void equip(CreatureObject actor, SWGObject item) {
80129
81130 public void unequip (CreatureObject actor , SWGObject item ) {
82131
83- String template = item .getTemplate ();
132+ String template = (( item .getAttachment ( "customServerTemplate" ) == null ) ? item . getTemplate () : ( item . getTemplate (). split ( "shared_" )[ 0 ] + "shared_" + (( String ) item . getAttachment ( "customServerTemplate" )) + ".iff" ) );
84133 String serverTemplate = template .replace (".iff" , "" );
85134 PyObject func = core .scriptService .getMethod ("scripts/" + serverTemplate .split ("shared_" , 2 )[0 ].replace ("shared_" , "" ), serverTemplate .split ("shared_" , 2 )[1 ], "unequip" );
86135 if (func != null )
87136 func .__call__ (Py .java2py (core ), Py .java2py (actor ), Py .java2py (item ));
88137
89- // TODO: remove health/action bonus from crafted weapon with augmentations
138+ if (actor .getSlotNameForObject (item ).contentEquals ("hold_r" ) == true )
139+ weaponCriticalToDisplay (actor , item , false );
90140
91141 Map <String , Object > attributes = new TreeMap <String , Object >(item .getAttributes ());
92142
93143 for (Entry <String , Object > e : attributes .entrySet ()) {
94144
95145 if (e .getKey ().startsWith ("cat_skill_mod_bonus.@stat_n:" )) {
96146 core .skillModService .deductSkillMod (actor , e .getKey ().replace ("cat_skill_mod_bonus.@stat_n:" , "" ), Integer .parseInt ((String ) e .getValue ()));
97- }
147+ }
98148
99149 }
100150
0 commit comments