Telemetius
Tele*
- 267
- Posts
- 9
- Years
- Italy
- Seen Jan 9, 2022
Hello forum, it's been a while since i posted something here.
I've been trying to tweak the method that checks if the player or the events can walk somewhere. It's called "def passable?" and it's located in the "Game_map" class.
What I'm trying to do is to force a certain event to never leave a specific terrain tag area if it's name is "Incontro".
Here's what I did so far:
This is the original method with what I added:
It works well until the event tries to exit his area, then I receive the error:
I suppose that self_event doesn't like names.
Is there anything else I can do at this point?
Thank you for your help.
I've been trying to tweak the method that checks if the player or the events can walk somewhere. It's called "def passable?" and it's located in the "Game_map" class.
What I'm trying to do is to force a certain event to never leave a specific terrain tag area if it's name is "Incontro".
Here's what I did so far:
This is the original method with what I added:
Spoiler:
Code:
def passable?(x, y, d, self_event = nil)
return false if !valid?(x, y)
bit = (1 << (d / 2 - 1)) & 0x0f
for event in events.values
if event.tile_id >= 0 and event != self_event and
event.x == x and event.y == y and not event.through
# if @terrain_tags[event.tile_id]!=PBTerrain::Neutral
return false if @passages[event.tile_id] & bit != 0
return false if @passages[event.tile_id] & 0x0f == 0x0f
return true if @priorities[event.tile_id] == 0
# end
end
end
if self_event==$game_player
return playerPassable?(x, y, d, self_event)
else
# All other events
newx=x; newy=y
case d
when 1; newx-=1; newy+=1
when 2; newy+=1
when 3; newx+=1; newy+=1
when 4; newx-=1
when 6; newx+=1
when 7; newx-=1; newy-=1
when 8; newy-=1
when 9; newx+=1; newy-=1
end
return false if !valid?(newx, newy)
[COLOR="Lime"]#####This is what I added to make sure that the event named Incontro doesn't leave the bush
#####terrain tag number 2.[/COLOR]
[COLOR="Red"]if self_event.name=="Incontro" and !PBTerrain.isGrass?($game_map.terrain_tag(newx,newy))
return false
end[/COLOR]
[COLOR="lime"]#####[/COLOR]
for i in [2, 1, 0]
tile_id = data[x, y, i]
if tile_id == nil
return false
# If already on water, only allow movement to another water tile
elsif self_event!=nil &&
PBTerrain.isJustWater?(@terrain_tags[tile_id])
for j in [2, 1, 0]
facing_tile_id=data[newx, newy, j]
return false if facing_tile_id==nil
if @terrain_tags[facing_tile_id]!=0 &&
@terrain_tags[facing_tile_id]!=PBTerrain::Neutral
return PBTerrain.isJustWater?(@terrain_tags[facing_tile_id])
end
end
return false
# Can't walk onto ice
elsif PBTerrain.isIce?(@terrain_tags[tile_id])
return false
elsif self_event!=nil && self_event.x==x && self_event.y==y
# Can't walk onto ledges
for j in [2, 1, 0]
facing_tile_id=data[newx, newy, j]
return false if facing_tile_id==nil
if @terrain_tags[facing_tile_id]!=0 &&
@terrain_tags[facing_tile_id]!=PBTerrain::Neutral
return false if PBTerrain.isLedge?(@terrain_tags[facing_tile_id])
break
end
end
# Regular passability checks
# if @terrain_tags[tile_id]!=PBTerrain::Neutral
if @passages[tile_id] & bit != 0 ||
@passages[tile_id] & 0x0f == 0x0f
return false
elsif @priorities[tile_id] == 0
return true
end
# end
# Regular passability checks
else #if @terrain_tags[tile_id]!=PBTerrain::Neutral
if @passages[tile_id] & bit != 0 ||
@passages[tile_id] & 0x0f == 0x0f
return false
elsif @priorities[tile_id] == 0
return true
end
end
end
return true
end
end
It works well until the event tries to exit his area, then I receive the error:
I suppose that self_event doesn't like names.
Is there anything else I can do at this point?
Thank you for your help.