RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[Resolved] Zylos has a question!

0 Members and 1 Guest are viewing this topic.

********
Furry Philosopher
Rep:
Level 94
Rawr?
2013 Best RPG Maker User (Creativity)Randomizer - GIAW 11Gold - GIAW 11 (Hard)Secret Santa 2013 ParticipantFor frequently finding and reporting spam and spam bots2012 Best RPG Maker User (Programming)2012 Best RPG Maker User (Mapping)Secret Santa 2012 ParticipantGold - GIAW 9Project of the Month winner for September 2008For taking a crack at the RMRK Wiki2011 Best RPG Maker User (Programming)2011 Kindest Member2011 Best Veteran2010 Most Deserving Of A Promotion2010 Best RPG Maker User (Technical)
The long story:

Before I begin, this is NOT an ABS question, this is a general mapping question to which I'm not sure where to begin with coding. Now then, lately I've been working on a game in my spare time using Blizzard's ABS system, but there's always been something I've been miffed about ever since I started Midnight: attacks can cut straight through walls.

There are a few ways that this is preventable, such as shooting actual events that cannot pass or the projectile setup in Blizzard's script. But these ways are annoying for being slow and clunky, and makes games that use handguns with speeding bullets rather than slower bows and arrows extremely difficult to do decently. The method I've always used for ranged weapons with Blizzard's ABS script is a straight-forward melee weapon that attacks anything seven tiles in front of him. I've tried going to Blizzard's website for help, but unfortunately the only solution they knew of was to use the projectile weapons I dislike. Melee weapons were not meant to have so long of a range.

However, it is very possible to script in the solution myself. I already know the basics for what I want to do: whenever I press to attack, I will need to figure out where my character is on a map and which direction he is facing. Then, we check each tile from his position to the edge of his range (seven tiles) to see if any of them have a specific terrain tag as marked in the tileset. If there IS a tile, we then calculate the distance to that tile, and shorten the range of our melee weapon to that number. We then execute the attack, and then return the range back to being seven tiles.

The problem is that I don't have any idea for how to do even half of this yet. 



The short summation:

I will need to determine the character's position on the map, determine the direction he is facing, determine if there is a tile with a specific terrain tag within seven tiles from the character's position in his given direction, and then if one exists, determine the distance between the character and the first terrain tagged tile away from him.

Anyone know anything that might help?
« Last Edit: September 18, 2011, 03:44:31 AM by Zylos »




*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Finding the character's position on the map is rather easy; just look for it's x and y co-ordintaes. If you wanted to find out the player's x and y, you would use $game_player.x or $game_player.y, depending on which value you want to know. 

Direction can be found by accessing the direction variable that all Game_Character classes carry. So if you wanted to find out the player's direction, you would use
Code: [Select]
$game_player.direction
It would then spit out an integer, which you can then translate to actual directions:
Code: [Select]
2 => Down
4 => Left
6 => Right
8 => Up

To check if there is a terrain tag in a specific direction, the easiest way would to use a for loop that checks if every space inside that loop is passable?, and also checks the player's direction. Something like:

Code: [Select]
range = 7
case $game_player.direction
when 2
  for i in 0...range
    return false if not $game_map.passable?($game_player.x, $game_player.y + i)
  end
when 4 
  for i in 0...range
    return false if not $game_map.passable?($game_player.x - i, $game_player.y)
  end
when 6
  for i in 0...range
    return false if not $game_map.passable?($game_player.x + i, $game_player.y)
  end
when 8
  for i in 0...range
    return false if not $game_map.passable?($game_player.x, $game_player.y - i)
  end
end
return true

Then all you have to do is shorten the range of the melee weapon. I'm unfamiliar with the workings of Blizz-ABS, but I'm assuming you can just change the variable of the weapon, or if it comes to that, forcefully unequip that weapon and change it with a different weapon, destroy the instance of that weapon and then re-equip your previous weapon.
 

********
Furry Philosopher
Rep:
Level 94
Rawr?
2013 Best RPG Maker User (Creativity)Randomizer - GIAW 11Gold - GIAW 11 (Hard)Secret Santa 2013 ParticipantFor frequently finding and reporting spam and spam bots2012 Best RPG Maker User (Programming)2012 Best RPG Maker User (Mapping)Secret Santa 2012 ParticipantGold - GIAW 9Project of the Month winner for September 2008For taking a crack at the RMRK Wiki2011 Best RPG Maker User (Programming)2011 Kindest Member2011 Best Veteran2010 Most Deserving Of A Promotion2010 Best RPG Maker User (Technical)
Cozziekuns, you are a godsend. I changed just a tiny bit and inserted that in the script where it goes to determine an attack's range, and it works perfect. A melee thrust of a spear will go up to but not beyond a passable tile. I'm actually surprised how easy that worked considering that I was told on Chaos Project that it preventing the attack wouldn't be possible.

*HUGS YOU TIGHTLY* Thaaaaaaaaank you. <3