#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure look_at_p_proc;
procedure map_enter_p_proc;
procedure use_p_proc;

variable rndx;
variable bonus;
variable test;
variable money;


procedure start
begin
	if (script_action == look_at_proc) then begin
		call look_at_p_proc;
	end
	else begin
		if (script_action == map_enter_proc) then begin
			call map_enter_p_proc;
		end
		else begin
			if (script_action == use_proc) then begin
				call use_p_proc;
			end
		end
	end
end

procedure look_at_p_proc
begin
	script_overrides;
	display_msg(message_str(SCRIPT_CHEPSLOT, 100));
end

procedure map_enter_p_proc
begin
	if (global_var(GVAR_GIZMO_DEAD) == 1) then begin
		destroy_object(self_obj);
	end
end

procedure use_p_proc
begin
	script_overrides;
	if (item_caps_total(dude_obj) < 10) then begin
		display_msg(message_str(SCRIPT_CHEPSLOT, 108));
	end
	else begin
		display_msg(message_str(SCRIPT_CHEPSLOT, 101));
		item_caps_adjust(dude_obj, -10);
		bonus := random(1, 50) - random(1, 50);
		test := roll_vs_skill(dude_obj, 16, bonus);
		if (is_success(test)) then begin
			if (is_critical(test)) then begin
				rndx := random(15, 30);
				float_msg(self_obj, message_str(SCRIPT_CHEPSLOT, 102), FLOAT_MSG_NORMAL);
				display_msg(message_str(SCRIPT_CHEPSLOT, 103) + rndx + message_str(SCRIPT_CHEPSLOT, 104));
			end
			else begin
				float_msg(self_obj, message_str(SCRIPT_CHEPSLOT, 105), FLOAT_MSG_NORMAL);
				display_msg(message_str(SCRIPT_CHEPSLOT, 106));
				rndx := 15;
			end
			item_caps_adjust(dude_obj, rndx);
		end
		else begin
			display_msg(message_str(SCRIPT_CHEPSLOT, 107));
		end
	end
end