attacking,can it be completely scripted?

Nirran

Vault Senior Citizen
Modder
i mean without the use of attack_complex,im trying to fix the cockroaches in megamod


Nirran
 
they run in circles instead of attacking,if i use script overrides they dont bug out,but they dont attack either,sometimes the loop forces a ctrl alt del to kill it
 
This is what I use for my cockroaches.

procedure critter_p_proc begin
if (self_can_see_dude) then begin
attack(dude_obj);
end
end

Of course, a distance modifier can be added. This has given me no problems and as soon as they see the player - they atatck
 
every once in a while,when it is the cockroaches turn in combet,they will get stuck in an animation loop moving in tiny cicles and not using action points,forcing a ctl alt del to crash the game,this is the current script

Code:
variable ProtoOfItemGiven;
variable ValueOfRollCheck := 1;
variable Scenery_Creation;
variable Scenery_Creation_Hex;
variable Scenery_Creation_Count;
variable Temp_Scenery_Creation_Hex;
variable Scenery_Creation_Ptr;
variable How_Many_Party_Members_Are_Injured;
variable How_Many_Party_Members_Armed;
variable PartyHealingItem;

procedure checkPartyMembersNearDoor;

variable Finding_New_Tile;
variable global_temp;
variable dest_tile;
variable step_tile;
variable in_dialog;
variable forced_node;
variable restock_amt;
variable restock_obj;
variable restock_trash;
variable removed_qty;

procedure start;
procedure destroy_p_proc;
procedure critter_p_proc;
procedure combat_p_proc;
procedure map_enter_p_proc;

variable starttile;
variable ctr;
variable chance;

procedure timed_event_p_proc;


procedure checkPartyMembersNearDoor
begin
	if (party_member_obj(16777278) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777278)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777376) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777376)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777377) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777377)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777305) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777305)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777313) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777313)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777323) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777323)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777352) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777352)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777378) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777378)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777368) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777368)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777379) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777379)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777380) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777380)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777295) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777295)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777381) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777381)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777407) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777407)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777411) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777411)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777412) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777412)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777413) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777413)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777481) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777481)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777558) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777558)) <= 5) then begin
			return 1;
		end
	end
	if (party_member_obj(16777600) != 0) then begin
		if (tile_distance_objs(self_obj, party_member_obj(16777600)) <5> 0) then begin
		LVar1 := obj_carrying_pid_obj(self_obj, 644);
		LVar2 := rm_mult_objs_from_inven(self_obj, LVar1, LVar0);
	end
	LVar3 := obj_is_carrying_obj_pid(self_obj, 654);
	if (LVar3 > 0) then begin
		LVar4 := obj_carrying_pid_obj(self_obj, 654);
		LVar5 := rm_mult_objs_from_inven(self_obj, LVar4, LVar3);
	end
	if (cur_map_index == 94) then begin
		set_map_var(1, map_var(1) - 1);
	end
end

procedure critter_p_proc
begin
	variable LVar0 := 0;
	if (obj_can_see_obj(self_obj, dude_obj)) then begin
		if (tile_distance_objs(self_obj, dude_obj) > 10) then begin
			animate_move_obj_to_tile(self_obj, tile_num(dude_obj), 1);
		end
		else begin
			attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
		end
	end
	else begin
		script_overrides;
	end
	if (not(combat_is_initialized) and ((critter_state(self_obj) bwand 1) == 0)) then begin
		add_timer_event(self_obj, game_ticks(random(1, 5)), 0);
	end
end

procedure combat_p_proc
begin
	variable LVar0 := 0;
	if (obj_can_see_obj(self_obj, dude_obj)) then begin
		if (tile_distance_objs(self_obj, dude_obj) > 10) then begin
			animate_move_obj_to_tile(self_obj, tile_num(dude_obj), 1);
		end
		else begin
			attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
		end
	end
	else begin
		script_overrides;
	end
	if (obj_pid(self_obj) == 16777755) then begin
		play_sfx("zmarch1at");
	end
	else begin
		play_sfx("zmarch2at");
	end
end

procedure map_enter_p_proc
begin
	starttile := tile_num(self_obj);
	critter_add_trait(self_obj, 1, 6, 186);
	critter_add_trait(self_obj, 1, 5, 132);
	if (not(combat_is_initialized) and ((critter_state(self_obj) bwand 1) == 0)) then begin
		add_timer_event(self_obj, game_ticks(random(1, 5)), 0);
	end
end

procedure timed_event_p_proc
begin
	if (not(combat_is_initialized) and ((critter_state(self_obj) bwand 1) == 0)) then begin
		reg_anim_func(2, self_obj);
		reg_anim_func(1, 1);
		animate_move_obj_to_tile(self_obj, tile_num_in_direction(tile_num(self_obj), random(0, 5), random(1, 3)), 0);
		reg_anim_func(3, 0);
	end
end

i tried changing ai to alien,changing combat proc to nothing,changing critter proc to nothing,only thing that stops it that i did was putting script_overrides; in the top of combat proc and critter proc,but then they dont attack

Nirran
 
I use this code for my roaches...

procedure critter_p_proc begin
if (self_can_see_dude) then begin
attack(dude_obj);
end
end

With nothing in combat_p_proc;

The use of self_can_see_dude helps as it takes out of the equation tile distance errors.

If not, its an engine bug of some kind. :?
 
Back
Top