Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 78 additions & 1 deletion gamedata/scripts/lua_help_ex.script
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@

game {
Fvector2 world2ui(Fvector pos, bool hud = false, bool allow_offscreen = false)
Fvector2 world2ui_with_depth(Fvector pos, bool hud = false, bool allow_offscreen = false)
Fvector world2ui_with_depth(Fvector pos, bool hud = false, bool allow_offscreen = false) // x and y are screen coordinates, z is the post projection w, negative behind the camera and its magnitude is the view distance in metres
table world2ui_many(table positions, bool hud, bool allow_offscreen) // projects an array of Fvector in one call, result[i] is the world2ui_with_depth vector for positions[i], stops at the first missing or non vector entry, empty table if the argument is not a table
function ui2world(Fvector2 pos) -> Fvector result, u16 object_id
function ui2world_offscreen(Fvector2 pos) -> Fvector result, u16 object_id
change_game_news_show_time(CUIWindow* UIWindow, float show_time)
Expand All @@ -199,6 +200,8 @@

ini_file() {
string get_filename()
Fvector4 r_vector4(string sec, string line) // reads four floats from one line, zero vector and a log line when the section or line is missing
bool remove_section(string sec) // drops a whole section with its lines, false if the name is empty, the file is read only or the section is not there
void dltx_print(string sec = nil, string line = nil)
string dltx_get_filename_of_line(string sec, string line)
table dltx_get_section(string sec)
Expand All @@ -221,6 +224,15 @@
function clone_upgrades(cse_alife_item_weapon*)
}

class cse_visual {
string visual_name() // current visual path, empty string when the entity has none
void set_visual_name(string name) // sets the visual path, ignores an empty name and logs it
}

class cse_alife_inventory_item {
property condition // float 0 to 1, a write outside that range is dropped and logged because the net packet only carries that range
}

class cse_alife_level_changer : cse_alife_space_restrictor {
property dest_game_vertex_id // u16
property dest_level_vertex_id // u32
Expand Down Expand Up @@ -557,6 +569,8 @@
float get_pp_effector_length(int id)
bool check_pp_effector(int id)

bool is_input_captured() // true while input is disabled or a UI dialog holds the top input receiver, so game keys will not reach scripts

// MT only
function scheduler_flush(bool)
}
Expand Down Expand Up @@ -713,9 +727,34 @@
function place_skeleton (game_object obj, string section, Fvector start, Fvector dir, float size, float ttl)
}

// slot ids, the same numbers move_to_slot and active_slot use, read as inventory.knife
enum inventory.slot {
no_active = 0,
knife = 1,
slot_2 = 2,
slot_3 = 3,
grenade = 4,
binocular = 5,
bolt = 6,
outfit = 7,
pda = 8,
detector = 9,
torch = 10,
artefact = 11,
helmet = 12,
backpack = 13,
custom_1, // custom_1 to custom_5 only exist in a build with the extra inventory slots
custom_2,
custom_3,
custom_4,
custom_5,
last, // highest valid slot id in this build, backpack without the extra slots
}

class game_object {
// Class casting
function cast_Knife()
function cast_Binoculars() // CWeaponBinoculars, nil when the object is not a pair of binoculars
function get_projector()
function get_stmgun()
function cast_Missile()
Expand Down Expand Up @@ -931,6 +970,19 @@
same as set_shader but resets to the default shader/texture values, so you don't need to store them in a table to reset them later
}

class CActorCondition : CEntityCondition {
enum influence_type
infl_rad
infl_fire
infl_acid
infl_psi
infl_electra

function GetInjuriousMaterialDamage() // damage per second of the injurious material the actor stands on, 0 on a normal material
function GetZoneMaxPower(influence_type) // the actor's max power for that influence, the value zone danger is measured against, 0 and a log line on a bad type
function GetZoneDanger(influence_type) // current danger for that influence, 0 to 1, 0 and a log line on a bad type
}

class CArtefact : CGameObject {
property m_additional_weight
}
Expand Down Expand Up @@ -963,6 +1015,27 @@
functiom SetParam(number id, Fvector val, string sec)
}

// hud states shared by every hud item, read as hud_state.idle, compare against item:get_state()
enum hud_state.states {
idle,
showing,
hiding,
hidden,
bore, // the idle fidget animation
}

// weapon only states, read as weapon_state.fire, they continue the hud_state numbering
enum weapon_state.states {
fire,
fire2, // second fire mode, grenade launcher or underbarrel
reload,
misfire,
switch, // switching ammo type
switch_mode, // switching fire mode
aim_start, // rotating into ADS
aim_end, // rotating out of ADS
}

class CWeapon : CGameObject {
// Return RPM in actual RPM value like in configs
function RealRPM()
Expand Down Expand Up @@ -1057,6 +1130,10 @@



// Zoom
bool StopZoom() // leaves ADS, plays the aim end animation when the weapon has one, false if the weapon was not zoomed
bool IsTextureZoomActive() // true only while the scope texture UI is actually drawn, so zoomed in with a scope texture and no longer rotating into ADS

//Scope UI
//Returns table containing this data
{
Expand Down
13 changes: 13 additions & 0 deletions src/3rd party/luabind/luabind/src/class_rep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,19 @@ int luabind::detail::class_rep::function_dispatcher(lua_State* L)

#endif

// a call that matched no overload raises an error instead of indexing before the overload table
if (match_index < 0)
{
{
string_class msg = "no matching overload for '";
msg += rep->name;
msg += "'";
lua_pushstring(L, msg.c_str());
}

lua_error(L);
}

#ifndef LUABIND_NO_EXCEPTIONS

try
Expand Down
13 changes: 13 additions & 0 deletions src/3rd party/luabind/luabind/src/function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ namespace luabind { namespace detail { namespace free_functions {
lua_error(L);
}
#endif
// a call that matched no overload raises an error instead of indexing before the overload table
if (match_index < 0)
{
{
string_class msg = "no matching overload for '";
msg += rep->name();
msg += "'";
lua_pushstring(L, msg.c_str());
}

lua_error(L);
}

overload_rep const& ov_rep = rep->overloads()[match_index];

#ifndef LUABIND_NO_EXCEPTIONS
Expand Down
20 changes: 20 additions & 0 deletions src/xrCore/Xr_ini.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2031,3 +2031,23 @@ void CInifile::remove_line(LPCSTR S, LPCSTR L)
data.Data.erase(A);
}
}

bool CInifile::remove_section(LPCSTR S)
{
R_ASSERT(!m_flags.test(eReadOnly));

if (!S || !S[0])
return false;

// sections are stored parsed and lower cased, the same way a write creates them
string256 sect;
_parse(sect, S);
_strlwr(sect);

RootIt I = std::lower_bound(DATA.begin(), DATA.end(), sect, sect_pred);
if (I == DATA.end() || xr_strcmp(*(*I).Name, sect) != 0)
return false;

DATA.erase(I);
return true;
}
1 change: 1 addition & 0 deletions src/xrCore/xr_ini.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ class XRCORE_API CInifile
void w_bool(LPCSTR S, LPCSTR L, BOOL V, LPCSTR comment = 0);

void remove_line(LPCSTR S, LPCSTR L);
bool remove_section(LPCSTR S);
};

// Main configuration file
Expand Down
6 changes: 6 additions & 0 deletions src/xrGame/ActorCondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,12 @@ void CActorCondition::SetZoneDanger(float danger, ALife::EInfluenceType type)
clamp(m_zone_danger[type], 0.0f, 1.0f);
}

float CActorCondition::GetZoneDanger(ALife::EInfluenceType type) const
{
VERIFY(type != ALife::infl_max_count);
return m_zone_danger[type];
}

float CActorCondition::GetZoneDanger() const
{
float sum = 0.0f;
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/ActorCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class CActorCondition : public CEntityCondition

void SetZoneDanger(float danger, ALife::EInfluenceType type);
float GetZoneDanger() const;
float GetZoneDanger(ALife::EInfluenceType type) const;

public:
IC CActor& object() const
Expand Down
33 changes: 33 additions & 0 deletions src/xrGame/ActorCondition_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ void WoundForEach(CActorCondition* conditions, const ::luabind::functor<bool> &f
}
}

float GetZoneMaxPower_script(CActorCondition* conditions, u32 infl_type)
{
if (infl_type >= ALife::infl_max_count)
{
Msg("!GetZoneMaxPower: bad influence type %u", infl_type);
return 0.f;
}

return conditions->GetZoneMaxPower((ALife::EInfluenceType)infl_type);
}

float GetZoneDanger_script(CActorCondition* conditions, u32 infl_type)
{
if (infl_type >= ALife::infl_max_count)
{
Msg("!GetZoneDanger: bad influence type %u", infl_type);
return 0.f;
}

return conditions->GetZoneDanger((ALife::EInfluenceType)infl_type);
}

#pragma optimize("s",on)
void CActorCondition::script_register(lua_State *L)
{
Expand Down Expand Up @@ -147,6 +169,9 @@ void CActorCondition::script_register(lua_State *L)
.def("BoostRadiationProtection", &CActorCondition::BoostRadiationProtection)
.def("BoostTelepaticProtection", &CActorCondition::BoostTelepaticProtection)
.def("BoostChemicalBurnProtection", &CActorCondition::BoostChemicalBurnProtection)
.def("GetInjuriousMaterialDamage", &CActorCondition::GetInjuriousMaterialDamage)
.def("GetZoneMaxPower", &GetZoneMaxPower_script)
.def("GetZoneDanger", &GetZoneDanger_script)
.def("IsLimping", &CActorCondition::IsLimping)
.def("IsCantWalk", &CActorCondition::IsCantWalk)
.def("IsCantWalkWeight", &CActorCondition::IsCantWalkWeight)
Expand All @@ -161,6 +186,14 @@ void CActorCondition::script_register(lua_State *L)
.def_readwrite("m_fAccelK", &CActorCondition::m_fAccelK)
.def_readwrite("m_fSprintK", &CActorCondition::m_fSprintK)
.def_readwrite("m_condition_flags", &CActorCondition::m_condition_flags)
.enum_("influence_type")
[
value("infl_rad", int(ALife::infl_rad)),
value("infl_fire", int(ALife::infl_fire)),
value("infl_acid", int(ALife::infl_acid)),
value("infl_psi", int(ALife::infl_psi)),
value("infl_electra", int(ALife::infl_electra))
]
.enum_("condition_flags")
[
value("eCriticalPowerReached", int(CActorCondition::eCriticalPowerReached)),
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Level_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void CLevel::IR_OnMouseWheel(int direction)
return;
}
}
//g_actor->callback(GameObject::eMouseWheel)(direction);
g_actor->callback(GameObject::eMouseWheel)(direction);
}
#endif
/* avo: end */
Expand Down
17 changes: 17 additions & 0 deletions src/xrGame/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2142,6 +2142,23 @@ void CWeapon::OnZoomOut()

}

bool CWeapon::StopZoom()
{
if (!IsZoomed())
return false;

if (GetState() != eAimEnd && HudAnimationExist("anm_idle_aim_end"))
SwitchState(eAimEnd);

OnZoomOut();
return true;
}

bool CWeapon::IsTextureZoomActive()
{
return IsZoomed() && ZoomTexture() && !IsRotatingToZoom();
}

CUIWindow* CWeapon::ZoomTexture()
{
if (UseScopeTexture())
Expand Down
3 changes: 3 additions & 0 deletions src/xrGame/Weapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ class CWeapon : public CHudItemObject,
};
CUIWindow* ZoomTexture();

bool StopZoom();
bool IsTextureZoomActive();

bool ZoomHideCrosshair();

IC float GetZoomFactor() const
Expand Down
27 changes: 26 additions & 1 deletion src/xrGame/WeaponAK74.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,30 @@ void CWeaponAK74::script_register (lua_State *L)
[
class_<CWeaponAK74,CGameObject>("CWeaponAK74")
.def(constructor<>()),


class_<enum_exporter<CHUDState::EHudStates>>("hud_state")
.enum_("states")
[
value("idle", int(CHUDState::eIdle)),
value("showing", int(CHUDState::eShowing)),
value("hiding", int(CHUDState::eHiding)),
value("hidden", int(CHUDState::eHidden)),
value("bore", int(CHUDState::eBore))
],

class_<enum_exporter<CWeapon::EWeaponStates>>("weapon_state")
.enum_("states")
[
value("fire", int(CWeapon::eFire)),
value("fire2", int(CWeapon::eFire2)),
value("reload", int(CWeapon::eReload)),
value("misfire", int(CWeapon::eMisfire)),
value("switch", int(CWeapon::eSwitch)),
value("switch_mode", int(CWeapon::eSwitchMode)),
value("aim_start", int(CWeapon::eAimStart)),
value("aim_end", int(CWeapon::eAimEnd))
],

class_<CWeapon,CGameObject>("CWeapon")
.def(constructor<>())
.def("can_kill", (bool (CWeapon::*)() const)&CWeapon::can_kill)
Expand All @@ -38,6 +61,8 @@ void CWeaponAK74::script_register (lua_State *L)

.def("IsZoomEnabled", &CWeapon::IsZoomEnabled)
.def("IsZoomed", &CWeapon::IsZoomed)
.def("StopZoom", &CWeapon::StopZoom)
.def("IsTextureZoomActive", &CWeapon::IsTextureZoomActive)
.def("GetZoomFactor", &CWeapon::GetZoomFactor)
.def("SetZoomFactor", &CWeapon::SetZoomFactor)

Expand Down
Loading
Loading