ID:2135666
 
Looking for help coding an attack that teleports 2 combatants to 3-5 random locations while still fighting. Like in DBZ...
So do you want us to program it for you?...

What have you got so far? Where are you stuck?
The description is a little too vague, I'm afraid. Can you go into more detail about what you're trying to do?
Well I have a teleportation code, I want to be taught or guided through adding the teleportation randomly to the melee attack so the player and the mob they are attacking teleport to random locations on the current z plane of map...
I mean I'm lost on the actual thing you're trying to accomplish. You're describing an effect you've seen in the show, presumably, but not everyone is familiar with that.
TL;DR: He wants the players to teleport around the map while punching each other in order to confuse and disorient his players. You know, because concepts always translate from one medium to another extraordinarily well.
It's quiet simple, try understanding what you want to achieve. "Teleporting a player and his opponent whenever they punch". In other words, you're trying to change the LOCATION of a MOB and his OPPONENT (key words here), whenever they punch.

So you should very quickly know what vars you are going to change... X and Y right? Because they are the vars that change the location of your mob.

What you'll have to do is simply, under your Punch or Kick or Attack command, add the following code, or something along those lines:


src.x += rand(-5,5) ; src.y += rand(-5,5) // You can play with these numbers to adjust how far they move away each time they punch
O.loc = src.loc // O is your opponent that you just Punched. In your Attack command you probably have something that checks if there is an opponent next to you. Change "O" to whatever it's called in your proc.
In response to Kidpaddle45
Your code runs the risk of teleporting into solid walls and off-limits areas, or off the map altogether.
I understand that Lummox Jr and I'll trip over that hurdle when I come to it. Thx Kidpaddle45...
In response to Lummox JR
Lummox JR wrote:
Your code runs the risk of teleporting into solid walls and off-limits areas, or off the map altogether.

Good point, as you said, his question needed to be more specific but I simply used that code because he mentionned DBZ and I know when exactly that particular "skill" comes into play. Most of the time the character is flying and so he's above walls and everything dense. The only issue he'll have is checking if he goes out of bounds of his map or not.