Skip to content

Commit 59b23c5

Browse files
committed
NPC focus action removed, wrapper for NPC interacting back. Fix #471
1 parent e2005ab commit 59b23c5

File tree

2 files changed

+127
-96
lines changed

2 files changed

+127
-96
lines changed

src/main/java/io/luna/game/model/mob/interact/NpcFocusAction.java

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/main/kotlin/api/api/predef/EventPredef.kt

Lines changed: 127 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -77,45 +77,133 @@ fun button(id: Int,
7777
action: EventAction<ButtonClickEvent>) =
7878
Matcher.get<ButtonClickEvent, Int>().set(id, action, InteractionPolicy.UNSPECIFIED)
7979

80-
/** The [NpcFirstClickEvent] matcher function. */
81-
fun npc1(id: Int,
82-
interaction: InteractionPolicySupplier,
83-
action: EventAction<NpcFirstClickEvent>) =
84-
Matcher.get<NpcFirstClickEvent, Int>().set(id, action, interaction)
85-
86-
fun npc1(id: Int,
87-
action: EventAction<NpcFirstClickEvent>) =
88-
npc1(id, InteractionPolicy.STANDARD_SIZE, action)
89-
90-
/** The [NpcSecondClickEvent] matcher function. */
91-
fun npc2(id: Int,
92-
interaction: InteractionPolicySupplier,
93-
action: EventAction<NpcSecondClickEvent>) =
94-
Matcher.get<NpcSecondClickEvent, Int>().set(id, action, interaction)
95-
96-
fun npc2(id: Int,
97-
action: EventAction<NpcSecondClickEvent>) =
98-
npc2(id, InteractionPolicy.STANDARD_SIZE, action)
99-
100-
/** The [NpcThirdClickEvent] matcher function. */
101-
fun npc3(id: Int,
102-
interaction: InteractionPolicySupplier,
103-
action: EventAction<NpcThirdClickEvent>) =
104-
Matcher.get<NpcThirdClickEvent, Int>().set(id, action, interaction)
105-
106-
fun npc3(id: Int,
107-
action: EventAction<NpcThirdClickEvent>) =
108-
npc3(id, InteractionPolicy.STANDARD_SIZE, action)
109-
110-
/** The [NpcFourthClickEvent] matcher function. */
111-
fun npc4(id: Int,
112-
interaction: InteractionPolicySupplier,
113-
action: EventAction<NpcFourthClickEvent>) =
114-
Matcher.get<NpcFourthClickEvent, Int>().set(id, action, interaction)
115-
116-
fun npc4(id: Int,
117-
action: EventAction<NpcFourthClickEvent>) =
118-
npc4(id, InteractionPolicy.STANDARD_SIZE, action)
80+
/**
81+
* The [NpcFirstClickEvent] matcher function.
82+
*/
83+
fun npc1(
84+
id: Int,
85+
interaction: InteractionPolicySupplier,
86+
focus: Boolean,
87+
action: EventAction<NpcFirstClickEvent>
88+
) = Matcher.get<NpcFirstClickEvent, Int>().set(id, {
89+
action(this)
90+
if (focus) {
91+
targetNpc.interact(plr)
92+
}
93+
}, interaction)
94+
95+
fun npc1(
96+
id: Int,
97+
interaction: InteractionPolicySupplier,
98+
action: EventAction<NpcFirstClickEvent>
99+
) = npc1(id, interaction, true, action)
100+
101+
fun npc1(
102+
id: Int,
103+
focus: Boolean,
104+
action: EventAction<NpcFirstClickEvent>
105+
) = npc1(id, InteractionPolicy.STANDARD_SIZE, focus, action)
106+
107+
fun npc1(
108+
id: Int,
109+
action: EventAction<NpcFirstClickEvent>
110+
) = npc1(id, InteractionPolicy.STANDARD_SIZE, true, action)
111+
112+
/**
113+
* The [NpcSecondClickEvent] matcher function.
114+
*/
115+
fun npc2(
116+
id: Int,
117+
interaction: InteractionPolicySupplier,
118+
focus: Boolean,
119+
action: EventAction<NpcSecondClickEvent>
120+
) = Matcher.get<NpcSecondClickEvent, Int>().set(id, {
121+
action(this)
122+
if (focus) {
123+
targetNpc.interact(plr)
124+
}
125+
}, interaction)
126+
127+
fun npc2(
128+
id: Int,
129+
interaction: InteractionPolicySupplier,
130+
action: EventAction<NpcSecondClickEvent>
131+
) = npc2(id, interaction, true, action)
132+
133+
fun npc2(
134+
id: Int,
135+
focus: Boolean,
136+
action: EventAction<NpcSecondClickEvent>
137+
) = npc2(id, InteractionPolicy.STANDARD_SIZE, focus, action)
138+
139+
fun npc2(
140+
id: Int,
141+
action: EventAction<NpcSecondClickEvent>
142+
) = npc2(id, InteractionPolicy.STANDARD_SIZE, true, action)
143+
144+
/**
145+
* The [NpcThirdClickEvent] matcher function.
146+
*/
147+
fun npc3(
148+
id: Int,
149+
interaction: InteractionPolicySupplier,
150+
focus: Boolean,
151+
action: EventAction<NpcThirdClickEvent>
152+
) = Matcher.get<NpcThirdClickEvent, Int>().set(id, {
153+
action(this)
154+
if (focus) {
155+
targetNpc.interact(plr)
156+
}
157+
}, interaction)
158+
159+
fun npc3(
160+
id: Int,
161+
interaction: InteractionPolicySupplier,
162+
action: EventAction<NpcThirdClickEvent>
163+
) = npc3(id, interaction, true, action)
164+
165+
fun npc3(
166+
id: Int,
167+
focus: Boolean,
168+
action: EventAction<NpcThirdClickEvent>
169+
) = npc3(id, InteractionPolicy.STANDARD_SIZE, focus, action)
170+
171+
fun npc3(
172+
id: Int,
173+
action: EventAction<NpcThirdClickEvent>
174+
) = npc3(id, InteractionPolicy.STANDARD_SIZE, true, action)
175+
176+
/**
177+
* The [NpcFourthClickEvent] matcher function.
178+
*/
179+
fun npc4(
180+
id: Int,
181+
interaction: InteractionPolicySupplier,
182+
focus: Boolean,
183+
action: EventAction<NpcFourthClickEvent>
184+
) = Matcher.get<NpcFourthClickEvent, Int>().set(id, {
185+
action(this)
186+
if (focus) {
187+
targetNpc.interact(plr)
188+
}
189+
}, interaction)
190+
191+
fun npc4(
192+
id: Int,
193+
interaction: InteractionPolicySupplier,
194+
action: EventAction<NpcFourthClickEvent>
195+
) = npc4(id, interaction, true, action)
196+
197+
fun npc4(
198+
id: Int,
199+
focus: Boolean,
200+
action: EventAction<NpcFourthClickEvent>
201+
) = npc4(id, InteractionPolicy.STANDARD_SIZE, focus, action)
202+
203+
fun npc4(
204+
id: Int,
205+
action: EventAction<NpcFourthClickEvent>
206+
) = npc4(id, InteractionPolicy.STANDARD_SIZE, true, action)
119207

120208
/**
121209
* The [GroundItemSecondClickEvent] matcher function.

0 commit comments

Comments
 (0)