Skip to content

Commit 0a9c2c7

Browse files
committed
Merge pull request #168 from Ziggeh/master
Combat rolls
2 parents dcab49c + 9c23fef commit 0a9c2c7

4 files changed

Lines changed: 86 additions & 13 deletions

File tree

scripts/buffs/me_evasion_1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
def setup(core, actor, buff):
44
core.skillModService.addSkillMod(actor, 'expertise_dodge', 35)
5-
core.skillModService.addSkillMod(actor, 'expertise_evasion_chance', 50)
5+
core.skillModService.addSkillMod(actor, 'display_only_evasion', 5000)
66
core.skillModService.addSkillMod(actor, 'combat_evasion_value', 50)
77
return
88

99
def removeBuff(core, actor, buff):
1010
core.skillModService.deductSkillMod(actor, 'expertise_dodge', 35)
11-
core.skillModService.deductSkillMod(actor, 'expertise_evasion_chance', 50)
11+
core.skillModService.deductSkillMod(actor, 'display_only_evasion', 5000)
1212
core.skillModService.deductSkillMod(actor, 'combat_evasion_value', 50)
1313
return
1414

src/services/EquipmentService.java

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
import java.util.Map;
2525
import java.util.Map.Entry;
2626
import java.util.TreeMap;
27+
2728
import org.python.core.Py;
2829
import org.python.core.PyObject;
30+
2931
import resources.objects.creature.CreatureObject;
3032
import main.NGECore;
3133
import 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

src/services/combat/CombatService.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ public byte getHitType(CreatureObject attacker, CreatureObject target, WeaponObj
673673
if(r <= missChance)
674674
return HitType.MISS;
675675
}
676-
float dodgeChance = (float) target.getSkillModBase("display_only_dodge") / 10000;
676+
float dodgeChance = (float) (target.getSkillModBase("display_only_dodge") - attacker.getSkillModBase("display_only_opp_dodge_reduction")) / 10000;
677677

678678
r = random.nextFloat();
679679
if(r <= dodgeChance)
@@ -683,7 +683,7 @@ public byte getHitType(CreatureObject attacker, CreatureObject target, WeaponObj
683683
WeaponObject weapon2 = (WeaponObject) core.objectService.getObject(((CreatureObject) target).getWeaponId());
684684
if(weapon2 != null && weapon2.isMelee()) {
685685

686-
float parryChance = (float) target.getSkillModBase("display_only_parry") / 10000;
686+
float parryChance = (float) (target.getSkillModBase("display_only_parry") - attacker.getSkillModBase("display_only_parry_reduction"))/ 10000;
687687

688688
r = random.nextFloat();
689689
if(r <= parryChance)
@@ -699,9 +699,23 @@ public byte getHitType(CreatureObject attacker, CreatureObject target, WeaponObj
699699

700700
}
701701

702-
float critChance = (float) (attacker.getSkillModBase("display_only_critical") - target.getSkillModBase("display_only_expertise_critical_hit_reduction")) / 10000;
702+
float critChance = 0;
703+
704+
critChance += (command.getCriticalChance());
705+
706+
critChance += ((float) attacker.getSkillModBase("display_only_critical") / 100);
707+
708+
critChance -= ((float) target.getSkillModBase("display_only_expertise_critical_hit_reduction") / 100);
709+
710+
critChance += ((float) target.getSkillModBase("critical_hit_vulnerable") / 100);
711+
712+
if(target.isPlayer())
713+
critChance += attacker.getSkillModBase("expertise_critical_niche_pvp");
714+
critChance -= ((float) target.getSkillModBase("display_only_expertise_critical_hit_pvp_reduction") / 100);
715+
703716
r = random.nextFloat();
704-
if(r <= critChance)
717+
718+
if(r <= ((float) critChance / 100))
705719
return HitType.CRITICAL;
706720

707721
// TODO: Punishing blow once AI is implemented
@@ -715,7 +729,7 @@ public byte doMitigationRolls(CreatureObject attacker, CreatureObject target, We
715729
float r;
716730
Random random = new Random();
717731

718-
float blockChance = (float) target.getSkillModBase("display_only_block") / 10000;
732+
float blockChance = (float) (target.getSkillModBase("display_only_block") - attacker.getSkillModBase("display_only_opp_block_reduction"))/ 10000;
719733

720734
r = random.nextFloat();
721735
if(r <= blockChance)

src/services/command/CombatCommand.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public class CombatCommand extends BaseSWGCommand {
7878
private float executeTime;
7979
private float warmupTime;
8080
private float vigorCost; // for commando kill meter and bm specials
81+
private float criticalChance;
8182

8283
public CombatCommand(String commandName) {
8384
super(commandName);
@@ -705,6 +706,14 @@ public float getVigorCost() {
705706
public void setVigorCost(float vigorCost) {
706707
this.vigorCost = vigorCost;
707708
}
709+
710+
public float getCriticalChance() {
711+
return criticalChance;
712+
}
713+
714+
public void setCriticalChance(float criticalChance) {
715+
this.criticalChance = criticalChance;
716+
}
708717

709718

710719

0 commit comments

Comments
 (0)