Swift daggers hero.throw() issue

Yeah, that’s really cool. I’m sure he could fix a few bugs there are lying around :grin:. It is a very cool project.

1 Like

I tried making a function for the hero.throw() method.

Still not working. it keeps giving me this ( ; ) needs to be included error.

I don’t know anything about c++, but I think in the function you have to write

auto enemy = hero.findNearestEnemy();
if (enemy){
   if(hero.isReady("throw")){
     hero.throw(enemy);
}
}

1 Like

And welcome to the forum! :partying_face:

1 Like

Hi @LordlyLump Welcome to Discourse :partying_face: :tada:
Wasn’t C++ released like 2 days ago in codecombat?

2 Likes

Uh cool peter. Thanks ill try that. :slight_smile:

Oh is it that new! Really cool! Thanks weary :slight_smile:

Hmm. I tried the code you suggested.

I still get the same error.

CPP is pretty new, and experimental.
Have you tried properly indenting your code? As well as adding a while true loop? Using pseudocode, you’d want the following.

  1. Get the nearest enemy as a variable. Hint: auto enemy = hero.findNearestEnemy();
  2. Check if there’s an enemy. Hint: if (enemy){}
  3. If an enemy exists, then check if you can throw the dagger. Hint: if (hero.isReady("throw"){}
  4. If you can throw the dagger, then throw the dagger at an enemy. Hint: hero.throw(enemy);
  5. If you can’t throw the dagger, then use a normal attack() method. Hint: else{ hero.attack(enemy); }

All of this inside a while true loop.

Hello Chaboi.

Thank you so much for all the hints.

It is so cool that CPP is available here. I really love the language.

I have tried all of your suggestions and i am thankfull for them :).

Sadly the issue persists.

Can you make throw work?

@LordlyLump,
Thanks for reaching out. I forgot about something very important in CPP. throw is actually a default method in CPP other than codecombat. It’s used as an exception handler. You can read more about the use here. Seems like hero.throw() and throw is conflicting. Thanks for the report. I’ve forwarded this issue here.

1 Like

Really cool Chaboi!

Thank you for the link :).

Maybe just change the name of the in game function to “toss” instead of “throw”?

Welcome to the forum! This is a family-friendly place where coders can share bugs, ask for help on any CodeCombat level (don’t forget to post your code correctly), or just hang out with other coders. But before you proceed, please check out our guidelines: this topic.
Have a great time! :partying_face:

Hello! You’re replying to a post that was actually from a year ago, which means this problem was already sorted out. Thanks so much for trying to help though!
Hope you have a good experience on the forum! :partying_face:

Um. Thank you, I do appreciate you getting back to me on that one.

I am currently working through the C++ course. It appears to me that this issue isn’t, in fact, sorted out, as the level in question, Swift Dagger, still won’t function.

Here is my recent screenshot, from less than a minute ago at the time of uploading that shows the hero.throw and throw c++ command are still conflicting with each other.

you can see the blue “throw” command indicating a c++ anchor term in the “hero.throw” command, and the program asking for me to close an expression that appears to me to be closed.

I was definitely curious as to why this hasn’t been resolved yet, nearly a year later, and if I take you are your word as a person with more experience on the forums than me, then I have to presume maybe this issue was “closed” prematurely, as evinced in the live program today. That was why i proposed a solution like I did, perhaps to start the ball rolling on development of a solution.

I’m new to this website, and comp-sci in general, if I’m missing something important, here, let me know. I didn’t see a solution when I was looking in this thread, or any indication that this problem had been resolved on the other levels that require the use of the throw command.

CPP isn’t fully implemented yet, so there’s a lot of issues. (Like, a lot. In mountain levels it’s pretty much impossible). For the throw issue, I’m not sure why it’s still being interpreted as the exception handler. It should be a really quick fix in the parser. :thinking:

1 Like

Ok.

Thanks for the update. I’m working my way through, I’ll get as far along as I can, and then decide where to go from there.

I bought the subscription only for the C++ since it was subscribers only and it did not say it was experimental.It is concerning that people still havent done anything about an existing bug for a year.I stuck here too and that’s how i find this page.Now i am reading that Mountains Leves are impossible?That’s really not a good look on codecombat.I can understand there are bugs and all but what i don’t get is everyone is aware of this situtation and yet they are not doing anything not even inform the users.I am not on mountain levels yet,if it checks out as you say I will definetly unsubscribe.I feel cheated just by reading this.

1 Like

Same here. Is the bug seriously not fixed yet? That’s ridiculous, will definitely also unsubscribe. Drives me nuts.