[solved] Where is "ai.attack" explained?

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
User avatar
doofus-01
Art Director
Posts: 4128
Joined: January 6th, 2008, 9:27 pm
Location: USA

[solved] Where is "ai.attack" explained?

Post by doofus-01 »

data/ai/lua/extCAexample.lua has the following line:

Code: Select all

 ai.attack(2, 12, 3, 12, 1, 1) -- showcasing the presence of the AI table
If I wanted to find out what that meant, where would I look?
Thanks.

(A bit unrelated, but if I wanted to search the forum for "ai.attack", how could I enter that without resulting in a (rejected) search for the two words attack and ai?)

EDIT:Changing title because this is solved.
EDIT2: Changing title again, new question. No, it was a stupid mistake on my part...
Last edited by doofus-01 on January 31st, 2016, 1:27 am, edited 3 times in total.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Where is "ai.attack" explained?

Post by Ravana »

Didnt think of way for searching "ai", but for attack att*ack works relatively well.

Searching git repo found trace of this ai.attack(attacker, defender, weapon). Might be worth looking data/ai/lua/ai_helper.lua and https://github.com/wesnoth/wesnoth/sear ... &type=Code
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Where is "ai.attack" explained?

Post by gfgtdf »

you can also look up the definition of the ai.attack function in this file https://github.com/wesnoth/wesnoth/blob ... a/core.cpp, it tslly you that it takes the parameters (attacker, defender, weapon_used, i_dont_know) where parameters 1 and 2 are eigher lua units, or locations passed as 2 integers.

I i understand that code correctly then this table https://github.com/wesnoth/wesnoth/blob ... e.cpp#L846 contains all the ai. functions.

In 1.13 you can maybe also alternativeley use [do_command] actionwml which lets you execute game actions in the format explained here in the replaywml wiki file.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
User avatar
doofus-01
Art Director
Posts: 4128
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: Where is "ai.attack" explained?

Post by doofus-01 »

Ravana wrote:Didnt think of way for searching "ai", but for attack att*ack works relatively well.
Thanks, using the astrix to tied things together looks like it works. I tried searching "ai*attack" and got no results, but at least it was a search for what I intended (I think).
gfgtdf wrote:you can also look up the definition of the ai.attack function in this file ...
Thanks as well, that answers my question. After all that, [do_command] is probably more my speed. Neither were quite what I was hoping for, but good to know anyway.

Thanks again, this is closed.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: [solved] Where is "ai.attack" explained?

Post by mattsc »

doofus-01: I know you already got your answer, but just for future reference: Customizing_AI_in_Wesnoth_1.8#Lua_AI_syntax
User avatar
doofus-01
Art Director
Posts: 4128
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: [solved] Where is "ai.attack" explained?

Post by doofus-01 »

Well that's embarrassing. Thanks for the link, mattsc.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: [solved] Where is "ai.attack" explained?

Post by mattsc »

doofus-01 wrote:(A bit unrelated, but if I wanted to search the forum for "ai.attack", how could I enter that without resulting in a (rejected) search for the two words attack and ai?)
I forgot to comment on this earlier. It's frequently bugged me that you cannot search the forums for "ai", but there's a workaround by using Google (and probably other search engines). In your case, you can type this into the Google search:

"ai.attack" site:forums.wesnoth.org

A minor annoyance is that the . is a placeholder here as Google ignores most special characters, so it will also find "ai attack", "ai_attack" etc., but there aren't so many instances of those on the forums that that is a serious problem.
Post Reply