Home   Help Search Login Register  

Author Topic: addAction problem...  (Read 875 times)

0 Members and 1 Guest are viewing this topic.

gundernak

  • Guest
addAction problem...
« on: 03 Feb 2004, 23:46:35 »
Hi all,

I have a boat(mark II) on the sea, my group is aboard.

If the gunner or the driver is killed, the other group members (assigned as Cargo), can not take the driver or the gunner seat.

Therefore I started to write a simple script, but I faced a problem. The script is:
Code: [Select]
_dude = _this select 0
_boat = vehicle _dude

#loop
@ _dude != vehicle _dude and not alive gunner _boat

gunnerseat = _boat addAction ["to gunner's seat","moveingunner.sqs"]

@ alive gunner _boat

_boat  removeAction gunnerseat

goto "loop"

exit

In addAction there must be a file name, not a command.

In the script called by the action (I named now "moveingunner.sqs") there should be a moveInGunner command for _dude.

Yes, but in this script how can I define who used the action???

thanks in advance

Offline Welshmanizer

  • Members
  • *
Re:addAction problem...
« Reply #1 on: 04 Feb 2004, 00:51:33 »
There are a few problems with this script:

1. @ _dude != vehicle _dude and not alive gunner _boat is wrong. The correct line depends on who _dude is. It could be this:

@ _boat != vehicle _dude and not alive gunner _boat

or possibly:

@ _dude != gunner _boat and not alive gunner _boat


2. gunnerseat = _boat addAction ["to gunner's seat","moveingunner.sqs"] is wrong. It should be:

gunnerseat = unitname addAction ["to gunner's seat","moveingunner.sqs"]

Replace unitname with the name of the unit you want to add the action to (who will use the action). It must be a Playable unit (or of course the Player).


3. _boat  removeAction gunnerseat is wrong. It should be:

unitname removeAction gunnerseat


gundernak

  • Guest
Re:addAction problem...
« Reply #2 on: 04 Feb 2004, 01:26:26 »
I think you did not understand exactly the situation, or I did not tell enough about it.

well...

1.
_dude is the playable unit who was passed into the script as select 0.

_boat is the vehicle he is in.

@ _dude != vehicle _dude and not alive gunner _boat means _dude is in a vehicle and in the _boat the gunner is dead. This is the condition...

But after experimenting _dude != vehicle _dude is not needed, only not alive gunner _boat is perfectly describes the condition.

2.
_boat is definetly a unitname. It referes the unit (mark II pbr) in which _dude starts the mission.

.........
after experimentin I changed the base of it. I start the script from the boat, so now it is select 0:
Code: [Select]
_boat = _this select 0

#loop
ActionUsed = false
@ not alive gunner _boat
gunnerseat = _boat addAction ["to gunner's seat","moveingunner.sqs"]

@ ActionUsed

_boat removeAction gunnerseat

goto "loop"

exit
moveingunner.sqs:
Code: [Select]
_boat = vehicle player

ActionUsed = true
player action ["eject",_boat]
player assignAsGunner _boat
player moveInGunner _boat

exit
This is perfectly what I wanted. I tryed this and it is working. But I can not test it together on LAN with another machine. So I have doubt to use it.
I am afraid of using 'player', because as I know in multiplayer OFP knows only one 'player', it is the unit choosed as 'player' in the editor. Other playable units will not be handled as 'player'.

Correct me if I am wrong.

The reason of this doubt is I have playable units in the boat, and they should have the opportunity to use this action as well.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:addAction problem...
« Reply #3 on: 04 Feb 2004, 09:55:46 »
:quote:
I am afraid of using 'player', because as I know in multiplayer OFP knows only one 'player', it is the unit choosed as 'player' in the editor. Other playable units will not be handled as 'player'.
:end of quote:

Halfway correct. "Player" is the unit which is actually played on a local machine. Means, Player is different on every machine. So if you have a map with 2 playable Units and you play with a friend, "Player" on your machine is your controlled loon, on your friends machine it is his loon.

I'm sorry, i'm sure it could be explained in a shorter and clearer way, but english isn't my original language. But i hope you see what is meaned.

:edit:
you can use the same mission from editor as a SP or a MP map. Say, you make a SP mission and you want the player not to be the group leader. Now you want to use same map fo MP playing. Just assign the group leader as "playable", the second as "player" and the rest of group also as "playable". This way you don't have edit the mission for converting from SP to MP.

You can also use the fact, "Player" is different on each Comp for Cutscenes in MP. When you use _cam camsettarget player, everyone see's himself and his actual pos....m8 be usefull sometimes
« Last Edit: 04 Feb 2004, 10:02:35 by myke13021 »

Offline Welshmanizer

  • Members
  • *
Re:addAction problem...
« Reply #4 on: 04 Feb 2004, 10:57:34 »
I think you did not understand exactly the situation, or I did not tell enough about it.

well...

1.
_dude is the playable unit who was passed into the script as select 0.

_boat is the vehicle he is in.

@ _dude != vehicle _dude and not alive gunner _boat means _dude is in a vehicle and in the _boat the gunner is dead. This is the condition...

But after experimenting _dude != vehicle _dude is not needed, only not alive gunner _boat is perfectly describes the condition.

2.
_boat is definetly a unitname. It referes the unit (mark II pbr) in which _dude starts the mission.

.........
after experimentin I changed the base of it. I start the script from the boat, so now it is select 0:
Code: [Select]
_boat = _this select 0

#loop
ActionUsed = false
@ not alive gunner _boat
gunnerseat = _boat addAction ["to gunner's seat","moveingunner.sqs"]

@ ActionUsed

_boat removeAction gunnerseat

goto "loop"

exit
moveingunner.sqs:
Code: [Select]
_boat = vehicle player

ActionUsed = true
player action ["eject",_boat]
player assignAsGunner _boat
player moveInGunner _boat

exit
This is perfectly what I wanted. I tryed this and it is working. But I can not test it together on LAN with another machine. So I have doubt to use it.
I am afraid of using 'player', because as I know in multiplayer OFP knows only one 'player', it is the unit choosed as 'player' in the editor. Other playable units will not be handled as 'player'.

Correct me if I am wrong.

The reason of this doubt is I have playable units in the boat, and they should have the opportunity to use this action as well.


Ahh OK, then #1 is fine.

But for #2, you cannot add an action to a vehicle. You must add it to a unit which can be played by one of the players (or all of them). In other words you need to add the action to the soldiers, not the boat.

Yes the _boat is a unit, but you cannot 'be' a boat, you can only 'be' soldier who is in the boat. So unitname needs to be the name of a unit which you can actually play.

If you want to add the action to all the soldiers in the boat, you need to add the action to them all individually.


gundernak

  • Guest
Re:addAction problem...
« Reply #5 on: 04 Feb 2004, 11:53:36 »
Welshmanizer,

I really appreciate you are trying to help me. In deed!

But unfortunately and luckily ;) you are not right.

Basically a boat is a unit. It is an armored unit. There can be a name of it, or you can refer to it by someones vehicle, or you can select it from an array.

A boat, a flagpole, a soldier, a car,  a telephone, are able to have an action as well.

It looks like, when you walk close enough to the object, you will see the action option in your action menu...

just try.... ;)

Offline Tomb

  • Contributing Member
  • **
  • in2 Metal? Go 2 my sig
Re:addAction problem...
« Reply #6 on: 04 Feb 2004, 16:51:22 »
I once made the following userAction to a custom boat of mine (addon),
but hence the "player/MP" discussion, I have no Idea if it'll work in MP?!

But if you make a custom boat - just a config tweak of the MARK-II - then ya can add
this little userAction to the vehicle:


class UserActions
{
         class FreePos
        {
                displayName="Stand up in Boat";
                position="component01";
                radius=10;
                condition="player in this && speed this <1";
                statement="player action [""eject"", this]; unassignVehicle player; player setpos [getpos this select 0, getpos this select 1, +0.750]";
         };
};


 :) try it out it works fine - only, the boat must slow down & hold before the action pops up






Offline Welshmanizer

  • Members
  • *
Re:addAction problem...
« Reply #7 on: 04 Feb 2004, 18:04:03 »
Welshmanizer,

I really appreciate you are trying to help me. In deed!

But unfortunately and luckily ;) you are not right.

Basically a boat is a unit. It is an armored unit. There can be a name of it, or you can refer to it by someones vehicle, or you can select it from an array.

A boat, a flagpole, a soldier, a car,  a telephone, are able to have an action as well.

It looks like, when you walk close enough to the object, you will see the action option in your action menu...

just try.... ;)

Well why didn't you say so! I was thinking of something completely different. :P

The answer to your question is that the unit who uses the script will always be 'Player'. This is because AI can't 'use' these actions, which leaves the playable units. As myke13021 said above: on each machine, 'Player' will be the unit who they are controlling. So you are OK to use Player in the moveingunner.sqs script.


gundernak

  • Guest
Re:addAction problem...
« Reply #8 on: 04 Feb 2004, 19:36:11 »
thanks guys!