Skip to content

Commit

Permalink
[CoC] Adding definitions from Call Of Chornobyl merge. (#1)
Browse files Browse the repository at this point in the history
* Add new type definitions from OXR-COC merge.
* Version bump.
* Add type checking method. Add some UI methods.
* Correct implementation of holder interface by car class.
* Reformat code.
  • Loading branch information
Neloreck authored Dec 19, 2024
1 parent 62cc473 commit 783a0e9
Show file tree
Hide file tree
Showing 14 changed files with 393 additions and 187 deletions.
177 changes: 99 additions & 78 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xray16",
"version": "1.1.3",
"version": "1.2.0",
"author": "Neloreck",
"repository": "https://github.com/stalker-xrts/xray-16-types",
"private": false,
Expand All @@ -16,7 +16,7 @@
"lint": "eslint . --ext .ts,.tsx,.js"
},
"peerDependencies": {
"typescript-to-lua": "^1.16.3"
"typescript-to-lua": "1.16.3"
},
"devDependencies": {
"@types/node": "20.3.1",
Expand All @@ -31,7 +31,7 @@
"eslint-plugin-sort-keys-fix": "^1.1.2",
"prettier": "^3.0.1",
"typedoc": "^0.24.8",
"typescript": "^5.1.6"
"typescript": "5.1.6"
},
"files": [
"plugins/**/*",
Expand Down
12 changes: 11 additions & 1 deletion types/xr_ai/xr_alife.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,22 @@ declare module "xray16" {

public create<T extends cse_alife_object = cse_alife_object>(object_id: u16): T;
public create<T extends cse_alife_object = cse_alife_object>(
item_section: string,
section: string,
position: vector,
level_vertex_id: u32,
game_vertex_id: u32,
parent_object_id?: u16
): T;
// Alundaio: Allows to call alife():register(se_obj) manually afterward,editing
// Alundaio: so that packet can be done safely when spawning object with a parent.
public create<T extends cse_alife_object = cse_alife_object>(
section: string,
position: vector,
level_vertex_id: u32,
game_vertex_id: u32,
parent_object_id: u16,
reg: boolean
): T;
}

/**
Expand Down
1 change: 0 additions & 1 deletion types/xr_lib/xr_game.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
declare module "xray16" {

/**
* Enumeration with possible game types:
* - eGameIDNoGame = u32(0),
Expand Down
1 change: 0 additions & 1 deletion types/xr_lib/xr_render.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,4 @@ declare module "xray16" {
* @returns whether renderer setting can be changed
*/
export function renderer_allow_override(this: void): boolean;

}
18 changes: 15 additions & 3 deletions types/xr_lib/xr_task.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ declare module "xray16" {
export class SGameTaskObjective {
public constructor(task: CGameTask, id: i32);

public remove_map_locations(flag: boolean): void;

public set_icon_name(icon_name: string): void;

public get_icon_name<T extends string = string>(): T | null;
Expand Down Expand Up @@ -75,7 +73,21 @@ declare module "xray16" {

public set_map_hint(hint: string): void;

public change_map_location(value: string, value2: u16): void;
/**
* @returns target map location of task object
*/
public get_map_location(): string;

/**
* @returns target map object ID of task object
*/
public get_map_object_id(): u16;

public change_map_location(new_map_location: string, new_map_object_id: u16): void;

public remove_map_locations(notify: boolean): void;

public create_map_location(on_load: boolean): void;

public set_map_object_id(id: i32): void;
}
Expand Down
58 changes: 54 additions & 4 deletions types/xr_object/client/xr_level.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ declare module "xray16" {

public constructor();

public SetEnterLocked(is_enabled: boolean): void;

public SetExitLocked(is_enabled: boolean): void;

public CanHit(): boolean;

public CarExplode(): void;
Expand All @@ -81,18 +85,31 @@ declare module "xray16" {

public FireDirDiff(): f32;

/**
* @returns amount of fuel in vehicle instance
*/
public GetfFuel(): f32;

/**
* @returns fuel consumption rate of vehicle instance
*/
public GetfFuelConsumption(): f32;

/**
* @returns fuel tank size (max possible amount of fuel at time)
*/
public GetfFuelTank(): f32;

/**
* @returns vehicle health value
*/
public GetfHealth(): f32;

/**
* @returns whether vehicle has mounted weapon
*/
public HasWeapon(): boolean;

public IsActiveEngine(): boolean;

public IsObjectVisible(game_object: game_object): boolean;

public PlayDamageParticles(): void;
Expand All @@ -107,12 +124,45 @@ declare module "xray16" {

public SetfHealth(health: f32): void;

public StartEngine(): void;
/**
* @returns whether vehicle engine is active at the moment
*/
public IsActiveEngine(): boolean;

public StopDamageParticles(): void;
/**
* Start vehicle engine.
*/
public StartEngine(): void;

/**
* Stop vehicle engine.
*/
public StopEngine(): void;

/**
* Set vehicle hand break in active state.
*/
public HandBreak(): void;

/**
* Deactivate vehicle hand break.
*/
public ReleaseHandBreak(): void;

/**
* @returns current vehicle RPM value (speed)
*/
public GetRPM(): f32;

/**
* Set current vehicle RPM value (speed).
*
* @param rpm - RPM value to apply
*/
public SetRPM(rpm: f32): void;

public StopDamageParticles(): void;

public engaged(): boolean;

public Action(value1: u16, value2: u32): void;
Expand Down
19 changes: 16 additions & 3 deletions types/xr_object/client/xr_physic.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

declare module "xray16" {
/**
* @source C++ class physics_element
Expand Down Expand Up @@ -194,8 +193,22 @@ declare module "xray16" {
export class holder {
public engaged(): boolean;

public Action(value1: u16, value2: u32): void;
public Action(id: u16, flags: u32): void;

public SetParam(id: i32, value: vector): void;

/**
* Set holder object enter state.
*
* @param is_enabled - whether holder object can be entered
*/
public SetEnterLocked(is_enabled: boolean): void;

public SetParam(value: i32, vector: vector): void;
/**
* Set holder object exist state.
*
* @param is_enabled - whether holder object can be exited
*/
public SetExitLocked(is_enabled: boolean): void;
}
}
80 changes: 39 additions & 41 deletions types/xr_object/script/xr_script_interface.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ declare module "xray16" {
* @group xr_script_interface
*/
export class callback {
/**
* Placeholder.
*/
public static readonly dummy: -1;

/**
* Default x-ray 16 callbacks.
*/
Expand Down Expand Up @@ -98,28 +93,31 @@ declare module "xray16" {
public static readonly trader_sound_end: 33;
public static readonly take_item_from_box: 34;
public static readonly weapon_no_ammo: 35;

/**
* Custom callbacks from open x-ray:
*/
public static readonly key_press: 36;
public static readonly key_release: 37;
public static readonly key_hold: 38;
public static readonly mouse_move: 39;
public static readonly mouse_wheel: 40;
public static readonly controller_press: 41;
public static readonly controller_release: 42;
public static readonly controller_hold: 43;
public static readonly item_to_belt: 44;
public static readonly item_to_slot: 45;
public static readonly item_to_ruck: 46;
public static readonly actor_before_death: 47;
public static readonly on_attach_vehicle: 48;
public static readonly on_detach_vehicle: 49;
public static readonly on_use_vehicle: 50;
public static readonly weapon_zoom_in: 51;
public static readonly weapon_zoom_out: 52;
public static readonly weapon_jammed: 53;
public static readonly hud_animation_end: 36;

public static readonly key_press: 37;
public static readonly key_release: 38;
public static readonly key_hold: 39;
public static readonly mouse_move: 40;
public static readonly mouse_wheel: 41;
public static readonly controller_press: 42;
public static readonly controller_release: 43;
public static readonly controller_hold: 44;
// public static readonly controller_attitude_change: 45;

public static readonly item_to_belt: 46;
public static readonly item_to_slot: 47;
public static readonly item_to_ruck: 48;

public static readonly weapon_zoom_in: 49;
public static readonly weapon_zoom_out: 50;
public static readonly weapon_jammed: 51;
public static readonly weapon_magazine_empty: 52;

public static readonly actor_before_death: 53;
public static readonly on_attach_vehicle: 54;
public static readonly on_detach_vehicle: 55;
public static readonly on_use_vehicle: 56;
}

/**
Expand Down Expand Up @@ -251,13 +249,13 @@ declare module "xray16" {
type: TXR_callbacks["hit"],
cb?:
| ((
this: void,
object: game_object,
damage: number,
direction: vector,
who: game_object,
bone_id: number
) => void)
this: void,
object: game_object,
damage: number,
direction: vector,
who: game_object,
bone_id: number
) => void)
| null,
object?: Maybe<T>
): void;
Expand All @@ -269,13 +267,13 @@ declare module "xray16" {
type: TXR_callbacks["sound"],
cb?:
| ((
this: void,
object: game_object,
source_id: number,
sound_type: TXR_snd_type,
position: vector,
sound_power: number
) => void)
this: void,
object: game_object,
source_id: number,
sound_type: TXR_snd_type,
position: vector,
sound_power: number
) => void)
| null,
object?: Maybe<T>
): void;
Expand Down
Loading

0 comments on commit 783a0e9

Please sign in to comment.