# Headhunter is vicious

**URL:** <https://discourse.codecombat.com/t/headhunter-is-vicious/2773>\
**Category:** Adventurer\
**Created:** [February 19, 2015, 6:26am UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773 "2015-02-19T06:26:16Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [February 21, 2015, 4:05am UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/22 "2015-02-21T04:05:31Z")

</div>

No you can’t. it’s 3 seconds. So you would have to stand there doing nothing for 3 seconds to get teleported back.

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [February 21, 2015, 4:11am UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/23 "2015-02-21T04:11:47Z")

</div>

Cool, 'cause that is how I have my routine coded (no escape for 3 secs)

---

<div class="post-metadata">

**Author:** ![eiler13](https://avatars.discourse-cdn.com/v4/letter/e/b77776/32.png) [@eiler13](https://discourse.codecombat.com/u/eiler13)\
**Post date:** [February 21, 2015, 4:36am UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/24 "2015-02-21T04:36:48Z")

</div>

> [@sotonin](#):
>
> No you can’t. it’s 3 seconds. So you would have to stand there doing nothing for 3 seconds to get teleported back.

Hmm… that is interesting and it makes more sense now what might be happening to me… thanks for that info.

I still don’t know exactly what is happening, just that my code works differently now than it did 12 to 24 hours ago. The timing is off now, such that the loop doesn’t work the same.

Also, something is different about movement. This may sound crazy (and no drugs are alcohol are involved, I promise) but when my hero moves to a target, he often seems to skid or slide past the target instead of stopping exactly on the target like he did previously (I think).

Like I said, it’s a cool level, but can be hard to figure out what is going on at times due to the teleporting.

---

<div class="post-metadata">

**Author:** ![eiler13](https://avatars.discourse-cdn.com/v4/letter/e/b77776/32.png) [@eiler13](https://discourse.codecombat.com/u/eiler13)\
**Post date:** [February 21, 2015, 4:42am UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/25 "2015-02-21T04:42:50Z")

</div>

> [@sotonin](#):
>
> All teleports are both entries and exits. so #2 doesn’t really make any sense.

In thinking about this some more, I don’t think it matters given the 3 second delay, which I did not realize was there. All I was saying is that when you re-appear after a teleport, it’s at a location that is also a teleport entry. It could be anywhere on the screen, it doesn’t have to be to another teleport location. Unless there is some law of physics regarding teleportation that I am unaware of. 😉

> [@sotonin](#):
>
> 3 - that doesn’t really make any sense either.

A teleport location could be an item in this sense:

```python
teleport = self.findNearest( self.findTeleport() )
self.moveXY( teleport.pos.x, teleport.pos.y )

```

I am just throwing this out there as a concept, I don’t know the coding specifics of how the teleporting happens, or what is feasible to code.

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [February 21, 2015, 4:51am UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/26 "2015-02-21T04:51:23Z")

</div>

I don’t know the feasibility of objectification of teleporters, but while we wait for the real answer I wrote my code something like this (pulling code and x,y # out of thin air to show the idea)

let’s say there were two porters

```python
porterloc = [(5,5),(100,100)]

def usePorter(num)
    px,py = porterloc[num]
    self.moveXY(px,py)

loop:
    #blahblahblah
    useporter(1)

```

would move you to 100,100 and if the porter was ready for use BAMPF!

---

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [February 21, 2015, 6:29am UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/27 "2015-02-21T06:29:03Z")

</div>

It perfectly feasible but very confusing and not something we’re gonna do. And it’s not going to solve anything (im not actually sure there’s a problem to be solved)… we’d have to respawn the potion or whatever is the teleporter in 3 seconds anyways so it’s re-usable. so it would in the end be the exact same situation.

it sounds like you just want an easier way to get teleports. But i don’t think something used on one level warrants a whole new component or systems behind it. Perhaps if we start using them a lot we could build a whole component around it that registers them. But i’m not exactly sure how players would get the skill. Typically we don’t make skills and put them on items if they are only going to be beneficial on a single or even a handful of select levels.

It’s only 4 telelports. just make an array of objects that have the x / y coords then loop over it and check distance to those coords to decide which one to move to

---

<div class="post-metadata">

**Author:** ![Vettax](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vettax/32/1514_2.png) [@Vettax](https://discourse.codecombat.com/u/Vettax)\
**Post date:** [February 21, 2015, 7:45am UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/28 "2015-02-21T07:45:44Z")

</div>

Maybe you’re talking only for advance players, because at this step of the game, creating object and calculate distance by hand was not learned in previous level.

About the use of portal, @sotonin, is what I observed a correct behavior:  
I try to catch an item close to a portal, so I use movexy to this item. Just before reaching the item position, the hero enter the portal and appear at the other end of the level, and she continues to target the same position, as she did not reach it. I lost control.

That make me thing that it could be great to have an additionnal and optional parameter to attacks and movexy : the distance we want to move before exiting the function and get back control on the hero. Same for attack because in one level, I also lost control of my hero because she try to attack an enemy that was always moving. And she can’t reach him : No more control. Ex:

```python
this.movexy(pos.x,pos.y,3); // move 3 meters in the direction of the target
this.attack(enemy,5); // Try to attack the enemy, but stop after 5m if this can't reach it

```

@nick, is it something feasible ? In the initial levels (in the old ages), the commands were not blocking like it is now, so it was possible to change direction taking into account the real time of the level.

@eiler13, I must stick to warrior right now, because I don’t have any equipment for the ranger or magician yet. The advantage of the ring is that you could use it for everyone (with hanzo also, if I have enough gems one day).

---

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [February 21, 2015, 1:59pm UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/29 "2015-02-21T13:59:27Z")

</div>

Calculating distance is not something learned by desert? Thats something learned very early on. Most people will use flags for this level anyways though.

```python
this.distanceTo(someobject with x and y);

```

I adjusted the level so the coins shouldn’t spawn too close to the teleporters anymore. this should help with that.

---

<div class="post-metadata">

**Author:** ![eiler13](https://avatars.discourse-cdn.com/v4/letter/e/b77776/32.png) [@eiler13](https://discourse.codecombat.com/u/eiler13)\
**Post date:** [February 21, 2015, 3:23pm UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/30 "2015-02-21T15:23:44Z")

</div>

> [@sotonin](#):
>
> It’s only 4 telelports. just make an array of objects that have the x / y coords then loop over it and check distance to those coords to decide which one to move to

Yeah, that’s what I’m doing actually, though I think I’ll adopt/steal Vlevo’s approach and do it in a function.

My point is not really about what’s possible to code but whether we have to code specific xy coordinates as opposed to more conceptual code that says move towards “nearest portal”. The former is a lot more verbose and my point is not really about the people discussing things in this forum but the kids who are using this site to learn. But maybe these repeatable levels are more about advanced users anyway.

Anyway, just meant to share some thoughts and ideas. No criticism intended, and no expectation that my advice is useful. 😉

---

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [February 21, 2015, 3:37pm UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/31 "2015-02-21T15:37:59Z")

</div>

Yeah. I understand. Most people will probably use flags anyways. Unfortunately as i described previously, it would be hard to justify making a whole new set of components for teleports to make them easily accessible when it’s only useful for one level or even a handful of them.

---

<div class="post-metadata">

**Author:** ![eiler13](https://avatars.discourse-cdn.com/v4/letter/e/b77776/32.png) [@eiler13](https://discourse.codecombat.com/u/eiler13)\
**Post date:** [February 21, 2015, 4:04pm UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/32 "2015-02-21T16:04:18Z")

</div>

LOL, I forgot about flags. I basically don’t use flags on repeatable levels since you can’t test them with the run, only the submit. Also, seems sort of like taking the lazy way out. Anyway, thanks for explaining.

---

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [February 21, 2015, 4:04pm UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/33 "2015-02-21T16:04:43Z")

</div>

Agreed. im the same way. Hate flags 🙂

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [February 21, 2015, 5:57pm UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/34 "2015-02-21T17:57:38Z")

</div>

I believe Vettax was refering to calculating distance to points on the map and not to objects since you keep shooting down the obectification of the teleporters. (not saying you’re wrong, just pointing out you say use an object at the same time you’re saying , no way the teleporter will be given to us as an object.)

So, which level teaches how to “create object with x and y”?

(Sarven Treasure is a free level, the teaching level should also be.)

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [February 21, 2015, 9:18pm UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/35 "2015-02-21T21:18:43Z")

</div>

Last night, I finally fixed the bug that was causing a dropped frame of idleness in between every hero action, plus the auto-braking in between every action, that was making `move` basically useless and also making `moveXY` much less fluid. So if you noticed any timing or balance changes on any levels starting last night, that’s probably why. This also makes you slide a bit if you transition into an action that doesn’t including any braking, like `say` or `cast`.

Keep your eye out for any levels that don’t work quite right any more. The heroes are more responsive, move works, even the gaps between attacks are less, but this can change a lot of little balance issues.

This change might have affected the code we were using in Sarven Treasure to cancel the in-progress movements during a teleportation. Will check it out. By the way, the `move` boots are awesome now for this sort of thing (since they allow you to change your targetPos every frame), so try them out.

We’ll be teaching the object literal syntax, like `{"x": 34, "y": 30}`, in the first few levels in Cloudrip Mountain.

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [February 21, 2015, 9:29pm UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/36 "2015-02-21T21:29:53Z")

</div>

I am also having a new problem (started last night) with a “infinite loop” that shouldn’t be infinite but I’ll open a new topic for that.

* * *

by “object literal syntax, like {“x”: 34, “y”: 30}” do you mean that we can/could:

if self.distanceTo({“x”: varx, “y”: vary}) \< somedistance:

* * *

I’m not sure I understand how the “move” command will work… is it basically the same as computing a partial distance and "moveXY"ing to it then if I still want to go to the original destination I compute the next partial and moveXY to it, except that the move-partial stuff is handled for me???

---

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [February 21, 2015, 9:36pm UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/37 "2015-02-21T21:36:40Z")

</div>

Yes. thats exactly correct about the objects. The move command is identical to movexy except you pass an object just like that in instead of individual x and y variables. It will not lock so you can be more responsive. (ie your script runs more cycles instead of waiting til you get there before allowing you to do any more actions)

I couldn’t get move boots working correctly on sarven treasure. it still seems to get stuttery. however they worked for treasure grove.

Also. i’m not “shooting down” the request for an object specifically for teleporters, I think it would be neat too, but I don’t think anybody will devote resources to building it for just one level. or even a few levels. It’s too specific. I’ve wanted to add specific things for levels but was informed that it would just confuse people. 🙂

---

<div class="post-metadata">

**Author:** ![eiler13](https://avatars.discourse-cdn.com/v4/letter/e/b77776/32.png) [@eiler13](https://discourse.codecombat.com/u/eiler13)\
**Post date:** [February 21, 2015, 11:29pm UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/38 "2015-02-21T23:29:52Z")

</div>

> [@nick](#):
>
> This also makes you slide a bit if you transition into an action that doesn’t including any braking,

Man I am glad to hear that. I thought maybe I was crazy for thinking my hero was skidding around like on skates. Also makes me wonder if in some cases I was skidding into the portal accidentally because I was coding to move near the portal, and then wait for enemies to get closer before going into the portal.

Just tried out the leap boots and move but didn’t have much luck with it – kind of slow and stuttery, but maybe I didn’t do it correctly. I’ll just wait until we get some instructions on that or see how other people use them…

---

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [February 22, 2015, 12:13am UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/39 "2015-02-22T00:13:43Z")

</div>

No you are right. for some reason on that level it doesn’t work right. It works great on multiplayer treasure grove though. I have no idea what could be different about that level though, very strange

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [February 22, 2015, 3:34am UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/40 "2015-02-22T03:34:35Z")

</div>

Cool (distanceTo thing)

So,

move  
attack

would be the same as

moveXY  
attack

since the attack waits until the move is done either way.

but

move  
\<insert bunches of code\>  
attack(enemy)

is much better than the same with moveXY since it doesn’t wait for the move to finish before processing some more code.

If that is correct then do multiple move commands stack allowing processing to continue until they are either done or you hit a blocking action?

(Sorry for being so slow on the uptake.)

Awesome! thanks. If so then I really may have to break down and buy a pair.

Too bad there weren’t “item test” levels (fitting room, whatever one wishes to call it), where npc-x lets you borrow his boots (or what not) so we could get a taste of what we were missing by not buying item X-Y-Z. 😄

---

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [February 22, 2015, 8:13pm UTC](https://discourse.codecombat.com/t/headhunter-is-vicious/2773/41 "2015-02-22T20:13:39Z")

</div>

Not quite. .attack moves to the enemy (probably using moveXY behind the scenes.) so that wouldn’t work it would still lock but on the attack instead.

You would set your script up so if at any time certain conditions are met: do this.

if enemy and distance \<= 5 or whatever  
attack  
else  
move({x: blah, y: blah});

but then you could add more conditions in there like if item go after the item etc. it will continually loop over all the conditions (even while moving) what the end result is… you could be in the middle of moving towards an item or enemy and suddenly change your mind because of some other condition that happens. (moving towards item but change mind because enemy is close now). So basically one long set of conditions that if matched do something. The difference being, with moveXY the script basically halts until you get to the coords. this doesnt happen with move it continues to cycle over and over through the loop while moving.

[Previous page](https://discourse.codecombat.com/t/headhunter-is-vicious/2773.md?page=1)

[Next page](https://discourse.codecombat.com/t/headhunter-is-vicious/2773.md?page=3)
