Skip to content

Commit faac01d

Browse files
authored
Merge pull request #4 from Glasislundr/abilitybuilder
Abilitybuilder v0.2
2 parents 21cc333 + ce9deb6 commit faac01d

File tree

88 files changed

+4167
-802
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+4167
-802
lines changed

core/assets/abilityBehaviors/humanHeroActives.json

Lines changed: 527 additions & 0 deletions
Large diffs are not rendered by default.

core/assets/abilityBehaviors/humanUnitActives.json

Lines changed: 213 additions & 523 deletions
Large diffs are not rendered by default.

core/assets/abilityBehaviors/nightElfUnitActives.json

Lines changed: 835 additions & 43 deletions
Large diffs are not rendered by default.
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
{
2+
"abilityList": [{
3+
"ids": [{"id":"AUsl", "castId": "sleep"}],
4+
"type": "NORMAL_UNITTARGET_SIMPLE",
5+
"onAddAbility": [{
6+
"type": "createStateModBuff",
7+
"buffType": "SLEEPING"
8+
},{
9+
"type": "storeValueLocally",
10+
"key": {
11+
"type": "rawString",
12+
"value": "sleep"
13+
},
14+
"instanceValue": {
15+
"type": "rawBoolean",
16+
"value": "false"
17+
},
18+
"valueToStore": {
19+
"type": "getLastCreatedStateModBuff"
20+
}
21+
},{
22+
"type": "createStateModBuff",
23+
"buffType": "INVULNERABLE"
24+
},{
25+
"type": "storeValueLocally",
26+
"key": {
27+
"type": "rawString",
28+
"value": "invuln"
29+
},
30+
"instanceValue": {
31+
"type": "rawBoolean",
32+
"value": "false"
33+
},
34+
"valueToStore": {
35+
"type": "getLastCreatedStateModBuff"
36+
}
37+
}],
38+
"onBeginCasting": [{
39+
"type": "createTemporarySpellEffectOnUnit",
40+
"target": {
41+
"type": "getAbilityTargetedUnit"
42+
},
43+
"id": {
44+
"type": "getSecondBuffId"
45+
},
46+
"effectType": "TARGET"
47+
},{
48+
"type": "createTimedBuff",
49+
"buffId": {
50+
"type": "getSecondBuffId"
51+
},
52+
"duration": {
53+
"type": "getAbilityDataAsFloat",
54+
"dataField": "A"
55+
},
56+
"showIcon": {
57+
"type": "rawBoolean",
58+
"value": "false"
59+
},
60+
"onAddActions": [{
61+
"type": "addStateModBuff",
62+
"targetUnit": {
63+
"type": "getCastingUnit"
64+
},
65+
"buff": {
66+
"type": "getStoredStateModBuffByKey",
67+
"instanceValue": {
68+
"type": "rawBoolean",
69+
"value": "false"
70+
},
71+
"key": {
72+
"type": "rawString",
73+
"value": "invuln"
74+
}
75+
}
76+
}],
77+
"onRemoveActions": [{
78+
"type": "removeStateModBuff",
79+
"targetUnit": {
80+
"type": "getCastingUnit"
81+
},
82+
"buff": {
83+
"type": "getStoredStateModBuffByKey",
84+
"instanceValue": {
85+
"type": "rawBoolean",
86+
"value": "false"
87+
},
88+
"key": {
89+
"type": "rawString",
90+
"value": "invuln"
91+
}
92+
}
93+
}]
94+
},{
95+
"type": "addBuff",
96+
"target": {
97+
"type": "getAbilityTargetedUnit"
98+
},
99+
"buff": {
100+
"type": "getLastCreatedBuff"
101+
}
102+
},{
103+
"type": "createTimedBuff",
104+
"buffId": {
105+
"type": "getFirstBuffId"
106+
},
107+
"duration": {
108+
"type": "getAbilityDuration",
109+
"target": {
110+
"type": "getAbilityTargetedUnit"
111+
}
112+
},
113+
"onAddActions": [{
114+
"type": "addStateModBuff",
115+
"targetUnit": {
116+
"type": "getCastingUnit"
117+
},
118+
"buff": {
119+
"type": "getStoredStateModBuffByKey",
120+
"instanceValue": {
121+
"type": "rawBoolean",
122+
"value": "false"
123+
},
124+
"key": {
125+
"type": "rawString",
126+
"value": "sleep"
127+
}
128+
}
129+
},{
130+
"type": "createDamageTakenListener",
131+
"actions": [{
132+
"type": "removeDamageTakenListener",
133+
"targetUnit": {
134+
"type": "getCastingUnit"
135+
},
136+
"listener": {
137+
"type": "getStoredDamageTakenListenerByKey",
138+
"key": {
139+
"type": "rawString",
140+
"value": "awakenListener"
141+
}
142+
}
143+
144+
},{
145+
"type": "removeBuff",
146+
"target": {
147+
"type": "getCastingUnit"
148+
},
149+
"buff": {
150+
"type": "getStoredBuffByKey",
151+
"key": {
152+
"type": "rawString",
153+
"value": "sleepbuff"
154+
}
155+
}
156+
}]
157+
},{
158+
"type": "addDamageTakenListener",
159+
"targetUnit": {
160+
"type": "getCastingUnit"
161+
},
162+
"listener": {
163+
"type": "getLastCreatedDamageTakenListener"
164+
}
165+
},{
166+
"type": "storeValueLocally",
167+
"key": {
168+
"type": "rawString",
169+
"value": "awakenListener"
170+
},
171+
"valueToStore": {
172+
"type": "getLastCreatedDamageTakenListener"
173+
}
174+
}],
175+
"onRemoveActions": [{
176+
"type": "removeStateModBuff",
177+
"targetUnit": {
178+
"type": "getCastingUnit"
179+
},
180+
"buff": {
181+
"type": "getStoredStateModBuffByKey",
182+
"instanceValue": {
183+
"type": "rawBoolean",
184+
"value": "false"
185+
},
186+
"key": {
187+
"type": "rawString",
188+
"value": "sleep"
189+
}
190+
}
191+
}]
192+
},{
193+
"type": "addBuff",
194+
"target": {
195+
"type": "getAbilityTargetedUnit"
196+
},
197+
"buff": {
198+
"type": "getLastCreatedBuff"
199+
}
200+
},{
201+
"type": "storeValueLocally",
202+
"key": {
203+
"type": "rawString",
204+
"value": "sleepbuff"
205+
},
206+
"valueToStore": {
207+
"type": "getLastCreatedBuff"
208+
}
209+
}]
210+
}]
211+
}

core/src/com/etheller/warsmash/viewer5/AudioBufferSource.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ public void connect(final AudioPanner panner) {
1111
this.panner = panner;
1212
}
1313

14-
public void start(final int value, final float volume, final float pitch, final boolean looping) {
14+
public long start(final int value, final float volume, final float pitch, final boolean looping) {
1515
if (this.buffer != null) {
1616
if (!this.panner.listener.is3DSupported() || this.panner.isWithinListenerDistance()) {
17-
Extensions.audio.play(this.buffer, volume, pitch, this.panner.x, this.panner.y, this.panner.z,
17+
return Extensions.audio.play(this.buffer, volume, pitch, this.panner.x, this.panner.y, this.panner.z,
1818
this.panner.listener.is3DSupported(), this.panner.maxDistance, this.panner.refDistance,
1919
looping);
2020
}
2121
}
22+
return -1;
2223
}
2324
}

core/src/com/etheller/warsmash/viewer5/gl/AudioExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ public interface AudioExtension {
88

99
float getDuration(Sound sound);
1010

11-
void play(Sound buffer, final float volume, final float pitch, final float x, final float y, final float z,
11+
long play(Sound buffer, final float volume, final float pitch, final float x, final float y, final float z,
1212
final boolean is3DSound, float maxDistance, float refDistance, boolean looping);
1313
}

core/src/com/etheller/warsmash/viewer5/handlers/w3x/UnitSound.java

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,25 +106,33 @@ public boolean playUnitResponse(final AudioContext audioContext, final RenderUni
106106
if (millisTime < unit.lastUnitResponseEndTimeMillis) {
107107
return false;
108108
}
109-
if (play(audioContext, unit.location[0], unit.location[1], unit.location[2], index)) {
109+
if (play(audioContext, unit.location[0], unit.location[1], unit.location[2], index) != -1) {
110110
final float duration = Extensions.audio.getDuration(this.lastPlayedSound);
111111
unit.lastUnitResponseEndTimeMillis = millisTime + (long) (1000 * duration);
112112
return true;
113113
}
114114
return false;
115115
}
116116

117-
public boolean play(final AudioContext audioContext, final float x, final float y, final float z) {
117+
public long play(final AudioContext audioContext, final float x, final float y, final float z, final boolean loopOverride) {
118+
return play(audioContext, x, y, z, (int) (Math.random() * this.sounds.size()), loopOverride);
119+
}
120+
121+
public long play(final AudioContext audioContext, final float x, final float y, final float z) {
118122
return play(audioContext, x, y, z, (int) (Math.random() * this.sounds.size()));
119123
}
120124

121-
public boolean play(final AudioContext audioContext, final float x, final float y, final float z, final int index) {
125+
public long play(final AudioContext audioContext, final float x, final float y, final float z, final int index) {
126+
return play(audioContext, x, y, z, index, null);
127+
}
128+
129+
public long play(final AudioContext audioContext, final float x, final float y, final float z, final int index, final Boolean loopOverride) {
122130
if (this.sounds.isEmpty()) {
123-
return false;
131+
return -1;
124132
}
125133

126134
if (audioContext == null) {
127-
return true;
135+
return -1;
128136
}
129137
final AudioPanner panner = audioContext.createPanner();
130138
final AudioBufferSource source = audioContext.createBufferSource();
@@ -139,10 +147,16 @@ public boolean play(final AudioContext audioContext, final float x, final float
139147
source.connect(panner);
140148

141149
// Make a sound.
142-
source.start(0, this.volume,
143-
(this.pitch + ((float) Math.random() * this.pitchVariance * 2)) - this.pitchVariance, this.looping);
150+
long soundId = -1;
151+
if (loopOverride == null) {
152+
soundId = source.start(0, this.volume,
153+
(this.pitch + ((float) Math.random() * this.pitchVariance * 2)) - this.pitchVariance, this.looping);
154+
} else {
155+
soundId = source.start(0, this.volume,
156+
(this.pitch + ((float) Math.random() * this.pitchVariance * 2)) - this.pitchVariance, loopOverride);
157+
}
144158
this.lastPlayedSound = source.buffer;
145-
return true;
159+
return soundId;
146160
}
147161

148162
public int getSoundCount() {
@@ -154,4 +168,12 @@ public void stop() {
154168
sound.stop();
155169
}
156170
}
171+
172+
public void stop(long soundId) {
173+
// This may misbehave if called for a list longer than 1, due to the random index used when starting?
174+
// Not sure if IDs are unique per source
175+
for (final Sound sound : this.sounds) {
176+
sound.stop(soundId);
177+
}
178+
}
157179
}

0 commit comments

Comments
 (0)