folib 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +23 -0
- package/CHANGELOG.md +5 -0
- package/README.md +3 -0
- package/eslint.config.js +23 -0
- package/package.json +26 -0
- package/src/base.d.ts +941 -0
- package/src/define.ts +18 -0
- package/src/index.ts +254 -0
- package/src/rp/animcomd.ts +42 -0
- package/src/rp/command.ts +25 -0
- package/src/rp/critterpid.ts +606 -0
- package/src/rp/global.ts +812 -0
- package/src/rp/itempid.ts +624 -0
- package/src/rp/maps.ts +398 -0
- package/src/rp/modoc.ts +10 -0
- package/src/rp/scenepid.ts +170 -0
- package/src/rp/scripts.ts +3076 -0
- package/src/sfall/ai_area.ts +8 -0
- package/src/sfall/ai_attack.ts +8 -0
- package/src/sfall/ai_cap.ts +18 -0
- package/src/sfall/ai_chem.ts +9 -0
- package/src/sfall/ai_disposition.ts +9 -0
- package/src/sfall/ai_distance.ts +8 -0
- package/src/sfall/ai_run_away.ts +11 -0
- package/src/sfall/ai_weapon.ts +11 -0
- package/src/sfall/command_lite.ts +29 -0
- package/src/sfall/define_extra.ts +472 -0
- package/src/sfall/define_lite.ts +913 -0
- package/src/sfall/dik.ts +131 -0
- package/src/sfall/index.ts +1634 -0
- package/src/sfall/lib.arrays.ts +307 -0
- package/src/sfall/lib.misc.ts +35 -0
- package/src/sfall/lib.strings.ts +118 -0
- package/src/sfall/sfall.d.ts +1706 -0
- package/src/sfall/sfall.ts +2478 -0
- package/src/types.d.ts +119 -0
- package/src/types.ts +49 -0
- package/tsconfig.json +11 -0
package/src/define.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Custom defines
|
|
2
|
+
|
|
3
|
+
import { debug_msg } from "./base.d";
|
|
4
|
+
|
|
5
|
+
// This will be set by the importing script
|
|
6
|
+
declare const SCRIPT_REALNAME: string;
|
|
7
|
+
|
|
8
|
+
/** Float constant 1.0 - use to force float division: FLOAT1 * a / b */
|
|
9
|
+
export const FLOAT1 = 1.0;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Logs a message to debug.log. Requires `SCRIPT_REALNAME` define to be set.
|
|
13
|
+
* @param msg log message
|
|
14
|
+
* @inline
|
|
15
|
+
*/
|
|
16
|
+
export function ndebug(msg: string): void {
|
|
17
|
+
debug_msg(SCRIPT_REALNAME + ": " + msg);
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
// Re-export types from declaration file
|
|
2
|
+
export type {
|
|
3
|
+
ArrayID,
|
|
4
|
+
AttackMode,
|
|
5
|
+
AttackType,
|
|
6
|
+
ContainerPtr,
|
|
7
|
+
CritterPtr,
|
|
8
|
+
CritterState,
|
|
9
|
+
DamageType,
|
|
10
|
+
Difficulty,
|
|
11
|
+
Direction,
|
|
12
|
+
DoorPtr,
|
|
13
|
+
Elevation,
|
|
14
|
+
FloatMsgColor,
|
|
15
|
+
GameMode,
|
|
16
|
+
Gender,
|
|
17
|
+
Hand,
|
|
18
|
+
HitResult,
|
|
19
|
+
HookID,
|
|
20
|
+
IfaceTag,
|
|
21
|
+
InvenSlot,
|
|
22
|
+
ItemPtr,
|
|
23
|
+
ObjectPtr,
|
|
24
|
+
ObjType,
|
|
25
|
+
PcStatID,
|
|
26
|
+
PerkID,
|
|
27
|
+
RollResult,
|
|
28
|
+
SceneryPtr,
|
|
29
|
+
SfallList,
|
|
30
|
+
SfallMap,
|
|
31
|
+
TraitID,
|
|
32
|
+
TraitType,
|
|
33
|
+
WeaponType,
|
|
34
|
+
} from './types.d';
|
|
35
|
+
|
|
36
|
+
// Re-export transpiler-handled functions from types.d
|
|
37
|
+
export { list, map } from './types.d';
|
|
38
|
+
|
|
39
|
+
// Re-export constants from runtime file
|
|
40
|
+
export {
|
|
41
|
+
DIFFICULTY_EASY,
|
|
42
|
+
DIFFICULTY_HARD,
|
|
43
|
+
DIFFICULTY_NORMAL,
|
|
44
|
+
DIRECTION_E,
|
|
45
|
+
DIRECTION_NE,
|
|
46
|
+
DIRECTION_NW,
|
|
47
|
+
DIRECTION_SE,
|
|
48
|
+
DIRECTION_SW,
|
|
49
|
+
DIRECTION_W,
|
|
50
|
+
ELEVATION_0,
|
|
51
|
+
ELEVATION_1,
|
|
52
|
+
ELEVATION_2,
|
|
53
|
+
ELEVATION_ALL,
|
|
54
|
+
HITRESULT_CRITICAL_HIT,
|
|
55
|
+
HITRESULT_CRITICAL_MISS,
|
|
56
|
+
HITRESULT_HIT,
|
|
57
|
+
HITRESULT_MISS,
|
|
58
|
+
LEFT_HAND,
|
|
59
|
+
NullPtr,
|
|
60
|
+
RIGHT_HAND,
|
|
61
|
+
} from './types';
|
|
62
|
+
|
|
63
|
+
// Re-export engine builtins from base.d
|
|
64
|
+
export {
|
|
65
|
+
action_being_used,
|
|
66
|
+
add_mult_objs_to_inven,
|
|
67
|
+
add_obj_to_inven,
|
|
68
|
+
add_timer_event,
|
|
69
|
+
AddNamedEvent,
|
|
70
|
+
AddNamedHandler,
|
|
71
|
+
anim,
|
|
72
|
+
anim_action_frame,
|
|
73
|
+
anim_busy,
|
|
74
|
+
animate_move_obj_to_tile,
|
|
75
|
+
animate_rotation,
|
|
76
|
+
animate_run_to_tile,
|
|
77
|
+
animate_set_frame,
|
|
78
|
+
animate_stand,
|
|
79
|
+
animate_stand_obj,
|
|
80
|
+
animate_stand_reverse,
|
|
81
|
+
animate_stand_reverse_obj,
|
|
82
|
+
art_anim,
|
|
83
|
+
attack_complex,
|
|
84
|
+
attack_setup,
|
|
85
|
+
ClearNamed,
|
|
86
|
+
combat_difficulty,
|
|
87
|
+
combat_is_initialized,
|
|
88
|
+
create_object_sid,
|
|
89
|
+
critter_add_trait,
|
|
90
|
+
critter_attempt_placement,
|
|
91
|
+
critter_dmg,
|
|
92
|
+
critter_heal,
|
|
93
|
+
critter_injure,
|
|
94
|
+
critter_inven_obj,
|
|
95
|
+
critter_is_fleeing,
|
|
96
|
+
critter_mod_skill,
|
|
97
|
+
critter_rm_trait,
|
|
98
|
+
critter_set_flee_state,
|
|
99
|
+
critter_state,
|
|
100
|
+
critter_stop_attacking,
|
|
101
|
+
cur_map_index,
|
|
102
|
+
days_since_visited,
|
|
103
|
+
debug_msg,
|
|
104
|
+
destroy_mult_objs,
|
|
105
|
+
destroy_object,
|
|
106
|
+
dialogue_reaction,
|
|
107
|
+
dialogue_system_enter,
|
|
108
|
+
difficulty_level,
|
|
109
|
+
display_msg,
|
|
110
|
+
do_check,
|
|
111
|
+
drop_obj,
|
|
112
|
+
dude_obj,
|
|
113
|
+
elevation,
|
|
114
|
+
end_dialogue,
|
|
115
|
+
endgame_movie,
|
|
116
|
+
endgame_slideshow,
|
|
117
|
+
explosion,
|
|
118
|
+
fixed_param,
|
|
119
|
+
float_msg,
|
|
120
|
+
floor,
|
|
121
|
+
game_ticks,
|
|
122
|
+
game_time,
|
|
123
|
+
game_time_advance,
|
|
124
|
+
game_time_hour,
|
|
125
|
+
game_ui_disable,
|
|
126
|
+
game_ui_enable,
|
|
127
|
+
game_ui_is_disabled,
|
|
128
|
+
gdialog_mod_barter,
|
|
129
|
+
gdialog_set_barter_mod,
|
|
130
|
+
get_critter_stat,
|
|
131
|
+
get_day,
|
|
132
|
+
get_month,
|
|
133
|
+
get_pc_stat,
|
|
134
|
+
get_poison,
|
|
135
|
+
gfade_in,
|
|
136
|
+
gfade_out,
|
|
137
|
+
giQ_Option,
|
|
138
|
+
give_exp_points,
|
|
139
|
+
global_var,
|
|
140
|
+
gSay_End,
|
|
141
|
+
gSay_Message,
|
|
142
|
+
gSay_Option,
|
|
143
|
+
gSay_Reply,
|
|
144
|
+
gSay_Start,
|
|
145
|
+
has_skill,
|
|
146
|
+
has_trait,
|
|
147
|
+
how_much,
|
|
148
|
+
inven_cmds,
|
|
149
|
+
is_critical,
|
|
150
|
+
is_success,
|
|
151
|
+
item_caps_adjust,
|
|
152
|
+
item_caps_total,
|
|
153
|
+
jam_lock,
|
|
154
|
+
kill_critter,
|
|
155
|
+
kill_critter_type,
|
|
156
|
+
load_map,
|
|
157
|
+
local_var,
|
|
158
|
+
map_var,
|
|
159
|
+
message_str,
|
|
160
|
+
metarule,
|
|
161
|
+
metarule3,
|
|
162
|
+
move_obj_inven_to_obj,
|
|
163
|
+
move_to,
|
|
164
|
+
obj_art_fid,
|
|
165
|
+
obj_being_used_with,
|
|
166
|
+
obj_can_hear_obj,
|
|
167
|
+
obj_can_see_obj,
|
|
168
|
+
obj_carrying_pid_obj,
|
|
169
|
+
obj_close,
|
|
170
|
+
obj_is_carrying_obj_pid,
|
|
171
|
+
obj_is_locked,
|
|
172
|
+
obj_is_open,
|
|
173
|
+
obj_item_subtype,
|
|
174
|
+
obj_lock,
|
|
175
|
+
obj_name,
|
|
176
|
+
obj_on_screen,
|
|
177
|
+
obj_open,
|
|
178
|
+
obj_pid,
|
|
179
|
+
obj_set_light_level,
|
|
180
|
+
obj_type,
|
|
181
|
+
obj_unlock,
|
|
182
|
+
override_map_start,
|
|
183
|
+
party_add,
|
|
184
|
+
party_member_obj,
|
|
185
|
+
party_remove,
|
|
186
|
+
pickup_obj,
|
|
187
|
+
play_gmovie,
|
|
188
|
+
play_sfx,
|
|
189
|
+
poison,
|
|
190
|
+
proto_data,
|
|
191
|
+
radiation_dec,
|
|
192
|
+
radiation_inc,
|
|
193
|
+
random,
|
|
194
|
+
reg_anim_animate,
|
|
195
|
+
reg_anim_animate_forever,
|
|
196
|
+
reg_anim_animate_reverse,
|
|
197
|
+
reg_anim_end,
|
|
198
|
+
reg_anim_func,
|
|
199
|
+
reg_anim_obj_move_to_obj,
|
|
200
|
+
reg_anim_obj_move_to_tile,
|
|
201
|
+
reg_anim_obj_run_to_obj,
|
|
202
|
+
reg_anim_obj_run_to_tile,
|
|
203
|
+
reg_anim_play_sfx,
|
|
204
|
+
rm_mult_objs_from_inven,
|
|
205
|
+
rm_obj_from_inven,
|
|
206
|
+
rm_timer_event,
|
|
207
|
+
roll_vs_skill,
|
|
208
|
+
rotation_to_tile,
|
|
209
|
+
running_burning_guy,
|
|
210
|
+
script_action,
|
|
211
|
+
script_overrides,
|
|
212
|
+
scr_return,
|
|
213
|
+
self_obj,
|
|
214
|
+
set_critter_stat,
|
|
215
|
+
set_exit_grids,
|
|
216
|
+
set_global_var,
|
|
217
|
+
set_light_level,
|
|
218
|
+
set_local_var,
|
|
219
|
+
set_map_music,
|
|
220
|
+
set_map_start,
|
|
221
|
+
set_map_var,
|
|
222
|
+
set_obj_visibility,
|
|
223
|
+
SignalNamed,
|
|
224
|
+
skill_contest,
|
|
225
|
+
source_obj,
|
|
226
|
+
start_gdialog,
|
|
227
|
+
target_obj,
|
|
228
|
+
terminate_combat,
|
|
229
|
+
tile_contains_obj_pid,
|
|
230
|
+
tile_contains_pid_obj,
|
|
231
|
+
tile_distance,
|
|
232
|
+
tile_distance_objs,
|
|
233
|
+
tile_is_visible,
|
|
234
|
+
tile_num,
|
|
235
|
+
tile_num_in_direction,
|
|
236
|
+
tokenize,
|
|
237
|
+
town_map,
|
|
238
|
+
use_obj,
|
|
239
|
+
use_obj_on_obj,
|
|
240
|
+
using_skill,
|
|
241
|
+
wield_obj_critter,
|
|
242
|
+
wm_area_set_pos,
|
|
243
|
+
world_map,
|
|
244
|
+
} from './base.d';
|
|
245
|
+
|
|
246
|
+
// Re-export enums from sfall (needed by core function signatures in base.d)
|
|
247
|
+
export { BODY } from './sfall/define_extra';
|
|
248
|
+
export { SKILL, STAT } from './sfall/define_lite';
|
|
249
|
+
|
|
250
|
+
// Re-export helpers from define
|
|
251
|
+
export {
|
|
252
|
+
FLOAT1,
|
|
253
|
+
ndebug,
|
|
254
|
+
} from './define';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ObjectPtr } from "../index";
|
|
2
|
+
import { reg_anim_func } from "../base.d";
|
|
3
|
+
|
|
4
|
+
// Animation mode constants
|
|
5
|
+
export const ANIMATE_WALK = 0;
|
|
6
|
+
export const ANIMATE_RUN = 1;
|
|
7
|
+
export const ANIMATE_INTERRUPT = 16;
|
|
8
|
+
export const ANIMATE_FORWARD = 0;
|
|
9
|
+
export const ANIMATE_REVERSE = 1;
|
|
10
|
+
export const ANIMATE_ROTATION = 1000;
|
|
11
|
+
export const ANIMATE_SET_FRAME = 1010;
|
|
12
|
+
export const MAX_ROTATIONS = 6;
|
|
13
|
+
|
|
14
|
+
// Animation registration command constants
|
|
15
|
+
export const REG_ANIM_BEGIN = 1;
|
|
16
|
+
|
|
17
|
+
// Death animation types
|
|
18
|
+
export const ANIM_electrified_to_nothing = 30;
|
|
19
|
+
export const ANIM_exploded_to_nothing = 31;
|
|
20
|
+
export const ANIM_electrified_to_nothing_sf = 58;
|
|
21
|
+
export const ANIM_exploded_to_nothing_sf = 59;
|
|
22
|
+
export const REG_ANIM_CLEAR = 2;
|
|
23
|
+
export const REG_ANIM_END = 3;
|
|
24
|
+
export const RB_UNRESERVED = 1;
|
|
25
|
+
export const RB_RESERVED = 2;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Terminates all animations that are currently registered for a given object.
|
|
29
|
+
* @param obj Object to clear animations for
|
|
30
|
+
*/
|
|
31
|
+
export function reg_anim_clear(obj: ObjectPtr): void {
|
|
32
|
+
reg_anim_func(REG_ANIM_CLEAR, obj);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Begin an unreserved animation sequence.
|
|
37
|
+
* Must be followed by reg_anim_end() after registering animations.
|
|
38
|
+
* @inline
|
|
39
|
+
*/
|
|
40
|
+
export function reg_anim_begin(): void {
|
|
41
|
+
reg_anim_func(REG_ANIM_BEGIN, RB_UNRESERVED);
|
|
42
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { dude_obj, get_critter_stat, global_var } from "../base.d";
|
|
2
|
+
import { len_array } from "../sfall/sfall.d";
|
|
3
|
+
import { party_member_list_critters } from "../sfall/sfall";
|
|
4
|
+
import { dude_elevation } from "../sfall/command_lite";
|
|
5
|
+
import { STAT } from "../sfall/define_lite";
|
|
6
|
+
import { GVAR_PLAYER_GOT_CAR } from "./global";
|
|
7
|
+
|
|
8
|
+
export { dude_elevation };
|
|
9
|
+
|
|
10
|
+
/** @inline */
|
|
11
|
+
export function dude_charisma(): number {
|
|
12
|
+
return get_critter_stat(dude_obj, STAT.ch);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** @inline */
|
|
16
|
+
export function dude_has_car(): number {
|
|
17
|
+
return global_var(GVAR_PLAYER_GOT_CAR);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Party size excluding dude_obj */
|
|
21
|
+
export function true_party_size(): number {
|
|
22
|
+
return len_array(party_member_list_critters()) - 1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const TEAM_PLAYER = 0;
|