-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtime.go
168 lines (143 loc) · 4.5 KB
/
runtime.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package ns
import (
"context"
"github.com/noxworld-dev/opennox-lib/player"
"github.com/noxworld-dev/noxscript/ns/v4/audio"
"github.com/noxworld-dev/noxscript/ns/v4/effect"
"github.com/noxworld-dev/noxscript/ns/v4/spell"
)
var impl Implementation
type implKey struct{}
// WithRuntime stores Implementation in the context.
func WithRuntime(ctx context.Context, g Implementation) context.Context {
return context.WithValue(ctx, implKey{}, g)
}
// GetRuntime loads Implementation from the context.
func GetRuntime(ctx context.Context) Implementation {
if v, ok := ctx.Value(implKey{}).(Implementation); ok {
return v
}
return impl
}
// Runtime returns implementation of all the accessible functions as an interface.
func Runtime() Implementation {
return impl
}
// Game is an optional interface for the engine that exposes NoxScript runtime.
type Game interface {
// NoxScript returns implementation of NoxScript runtime.
NoxScript() Implementation
}
// Implementation of the script runtime. Only used in the engine itself.
type Implementation interface {
TimeSource
FrameRate() int
Store(typ StorageType) Storage
TimerByHandle(h TimerHandle) Timer
NewTimer(dt Duration, fnc Func, args ...any) Timer
RandomFloat(min float32, max float32) float32
Random(min int, max int) int
StopScript(value any)
AutoSave()
StartupScreen(which int)
DeathScreen(which int)
ObjectType(name string) ObjType
ObjectTypeByInd(ind int) ObjType
ObjectByHandle(h ObjHandle) Obj
Object(name string) Obj
ObjectGroupByHandle(h ObjGroupHandle) ObjGroup
ObjectGroup(name string) ObjGroup
CreateObject(typ string, pos Positioner) Obj
ObjSearcher
GetTrigger() Obj
GetCaller() Obj
GetHost() Obj
IsTrigger(obj Obj) bool
IsCaller(obj Obj) bool
IsGameBall(obj Obj) bool
IsCrown(obj Obj) bool
IsSummoned(obj Obj) bool
MakeFriendly(obj Obj)
MakeEnemy(obj Obj)
BecomePet(obj Obj)
BecomeEnemy(obj Obj)
Teams() []Team
HostPlayer() Player
Players() []Player
GetCharacterData(field int) int
Print(message StringID)
PrintStr(message string)
PrintToAll(message StringID)
PrintStrToAll(message string)
ClearMessages(player Obj)
UnBlind()
Blind()
ImmediateBlind()
WideScreen(enable bool)
IsTalking() bool
IsTrading() bool
SetHalberd(upgrade HalberdLevel)
EndGame(class player.Class)
DestroyEveryChat()
SetShopkeeperText(obj Obj, text StringID)
SetShopkeeperTextStr(obj Obj, text string)
SetDialog(obj Obj, typ DialogType, start Func, end Func)
CancelDialog(obj Obj)
StoryPic(obj Obj, name string)
TellStory(audio audio.Name, story StringID)
TellStoryStr(audio audio.Name, story string)
StartDialog(obj Obj, other Obj)
GetAnswer(obj Obj) DialogAnswer
AudioEvent(audio audio.Name, p Positioner)
Music(music int, volume int)
MusicPushEvent()
MusicPopEvent()
MusicEvent()
Effect(effect effect.Effect, p1, p2 Positioner)
CastSpell(spell spell.Spell, source, target Positioner)
CastSpellLvl(spell spell.Spell, lvl int, source, target Positioner)
NewTrap(pos Positioner, spells []TrapSpell) Obj
GetQuestStatus(name string) int
GetQuestStatusFloat(name string) float32
SetQuestStatus(status int, name string)
SetQuestStatusFloat(status float32, name string)
ResetQuestStatus(name string)
JournalEntry(obj Obj, message StringID, typ EntryType)
JournalEdit(obj Obj, message StringID, typ EntryType)
JournalDelete(obj Obj, message StringID)
JournalEntryStr(obj Obj, message string, typ EntryType)
JournalEditStr(obj Obj, message string, typ EntryType)
JournalDeleteStr(obj Obj, message string)
Waypoints() []WaypointObj
WaypointByHandle(h WaypointHandle) WaypointObj
Waypoint(name string) WaypointObj
NewWaypoint(name string, pos Pointf) WaypointObj
WaypointGroupByHandle(h WaypointGroupHandle) WaypointGroupObj
WaypointGroup(name string) WaypointGroupObj
NoWallSound(noWallSound bool)
WallByHandle(h WallHandle) WallObj
Wall(x int, y int) WallObj
WallGroupByHandle(h WallGroupHandle) WallGroupObj
WallGroup(name string) WallGroupObj
FindWalls(fnc func(it WallObj) bool, conditions ...WallCond) int
OnFrame(fnc FrameFunc)
OnMapEvent(typ MapEvent, fnc MapEventFunc)
OnChat(fnc ChatFunc)
OnPlayerJoin(fnc PlayerJoinFunc)
OnPlayerLeave(fnc PlayerLeaveFunc)
OnPlayerDeath(fnc PlayerDeathFunc)
Unused1f(id int)
Unused20(id int)
Unused50()
Unused58(arg1 int, arg2 int)
Unused59(arg1 int, arg2 int)
Unused5a(arg1 int, arg2 int)
Unused5b(arg1 int, arg2 int)
Unused5c(arg1 int, arg2 int)
Unused5d(arg1 int, arg2 int)
Unused5e(str string) int
Unused74(arg1 int, arg2 int)
Unknownb8(id int) bool
Unknownb9(id int) bool
Unknownc4()
}