February 17, 2020, 03:40:03 PM

Author Topic: Blink (Skill)  (Read 1148 times)

Offline Predz

  • Moderator
  • Level 7 Expert
  • *****
  • Posts: 552
  • Country: england
  • Warcraft: GO Co-Lead Programmer
Blink (Skill)
« on: January 25, 2016, 07:18:28 PM »
I am unsure if people would like me to do this, so I will try to anyway.

Below I am going to show the way I go about creating some really complex skills and ultimates for my new server I am working on. The first example I will show is my newly (hopefully unbreakable) teleport skill.

This new "blink" works by checking the space in which the player wants to teleport and then teleporting the player as long as they aren't trying to fly out of the map, or teleport into walls.

Code: [Select]
@Archmage.skill
class Blink(Skill):
    'Teleport a short distance in front of yourself. Ultimate.'

    max_level = 8

    _msg_a = '>> \x0bBlink: \x02Cannot \x03blink into a wall.'
    _msg_b = '>> \x0bBlink: \x02Cannot \x03blink into the air.'

    def _cooldown(self, **eargs):
        return 10 - self.level

    @cooldownf(_cooldown, message='>> \x0bBlink: \x05On cooldown for \x04{remaining_cd:0.0f} seconds\x01.')
    def player_ultimate(self, player, **eargs):
        view_vector = player.view_vector
        view_coordinates = player.view_coordinates

        # Here we check that the vector being teleported to is not inside wall.
        # Basically we say that the player's view coordinates is the closest object,
        # and so therefore if the object is closer than the teleport distance, then
        # there must be an object in the way.

        if player.origin.get_distance(view_coordinates) < 300:
            self.player_ultimate.remaining_cooldown = 0
            SayText2(self._msg_a).send(player.index)
            return

        teleport_vector = player.eye_location + (view_vector * 300)

        # Here we are checking the vector being teleported to, is not in the sky.
        # Teleporting into the floor will not matter, because the if statement above
        # will stop the callback, due to the floor technically being a wall.

        if teleport_vector.z-player.origin.z > 150:
            self.player_ultimate.remaining_cooldown = 0
            SayText2(self._msg_b).send(player.index)
            return

        player.teleport(teleport_vector, None, None)

Offline Kamilot

  • Level 0 Beginner
  • Posts: 10
Re: Blink (Skill)
« Reply #1 on: January 30, 2016, 09:49:05 AM »
Quote
I am unsure if people would like me to do this, so I will try to anyway.

I am sure having examples with explanations will help a lot for people to create interesting reaces (Not just attribute improvements.

On the subject of your code:
I have a question: is players position defined by the head/eye position
It just feels that the way you wrote it, people gonna be stuck in the walls all the time.
Simple Example: Person looking under the balcony is gonna be stuck in the balcony after the blink, any narrow holes also the problem (car wrecks for example).
Also not sure how teleport method works, but seems any kind of slope is a potential problem.

If I simple lack some knowledge, and completely wrong, please say so :)

Disclaimer: 1)I want to start coding races, but to lazy to really understand what Source.Python allows me to do. I studied this plugins code, but can't yet bring myself to read through Source.Python's code.
2) I haven't tried to use the skill

Offline Predz

  • Moderator
  • Level 7 Expert
  • *****
  • Posts: 552
  • Country: england
  • Warcraft: GO Co-Lead Programmer
Re: Blink (Skill)
« Reply #2 on: January 30, 2016, 04:33:28 PM »
The balcony situation technically would get you stuck, however due to the way hit-boxes work you would be able to just blink out.

The situation about blinking through car windows and stuff, is not possible, again due to the way the source engine handles model hit-boxes. The window in the car (the hole in where the window should be) is not actually empty space. Upon a trace ray hitting the window, it actually registers as a part of the world and so therefore you cannot blink inside the car.

The way the function works is by calculating the space 300 units in front of the players eyes. The teleport function is really clever for a player as if they try to blink forward into a slope, they will actually get raised up slightly. Clever source engine :P
« Last Edit: January 30, 2016, 04:35:12 PM by Predz »

Offline Kamilot

  • Level 0 Beginner
  • Posts: 10
Re: Blink (Skill)
« Reply #3 on: January 31, 2016, 01:55:20 PM »
Well, cool then. Still gonna do some extensive testing. :)

In case I would want a failproof teleport:
I saw you casting(tracing) rays in some heroes. How fast does it work? Is it ok to cast 10-20 rays for one skill. (let's say it's ultimate with a cooldown, so not spammable)

Offline Predz

  • Moderator
  • Level 7 Expert
  • *****
  • Posts: 552
  • Country: england
  • Warcraft: GO Co-Lead Programmer
Re: Blink (Skill)
« Reply #4 on: January 31, 2016, 02:06:35 PM »
If you call extensive amounts of trace rays then yes the server may experience some lag. However creating a few shouldn't cause a problem. As soon as you call the trace ray, a few milliseconds later calling another is not gonna cause the server any problems either.