Traps/Hazards states are unclear

One can find all hazards with findHazards(), but this also will find the hazards which have been triggered by an entity, for example a closed bear-trap or an exploded fire-trap.

I have some questions regarding this:

  1. Is this the intended behaviour, like a very high cooldown for traps?

  2. Is there a way to question the state of a hazard, something like hazard.isActive or hazard.getCooldown()?

  3. What effect does the bear-trap provide to a trapped entity? I would like to know if there are some cheap shots possible at the poor soul which is trapped in there. Something like enemy.hasEffect(‘ensnared’).


Feel free to help yourself: CodeCombat - Coding games to learn Python and JavaScript

(hint: see the combat.Attacks section)

I am sorry, but there seems to be nothing which helps me. I can only see that it does some damage and has a cooldown of over 9000 (a DBZ reference I suppose). The other categories are equally useless for my search.

Did I miss something?

Hey Marrrk,

Hopefully I can answer some questions:

  1. I wouldn’t say it is intended behavior. If a trap has exploded, it probably shouldn’t be included in the findHazards() array.
  2. If you check the Thang Editor for the items Fire Trap, Bear Trap you can see what API methods are available during runtime. Go to the Components tab and look at programming.hasAPI. These are what you can reference. (findNearest(), position, team, type, etc.) If you think there should be additional information revealed, feel free to submit a patch by adding to the Thang’s data and saving it with a commit message.
  3. If you look up the actual code that drives the Bear Trap you will see how it operates. You can do so by creating a level using the Level Editor and looking at the code in the Component view. It would seem Bear Trap doesn’t apply an effect and is instead hard-coded to root an individual in place for a certain amount of time. Again, just like editing Thangs, you can submit a patch for individual Components (or Levels, or Systems!) and someone on the dev team will review it to see if it would be a good fit. Take a look around the available components to see if you can implement effects into the combat.BearTrap component.

I hope these answer your questions and provide you enough information to start exploring the codebase on your own!

I will look into that, have my thanks.