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:54:35 +08:00
parent 490934bb3c
commit 81e612f383
5 changed files with 24 additions and 16 deletions
+8 -8
View File
@@ -763,7 +763,7 @@
- makes the specified item (pid) an explosive item like Dynamite or Plastic Explosives
- `maxDamage` is optional
- `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
- minDamage/maxDamage 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 pids of Dynamite and Plastic Explosives
@@ -973,7 +973,7 @@
doc: Alters the AC bonus you receive per unused action point at the end of your turn in combat. To allow for fractional values, the value given if divided by 4. (Hence the default value is 4 and not 1.)
- name: get_unspent_ap_bonus
detail: int get_unspent_ap_bonus
doc: Gets the AC bonus you receive per unused action point at the end of your turn in combat. To allow for fractional values, the value given if divided by 4. (Hence the default value is 4 and not 1.)
doc: Returns the AC bonus you receive per unused action point at the end of your turn in combat. To allow for fractional values, the value given if divided by 4. (Hence the default value is 4 and not 1.)
opcode: 0x81e7
- name: set_unspent_ap_perk_bonus
detail: void set_unspent_ap_perk_bonus(int multiplier)
@@ -1226,7 +1226,7 @@
opcode: 0x823c
- name: get_sfall_arg_at
detail: mixed get_sfall_arg_at(int argNum)
doc: Gets the value of hook argument with the specified argument number (first argument of hook starts from 0)
doc: Returns the value of hook argument with the specified argument number (first argument of hook starts from 0)
macro: sfall.h
- name: set_sfall_return
detail: void set_sfall_return(any value)
@@ -1422,7 +1422,7 @@
macro: sfall.h
- name: item_weight
detail: int item_weight(ObjectPtr obj)
doc: Gets the current weight of an object.
doc: Returns the weight of an item object.
macro: sfall.h
- name: spatial_radius
@@ -1612,7 +1612,7 @@
- name: get_bodypart_hit_modifier
detail: int get_bodypart_hit_modifier(int bodypart)
opcode: 0x81df
doc: Gets the hit percentage modifiers for aiming at specific bodyparts. Valid bodypart id's are from 0 to 8.
doc: Returns the hit percentage modifiers for aiming at specific bodyparts. Valid bodypart id's are from 0 to 8.
- name: combat_data
detail: mixed combat_data
doc: |
@@ -1631,7 +1631,7 @@
- name: get_critical_table
detail: int get_critical_table(int crittertype, int bodypart, int level, int valuetype)
opcode: 0x81e2
doc: Gets current critical table. For details see [critical hit tables](http://falloutmods.wikia.com/wiki/Critical_hit_tables). Requires `OverrideCriticalTable` to be enabled in `ddraw.ini` (already enabled by default).
doc: Returns the current critical table. For details see [critical hit tables](http://falloutmods.wikia.com/wiki/Critical_hit_tables). Requires `OverrideCriticalTable` to be enabled in `ddraw.ini` (already enabled by default).
- name: reset_critical_table
detail: void reset_critical_table(int crittertype, int bodypart, int level, int valuetype)
opcode: 0x81e3
@@ -1846,7 +1846,7 @@
macro: sfall.h
- name: get_outline
detail: int get_outline(ObjectPtr obj)
doc: Gets the current outline color for an object.
doc: Returns the current outline color of an object.
macro: sfall.h
- name: set_outline
detail: void set_outline(ObjectPtr obj, int color)
@@ -2054,7 +2054,7 @@
- name: get_flags
detail: int get_flags(ObjectPtr obj)
doc: Gets the current value of object flags (see **define_extra.h** for available flags).
doc: Returns the current value of object flags (see **define_extra.h** for available flags).
macro: sfall.h
- name: set_flags
detail: void set_flags(ObjectPtr obj, int flags)
+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
@@ -899,7 +899,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::var::combat_free_move = value;
if (fo::var::main_ctd.attacker == fo::var::obj_dude) {
if (fo::var::combat_state & fo::CombatStateFlag::InCombat && fo::var::main_ctd.attacker == fo::var::obj_dude) {
fo::func::intface_update_move_points(fo::var::obj_dude->critter.movePoints, fo::var::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
@@ -284,7 +284,9 @@ void op_set_critter_current_ap(OpcodeContext& ctx) {
if (ap < 0) ap = 0;
obj->critter.movePoints = ap;
if (obj == fo::var::obj_dude) fo::func::intface_update_move_points(ap, fo::var::combat_free_move);
if (obj == fo::var::obj_dude && fo::var::combat_state & fo::CombatStateFlag::InCombat) {
fo::func::intface_update_move_points(ap, fo::var::combat_free_move);
}
} else {
ctx.printOpcodeError(objNotCritter, ctx.getOpcodeName());
}