コード例 #1
0
ファイル: script_weap_target.c プロジェクト: rzel/dim3
JSValueRef js_weap_target_end_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
	obj_type			*obj;
	weapon_type			*weap;
	
	if (!script_check_param_count(cx,func,argc,0,exception)) return(script_null_to_value(cx));
	
	obj=object_get_attach(j_obj);
	weap=weapon_get_attach(j_obj);
	
	return(script_bool_to_value(cx,weapon_target_end(obj,weap)));
}
コード例 #2
0
ファイル: player_input.c プロジェクト: prophile/dim3
void player_weapon_change_input(int tick,obj_type *obj,weapon_type *weap)
{
	int				i,k;
	bool			down_key,weapon_key[(nc_weapon_end-nc_weapon_start)+1],
					next_weapon_key,previous_weapon_key;
	
		// special check if weapon change key is same as the
		// zoom or targetting keys.  If either are on, don't
		// change the weapon
		
	next_weapon_key=input_action_get_state(nc_next_weapon);
	previous_weapon_key=input_action_get_state(nc_previous_weapon);
		
	if ((weap->zoom.on) && (weap->zoom.mode!=zoom_mode_off)) {
		if (input_check_action_same_attachment(nc_next_weapon,nc_weapon_zoom_increase)) next_weapon_key=FALSE;
		if (input_check_action_same_attachment(nc_next_weapon,nc_weapon_zoom_decrease)) next_weapon_key=FALSE;
		if (input_check_action_same_attachment(nc_previous_weapon,nc_weapon_zoom_increase)) previous_weapon_key=FALSE;
		if (input_check_action_same_attachment(nc_previous_weapon,nc_weapon_zoom_decrease)) previous_weapon_key=FALSE;
	}
	if (weap->target.on) {
		if (input_check_action_same_attachment(nc_next_weapon,nc_weapon_target_next)) next_weapon_key=FALSE;
		if (input_check_action_same_attachment(nc_next_weapon,nc_weapon_target_previous)) next_weapon_key=FALSE;
		if (input_check_action_same_attachment(nc_previous_weapon,nc_weapon_target_next)) previous_weapon_key=FALSE;
		if (input_check_action_same_attachment(nc_previous_weapon,nc_weapon_target_previous)) previous_weapon_key=FALSE;
	}
	
		// any weapon change keys down?
		
	down_key=next_weapon_key||previous_weapon_key;

	for (i=nc_weapon_start;i<=nc_weapon_end;i++) {
		k=i-nc_weapon_start;
		weapon_key[k]=input_action_get_state(i);
		down_key=down_key||weapon_key[k];
	}
	
	if (!down_key) {
		weapon_change_key_down=FALSE;
		return;
	}
	
		// key held down, ignore
		
	if (weapon_change_key_down) return;
	
		// change weapons

	weapon_zoom_off(obj,weap);
	weapon_target_end(obj,weap);
		
	if (next_weapon_key) {
		weapon_switch(tick,obj,1);
		weapon_change_key_down=TRUE;
		return;
	}

	if (previous_weapon_key) {
		weapon_switch(tick,obj,-1);
		weapon_change_key_down=TRUE;
		return;
	}
	
	for ((i=nc_weapon_start);(i<=nc_weapon_end);i++) {
		k=i-nc_weapon_start;
		if (weapon_key[k]) {
			weapon_pick(tick,obj,k);
			weapon_change_key_down=TRUE;
			return;
		}
	}
}