Added object type validation to item_weight metarule

Fixed set_critter_current_ap and set_combat_free_move to update
player's AP lights only in combat

Edits to scripting documents.

(ref. fallout2-ce/fallout2-ce#380)
This commit is contained in:
NovaRain
2026-04-17 11:58:57 +08:00
parent 651ba4d95c
commit 3e91b9a7ce
4 changed files with 16 additions and 8 deletions
+5 -5
View File
@@ -556,12 +556,12 @@ sfall_funcX metarule functions
----
#### item_weight
`int sfall_func1("item_weight", object obj)`
- Gets the current weight of an object
- Returns the weight of an item object
----
#### get_outline
`int sfall_func1("get_outline", object obj)`
- Gets the current outline color for an object
- Returns the current outline color of an object
----
#### set_outline
@@ -574,7 +574,7 @@ sfall_funcX metarule functions
----
#### get_flags
`int sfall_func1("get_flags", object obj)`
- Gets the current value of object flags (see **define_extra.h** for available flags)
- Returns the current value of object flags (see **define_extra.h** for available flags)
-----
#### set_flags
@@ -723,7 +723,7 @@ sfall_funcX metarule functions
`void sfall_func4("item_make_explosive", int pid, int activePid, int min, int max)`
- Makes the specified item (pid) an explosive item like Dynamite or Plastic Explosives
- `activePid` is for an item with an active timer, can be the same as the `pid` argument
- The item proto must be the **Misc Item** type and have the **Use** action flag
- The item proto must be of the **Misc Item** type and have the **Use** action flag
- `min` and `max` are the minimum and maximum explosion damage
- Using the function on an item that is already set as an explosive will override its previous settings
- __NOTE:__ this function does not work for pid's of Dynamite and Plastic Explosives
@@ -882,7 +882,7 @@ sfall_funcX metarule functions
----
#### get_sfall_arg_at
`mixed sfall_func1("get_sfall_arg_at", int argNum)`
- Gets the value of hook argument with the specified argument number (*first argument of hook starts from 0*)
- Returns the value of hook argument with the specified argument number (*first argument of hook starts from 0*)
----
#### hide_window
+1 -1
View File
@@ -274,7 +274,7 @@ void mf_set_combat_free_move(OpcodeContext& ctx) {
if (value < 0) value = 0;
*fo::ptr::combat_free_move = value;
if ((*fo::ptr::main_ctd).attacker == *fo::ptr::obj_dude) {
if (*fo::ptr::combat_state & fo::CombatStateFlag::InCombat && (*fo::ptr::main_ctd).attacker == *fo::ptr::obj_dude) {
fo::func::intface_update_move_points((*fo::ptr::obj_dude)->critter.movePoints, *fo::ptr::combat_free_move);
}
}
@@ -104,7 +104,13 @@ void mf_critter_inven_obj2(OpcodeContext& ctx) {
}
void mf_item_weight(OpcodeContext& ctx) {
ctx.setReturn(fo::func::item_weight(ctx.arg(0).object()));
fo::GameObject* obj = ctx.arg(0).object();
if (obj->IsNotItem()) {
ctx.printOpcodeError("%s() - the object is not an item.", ctx.getMetaruleName());
ctx.setReturn(0);
return;
}
ctx.setReturn(fo::func::item_weight(obj));
}
void mf_get_current_inven_size(OpcodeContext& ctx) {
+3 -1
View File
@@ -297,7 +297,9 @@ void op_set_critter_current_ap(OpcodeContext& ctx) {
if (ap < 0) ap = 0;
obj->critter.movePoints = ap;
if (obj == *fo::ptr::obj_dude) fo::func::intface_update_move_points(ap, *fo::ptr::combat_free_move);
if (obj == *fo::ptr::obj_dude && *fo::ptr::combat_state & fo::CombatStateFlag::InCombat) {
fo::func::intface_update_move_points(ap, *fo::ptr::combat_free_move);
}
} else {
ctx.printOpcodeError(objNotCritter, ctx.getOpcodeName());
}