Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sniper v2.1 #5522

Merged
merged 9 commits into from
Sep 19, 2016
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ If you do not want any data to be gathered, you can turn off this feature by set
* 05-032
* sinistance
* CapCap
* YvesHenri
* mzupan
* gnekic(GeXx)
* Shoh
Expand Down
44 changes: 44 additions & 0 deletions configs/config.json.map.example
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,50 @@
}
}
},
{
"type": "Sniper",
"config": {
"enabled": true,
"mode": "social",
"bullets": 3,
"homing_shots": true,
"special_iv": 100,
"order": ["missing", "iv", "priority", "vip", "expiration_timestamp_ms"],
"sources": [
{
"url": "http://localhost:5000/raw_data",
"key": "pokemons",
"mappings": {
"iv": { "param": "iv" },
"id": { "param": "pokemon_id" },
"name": { "param": "pokemon_name" },
"latitude": { "param": "latitude" },
"longitude": { "param": "longitude" },
"expiration": { "param": "disappear_time", "format": "milliseconds" }
}
}
],
"catch": {
"Snorlax": 1000,
"Dragonite": 1000,
"Growlithe": 600,
"Clefairy": 500,
"Kabuto": 500,
"Dratini": 500,
"Dragonair": 500,
"Mr. Mime": 500,
"Magmar": 500,
"Electabuzz": 500,
"Tangela": 500,
"Tauros": 500,
"Primeape": 500,
"Chansey": 500,
"Pidgey": 100,
"Caterpie": 100,
"Weedle": 100
}
}
},
{
"type": "MoveToFort",
"config": {
Expand Down
101 changes: 101 additions & 0 deletions docs/configuration_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
- [Description](#description)
- [Options](#options)
- [Example](#example)
- [Sniping _(Sniper)_](#sniping-_-sniper-_)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why, but navigating from the links does not jump to the new sniper section, and the sublinks go to the previous one (for example, new sniper description goes to old sniper description).

- [Description](#description)
- [Options](#options)
- [Example](#example)
- [FollowPath Settings](#followpath-settings)
- [Description](#description)
- [Options](#options)
Expand Down Expand Up @@ -720,6 +724,103 @@ This task will fetch current pokemon spawns from /raw_data of an PokemonGo-Map i
}
```

## Sniping _(Sniper)_
[[back to top](#table-of-contents)]

### Description
[[back to top](#table-of-contents)]

This task is an upgrade version of the MoveToMapPokemon task. It will fetch pokemon informations from any number of urls (sources), including PokemonGo-Map, or from the social feature. You can also use the old PokemonGo-Map project. For information on how to properly setup PokemonGo-Map have a look at the Github page of the project [here](https://github.com/PokemonGoMap/PokemonGo-Map). You can also use [this](https://github.com/YvesHenri/PogoLocationFeeder), which is an adapted version of the application that NecroBot used to snipe. There is an example config in `config/config.json.map.example`.

### Options
[[back to top](#table-of-contents)]

* `mode` - The mode on which the sniper will fetch the informations. (default: social)
- `social` - Information will come from the social network.
- `url` - Information will come from one or multiple urls.
* `bullets` - Each bullet corresponds to an attempt of catching a pokemon. (default: 1)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add an example here. I still don't understand what that means.
i understand that I will try to catch it only once (unlikely that this is its meaning :) ), and next option ensures that I won't miss.

* `homing_shots` - This will ensure that each bullet will catch a target. (default: true)
* `special_iv` - This will skip the catch list if the value is greater than the target's IV. This currently does not work with `social` mode and only works if the given `url` has this information. (default: 100)
* `time_mask` - The time mask used (if `expiration.format` is a full date). The default mask is '%Y-%m-%d %H:%M:%S'.
* `order` - The order on which you want to snipe. This can be one or multiple of the following values (default: [`missing`, `vip`, `threshold`]):
- `iv` - Order by IV, if any. See `min_iv_to_ignore_catch_list`.
- `vip` - Order by VIP.
- `missing` - Order by the target's pokedex missing status.
- `threshold` - Order by the threshold you have specified in the `catch` list.
- `expiration_timestamp_ms` - Order by the expiration time.
* `sources` - This should map a JSON param values from a given url. For example: different urls will provide different JSON response formats. If a param does not exist, you DO NOT have to specify it! Map bellow their corresponding values:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: bellow -> below

- `iv` - The JSON param that corresponds to the pokemon IV. Only certain sources provide this info. NOTE: social does not provide this info!
- `id` - The JSON param that corresponds to the pokemon ID. (required)
- `name` - The JSON param that corresponds to the pokemon name. (required)
- `latitude` - The JSON param that corresponds to the latitude. It will work if a single param is used for both `latitude` and `longitude`, eg.: "coords": "1.2345, 6.7890" (required)
- `longitude` - The JSON param that corresponds to the longitude. It will work if a single param is used for both `latitude` and `longitude`, eg.: "coords": "1.2345, 6.7890" (required)
- `encounter` - The JSON param that corresponds to encounter ID. This value is very unlikely to be provided by third-party urls. However, it is safely updated internally.
- `spawnpoint` - The JSON param that corresponds to spawnpoint ID. This value is very unlikely to be provided by third-party urls. However, it is safely updated internally.
- `expiration` - The JSON param that correspond to the pokemon expiration time.
- `expiration.format` - The time type. It can be either seconds, milliseconds or utc
* `catch` - A dictionary of pokemon to catch with an assigned priority (higher => better).

#### Example
[[back to top](#table-of-contents)]

```
{
"type": "Sniper",
"config": {
"enabled": true,
"mode": "url",
"bullets": 1,
"homing_shots": true,
"special_iv": 100,
"order": ["missing", "iv", "priority", "vip"],
"sources": [
{
"url": "http://pokesnipers.com/api/v1/pokemon.json",
"key": "results",
"mappings": {
"iv": { "param": "iv" },
"name": { "param": "namez" },
Copy link

@lucasbento lucasbento Sep 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here, must be { "param": "name" }.

Also needs to add id param, e.g.: "id": { "param": "id" }

Copy link
Author

@YvesHenri YvesHenri Sep 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely. Accidently pasted the config I was using to test whether it would recognize wrong mappings or not (not a type tho). 😄

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A mapping should only be added if it really exists in the response AND the value is correct. A special case is the pokesnipers; it has an ID but the value is somewhat a custom ID, not the pokedex id, so just dont put it.

"latitude": { "param": "coords" },
"longitude": { "param": "coords" },
"expiration": { "param": "until", "format": "utc" }
}
},
{
"url": "http://localhost:5000/raw_data",
"key": "pokemons",
"mappings": {
"iv": { "param": "iv" },
"id": { "param": "pokemon_id" },
"name": { "param": "pokemon_name" },
"latitude": { "param": "latitude" },
"longitude": { "param": "longitude" },
"expiration": { "param": "disappear_time", "format": "milliseconds" }
}
}
],
"catch": {
"Snorlax": 1000,
"Dragonite": 1000,
"Growlithe": 600,
"Clefairy": 500,
"Kabuto": 500,
"Dratini": 500,
"Dragonair": 500,
"Mr. Mime": 500,
"Magmar": 500,
"Electabuzz": 500,
"Tangela": 500,
"Tauros": 500,
"Primeape": 500,
"Chansey": 500,
"Pidgey": 100,
"Caterpie": 100,
"Weedle": 100
}
}
}
```

## FollowPath Settings
[[back to top](#table-of-contents)]

Expand Down
9 changes: 6 additions & 3 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ def _setup_event_system(self):
debug = self.config.debug

handlers.append(LoggingHandler(color, debug))

if self.config.enable_social:
handlers.append(SocialHandler(self))
handlers.append(SocialHandler(self))

if self.config.websocket_server_url:
if self.config.websocket_start_embedded_server:
Expand Down Expand Up @@ -689,6 +687,11 @@ def _register_events(self):
parameters=('type', 'incense_count')
)

# Sniper
self.event_manager.register_event('sniper_log', parameters=('message', 'message'))
self.event_manager.register_event('sniper_error', parameters=('message', 'message'))
self.event_manager.register_event('sniper_teleporting', parameters=('latitude', 'longitude', 'name'))

def tick(self):
self.health_record.heartbeat()
self.cell = self.get_meta_cell()
Expand Down
1 change: 1 addition & 0 deletions pokemongo_bot/cell_workers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .incubate_eggs import IncubateEggs
from .move_to_fort import MoveToFort
from .move_to_map_pokemon import MoveToMapPokemon
from .sniper import Sniper
from .nickname_pokemon import NicknamePokemon
from .pokemon_catch_worker import PokemonCatchWorker
from .pokemon_hunter import PokemonHunter
Expand Down
Loading