I want to make the dude automatically reload his weapon on combat end (like the companions do). I'm checking both command reference and companion scripts, but I don't see any reference to reloading weapons. Anyone has a clue?
set_weapon_ammo_count(weapon, count);
Ah so that's your mod that makes them do it. I'm playing with Restoration project, so I wasn't sure. Do I just take the relevant chunk of code and stick it on the top of obj_dude script, or there are more considerations?
#define is_ammo_type(pid, type) ((scan_array(ap_ammo_list, pid) != -1) == (type == AMMO_TYPE_AP))
procedure dude_switch_ammo(variable ammo_type) begin
variable begin
i;
weapon := 0;
ammopid := 0;
list;
item;
bestammo;
caliber;
magsize;
end
Any pointers? Is there a guide about more advanced sfall scripting, maybe?
define_lite.h is included in lib.inven.h, which is included id party orders script. If you need some header, just include it in your script, nothing bad will happen if it's already included somewhere."undefined symbol item_type_weapon"
The thing is, I already included it, it still complains. define_lite.h, compile.exe, obj_dude.ssl are all in the same directory. Is there something else I'm missing?define_lite.h is included in lib.inven.h, which is included id party orders script. If you need some header, just include it in your script, nothing bad will happen if it's already included somewhere.
The thing is, I already included it, it still complains. define_lite.h, compile.exe, obj_dude.ssl are all in the same directory. Is there something else I'm missing?define_lite.h is included in lib.inven.h, which is included id party orders script. If you need some header, just include it in your script, nothing bad will happen if it's already included somewhere.
I'm using compile.exe. Is it not aware of includes?
Yes, I used it from command line, but I wasn't aware that including is called "preprocessing".You are using it from the command line? Have you read the help when running it without arguments? There is a key which enables preprocessing "-p".
As long as you use full compiler optimization (-O2) it won't matter how many headers you include, all unused code will not be included. Even without optimization, it's just bigger script file with a lot of unused code. Slowdowns can be caused by calling a lot of script functions inside global scripts with 0 delay (eg. set_global_script_repeat(0) ), so avoid doing this. Crashes are typically caused by invalid or zero object pointers passed to script functions, so add necessary checks for zero pointers. Also you need to remember that in SSL, unlike most other decent languages, all expressions in one condition are always executed. For example, in normal language like LUA you can write something like:I'm including more and more stuff it requires... I start to wonder if it's even a good idea to dump all that into obj_dude script? Won't it cause slowdowns or other issues? I was hoping this idea could be implmented quick and dirty, but it doesn't seem to be the case.
if (object != nil and object.weapon != nil and object.weapon.pid == PID_SPEAR) then ....
if (object) then if (critter_weapon(object)) then if (obj_pid(critter_weapon(object)) == PID_SPEAR)
is_ammo macro is located in Zcustom.h header. It's likely I forgot to include it in mod sources, since it was taken from original Party Orders Addon sources.In any case, right now I'm stuck with "Undefined symbol: is_ammo", which I can't find in any headers.
#define is_ammo(x) (obj_item_subtype(x) == item_type_ammo)
#define actual_ammo_count(crit, obj) ((obj_is_carrying_obj_pid(crit, obj_pid(obj)) - 1)*get_proto_data(obj_pid(obj), PRODATA_IT_AM_PACK_SIZE) + get_weapon_ammo_count(obj))
procedure combat_p_proc;
procedure dude_switch_ammo(variable ammo_type);
procedure map_update_p_proc;