Home   Help Search Login Register  

Author Topic: AI using "action" command  (Read 1562 times)

0 Members and 1 Guest are viewing this topic.

sussmori

  • Guest
AI using "action" command
« on: 23 Aug 2002, 02:53:49 »
Hi,

I didn't get an answer for this before the old forum was killed.

Is it possible for AI to use the action command to activate a script-added action (ie. action added by addAction?

e.g. with addAction["Use knife", "knife.sqs"]
can
_aiUnit action ["use knife"] be made to work?

I can't get it to work.

thx,
Sussmori

P.S. don't bother saying "just modify the script to run the .sqs", i already know this :)

mikeb

  • Guest
Re:AI using "action" command
« Reply #1 on: 23 Aug 2002, 02:59:08 »
Love to help but I can't!

Just want to know if you actually have a knife script and addon (res?) and whether I could steal/borrow/obtain it.

Sorry to reply and not help in anyway.

sussmori

  • Guest
Re:AI using "action" command
« Reply #2 on: 23 Aug 2002, 03:13:04 »
U'll have to wait for www.invasion1944.com :)

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:AI using "action" command
« Reply #3 on: 23 Aug 2002, 03:40:25 »
I'd suggest trying something like:

[ unit ] exec "knife.sqs"

As that should be exactly the same as the player executing the script by clicking on the action... except of course the AI is now the first arguement ;)
« Last Edit: 23 Aug 2002, 03:59:57 by Sui »

sussmori

  • Guest
Re:AI using "action" command
« Reply #4 on: 23 Aug 2002, 06:04:29 »
I'd suggest trying something like:

[ unit ] exec "knife.sqs"

As that should be exactly the same as the player executing the script by clicking on the action... except of course the AI is now the first arguement ;)

Yes i know this, but for many reasons i won't go into, i wish to know if it's possible for AI to use the 'action' command
« Last Edit: 23 Aug 2002, 06:16:14 by sussmori »

Offline KTottE

  • Former Staff
  • ****
Re:AI using "action" command
« Reply #5 on: 24 Aug 2002, 00:07:36 »
In my experience, it's possible for the AI to use existing actions.
Action "EngineOn" and so on.
But you can't make the AI use custom actions. At least, as I said, not in my experience.
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Offline uiox

  • Contributing Member
  • **
Re:AI using "action" command
« Reply #6 on: 24 Aug 2002, 18:34:15 »
AI can use the action command if you are the AI... :)

After a command like switchcamera "group", but it's not the solution of your problem.
If you don't want use the solution of Sui you can't.

Offline Peter_Bullet

  • Members
  • *
  • "The evil that men do lives on and on"
Re:AI using "action" command
« Reply #7 on: 08 Nov 2004, 08:10:49 »
Hehe, I'm in school reading these old ones through...

Its
ActionName = Ap AddAction ["Use Knife","Knife.sqs"]
Execute the action like: Ap action ActionName or something like that (quotes, maybe?)!

Komuna

  • Guest
Re:AI using "action" command
« Reply #8 on: 10 Nov 2004, 22:14:37 »
I have two answers fot you:

No, it's not possible and...
Yes, it's possible.

First: AI is AI, therefore completly stupid. So, if you want the AI to call the actions by themselves - as if they had their own will - you might want to get OFP's source code...

Second: Sure, AI can perform the actions, as long as the player asks it to do so. The player chooses a unit in his/her group - F1 ~F12 -, opens the Commands->Actions menu (is it 6?) and presses the action number. Then, the AI will activate the script that is associated with the action and, thus, become the one of the arguments. A far as I remember, the arguments returned are: [action attached to whom, who activated, action index]; you should confirm, though.

I hope the explanation fits your purposes. :D

#Edit - Note:

Well, uiox sugests trying the 'action' command, but, as he supposes, I think that it's available only for a few hard-coded actions, too.

Thus, Sui's solution is the best - your script just needs a bunch of conditions, a waipoint for the unit and the virtual action.

#Edit 2 - Note:

Just occured:

If you attach the action to an AI unit, either the player or other unit could activate it, so, I think that the AI is able to activate an action on themselves - like the common "Lower Goggles" action that we're used to.

Long live the community!
« Last Edit: 10 Nov 2004, 22:26:32 by Komuna »

Offline KTottE

  • Former Staff
  • ****
Re:AI using "action" command
« Reply #9 on: 11 Nov 2004, 11:16:42 »
I'll just hop in to confirm that it is:

Object - the object the action is attached to.
Unit - the unit who activated the action.
Index - Index of the action.'

You can for instance make sure that only the unit that has the action attached to him will use it:

?((_this select 0) != (_this select 1)): exit

And you could remove the action as soon as it's used:

(_this select 0) removeAction (_this select 2)

As for using the action-command to trip actions added with addActions, I'm not sure it's possible, but it's worth experimenting with.
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:AI using "action" command
« Reply #10 on: 13 Nov 2004, 23:19:16 »
You know, I've wondered about this for a while too... I'm still hopeful and think that there may be a way to do this.

If you look through the "Time for action has come" thread in the General board, you'll see that someone posted a list of all the possible "action" commands (from the game's exe, I guess). There is one action there that sounds like it might be for this purpose: "User Type". I don't know what else this could be used for, but I'm hoping that it is for either (a) actions added through the addaction command, or (b) actions added via the config.

I've already tried as many combinations as I can think of for the first option, but to no avail. Hopefully I missed something, and it is possible though... One of these days I'll learn how actions work via the config, and try it that way.


So basically I have nothing to add here, really :P. As of yet, there is no way to do that, AFAIK. But the fact of the matter is, you don't really NEED to be able to do that, because you can always just "fake it".
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!