{"action":"created","issue":{"url":"https://api.github.com/repos/wesnoth/wesnoth/issues/2247","repository_url":"https://api.github.com/repos/wesnoth/wesnoth","labels_url":"https://api.github.com/repos/wesnoth/wesnoth/issues/2247/labels{/name}","comments_url":"https://api.github.com/repos/wesnoth/wesnoth/issues/2247/comments","events_url":"https://api.github.com/repos/wesnoth/wesnoth/issues/2247/events","html_url":"https://github.com/wesnoth/wesnoth/issues/2247","id":277023978,"number":2247,"title":"Backstab special causes WFL error with wesnoth.simulate_combat in AI context","user":{"login":"mattsc","id":2106424,"avatar_url":"https://avatars3.githubusercontent.com/u/2106424?v=4","gravatar_id":"","url":"https://api.github.com/users/mattsc","html_url":"https://github.com/mattsc","followers_url":"https://api.github.com/users/mattsc/followers","following_url":"https://api.github.com/users/mattsc/following{/other_user}","gists_url":"https://api.github.com/users/mattsc/gists{/gist_id}","starred_url":"https://api.github.com/users/mattsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattsc/subscriptions","organizations_url":"https://api.github.com/users/mattsc/orgs","repos_url":"https://api.github.com/users/mattsc/repos","events_url":"https://api.github.com/users/mattsc/events{/privacy}","received_events_url":"https://api.github.com/users/mattsc/received_events","type":"User","site_admin":false},"labels":[{"id":35865188,"url":"https://api.github.com/repos/wesnoth/wesnoth/labels/bug","name":"bug","color":"fc2929","default":true},{"id":707219844,"url":"https://api.github.com/repos/wesnoth/wesnoth/labels/regression","name":"regression","color":"fc2929","default":false},{"id":622855864,"url":"https://api.github.com/repos/wesnoth/wesnoth/labels/WFL","name":"WFL","color":"d455f9","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-11-27T13:48:00Z","updated_at":"2017-12-02T16:19:07Z","closed_at":null,"author_association":"MEMBER","body":"When a Lua AI uses wesnoth.simulate_combat with an attacker that has the backstab special, this causes the following error:\r\n```\r\nERROR: TYPE ERROR: expected string but found null (null())\r\n  enemy_of\r\n  unit_at\r\n  direction_from\r\nformula type error: TYPE ERROR: expected string but found null (null())\r\n```\r\nThis almost certainly also means that the backstab special is no evaluated correctly.  The problem does not happen if wesnoth.simulate_combat is called during the player's turn.\r\n\r\nThe error originates in https://github.com/wesnoth/wesnoth/blob/master/data/core/macros/abilities.cfg#L293 and according to an irc chat with @CelticMinstrel yesterday, the reason is that `other` in the equation is null in this context.\r\n\r\nTo reproduce, I have attached a save from a slightly modified version of the Fast Micro AI test scenario which uses only Thieves.  Just load, type `:droid` and stderr will be flooded with error messages of that type.\r\n\r\n[Fast_Turn_1_backstab_bug.gz](https://github.com/wesnoth/wesnoth/files/1505999/Fast_Turn_1_backstab_bug.gz)\r\n"},"comment":{"url":"https://api.github.com/repos/wesnoth/wesnoth/issues/comments/348702364","html_url":"https://github.com/wesnoth/wesnoth/issues/2247#issuecomment-348702364","issue_url":"https://api.github.com/repos/wesnoth/wesnoth/issues/2247","id":348702364,"user":{"login":"CelticMinstrel","id":578731,"avatar_url":"https://avatars3.githubusercontent.com/u/578731?v=4","gravatar_id":"","url":"https://api.github.com/users/CelticMinstrel","html_url":"https://github.com/CelticMinstrel","followers_url":"https://api.github.com/users/CelticMinstrel/followers","following_url":"https://api.github.com/users/CelticMinstrel/following{/other_user}","gists_url":"https://api.github.com/users/CelticMinstrel/gists{/gist_id}","starred_url":"https://api.github.com/users/CelticMinstrel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CelticMinstrel/subscriptions","organizations_url":"https://api.github.com/users/CelticMinstrel/orgs","repos_url":"https://api.github.com/users/CelticMinstrel/repos","events_url":"https://api.github.com/users/CelticMinstrel/events{/privacy}","received_events_url":"https://api.github.com/users/CelticMinstrel/received_events","type":"User","site_admin":false},"created_at":"2017-12-02T16:19:07Z","updated_at":"2017-12-02T16:19:07Z","author_association":"MEMBER","body":"Ideally the fix would be to not try to recover the unit from the location. I haven't looked at the code, does that seem viable @gfgtdf?"}}
{"actor":{"display_login":"CelticMinstrel"}}