source: lost-haven/main/EquippedWeapon.java@ a49176d

Last change on this file since a49176d was 8edd04e, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 4 years ago

Make the decompiled game code compile successfully

  • Property mode set to 100644
File size: 4.6 KB
Line 
1package main;
2
3import java.awt.*;
4import java.awt.image.BufferedImage;
5
6public class EquippedWeapon extends Weapon {
7
8 Creature controller;
9 Weapon baseWeapon;
10
11 public EquippedWeapon(Creature controller, Weapon baseWeapon) {
12 super(baseWeapon, (Point)null);
13 this.controller = controller;
14 this.baseWeapon = baseWeapon;
15 }
16
17 public EquippedWeapon(EquippedWeapon copy, Point loc) {
18 super(copy, loc);
19 this.controller = copy.controller;
20 this.baseWeapon = copy.baseWeapon;
21 }
22
23 public EquippedWeapon copy(Point loc) {
24 return new EquippedWeapon(this, loc);
25 }
26
27 public void update() {
28 Player p;
29 boolean[] usedGems;
30 int x;
31 if (this.controller.getType() == CreatureType.Player) {
32 p = (Player)this.controller;
33 } else {
34 return;
35 }
36 this.spawnEffects.clear();
37 this.contactEffects.clear();
38 this.contactEffects.add(new Damage(0, TargetType.Enemy));
39 setAttackSpeed(this.baseWeapon.getAttackSpeed() - this.controller.getAttribute(Attribute.Dexterity) / 2 + 3);
40 switch (getType()) {
41 case LightWeapon:
42 setDamage(this.baseWeapon.getDamage() + p.getAttribute(Attribute.Strength) - 6 + 2 * p.getSkill(Skill.LightWeapons));
43 break;
44 case HeavyWeapon:
45 setDamage(this.baseWeapon.getDamage() + 2 * p.getAttribute(Attribute.Strength) - 12 + 4 * p.getSkill(Skill.HeavyWeapons));
46 break;
47 case RangedWeapon:
48 setDamage(this.baseWeapon.getDamage() + 2 * p.getSkill(Skill.RangedWeapons));
49 break;
50 case Spell:
51 usedGems = new boolean[4];
52 setSpawnEffect(new ManaDrain((p.getGemValue() + 1) / 2, TargetType.Creator));
53 if (p.getGemNum("FireGem") > 0) {
54 setDamage(4 * p.getGemNum("FireGem"));
55 usedGems[2] = true;
56 }
57 if (p.getGemNum("WaterGem") > 0) {
58 setContactEffect(new ChangeDamage(0.8D, TargetType.Enemy, (5000 * p.getGemNum("WaterGem"))));
59 usedGems[3] = true;
60 }
61 if (p.getGemNum("AirGem") > 0) {
62 setSpawnEffect(new ProjectileSpeed(100 * p.getGemNum("AirGem"), TargetType.Projectile));
63 usedGems[0] = true;
64 }
65 if (p.getGemNum("EarthGem") > 0) {
66 setContactEffect(new AreaOfEffect(new Damage(4 * p.getGemNum("EarthGem"), TargetType.Enemy), 100, TargetType.Enemy));
67 usedGems[1] = true;
68 }
69 if (p.getGemNum("SteamMetaGem") > 0) {
70 setContactEffect(new Confuse(TargetType.Enemy, (2000 * p.getGemNum("SteamMetaGem"))));
71 usedGems[2] = true;
72 usedGems[3] = true;
73 }
74 if (p.getGemNum("SandMetaGem") > 0) {
75 setContactEffect(new Disable(TargetType.Enemy, (4000 * p.getGemNum("SandMetaGem"))));
76 usedGems[0] = true;
77 usedGems[2] = true;
78 }
79 if (p.getGemNum("MetalMetaGem") > 0) {
80 setSpawnEffect(new Penetrate(TargetType.Projectile));
81 usedGems[1] = true;
82 usedGems[2] = true;
83 }
84 if (p.getGemNum("IceMetaGem") > 0) {
85 setContactEffect(new MoveSpeed(0.0D, TargetType.Enemy, (3000 * p.getGemNum("IceMetaGem"))));
86 setContactEffect(new Disable(TargetType.Enemy, (3000 * p.getGemNum("IceMetaGem"))));
87 usedGems[0] = true;
88 usedGems[3] = true;
89 }
90 if (p.getGemNum("MudMetaGem") > 0) {
91 setContactEffect(new MoveSpeed(0.6D, TargetType.Enemy, (8000 * p.getGemNum("MudMetaGem"))));
92 usedGems[1] = true;
93 usedGems[3] = true;
94 }
95 if (p.getGemNum("CrystalMetaGem") > 0) {
96 setSpawnEffect(new Damage(-5 * p.getGemNum("CrystalMetaGem"), TargetType.Creator));
97 usedGems[0] = true;
98 usedGems[1] = true;
99 }
100 for (x = 0; x < 8; x++) {
101 this.imgProj[x] = generateSprite(x, usedGems);
102 }
103 break;
104 }
105 }
106
107 private BufferedImage generateSprite(int dir, boolean[] usedGems) {
108 GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
109 GraphicsDevice device = env.getDefaultScreenDevice();
110 GraphicsConfiguration gc = device.getDefaultConfiguration();
111 BufferedImage source = gc.createCompatibleImage(50, 50, 3);
112 Graphics2D srcGraphics = source.createGraphics();
113 if (usedGems[1]) {
114 srcGraphics.drawImage(LostHavenRPG.earthSprites[dir], 0, 0, null);
115 }
116 if (usedGems[0]) {
117 srcGraphics.drawImage(LostHavenRPG.airSprites[dir], 0, 0, null);
118 }
119 if (usedGems[2]) {
120 srcGraphics.drawImage(LostHavenRPG.fireSprites[dir], 0, 0, null);
121 }
122 if (usedGems[3]) {
123 srcGraphics.drawImage(LostHavenRPG.waterSprites[dir], 0, 0, null);
124 }
125 return source;
126 }
127}
Note: See TracBrowser for help on using the repository browser.