#include <define.h>

//#define NAME                    SCRIPT_

#include <command.h>
//#include <ModReact.h>



procedure start;
#include <push.h>
procedure critter_p_proc;
procedure use_skill_on_p_proc;
procedure combat_p_proc;


procedure start
begin
	if (script_action == use_skill_on_proc) then begin
		call use_skill_on_p_proc;
	end
	else begin
		if (script_action == critter_proc) then begin
			call critter_p_proc;
		end
		else begin
			if (script_action == combat_proc) then begin
				call combat_p_proc;
			end
		end
	end
end

procedure critter_p_proc
begin
	if (obj_can_see_obj(self_obj, dude_obj) and (global_var(GVAR_GLOW_POWER) == 2) and (global_var(GVAR_WEAPONS_ARMED) == 0)) then begin
		attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
	end
	else begin
		if (global_var(GVAR_GLOW_POWER) != 2) then begin
			anim(self_obj, 48, 0);
		end
	end
end

procedure use_skill_on_p_proc
begin
	if (action_being_used == 12) then begin
		script_overrides;
		if ((global_var(GVAR_GLOW_POWER) == 2) and is_success(roll_vs_skill(dude_obj, 12, -10))) then begin
			display_msg(message_str(SCRIPT_GENCHAT, 173));
			if (local_var(0) == 0) then begin
				give_exp_points(100);
			end
		end
		else begin
			display_msg(message_str(SCRIPT_GENCHAT, 174));
		end
	end
end

procedure combat_p_proc
begin
	display_msg("Glow_Power == " + global_var(GVAR_GLOW_POWER));
	display_msg("Weapons_Armed == " + global_var(GVAR_WEAPONS_ARMED));
	if ((fixed_param == 4) and (global_var(GVAR_GLOW_POWER) != 2) and (global_var(GVAR_WEAPONS_ARMED) != 0)) then begin
		script_overrides;
		anim(self_obj, 48, 0);
	end
end