Fallout 2 mod Proto editing in-game via scripting

banjo_oz

First time out of the vault
If I wanted to edit the "Robot Parts" item proto in-game (rather than via a proto editor), can I use code like:
Code:
set_proto_data(obj_pid(PID_ROBOT_PARTS), PROTO_IT_COST, 20);

If so, where should I run it? I was trying a global script that does:
Code:
procedure start begin
   if (game_loaded) then begin
      set_proto_data(obj_pid(PID_ROBOT_PARTS), PROTO_IT_COST, 20);
   end
end
... but this crashes the game (even though no errors in the editor/compiler).

Am I using it in the wrong place or is my "set_proto_data" code just plain wrong?
 
set_proto_data(obj_pid(PID_ROBOT_PARTS), PROTO_IT_COST, 20);
... but this crashes the game (even though no errors in the editor/compiler).

Am I using it in the wrong place or is my "set_proto_data" code just plain wrong?
Why you use obj_pid function while PID_ROBOT_PARTS is already the PID you want to edit?
You're trying to tell obj_pid to access the memory area it shouldn't.
 
Why you use obj_pid function while PID_ROBOT_PARTS is already the PID you want to edit?
You're trying to tell obj_pid to access the memory area it shouldn't.
Doh! Because I didn't know any better and made a stupid mistake. I'm still learning all this stuff from scratch. :)

So...
set_proto_data(PID_ROBOT_PARTS, PROTO_IT_COST, 20);
... is the correct usage and can be run on game load/start?
 
Doh! Because I didn't know any better and made a stupid mistake. I'm still learning all this stuff from scratch. :)

So...
set_proto_data(PID_ROBOT_PARTS, PROTO_IT_COST, 20);
... is the correct usage?
Yes, you should check the document for the arguments of the function.
Code:
void set_proto_data(int pid, int offset, int value)
 
Back
Top