dragontamerseven
Member
So when I have an object on a map (using earthbound's item sprite as a placeholder for testing) and I go up to it and press Z, I do interact with it okay. However, what happens is, I can click on blank space surrounding the item and it treats it as if I'm interacting with the item? Now, I feel like it may be something to do with the player object itself, due to it not only happening with using this sprite as an object, but ANY objects I use?
(example)
(example)
Create:
Alarm [0]
Alarm 1
Alarm 11
Draw
User Event 0
GML:
pid = 0
item = 0
image_speed = 0
alarm[0] = 1
b = 0
GML:
if ds_map_find_value(global.presents,pid) = 0 {
image_index = 1
} else {
image_index = 0
item = ds_map_find_value(global.presents,pid)
}
GML:
if instance_exists(objTextBox) {
alarm[1] = 1
} else {
if item = -1 {
ds_map_replace(global.presents,pid,0)
image_index = 1
} else {
var a;
a = instance_create(0,0,objTextBox);
a.strno = 0
b = add_item_ext(item);
if b = -1 {
if global.pl_count = 1 {
a.str[0] = "@ But "+global.s_name[1]+" was carrying too much stuff already."
} else {
a.str[0] = "@ But everyone was carrying too much stuff already."
}
} else {
a.str[0] = "@ "+global.s_name[b+1]+" took it."
ds_map_replace(global.presents,pid,0)
image_index = 1
audio_play_sound(snditemget1,0,0)
}
}
}
GML:
event_user(0)
GML:
draw_self()
GML:
var a = instance_create(0,0,objTextBox);
if image_index != 1 {
a.strno = 1;
a.str[0] = "@ " + global.s_name[1] + " opened the present."
if item = -1 {
a.str[1] = "@ But it was empty."
} else {
a.str[1] = "@ Inside the present, there was "+global.item[item,17]+global.item[item,1]+"!"
}
audio_play_sound(sndpresent,0,0)
alarm[1] = 1;
} else {
a.strno = 0;
a.str[0] = "@ It's empty."
}
Create
Step
End Step
Alarm 11
Draw
Room Start
User Event 0
GML:
if instance_number(objPlayer) > 1 { instance_destroy(); exit }
dir = 270;
direction = dir
walk_speed = 2;
water_speed = 1;
run_speed = walk_speed;
canmove = 1;
water = 0;
ladder = 0;
can_splash = true;
stairs_ang = 0;
invincible = 0;
invertedcontrols = 0;
shadow = 1
player = 1
dx = 0
dy = 0
key_direction = 270;
for(var c = 0;c <= 5*100;c++){
prevx[c] = x
prevy[c] = y
prevd[c] = direction
}
spr_walking[0,0] = sprProtag_f_r
spr_walking[90,0] = sprProtag_f_u
spr_walking[180,0] = sprProtag_f_l
spr_walking[270,0] = sprProtag_f_d
GML:
/// @description Movement
depth = -y
// Handle keyboard input
dx = 0
dy = 0
if !global.s_strange[1] {
dx = (keyboard_check(vk_right) xor round(joy_axis(objPersistent.device,0)) == 1) - (keyboard_check(vk_left) xor round(joy_axis(objPersistent.device,0)) == -1);
dy = (keyboard_check(vk_down) xor round(joy_axis(objPersistent.device,1)) == 1) - (keyboard_check(vk_up) xor round(joy_axis(objPersistent.device,1)) == -1);
} else {
switch invertedcontrols {
case 0:
dx = -(keyboard_check(vk_right) or round(joy_axis(objPersistent.device,0)) == 1) + (keyboard_check(vk_left) or round(joy_axis(objPersistent.device,0)) == -1);
dy = -(keyboard_check(vk_down) or round(joy_axis(objPersistent.device,1)) == 1) + (keyboard_check(vk_up) or round(joy_axis(objPersistent.device,1)) == -1);
break;
case 1:
dx = (keyboard_check(vk_right) or round(joy_axis(objPersistent.device,0)) == 1) - (keyboard_check(vk_left) or round(joy_axis(objPersistent.device,0)) == -1);
dy = (keyboard_check(vk_down) or round(joy_axis(objPersistent.device,1)) == 1) - (keyboard_check(vk_up) or round(joy_axis(objPersistent.device,1)) == -1);
break;
case 2:
dx = (keyboard_check(vk_down) or round(joy_axis(objPersistent.device,1)) == 1) - (keyboard_check(vk_up) or round(joy_axis(objPersistent.device,1)) == -1);
dy = (keyboard_check(vk_right) or round(joy_axis(objPersistent.device,0)) == 1) - (keyboard_check(vk_left) or round(joy_axis(objPersistent.device,0)) == -1);
break;
case 3:
dx = -(keyboard_check(vk_down) or round(joy_axis(objPersistent.device,1)) == 1) + (keyboard_check(vk_up) or round(joy_axis(objPersistent.device,1)) == -1);
dy = -(keyboard_check(vk_right) or round(joy_axis(objPersistent.device,0)) == 1) + (keyboard_check(vk_left) or round(joy_axis(objPersistent.device,0)) == -1);
break;
}
}
if global.debug {
objDebug.dx = dx
objDebug.dy = dy
}
water = position_meeting(x,y,objWater)
ladder = position_meeting(x,y,objLadder)
if canmove = 1 {
//if (dx > 0.5 or dx < -0.5) || (dy > 0.5 or dy < -0.5) {
if (abs(dx) > 0.5) || (abs(dy) > 0.5) {
// Walk
key_direction = point_direction(0, 0, dx, dy);
speed = (walk_speed-0.5*(water||ladder)-0.75*(global.s_numb[1] or global.s_numb[2] or global.s_numb[3] or global.s_numb[4]))
if speed > 0 {
if position_meeting(x,y,objStairs){
stairs_ang = -45*(abs(dx) > 0 and abs(dy) < 0.5 )
} else if position_meeting(x,y,objStairs2) {
stairs_ang = 45*(abs(dx) > 0 and abs(dy) < 0.5 )
} else {
stairs_ang = 0
}
} else {
stairs_ang = 0
}
direction = key_direction+stairs_ang
if water {
if can_splash {
audio_play_sound(sndsplash,0,0)
alarm[2] = 30
can_splash = false
}
}
} else {
// Idle
speed = 0
image_index = 0
}
}
if (direction >= 0 and direction < 45/2) or (direction >= 315+45/2 and direction < 360) {
dir = 0-stairs_ang
} else if (direction >= 45+45/2 and direction < 90+45/2) {
dir = 90-stairs_ang
} else if (direction >= 135+45/2 and direction < 180+45/2) {
dir = 180-stairs_ang
} else if (direction >= 225+45/2 and direction < 270+45/2) {
dir = 270-stairs_ang
}
if dir < 0 {
dir = 360+dir
} else if dir = 360 {
dir = 0
}
if !ladder {
sprite_index = spr_walking[dir,global.dead[player]]
} else {
sprite_index = spr_climbing[0]
}
/// Interaction with objects
audio_listener_position(x, y, 0);
if keyboard_check_pressed(global.kb_choose) and canmove and !instance_exists(obj_inv) and !instance_exists(objStorage) {
var npc, angle, box;
if distance_to_object(objNPCExtender) < 12 {
npc = instance_nearest(x,y,objNPCExtender).link
angle = point_direction(x,y,npc.x,npc.y)
if (angle < 360+(45/2)) and (angle > 360-(45/2))
or (angle < 0+(45/2)) and (angle > 0-(45/2)) { direction = 0 }
else if (angle < 90+(45/2)) and (angle > 90-(45/2)) { direction = 90 }
else if (angle < 180+(45/2)) and (angle > 180-(45/2)) { direction = 180 }
else if (angle < 270+(45/2)) and (angle > 270-(45/2)) { direction = 270 }
speed = 0
image_index = 0
with npc { alarm[11] = 1 }
exit
}
if distance_to_object(parDoor) < 8 {
npc = instance_nearest(x,y,parDoor)
if npc.visible {
angle = point_direction(x,y,npc.x,npc.y)
if (angle < 360+(45/2)) and (angle > 360-(45/2))
or (angle < 0+(45/2)) and (angle > 0-(45/2)) { direction = 0 ; with npc { direction = 180 } }
else if (angle < 90+(45/2)) and (angle > 90-(45/2)) { direction = 90 ; with npc { direction = 270 } }
else if (angle < 180+(45/2)) and (angle > 180-(45/2)) { direction = 180 ; with npc { direction = 0 } }
else if (angle < 270+(45/2)) and (angle > 270-(45/2)) { direction = 270 ; with npc { direction = 90 } }
}
with npc { alarm[11] = 1 }
speed = 0
image_index = 0
exit
}
if distance_to_object(parNpc) < 12 {
npc = instance_nearest(x,y,parNpc)
if npc.visible {
angle = point_direction(x,y,npc.x,npc.y)
if (angle < 360+(45/2)) and (angle > 360-(45/2))
or (angle < 0+(45/2)) and (angle > 0-(45/2)) { direction = 0 ; with npc { direction = 180 } }
else if (angle < 90+(45/2)) and (angle > 90-(45/2)) { direction = 90 ; with npc { direction = 270 } }
else if (angle < 180+(45/2)) and (angle > 180-(45/2)) { direction = 180 ; with npc { direction = 0 } }
else if (angle < 270+(45/2)) and (angle > 270-(45/2)) { direction = 270 ; with npc { direction = 90 } }
}
with npc { alarm[11] = 1 }
speed = 0
image_index = 0
exit
}
}
///Prolong invincibility if menu exists
if ie(parDeactivator) and invincible {
alarm[3]++;
}
GML:
/// @description Bouncing off solids
if speed > 0 { image_speed = 0.15/(2*global.s_numb[1]+1)} else { image_speed = 0 }
collision_handle();
///Handling party movement
var more;
more = 1 // This adds an additional gap between party members. 1 by default, don't set it to zero!
if(hspeed != 0 or vspeed != 0){
for(var c = 5*10*more;c > 0;c -= 1){
prevx[c] = prevx[c - 1]
prevy[c] = prevy[c - 1]
prevd[c] = prevd[c - 1]
}
prevx[0] = x
prevy[0] = y
prevd[0] = direction
}
//Party members' direction handle and position update
with(objPartyCharacter){
x = other.prevx[player_index*10*more]
y = other.prevy[player_index*10*more]
direction = other.prevd[player_index*10*more]
if !(direction = 0 or direction = 90 or direction = 180 or direction = 270) and player_index > 1 {
x = floor(x)
y = floor(y)
}
}
///Views
if !global.cutscene or get_flag(28) {
__view_set( e__VW.XView, 0, min(max(x-__view_get( e__VW.WView, 0 )/2,0),room_width-__view_get( e__VW.WView, 0 )) );
__view_set( e__VW.YView, 0, min(max(y-__view_get( e__VW.HView, 0 )/2,0),room_height-__view_get( e__VW.HView, 0 )) );
__view_set( e__VW.XView, 0, round(__view_get( e__VW.XView, 0 )) )
__view_set( e__VW.YView, 0, round(__view_get( e__VW.YView, 0 )) )
}
GML:
speed = 0
GML:
if !water {
if shadow { draw_sprite(sprShadow,0,x,y) }
draw_sprite_ext(sprite_index,image_index,x,y,image_xscale,image_yscale,image_angle,image_blend,image_alpha)
} else {
draw_sprite_part_ext(sprite_index,image_index,0,0,sprite_width,2*sprite_height/3,x-sprite_width/2,y-16,image_xscale,image_yscale,image_blend,image_alpha)
draw_sprite(sprWaterRipple,image_index,x,y)
}
GML:
/// @description Move the player to saved position
if global.thex > 0 and global.they > 0 and room != rmGameOver {
x = global.thex
y = global.they
direction = global.thedir
}
event_user(0)
///Event stuff
///Views
__view_set( e__VW.XView, 0, round(__view_get( e__VW.XView, 0 )) )
__view_set( e__VW.YView, 0, round(__view_get( e__VW.YView, 0 )) )
if !global.cutscene or get_flag(28) {
__view_set( e__VW.XView, 0, min(max(x-__view_get( e__VW.WView, 0 )/2,0),room_width-__view_get( e__VW.WView, 0 )) );
__view_set( e__VW.YView, 0, min(max(y-__view_get( e__VW.HView, 0 )/2,0),room_height-__view_get( e__VW.HView, 0 )) );
__view_set( e__VW.XView, 0, round(__view_get( e__VW.XView, 0 )) )
__view_set( e__VW.YView, 0, round(__view_get( e__VW.YView, 0 )) )
}
GML:
/// @description Check whether to trigger invincibility
if ie(objOwEnemyBlink) and !invincible {
invincible = 1
alarm[3] = 120 // 2 seconds
alarm[4] = 10
}
///Make allies that follow you around
for(var c = 0;c <= 5*14;c++){
prevx[c] = x
prevy[c] = y
prevd[c] = direction
}
if room != rmGameOver {
if(!instance_exists(objPartyCharacter)){
for(c = 1;c < global.pl_count;c += 1){
var partyCharacter = instance_create(x,y,objPartyCharacter);
partyCharacter.player_index = c
with(partyCharacter){
x = objPlayer.prevx[0]; y = objPlayer.prevy[0];
switch player_index {
default:
spr_walking[0,0] = sprProtag_f_r
spr_walking[90,0] = sprProtag_f_u
spr_walking[180,0] = sprProtag_f_l
spr_walking[270,0] = sprProtag_f_d
break;
}
}
}
}
}