[XP] NPCS THAT ONLY COLLIDE WITH CERTAIN ELEMENTS: IS IT POSSIBLE?
Posts
Pages:
1
Sooz
They told me I was mad when I said I was going to create a spidertable. Who’s laughing now!!!
5354
I'm in the very early planning stages of a game, and need to see if this concept is even possible:
I'd like to have enemy-type NPCs that move around onscreen and can "collide" with the PC and other enemy-types, but NOT with not-enemy-type NPCs, which they would just "ghost" through with no effects.
Is this a thing that can be done in XP? In any RPGMaker game?
I'd like to have enemy-type NPCs that move around onscreen and can "collide" with the PC and other enemy-types, but NOT with not-enemy-type NPCs, which they would just "ghost" through with no effects.
Is this a thing that can be done in XP? In any RPGMaker game?
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
By default, events won't overlap unless one of them is set to have the "through" property, allowing it to pass through anything. This is true even if one or both of the events can be walked on by the hero.
It's absolutely possible to edit the way passability is handled in the default scripts to change this, though. Passability for events is handled in the Game_Character 1 script, starting on line 135. Here's an example way to change it:
Untested because I'm lazy, but what this does is replace how an event or hero decides if the tile it's about to move to is passable. It first checks the built-in passability code. If the built-in passability code returns "true" - that is, it thinks the tile you're about to move to is passable - then it checks to see if either the event that's moving or the event that's in the spot you're moving to is an enemy or the player. The way it checks to see if something is an enemy is by checking the filename graphic: any event using a charset that starts with "Enemy" will count as an enemy. So you can easily control which events are enemies just by changing the graphics filenames. You could do it a different way, but this way seemed easy.
You would just add that script as a new script above Main like any other script; you don't need to replace or edit the original code in Game_Character 1. Lemme know if it errors and you can't fix it, I guess.
It's absolutely possible to edit the way passability is handled in the default scripts to change this, though. Passability for events is handled in the Game_Character 1 script, starting on line 135. Here's an example way to change it:
class Game_Character alias enemy_collision_only_passable? passable? def passable?(x, y, d) original_value = enemy_collision_only_passable? if original_value == true new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0) new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0) # Loop all events for event in $game_map.events.values # If event coordinates are consistent with move destination if event.x == new_x and event.y == new_y # If through is ON if event.through # If self is event and is an enemy if self != $game_player and @character_name.size >= 5 and @character_name[0..4] == "Enemy" # check if event at the destination is another enemy if event.character_name.size >= 5 and event.character_name[0..4] == "Enemy" # impassable return false end end # With self as the player and an enemy in the destination if event.character_name != "" and event.character_name.size >= 5 and event.character_name[0..4] == "Enemy" # impassable return false end end end end # If player coordinates are consistent with move destination if $game_player.x == new_x and $game_player.y == new_y # If this event is an enemy if @character_name != "" and @character_name.size >= 5 and @character_name[0..4] == "Enemy" # impassable return false end end end return original_value end end
Untested because I'm lazy, but what this does is replace how an event or hero decides if the tile it's about to move to is passable. It first checks the built-in passability code. If the built-in passability code returns "true" - that is, it thinks the tile you're about to move to is passable - then it checks to see if either the event that's moving or the event that's in the spot you're moving to is an enemy or the player. The way it checks to see if something is an enemy is by checking the filename graphic: any event using a charset that starts with "Enemy" will count as an enemy. So you can easily control which events are enemies just by changing the graphics filenames. You could do it a different way, but this way seemed easy.
You would just add that script as a new script above Main like any other script; you don't need to replace or edit the original code in Game_Character 1. Lemme know if it errors and you can't fix it, I guess.
Sooz
They told me I was mad when I said I was going to create a spidertable. Who’s laughing now!!!
5354
I'll have to try that out when I have actual game noodling time (as opposed to forum-posting time). Thanks!
Pages:
1














