Home   Help Search Login Register  

Author Topic: addaction troubles with multiplayer- please help!  (Read 3242 times)

0 Members and 1 Guest are viewing this topic.

Offline ericstephenvorm

  • Members
  • *
addaction troubles with multiplayer- please help!
« on: 25 Oct 2009, 16:00:59 »
Hi, everyone. I am making a mission where you have to make your way into town and insert "blasting caps" to explosives that have already been set. Once the blasting caps are set, the player will be able to blow up the bridge.

I have been experimenting with basic "addaction", but I cannot seem to get it to work for various reasons. For one, I can't figure out the syntax to allow all playable characters to enable the trigger that will add the action "plant blasting cap" to their menu. For another, I can't figure out how to enable the radio trigger to blow up the bridge for that player only (so that only the dude that planted the cap can blow that bridge).

I have already set up radio triggers that will blow up the bridges individually, and I have triggers set to tick off objectives based on the damage to the bridges, so that's no problem.

What I need exactly is this:

1. A trigger that will add the action "plant blasting cap" to whatever player approaches to within 2m of the object (which will be a bunch of explosives under the bridge).
2. A way to remove that action as soon as they are not within range of it (probably going to be accomplished by making it a "once" trigger... but I am wondering what will happen if the man who plants the blasting cap is killed before he has time to blow the bridge?)
3. A radio trigger that will be enabled only once the blasting cap is planted, and only by the person that planted the blasting cap.

The mission has three bridges to blow, each as an objective. I would ideally like to have two teams of four or five be able to work independently, so I need the triggers to be functional with anyone that takes a slot in the game.

Thanks to whomever is willing to help me along. I am afraid my knowledge of scripting is only as strong as my ability to hit "ctrl+C" and "ctrl+v". :)

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re: addaction troubles with multiplayer- please help!
« Reply #1 on: 25 Oct 2009, 18:42:54 »


1) You dont need any triggers to add or remove actions.
     The addaction command allows you to add conditions to the action, which defines when it will be available


The following is untested but should work

lets name the object at the 1st Bridge "Bridge_1"
lets name the object at the 2nd Bridge "Bridge_2"
lets name the object at the 3rd Bridge "Bridge_3"




/////////////////////////////////////////////
/////      INIT.sqf"      /////
/////////////////////////////////////////////

add the actions to reach player and use the condition that they
1) have to be alive
2) have to be within 2 metres of a bridge object
3) The bridge object hasnt yet been destroyed

Code: [Select]
  sleep 5;
  _title = "";
  _condition = "";
  _actionID = 0;

  if ! (IsDedicated)then
  {

_title = format ["Set Det's at %1",_x];
_condition = format ["(alive _target) && (_target  distance %1 < 2 )&&(alive %1)&&(%1 getvariable 'Tx_demsReady') ",_x];
_actionID = Player addAction [_title, "SetDetonators.sqf", _x , -20 , false , false , "" , _condition];

  }foreach [Bridge_1,Bridge_2,Bridge_3] ;

/////////////////////////////////////////////
/////      SetDetonators.sqf   /////
/////////////////////////////////////////////

add the actions to the player that set the detonators
with the condition that
1) he has to be alive
2) The bridge object hasnt yet been destroyed

Code: [Select]
  _player = _this select 0;
  _caller = _this select 1;
  _id = _this select 2;
  _bridge = _this select 3;

  if !(_player == _caller)exitwith{};
  _bridge setvariable ["Tx_demsReady", true];
  _player removeaction _id;
  _player sidechat format ["<< DEMS >>     %1 set for dems",_bridge];

  _title = format ["Blow %1",_bridge];
  _condition = format ["(alive _target) && (alive %1)  && ((_target distance %1) < 100",_bridge];
  _actionID = Player addAction [_title, "BlowBridge.sqf", _bridge , -20 , false , false , "" , _condition];
/////////////////////////////////////////////
/////      BlowBridge.sqf   /////
/////////////////////////////////////////////
Code: [Select]
  _player = _this select 0;
  _caller = _this select 1;
  _id = _this select 2;
  _bridge = _this select 3;
  if !(_player == _caller)exitwith{};

  _player sidechat format ["<< DEMS >> Detonating %1 in 10 seconds", _bridge];
  _sleep 10;
  if! (alive _player)exitwith{};
  _player sidechat "<< DEMS >>     Fire In the hole";
  _bridge setdammage 1;
  _player removeaction _id;

/*
    add code to:
  1)   createvehicle bomb, or whatever else you are doing to create the explosion
  2) Update your briefing "Tasks"

<< STAGE 1>>
The initial Set Detonators actions will be attached to the players at the start of the mission, (one for each bridge) but they will only be visible and  available when the conditions have been met, they will automatically be invisible when these conditions are not true

<< STAGE 2>>
Once the player has selected the "Set Dets" action, that action specific to that bridge will be removed and replaced with another action, to blow the bridge up   
This action will only be visible while the player is within 100m and the bridge hasnt yet been blown

<< STAGE 3>>
Once the player has selected the "Blow Bridge" action, that action specific to that bridge will be removed, you will need to add some code , eg createvehicle "Bomb" to creatre the explosion FX and actually blow the bridge itself up   
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline ericstephenvorm

  • Members
  • *
Re: addaction troubles with multiplayer- please help!
« Reply #2 on: 25 Oct 2009, 19:40:54 »
Hmmm... well, this is a tremendous amount of work. Thank you very much.

However, I have not been able to make it work thus far. I have not worked with SQF files very much before, so that might be the problem.

Here is what I did:

1. I copied and pasted the INIT.SQF portion into my current init file. Might that be a problem, seeing as I believe my init file is an sqs?

2. I copied and pasted the SETDETONATORS.SQF portion into a notepad and saved it as SETDETONATORS.SQF in my missions folder.

3. I copied and pasted the BLOWBRIDGE.SQF portion into a notepad and saved it as BLOWBRIDGE.SQF in my missions folder.

4. I named an object "Bridge_1"

5. Testing it, I walked up to the object, but nothing happened.

I am able to add an action to my player's menu when he approaches an object already by using a trigger.

Trigger name= foxtrotbridge
Condition= (myplayername distance myobjectname < 2)
On Activation= Bridgedet = myplayername addaction ["plant blasting cap","bridgedet.sqs"]
On Deactivation= myplayername removeaction Bridgedet

The problem with this is:
1. It is only set to the active player, which I think will be a problem in a 10-person MP game
2. The On Deactivation part doesn't work to remove the action once he has moved away from the object

See, I figured that I could use my current radio trigger (which will blow up the bridge), but enable it on the player's radio only once the trigger above (foxtrotbridge) is completed. That, of course, won't work because I want the player to have the ability to blow up the bridge once he has executed the action (in this case "Plant blasting cap"),  not just when he has tripped the trigger. Does that make sense?

Also, I noticed that you made this a time delay. I already have the "detonator" scripted with a radio trigger, and I'd prefer to keep it that way. What I would ideally like to have is an action that is created or enabled when I approach an object. Upon execution of that action, I want the radio trigger to be enabled which will give the player the ability to detonate the explosives. I do not want the explosion to be controlled by any other means than by what I have already scripted (since I worked so hard on that already), but rather, I just want to be able to create an action, then execute that action which will enable a radio trigger.

Thank you very much for your efforts. I just wish I could do them better justice. Let me know what I did wrong. I'll keep tweaking in the meantime.

ESV

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re: addaction troubles with multiplayer- please help!
« Reply #3 on: 25 Oct 2009, 21:09:05 »
difference between sqf and sqs is quite a lot, you should be learning .sqf syntax, sqs is an old OFP standard

"Player"  returns the actual Player on that client machine.
With 10 players connected, "Player" returns a different Player on each machine
therefore think of "Player" as being the local player to that machine.

The entire action menu is localised and will not effect other players on other machines
But all players should get the menu when they are close enough to the objects

The code did as you asked, simply add Init.sqf to your root folder and the code should work.

Init.sqf will run before init.sqs


also check your .rpt file for any errors caused by that script and add the following line to your ArmA2 shortcut params

"  -showScriptErrors  "


to do this, left click on your arma2 shortcut on yourn desktop
select properties
select the shortcut tab

and at the end of the text in the "Target" field paste     -showScriptErrors

so it looks something like

D:\Games\ArmA2\arma2.exe -nosplash  -showScriptErrors



The script I wrote, as I said was untested, it took 10 mins of my time

Please do as i ask and then paste any rpt errors or error messages it throws up

« Last Edit: 25 Oct 2009, 21:20:20 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline ericstephenvorm

  • Members
  • *
Re: addaction troubles with multiplayer- please help!
« Reply #4 on: 02 Nov 2009, 21:32:35 »
As quality as your script was (and it did technically work), it's not exactly what I am looking for.

To illustrate what I want, the satchel charge is a great analogy. It has the following properties:

1. An action menu item is added that allows a player to place a satchel charge wherever he wants
2. Once the satchel is place, another action is added, this time to detonate the charge.
3. The player then moves a safe distance away and executes the action, which blows up the charge.

I want exactly the same thing, except in my example I need the following:

1. An action menu item that is enabled once the player is close enough to a certain object (within 2m), it will be called "insert blasting caps"
2. Once the "blasting caps" are set, another action is added that, instead of blowing up a certain item, will execute the script I have already written to blow up the bridge, (exec "blowbridge.sqf")
3. The player will then be able to move a safe distance away and execute the action, which will blow up the bridge via the script that I have already written.

In case anyone cares, the script to blow up the bridge is a simple one that spawns 5 Mk-82's between two set game logics. The reason I like this so much is for one, I wrote it. For another, it blows the bridge quite nicely, leaving only the stanchions remaining.

So you see, all I need is essentially what is already in the game with the satchel charge. I just can't figure out how to make it work...

This is all that is really remaining before I can finish my mission and publish it. Thank you again for your efforts, Terox. I have already added you to the credits. :)

ESV

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re: addaction troubles with multiplayer- please help!
« Reply #5 on: 06 Nov 2009, 02:09:35 »
the code I wrote basically does as you ask.

apart from this line

_condition = format ["(alive _target) && (alive %1)  && ((_target distance %1) < 100",_bridge];


this defines when an action will be visible to the player and in this case it states
1) is the object that this action is attached too still alive ? (aka _target)
2) is the bridge object still alive, eg not blown up
3) and is the object that this action is attached too (aka _target) within 100m of the bridge


if you do not want to limit the maximum distance away from the bridge that the player can detonate from, then use the line

_condition = format ["(alive _target) && (alive %1)",_bridge];
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123