add_mult_objs_to_inven, patrolling, object name

Sirren67

Look, Ma! Two Heads!
A): I tried this procedure:

add_mult_objs_to_inven(self_obj,351,1);
add_mult_objs_to_inven(self_obj,363,4); (items are fn fal and its
ammo)

Somehow it crashes the mapper. I put it in procedure map_enter_p_proc and procedure start, but it makes no difference. What's wrong?

B): I'm using animate_move_to_tile, and by calling two different tiles I managed to get a "patrolling" guard:
Is there a way to make the critter wait a few seconds before going back to the previous tile?
I had to add the procedure in procedure critter_p_proc, if I put it in procedure timed_event_p_proc it does not work.

C): (Still killing my critters...) When I hit one of my critters in the message window I get "Object name was hit..." instead of "P. Oil Security was hit..." The critter has its own proto, and a script with a .MSG...
If I kill the same critter while it has no script the message window displays the proto name. Again, what's wrong?
 
Sirren67 said:
add_mult_objs_to_inven(self_obj,363,4);
This command expects an item pointer not a PID number.
In other words, it must be an object that exists, not the prototype (blueprint) of an object.

variable item;
item := create_object(PID_7_62MM_AMMO, 0, 0 );
add_mult_objs_to_inven( self_obj, item, 4 );

Sirren67 said:
Somehow it crashes the mapper.
Null pointer exception. 363 is not a valid object pointer. Engine tries to add an object that doesn't exist. In this engine, all hell breaks loose. In the code people pay me to write, even if null, exception is caught, action might fail but program will not ... this is one thing they really needed but didn't have in fallout engine.

Sirren67 said:
Is there a way to make the critter wait a few seconds before going back to the previous tile? <snip>
procedure timed_event_p_proc it does not work.

Sure it does. Look at existing scripts like acbrahmin.ssl
add_timer_event(self_obj,game_ticks(random(3,5)),1);

Not sure about C without looking at your code and msg files etc.
 
C): (Still killing my critters...) When I hit one of my critters in the message window I get "Object name was hit..." instead of "P. Oil Security was hit..." The critter has its own proto, and a script with a .MSG...
If I kill the same critter while it has no script the message window displays the proto name. Again, what's wrong?

Object names used in combat are stored in scrname.msg file in data/text/english/game/ folder.
When you register your script (scripts.lst and scripts.h) it is good to add also object name in scrname.msg(order must be same as in scripts.lst).
Here is a fragment of that file :
Code:
{1286}{}{Typhon}                        # hcTyphon.int    ; Typhon, Son of Set - Broken Hills
{1287}{}{Bodyguard}                     # ECBdyGrd.int    ; BodyGuard in Vignette
{1288}{}{Map Script}                    # GamMovie.int    ; Game Movie map
{1289}{}{Locker}                        # ziLocker.int    ; Generic Locker Script
{1290}{}{Well}                          # hiWell.int      ; Broken Hills Well
{1291}{}{Micky}                         # hcMicky.int     ; Mickey the Dwarf - Broken Hills
{1292}{}{Turret}                        # WCTurret.int    ; Turret for Sierra Depot
{1293}{}{Old Ghoul}                     # hcOldGhl.int    ; Ghouls in Old-Folks Home - Broken Hills
{1294}{}{Henchman}                      # hcHench.int     ; Broken Hills Outfitter Henchmen
{1295}{}{Elmo}                          # hcElmo.int      ; Elmo - Broken Hills
{number}{}{Objectname} #comments
 
To Jargo: Thanks, i really did not know about this detail, I just thougt that registering the script was all I had to do.

To Dude_Object: I had to fix several mistakes I made and I put together the following piece of code

procedure map_enter_p_proc begin
variable item;

Only_Once:=0;
critter_add_trait(self_obj,TRAIT_OBJECT,OBJECT_TEAM_NUM,TEAM_POSEIDON_OIL);
critter_add_trait(self_obj,TRAIT_OBJECT,OBJECT_AI_PACKET,AI_TOUGH_GUARD);

if (map_first_run) then begin
item:=create_object(PID_7_62MM_AMMO,0,0);
add_mult_objs_to_inven(self_obj,item,4);
item:=create_object(PID_FN_FAL,0,0);
add_mult_objs_to_inven(self_obj,item,1);
end

end

I tested it in game and it works the SECOND time I enter the map. At least my critters stay dead...
I'm still working on the rest of my post stuff, more to come.

Edit

O.K., now the procedure in timed_event_p_proc works; making a critter to wander randomly it's easier, I think...
 
Sorry to dredge this topic up, but I'm having a bit of trouble with this. At the top, I've already put in

#define item := create_object(PID_BOTTLE_CAPS,0,0);

It compiles and everything works fine. But if I add in

add_mult_objs_to_inven(dude_obj,item,100);

after one of the dialog choices, it crashes the game/mapper when I get to that dialog Node. What am I missing here?
 
8-Ball said:
#define item := create_object(PID_BOTTLE_CAPS,0,0);
add_mult_objs_to_inven(dude_obj,item,100);

Don't use #define, that is for setting up a constant or macro that gets merged into the source code on precompile. You see #define in the header files, where constants like PID_BOTTLE_CAPS are. That item needs to be a variable:

variable item;
item := create_object(PID_BOTTLE_CAPS,0,0);
add_mult_objs_to_inven(dude_obj,item,100);
 
dude_obj said:
Don't use #define, that is for setting up a constant or macro that gets merged into the source code on precompile. You see #define in the header files, where constants like PID_BOTTLE_CAPS are. That item needs to be a variable:

variable item;
item := create_object(PID_BOTTLE_CAPS,0,0);
add_mult_objs_to_inven(dude_obj,item,100);

Hey, that worked, thanks a lot! While I've got your attention, though, I'd like to ask another question. I've got a character inside a building surrounded by Radscorpions. Whenever I load the map and start attacking the Radscorpions, the man runs for his life, even though they're on different teams. Is there any way I can get him to stand still while I kill the bugs outside?
 
There are several things that affect this.

The AI packet specified in the critter proto has settings for agressiveness and thresholds of when to flee, among other things. So a "Wimpy Peasant" critter will behave differently than a "Strong Guard" critter (these are existing AI packets). If you click on a critter proto and edit (in the mapper) you can see which AI packet is configured for the critter. If you change anything in the proto, you should delete the old instance of that critter from the map and place a new one.

Scripts have attack commands in them, for example many say if self_can_see_dude then attack. So what script is attached to the critter? I think a critter won't attack unless someone attacks it, unless the script says otherwise.

There are critter flee flags that can be set by script commands. These are supposed to be able to turn off fleeing, but I've had some weird problems with fleeing cockroaches. See these commands in the mapper documentation:

set_critter_flee_state
critter_is_fleeing
 
dude_obj said:
what script is attached to the critter?

I'm using Arroyo Villager AI packet. I wanted the character to be a wimp and flee if attacked, but I didn't think he'd run if I started shooting at someone else.

dude_obj said:
There are critter flee flags that can be set by script commands. These are supposed to be able to turn off fleeing, but I've had some weird problems with fleeing cockroaches. See these commands in the mapper documentation:

set_critter_flee_state
critter_is_fleeing


OK, so where would I put critter_set_flee_state? And it says "who (ObjectPtr) flee_on (Boolean)", so would that be "critter_set_flee_state (self_obj, 0)" if I wanted him not to flee, right?


EDIT: Never mind, got it working myself. Thanks a million for the help, dude_obj.
 
Back
Top