-
Notifications
You must be signed in to change notification settings - Fork 0
/
MeleeAttackScript.groovy
36 lines (30 loc) · 1.29 KB
/
MeleeAttackScript.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import roguelikeengine.item.*;
import roguelikeengine.largeobjects.*;
import roguelikeengine.stat.*;
/**
*
* @author greg
*/
class MeleeAttackScript implements AttackScript {
public Attack generateAttack(Body attacker, Item weapon, Trait attack){
HashMap<String, Stat> attackStats;
attackStats = new HashMap<>();
try {
//println weapon.getName() + ": " + attack.getName();
float velocity = attacker.getScore("Strength");
if (weapon.getScore("Mass") > 250 * attacker.getScore("Strength")) {
velocity -= (weapon.getScore("Mass") - 250 * attacker.getScore("Strength"))/250;
}
attackStats.put("Velocity", new NumericStat((float) velocity * attack.getScore("Mechanical Advantage")));
attackStats.put("Sharpness", weapon.viewStat("Sharpness"));
attackStats.put("Mass", new NumericStat(weapon.getScore("Mass")));
attackStats.putAll(attack.viewStats());
}
catch (NoSuchStatException e) {
}
MeleeAttack ret = new MeleeAttack(attack.getName(), weapon, attacker, attackStats);
ret.addStat("Raw Damage", new DerivedStat("Velocity", "Effective Mass", "*".charAt(0)));
ret.refactor();
return ret;
}
}