Casting most talents is pretty easy, but some of them require further input.
Generally speaking, you set the target of the player and then ask the player to cast its talent. Simple.
But then you get talents like Rush. Casting rush prints "<name> rushes out!" into the console and enters the line-targeting mode so a player can click on the tile they want to rush towards. Naturally, this confuses the player AI who just wanted to cast the power. Similarly, single-target abilities like Dual Strike, when used in the presence of multiple enemies, enters a targeting mode as well.
Is there a way to A) bypass this targeting mode to just cast the power on the target of my choosing, or B) a good way to recognize that a targeting mode has been engaged and to therefore target an enemy?
Picky-Choosey Talent Casting
Moderator: Moderator
Picky-Choosey Talent Casting
Currently developing the Player AI addon. You can get it from the T-Engine Addon Hub or Steam
You can also view the source code.
You can also view the source code.
Re: Picky-Choosey Talent Casting
when you annoy a mob, then it targets you.
you know, when you mouse over someone, at the near bottom it says "target: nothing" or "target:[player]"
if you have minions, the enemies can target them instead.
you could see if that can also be applied to your AIplayer?
i haven't seen a mod who would have problem with it so there may be a solution somewhere in vanilla already, just need to look closely.
you know, when you mouse over someone, at the near bottom it says "target: nothing" or "target:[player]"
if you have minions, the enemies can target them instead.
you could see if that can also be applied to your AIplayer?
i haven't seen a mod who would have problem with it so there may be a solution somewhere in vanilla already, just need to look closely.
Re: Picky-Choosey Talent Casting
Not to be rude, but the reason you've never heard of people struggling with this before is because, AFAIK, nobody has really tried to perform actions as the player. People make new talents and give the player the right to cast them, but that's not the same thing at all. What I may need to look into is using the actual ToME AI interface to run the player, cause right now I'm actually just hooking act() and manually performing actions on the player's behalf. But back to the current problem.
Those displays you point out are the targets *of the enemy*. Even so, the target of the player is easy to set. You just call Player.setTarget(enemy). That's super easy, and it's what the code does right now. The issue comes from talents with "special" targeting.
The issue is that the effect of casting certain talents doesn't check the target, it enters a separate game mode with a targeting cursor allowing the user to pick a given actor (or sometimes tile) to target. In this mode, my normal act() hook won't trigger (because this is a part of the previous act() call) so unless I can identify that i've just used a talent that has activated this mode (and obnoxiously, some talents SOMETIMES activate targeting mode) I won't really be able to react and use this new targeting interface, and the AI will just hang.
I need to deal with that mode, by either handling it or bypassing it. Generally speaking the equivalent of an "enter" keypress (whatever that is internally) is the right answer for tile-targeted powers like Rush or any kind of bolt spell. For the talents that sometimes enter this mode, that generally means it's a single-target melee talent and you have multiple adjacent enemies. In this case, the right answer is a movement keypress in the direction of the target. To make my life more interesting, I would expect that calling the internal move() function at that time. will not at all do what I want, and may crash the game.
Those displays you point out are the targets *of the enemy*. Even so, the target of the player is easy to set. You just call Player.setTarget(enemy). That's super easy, and it's what the code does right now. The issue comes from talents with "special" targeting.
The issue is that the effect of casting certain talents doesn't check the target, it enters a separate game mode with a targeting cursor allowing the user to pick a given actor (or sometimes tile) to target. In this mode, my normal act() hook won't trigger (because this is a part of the previous act() call) so unless I can identify that i've just used a talent that has activated this mode (and obnoxiously, some talents SOMETIMES activate targeting mode) I won't really be able to react and use this new targeting interface, and the AI will just hang.
I need to deal with that mode, by either handling it or bypassing it. Generally speaking the equivalent of an "enter" keypress (whatever that is internally) is the right answer for tile-targeted powers like Rush or any kind of bolt spell. For the talents that sometimes enter this mode, that generally means it's a single-target melee talent and you have multiple adjacent enemies. In this case, the right answer is a movement keypress in the direction of the target. To make my life more interesting, I would expect that calling the internal move() function at that time. will not at all do what I want, and may crash the game.
Currently developing the Player AI addon. You can get it from the T-Engine Addon Hub or Steam
You can also view the source code.
You can also view the source code.
-
- Uruivellas
- Posts: 708
- Joined: Wed Apr 30, 2008 5:55 pm
Re: Picky-Choosey Talent Casting
You can set game.target.forced = {x, y, target}. See technique/skirmisher-slings/T_HURRICANE_SHOT for an example.
The relevant code is in engine/interface/GameTargeting.lua:targetGetForPlayer
The relevant code is in engine/interface/GameTargeting.lua:targetGetForPlayer
Addons: Arcane Blade Tweaks, Fallen Race, Monk Class, Weapons Pack
Currently working on Elementals. It's a big project, so any help would be appreciated.
Currently working on Elementals. It's a big project, so any help would be appreciated.

Re: Picky-Choosey Talent Casting
Thanks, that worked perfectly. Talents are now used properly. I'll clean up my test prints and try to iron out some of the weird halts and infinite autoexplore loops and maybe get a release posted later today.
Currently developing the Player AI addon. You can get it from the T-Engine Addon Hub or Steam
You can also view the source code.
You can also view the source code.
Re: Picky-Choosey Talent Casting
We should probably fix Rush.
I consider any talent log output printed before the described action actually executes to be a bug.
... The thing about Rush is that it uses a "message" entry in the talent definition table, which is nice, but there is clearly a problem with its working. Now, the vast majority of talents in both official ToME and any addons do not use this property, so maybe it could be altered drastically by moving it to the end of the talent's execution, or just plain deprecated.
For reference:
I consider any talent log output printed before the described action actually executes to be a bug.
... The thing about Rush is that it uses a "message" entry in the talent definition table, which is nice, but there is clearly a problem with its working. Now, the vast majority of talents in both official ToME and any addons do not use this property, so maybe it could be altered drastically by moving it to the end of the talent's execution, or just plain deprecated.
For reference:
Code: Select all
name = "Rush",
type = {"technique/combat-techniques-active", 1},
message = "@Source@ rushes out!",
require = techs_strdex_req1,
...
Re: Picky-Choosey Talent Casting
That would make sense. It always feels odd that it announces "<Player> rushes out!" before you even pick your destination, not to mention the internal return where you don't have a path and it "succeeds". Fixing the base ToME functionality around that to be more consistent would be much appreciated.
Currently developing the Player AI addon. You can get it from the T-Engine Addon Hub or Steam
You can also view the source code.
You can also view the source code.