General attacks

Lyer

First time out of the vault
Greetings to everyone,this is my first post after reading so many topics as a guest.I believe
this is not mentioned before in the forums(i hope so or else....!).

(1)I 'm trying to set up 'on sight' attacks between critter types from critter scripts.
(e.g. a floater will instantly attack if see or hear or tile_distance any specific critter_pid or some of them,or all of them if possible)
Attacks that will not involve in any way obj_dude.
I searched in scripts and in game but couldn't find anything similar except
for the random encounters fighting each other but again i can't find their scripts either(i don't know how their behavior is handled.)

the simpliest example would be:

#define any_obj (PID_SHI_GUARD) or\
(PID_SHI_MALE_PEASANT) or\
(PID_SHI_FEMALE_PEASANT)


procedure critter_p_proc begin
if (obj_can_see_obj(self_obj,any_obj)) then begin
attack(any_obj);
end
end

In any way that i tried this concept(not necessary with the above example) the game crashed upon function of the script.
I 'm coming to the conclusion that this cannot happen as all game twists around the player and no 'indepedent' action can be taken outside the player.Any suggestions?

(2)my second bugging is how to override players damage or destroy procedure so the health counter will not go down when is hitted and obviously never die.
like the "Is Invulnerable????" in critter flags while critter editing in the mapper.
i cannot really uderstand vorpal rat script for a hint.


In any way thanks for reading this and sorry for the hassles...Lyer,out.
 
Hi Lyer.
I checked the Vorpal rat's and king Arthur's scripts and I think the answer to your first question lies there.
The thing is handled via the map script: you export any_obj as a variable, then you import it in both the attacker and target scripts.

Map script:
export variable any_obj;
I think that any_obj should defined here in the map script.

Attacker script:
import variable any_obj;
IMPORTANT: never EXPORT such a variable from a critter script, the script itself becomes erratic and does not work properly.

procedure critter_p_proc begin
if (obj_can_see_obj(self_obj,any_obj)) then begin
attack(any_obj);
end
end

Target script:
import variable any_obj;

procedure map_enter_p_proc begin
any_obj := self_obj;
end

procedure damage_p_proc begin
attack(source_obj);/flee_from...
end
(this prevents the critter from attacking dude_obj.)

Actually as far as I know your sample code *should* work, but no harm in trying an original method/piece of code.

About your second question... You can't take the Vorpal rat as an exemple becouse it's the critter proto which is invulnerable... You can only kill it if you use the Holy Grenade (no matter if you hit or miss the rat), that's way the thing is handled via a item variable block. I really don't know how achieve this... You can try to heal dude if he/she gets wounded... It could be done via dude's or a critter's scripts...
Something like:
(dude's) procedure damage_p_proc begin
if source(given_obj) then
full_heal_dude_obj;
end
end... Or something similar... You can't override an instant death, though...
A completely different approach would be a scripted cutscene, but it can become extremely complex if there are a lot of actors.
What are you exactly tryng to achieve?
Please let me know if I managed to help in any way.
Cheers.
 
Sirren67 thanks kindly for your reply,you did helped much

(1)
I think i wanted to create a more general rule so i wouldn't have to define it in or export/import it from everywhere as i proceed in the game and the maps.any_obj(or whatever)includes the (x)pids and a critter should attack them
on sight with no other definitions,or exports (or talkbacks) from any map.(i thougt that was possible cause seems quite clear)

you see i wasn't planning to work on a map and create an incident in that map only, between 2 or more critters as a part of a story ,like in rndholy2.

For example if i wanted to have a deathclaw to follow me (not in my team,just follow)and to attack specific critter_pids
or critters that belong to specific teams that it sees(that is just an example)sould i have to make imports/exports(i'm not too good at this) to all the map that i visit but even then would it be possible?

therefore i don't know where the problem relies on .
any_obj is (20?)pids that you desire or more easily, critters that belong to some specific teams

other teams/critters that will see or have some distance from that any_obj will instantly attack,warn them,etc and vice versa.things that happen to the player.

you see i don't want only obj_dude to interact with all the others.but...

maybe i'm just saying !@#$# and none of that can be done except for some incident between some critters at a given time and place(map) as you explained (and i needed to clear that up too.Thanks).
i'm feeling i'm missing a big point here as i read again your answer.

(2)
as for the invulnerable thing are you sure it's the prototype,because scrolling to vorpal rat i see only the steal and drop flags in the mapper.(maybe was putted afterwards,i dont know the procedures)
On the other hand I thought was suspicious(for invulnerability) and couldn't understand that:


procedure destroy_p_proc begin
i_vorpal_obj := -1; :?:
end

procedure damage_p_proc begin
if (target_obj) then begin
if (obj_pid(target_obj) == PID_HOLY_HAND_GRENADE) then begin
script_overrides; :?:
i_vorpal_obj := -1; :?:
critter_damage(self_obj, 99999);
end
end
end


that's why i thought it was done in script somehow and wanted to use it to obj_dude.
I just wanted to know if there is any command to set that (Is_Invulnerable????)critter flag as you see it in the mapper ,to the player(maybe not).

my current "solution" under the damage_p_proc is this:
script_overrides;*(i don't know if thats needed)*
set_critter_stat(dude_obj,STAT_current_hp,999);
critter_uninjure(dude_obj, (DAM_CRIP_LEG_LEFT bwor DAM_CRIP_LEG_RIGHT bwor DAM_CRIP_ARM_LEFT bwor DAM_CRIP_ARM_RIGHT bwor DAM_BLIND));
poison(dude_obj,-get_poison(dude_obj));
radiation_dec(dude_obj,get_critter_stat(dude_obj,STAT_current_rad));

maybe its a bit crappy

again,THANKS.
 
O.K.... Lemmy see...
1): You could define a macro in a header and call it in your scripts...
In define.H for exemple: it's mandatory in every script. I never tried to define a macro, though... It should be simple with FSE.
You could do it even without a macro. There are 10 ruined town in the game, and they all use the same map script. The same goes with coast/desert maps. In the end we're talking about 3/4scripts.
Then you'll have to edit the critters' ones. I haven't looked much in the random encounters tables yet... I think that here we're talking about adding/editing encounters tables, as well (?). I wander if you can have a critter attack a given TEAM, instead of a given proto. It would be easier this way... (Folks, any leads?)

For example if i wanted to have a deathclaw to follow me (not in my team,just follow)and to attack specific critter_pids
or critters that belong to specific teams that it sees(that is just an example)sould i have to make imports/exports(i'm not too good at this) to all the map that i visit but even then would it be possible?
The deeper I get into scripting the more I realize we're talking about problem solving. You could do something like this:
Add the critter in maps.
turn visibility flag off upon map enter (if a certain condition dictates that it must not help/follow dude).
If it must follow dude turn visibility on and team to zero (dude's team). You could use follow_dude...
Have the critter attack other critters. Macro or pointers, as you whish.
Upon map exiting you turn visibility off and change team...
(Now that I think about it I had troubles wit a temporary allies script... I must try this and tell you what.)

maybe i'm just saying !@#$# and none of that can be done except for some incident between some critters at a given time and place(map)
No, I don't think it's crap. Usually Fo2 scriptors used the pointers method, but nothing and nobody force you to use that method. The point is: here we're probably talking about something which looks like a form of A.I. I think it could be done with the scripting engine as is, but know it's a lot of work. Tinkering in the headers will be mandatory.

2): Yes, I'm sure. What makes the rat invulnerable is not the flag. It's the incredibly hig damage Thresholds/resistences. You really can't scratch the critter's hide. I think they made it this way to give the player the possibility to kill it. If you turn a invulnerability flag on, probably the only way to get rid of the critter is the command destroy_obj.
procedure destroy_p_proc begin
i_vorpal_obj := -1;
end
I-vorpal_obj is included in K. Arthur's and his followers' scripts. It tells them that the critter is dead, so stop attacking her, gents (a kind of variable block)...

procedure damage_p_proc begin
if (target_obj) then begin
if (obj_pid(target_obj) == PID_HOLY_HAND_GRENADE) then begin
script_overrides;
i_vorpal_obj := -1;
critter_damage(self_obj, 99999);
end
end
end
script_overrides;... Powerful and important piece of code... Well, it overrides the normal behaviour of something. As I said you simply need to target the critter to kill it. Without that piece of code IF and WHEN you hit it the grenade only deals standard damage. It's not enough to kill the rat. In short the procedure kills the rat no matter both dude's throwing skill and the rat's DT and resistence.
About your last piece of code:
Script_overrides is mandatory. Add a GVAR block, or the player will be ALWAYS invulnerable. Remember to get dude's hp before setting them to 999, and to lower them again when you don't need invulnerability anymore...
Apart from this I hear some procedures don't work properly in obj_dude.int. According to Dude_Object there are problems with procedure combat, for exemple.
In short you're going to try something hard, but I think it can be done. Lyer, please keep us informed about you achievements. Please don't esitate to post more questions, what you're trying to achieve is challenging.
See you soon.
 
you know i still cannot understand why the engine is refusing the simpliest command(or i'm just dumb,that rhymes):
ok, we have some selected pids,if you see any of them ,attack them.

the idea of generic attacks i think consists of saving some work by applying generic conditions such as PIDS,TEAMS or even FIDS and
so grouping the targets etc.also i believe is giving some independency to critters(many conditions ,movement can follow).

Therefore the goal should be not to modify the scripts of the attacked ones(except the pointers if definitely needed), as this would mean much work to be done etc.and at this point the only thing i'm trying to manage is only to achieve the attack but only with generic conditions.

Therefore i'm trying to avoid any other script tinkering(to the attacked critters)and hopefully the attacker will just handle things as he sees/interacts with them,but
the game still denies to allow the attacks from critters (other than the player or to the player) to pids(or recognize the pids) the way I write them.***unfortunately the all way thinking may be wrong(or cannot be achieved)..and the map/critter pointers are necessary.***

For example:(from modoc.h-the peaceful residents of Modoc slaughters everybody ..even the children!!-)
#define Do_Attacking_Slag(x,y)

if (obj_is_visible_flag(self_obj)) then begin
if (obj_can_see_obj(self_obj,ghost_farm_slag_obj)) then begin
attack(ghost_farm_slag_obj);
end else begin Follow_Dude(x,y) end \
end

So the only problem in the above example is the correct/acceptable_by_the_engine definition of the attacked(target) which above is:(ghost_farm_slag_obj)
the rest of the code is ok.

as for the team attacks i guess it should be something like:


if (get_critter_stat(target_obj,OBJECT_TEAM_NUM) == TEAM_SCORPION) then begin
attack(target_obj);

but of course it aint working either.

what do you think about it, could there be some weakness/inavailability
from the scripting engine to handle such generic conditions or just the lack of proper elements.

I think i'm going way off my lead.

p.s.you were absolutely right about the vorpal rat.Thanks for clearing that up..

REGARDS-Lyer,out-
 
Hi there, Lyer.
I gave your first piece of code a try:
Code:
#define any_obj  ( (PID_SHI_GUARD) or\ 
                              (PID_SHI_MALE_PEASANT) or\ 
                              (PID_SHI_FEMALE_PEASANT) )


procedure critter_p_proc begin 
   if (obj_can_see_obj(self_obj,any_obj)) then begin 
      attack(any_obj); 
   end 
end

The only thing that I managed to get is Fo2 crashing, no matter what I tried. Whilst it's positive that the engine handles critter pids, apparently you can't have a critter attack another critter with a simple pid variable. (The engine seems to handle item and scenery objects in a more extensive way.) Obj import and export must be used. This is something which puzzles me, but I can't find a workaround with my current scripting skills. You'd need a professional programmer, IF it can be done. As a side note there was a mistake in your define: I added opening/closing parenthesis. NOT that this makes a difference in this situation.
At this point you really should follow the whole Ghost Farm example: it's a rather compact and easy one. Interesting coding in those scripts, too. On the other this example will allow you to add a whole new feature to the game, with a relatively small amount of tinkering...
That's all, for now. If you need more, I'm at your disposal. Have a nice Sunday.
 
The only thing that I managed to get is Fo2 crashing,
me too,you know another funny thing that i tried long time ago was to tell the critter
anything you see except me, attack it..:

if (target_obj != dude_obj) then begin
if (obj_can_see_obj(self_obj,target_obj)) then begin

i've changed target with source_obj added some other conditions
with tile_distance do this ,do that only
to achieve the self_obj shooting and hurting himself!!(that kind of denial)


Whilst it's positive that the engine handles critter pids

of course,a nice example that was interesting(for me,that is)was ktgoo spatial script
which is hurting(unfortunately not attacking)everyone except 2 pids:
if ( (obj_pid(source_obj) == PID_GOLDEN_GECKO) or (obj_pid(source_obj) == PID_TOUGH_GOLDEN_GECKO)
or (obj_pid(source_obj) == PID_GECKO_SMALL) or (obj_pid(source_obj) == PID_TOUGH_GECKO_SMALL) ) then begin
//do nothing
end
else
call pain;
end

Obj import and export must be used.
I'm thinking thats the resume.

At this point you really should follow the whole Ghost Farm example
i will,mate.Thanks for everything.

HOWEVER if you have any insight...

[/quote]
 
Hehe... Needed any evidence that computers are rocket fast idiots?
only
to achieve the self_obj shooting and hurting himself!!(that kind of denial)
That's interesting though. Did you try something like:
Code:
if ((target_obj != dude_obj) and (target_obj != self_obj)) then begin 
   if (obj_can_see_obj(self_obj,target_obj)) then begin
      attack(target_obj);
   end
end
If this works then the critter will attack everything except for dude and itself, but it's a start.
In the meanwhile I'm implementing the G. Farm example in my mod.
Two temporary allies required I edited some 14 scripts and a header, but it only took a couple of hours (test included). If this piece of code does not work, then definitely go for the obj export/import: a bit complex but effective like hell.
See you soon.
 
In the AI.txt file (extract it out of master.dat/data/data with the datexpl tool), there is a parameter about aggression for every critter type.
Maybe I have misunderstand you but this is maybe the general "attack on sight" behavoir you are looking for.

[Gecko]
aggression=50
attack_end=50140
attack_start=50140
body_type=None
called_freq=20
chance=0
chem_primary_desire=284,81,103
chem_use=always
color=58
font=101
general_type=None
hit_eyes_end=50080
hit_eyes_start=50080
hit_groin_end=50090
hit_groin_start=50090
hit_head_end=50000
hit_head_start=50000
hit_left_arm_end=50010
hit_left_arm_start=50010
hit_left_leg_end=50070
hit_left_leg_start=50070
hit_right_arm_end=50020
hit_right_arm_start=50020
hit_right_leg_end=50060
hit_right_leg_start=50060
hit_torso_end=50030
hit_torso_start=50030
hurt_too_much=crippled, blind
max_dist=10
min_hp=0
min_to_hit=0
miss_end=50160
miss_start=50160
move_end=50120
move_start=50120
outline_color=55
packet_num=26
run_end=50100
run_start=50100
secondary_freq=20

If you set aggression to 100, the critter would most likely always attack on sight.
There are more interesting AI settings, like max_dist, which is maybe the perception radius of every critter.
 
Back
Top