A modding question regarding recharging of Stealth Boys, Geiger Counters and Motion Sensors

arroyoman

First time out of the vault
UPDATE: Here is the script i wrote to recharge stealth boys, geiger counter and motion sensors.


Requirements:
- Sfall (tested on 4.8.1 version)

Installation:
- place in data/scripts folder

Compatibility:
- (probably) compatible with any other mods

How to recharge Stealth Boys/ Geiger Counter/ Motion Sensor
- place on ground
- use Science Skill / Repair Skill
- min Science 30, Repair 40




Original Post:
Has anyone ever done a mod that allows miscellaneous items with 'charges' such as stealth boys, geiger counters and motion sensors to be recharged? I have searched for such a mod but it seems that this hasn't been done yet.

If not, is it possible to implement a method of recharging via scripting?

Also, if I edit the proto files of the aforementioned items using a proto editor, the 'Misc' section containing 2 fields called 'Power PID' and 'Power Type'. For stealth boy/geiger counter/motion sensor, the fields are filled with the values 'Small Energy Cell' and 'C Energy Cell'. I'm quite confused, since these items cannot be recharged in the first place, what are those fields for?

Any insights/suggestions on the topic would be greatly appreciated.

 
Last edited:
Thanks for the tip, NovaRain!

Something strange is going on. I've written a simple script to test out the idea, but i cannot get it to work. Here's what I did:

I added a new row in scripts.lst. Then, I've assigned the script to the stealth boy item proto using a proto manager. Then, I wrote a script and started a new game.

It is supposed to display "used SCIENCE skill on the stealth boy" and "used REPAIR skill on the stealth boy" when the player uses the corresponding skills.

Here's the script, in text form (since it's quite short)
#include "C:\GOG Games\Classics\TOOLS\HEADERS\DEFINE.H"
procedure start;
procedure use_p_proc;
procedure use_obj_on_p_proc;
procedure use_skill_on_p_proc;

procedure start begin
end

procedure use_p_proc begin
display_msg("used stealth boy.");
end

procedure use_obj_on_p_proc begin
end

procedure use_skill_on_p_proc begin
script_overrides;

if action_being_used==SKILL_REPAIR then begin
display_msg("used REPAIR skill on stealthboy");
set_weapon_ammo_count(self_obj,100);
end
if action_being_used==SKILL_SCIENCE then begin
display_msg("used SCIENCE skill on stealthboy");
set_weapon_ammo_count(self_obj,100);
end

end
/***************end of script*******************/

My suspicion is that the problem is not with the script, but the way I assigned the script to the item (using a proto manager, see pic below).



Or maybe it could be some obscured detail that I have not noticed. Am I missing something?
 
Last edited:
You can't use repair and science in the inventory. Actually you can't use any skills on items in the inventory. The only way for the use_skill_on_p_proc procedure to be called is if you use these skills on the item while it is dropped on the ground.

You have to check what the player is doing via hook script - moving objects around, etc. something along the lines.
 
Thanks, Lexx!

I've been reading up on the sfall documentation on hook scripts and global scripts. So far, I have a question regarding global scripts creation:

When creating a global script, all that is needed is to name the file in the format gl_xxx and place it in the data/scripts folder, right? No need to do other stuff, such as editing the scripts.lst file?

UPDATE: Figured it out. all that is required for a global script to run is to name it as gl_XXX.
 
Last edited:
Here's the direct google drive link if anyone else is as dumb as I am and can't figure out how to download it from that media spoiler. Nice work btw arroyoman, this is something I've really wanted.
 
Back
Top