-
Content Count
556 -
Joined
-
Last visited
-
Medals
Posts posted by Bon
-
-
In your Init.sqf goes
killyou = false;
We initialize the variable killyou, nothing more, and nothing less. Also regard that, whatever is written in the init.sqf, it is executed on every machine. So absolutely no point in broadcasting it.
You want the trigger to activate on all machines once a single machine sets the variable killyou to true. So at this point the variable has to be broadcasted. In the killyou.sqf goes
killyou=true; publicVariable "killyou";
-----------------------------------------------
My approach would be to use publicVariable together with publicVariableEventhandler, as it completely separates your script from the editor/mission.sqm:
In init.sqf goes:
"killyou" = true; //or whatever you want it to initialize with, it doesn't matter "killyou" addPublicVariableEventHandler {playMusic "killyou"};In killyou.sqf goes:
playMusic "killyou"; publicVariable "killyou";
No more triggers etc. needed.
Please make yourself familiar with publicVariable and addpublicVariableEventHandler and try to understand what exactly happens here and why - its in your own interest.
-
Think again. Something is not necessary and something is missing. ;)
-
ehm, why not just writing
playMusic "killyou"; killyou = false
into the triggers init line, and in the condition goes just
killyou
Would be better to initialize killyou with false somewhere in your init.sqf.
-
galzohar,
as I like the BIS module pretty much, but can't use it in my MP missions, I wrote my own little AIS which is more a small BIS AIS clone:
http://forums.bistudio.com/showthread.php?t=90466
It works flawlessly with respawn and you can even customize it by setting the threshold of received damage to be deadly or just forces you to fall in agony.
One drawback: it is not considered to work with AI - AI units won't fall in agony, they also can't apply first aid unless they are medics.
-
I don't think that's all rarely documented. The Bohemia Interactive Wiki is a darn good reference. When I am not sure about something scripting related, I find the answer in this biki in 99% of all cases.
You're just not searching right (or not searching at all?).
Take your first question as an example: It already includes its answer.
For your second one: Array
-
I recommend you read the changelog that came with official patch 1.03. It claims the BIS Alternative Injury System works with respawn since then.
http://forums.bistudio.com/showthread.php?t=82753
My own experiences tell the opposite. Sometimes you can still be healed by human players after respawn, most of the time not.
Sometimes the captive status remains, even if you respawned or got healed.
Same with the dragging stuff.
So for me it is totally unreliable in MP environment.
And although I just heared it from another person and this is the way rumors arise, there's no further work planned on the AIS module from BIS side.
-
Pls try it again by dropping this check.
-
May I ask why you're checking for the crate to be local?
-
Ok, thing is:
OR is a logical operator, that receives two boolean statements A and B and returns true if at least one of them is true.
That means:
A or B => true
A or not B => true
not A or B => true
not A or not B => false
These are the four possibilities, not more, but also not less.
What you are trying to do is the following:
A or any.
And, what a surprise: "any" is NOT a boolean statement.
-
http://10th-community.com/arma2/10th-missions/Hunt_Waldo_2_v22.zip
unPBO one of the files and check out the "scripts\bon_lasertargeting" script component.
Has anybody played a mission that requires laser targeting, so I can go pull it apart? -
-
-10 equals 350 as well as -370 in this case. So all results are correct.
-
2 ways:
-
setVehicleInit:
_unit = _this select 0; _unit setVehicleInit " this say ['NeedMedic',1]; this sideChat 'I need a Medic!'; "; processInitCommands;
It's the easier way. Drawback: setVehicleInit code is stored and transferred to join in progress (jip) players. So it is likely that a player who joins in progress will get tons of "i need a medic" messages and, what's even more problematic: the amount data to transfer to the jip player grows and grows. However, if you're creating a mission without jip/respawn etc., this is pretty much all you need. -
publicVariable/-EventHandler:
_unit = _this select 0; (_unit) say ["NeedMedic",1]; _unit sideChat "I need a Medic!"; soldier_needs_medic = _unit; publicVariable "soldier_needs_medic";
The "soldier_needs_medic" of course is something you can choose by yourself.
You also have to write the following into your Init.sqf:"soldier_needs_medic" addpublicVariableEventHandler { _unit = _this select 1; _unit say ["NeedMedic",1]; _unit sideChat "I need a Medic!"; };
-
setVehicleInit:
-
Alright, it is likely the condition of your trigger, once it becomes true, will be globally true, i.e. on all machines. Then adding an action to a unit or object leads into the problem that everyone who comes close to this unit/object will have this action popping in her menu (since the code of the trigger executes on all machines) - that's some locality basics, are hardly documented.
You can easily write in your trigger
if(player == man1) then{player addAction [...]};but why not keeping this in Init.sqf:
getMyLaserTarget = compile (preprocessFileLineNumbers "func_getMyLaserTarget.sqf"); sleep 0.1; // give precompiling a break ^^ if(not isDedicated) then{ //prevent a ded. server to try to assign an action to a (then) non-existent player unit if(player == man1) then{player addAction ["Call Arty on Laser", "arty.sqf"]}; };It indeed doesn't matter if you add the action altough the function is not precompiled at this moment. But it must be precompiled when you hit the action. Btw, this tenth of a second (precompilation needs way less time) is even shorter than the Black-In fading when the mission starts. You won't even notice it. In general if you want some code executed in a script that needs breaks by sleeps, but do not want to block the rest of the script by it, no matter how small the break would be, you use spawn.
Last but not least we have to modify the getMyLaserTarget.sqf a bit, as the player calling arty should differ from the player who is using the laserdesignator. Very simple.
Edit the arty.sqf, specifically, the call of the getMyLaserTarget function:
arty.sqf
... _myLaserTarget = [man5] call getMyLaserTarget; ...
in words, we pass the script the laserdesignatorman as parameter.
The func_getMyLaserTarget.sqf then has to be modified as follows (highlighted the changes in blue):
func_getMyLaserTarget.sqf
//by Bon_Inf* /** returns the laser target the player is lasering at, or ObjNull if it does not exist **/ private ["_xpos","_ypos","_myLaserTarget","_lasertargets","_dir","_distance","_min","_target","_targetpos","_targetdistance","_aimpos"]; [color="Blue"]_unit = _this select 0; // _this = [man5][/color] _lasertargets = nearestObjects[[color="Blue"]_unit[/color],["LaserTarget"],2000]; if(count _lasertargets == 0) exitWith{ObjNull}; _xpos = getPos [color="Blue"]_unit[/color] select 0; _ypos = getPos [color="Blue"]_unit[/color] select 1; _myLaserTarget = ObjNull; _dir = [color="Blue"]_unit[/color] weaponDirection "Laserdesignator"; _dir = (_dir select 0) atan2 (_dir select 1); // get direction of the lasermarker aiming at _distance = 99; _min =99; for "_i" from 0 to (count _lasertargets - 1) do{ _target = _lasertargets select _i; _targetpos = [getPos _target select 0,getPos _target select 1,0]; _targetdistance = _targetpos distance [getPos [color="Blue"]_unit[/color] select 0, getPos player select 1, 0]; _aimpos = [_xpos + _targetdistance*sin(_dir), _ypos + _targetdistance*cos(_dir),0]; if((_targetpos distance _aimpos)<_min) then{ _myLaserTarget=_target; _min = _targetpos distance _aimpos; }; }; if(_min>2) then{_myLaserTarget = ObjNull}; _myLaserTarget -
i have the suspicion that you can't use precompiled functions from within triggers, maybe because triggers get initialized earlier than the functions get precompiled. Anyway, using radio triggers in MP is generally not a good idea. When you click on the radiobutton, the code in your trigger gets executed on all machines, means, when there are 5 players ingame, there will be a firemission requested 5 times - one for each player. I recommend using an action instead:
- In your Init.sqf script (if you don't have one yet, just create it in your mission folder) write the following on top of it:
getMyLaserTarget = compile (preprocessFileLineNumbers "func_getMyLaserTarget.sqf"); sleep 0.1; player addAction ["Call Arty on Laser", "arty.sqf"];
- Now create another file func_getMyLaserTarget.sqf and paste in it the code from my last post.
- Last but not least create a third file, lets name it arty.sqf and write in it:
_myLaserTarget = [] call getMyLaserTarget; if(not isNull _myLaserTarget) then { [artbatt, getposASL _myLaserTarget, ["IMMEDIATE", "LASER", 0, 1]] call BIS_ARTY_F_ExecuteTemplateMission; artilleryuse = artilleryuse + 1; if (artilleryuse == 1) then {player sideChat "Used one!"}; if (artilleryuse == 2) then {player sideChat "Used ALL!"; 1 setRadioMsg "NULL"}; } else {hint "no lasertarget found"};
Now start the mission, laze your target and use the mouse wheel menu to start the script.
Can't guarantee this works as I don't have any clue about the artillery module. Maybe you have to change your templatemisison. What I can guarantee is at the line where you call the BIS_ARTY_Function you have either your lasertarget detected and you can easily retrieve its position with getPos or getPosASL, or it tells you that it didn't find your lasertarget.
- In your Init.sqf script (if you don't have one yet, just create it in your mission folder) write the following on top of it:
-
Here a solution that also works in MP:
The function follows the following algorithm: Gather all near lasertargets. Draw an imaginary line along the direction you're aiming your laserdesignator at.
Check for each near lasertarget the distance to this line. If the lasertarget with closest distance to this line is closer than 2m, it returns this lasertarget, otherwise ObjNull.
Note: its a function that has to be precompiled.
func_getMyLaserTarget.sqf
//by Bon_Inf* /** returns the laser target the player is lasering at, or ObjNull if it does not exist **/ private ["_xpos","_ypos","_myLaserTarget","_lasertargets","_dir","_distance","_min","_target","_targetpos","_targetdistance","_aimpos"]; _lasertargets = nearestObjects[player,["LaserTarget"],2000]; if(count _lasertargets == 0) exitWith{ObjNull}; _xpos = getPos player select 0; _ypos = getPos player select 1; _myLaserTarget = ObjNull; _dir = player weaponDirection "Laserdesignator"; _dir = (_dir select 0) atan2 (_dir select 1); // get direction of the lasermarker aiming at _distance = 99; _min =99; for "_i" from 0 to (count _lasertargets - 1) do{ _target = _lasertargets select _i; _targetpos = [getPos _target select 0,getPos _target select 1,0]; _targetdistance = _targetpos distance [getPos player select 0, getPos player select 1, 0]; _aimpos = [_xpos + _targetdistance*sin(_dir), _ypos + _targetdistance*cos(_dir),0]; if((_targetpos distance _aimpos)<_min) then{ _myLaserTarget=_target; _min = _targetpos distance _aimpos; }; }; if(_min>2) then{_myLaserTarget = ObjNull}; _myLaserTargetSometimes it doesn't find the lasertarget, e.g. you are aiming at specific walls of houses (other walls work even if they belong to the same house :confused: ), but all in all its working pretty reliable.
-
thanks again for the great script Bon, just released a mission that uses this, but I had a question:In post #10 I display my description.ext which when I applied Revive towards the mission, there is now a conflict with the cfgSounds from the art.
Anyway to have these run together or know what the problem might be?
If you mean the Norrin Revive Script, I just dowloaded it and checked it out, it defines its sounds in revive_sqf\dialogs\config.cpp.
Simplest way would be to copy the #include "bon_artillery\cfgSounds.sqf" into it, so that it will look like
class CfgSounds { [color="Blue"]#include "bon_artillery\cfgSounds.sqf"[/color] sounds[] = { Brian_Im_hit, Brian_Im_bleeding,Brian_Medic,Brian_Bastards,Brian_Shit_Man_down,Brian_Oh_no, Brian_Fuck,Brian_Fuck_it,Brian_Shit,Brian_Need_help,Brian_A_little_help_here }; class Brian_Im_hit { name="Brian_Im_hit"; sound[]={"revive_sqf\sound\UNIV_v05.ogg",0.05,1.0}; titles[]={}; }; .... };Afterwards completely delete the cfgSounds section in the Description.ext.
I recommend something else:
Delete the line class CfgSounds and the sectionclosing curly bracket from the revive_sqf\dialogs\config.cpp:
[color="Red"]class CfgSounds //DELETE THIS LINE { // AND THIS BRACE[/color] sounds[] = { Brian_Im_hit, Brian_Im_bleeding,Brian_Medic,Brian_Bastards,Brian_Shit_Man_down,Brian_Oh_no, Brian_Fuck,Brian_Fuck_it,Brian_Shit,Brian_Need_help,Brian_A_little_help_here }; class Brian_Im_hit { name="Brian_Im_hit"; sound[]={"revive_sqf\sound\UNIV_v05.ogg",0.05,1.0}; titles[]={}; }; .... [color="Red"]}; // DELETE THIS BRACE[/color]Afterwards edit the cfgSounds section in the Description.ext:
class CfgSounds { #include "bon_artillery\cfgSounds.sqf" [color="Blue"]#include "revive_sqf\dialogs\config.cpp"[/color] };Firstly its a thing of taste, but this way you keep the Description.ext as a common interface/place for definitions and you get less scattered code - its much easier now to add further sounds from, lets say, other scripts, as you don't have to keep in mind where in the Norrin Revive System the sounds are defined.
-
Ok got the option finally. But the shells never actually hit. do i need to put artillery units on that map?No you don't need to put any artillery units on the map. Take a look at the usage manual and watch the demonstration videos carefully, I assume you just don't use it correctly ;)
Most people (even myself) often forget to press "confirm" to apply settings to marked cannons.
-----------------------------------------------------------------
Total editing noob here :oWhat exactly do you do with:
Now, you might probably have a CfgSounds class
defined already, then only copy the line
#include “bon_artillery\Description.extâ€
INTO your CfgSounds class.
I wouln't even know where to find 'CfgSounds class' ,let alone define it?
The rest of the install explanations in the manual, I can find where I need to put them, however it feels asthough I'm missing a couple of obvious steps.
If your own mission has no file named description.ext (not case-sensitive), just don't care about it, and use the one from the archive.
If you have one already, search in it for a structure like
class cfgSounds { some stuff };That defines custom sounds for the mission.
If there is no such structure, just use the one from the archive's Description.ext. If there is such structure already, only copy the line
#include “bon_artillery\Description.extâ€
into it, so that it becomes something like
class cfgSounds { #include “bon_artillery\Description.ext†some stuff };All in all its very simple:
If there is a file in the archive that is already there in your mission folder, merge both the contents.
If not, just use the one from the archive.
-
Is there anything wrong with the ports from {op4} Bsilenced?
http://forums.bistudio.com/showthread.php?t=95400
I don't have anything to do with domination, so can't say whether the one port has sidemissions enabled and the other one not and stuff.
But a small discussion here seems to start, where, just a few threads above/beneath there is what you apparently are searching for.
EDIT: ya, saw Bushlurkers last edit a bit too late, nevermind ^^
-
-
Its totally on your own and not in the responsibility of the script to provide the access to the menu to the game (it just provides the menu itself).
I usually assign the action to a backpack heap or, even simpler, an ammobox, by writing
this addAction ["Get Equipment Preset","bon_loadoutpresets\bon_loadout_presets.sqf"]
into its initline.
-
It's all local, there shouldn't be any probs at all in MP.
This is cool! Is it possible to get this to work in multiplayer, i play singleplayer in multiplayer if you know what i mean. -
As isOnRoad is introduced in ArmA2, it might not work on Armed-Assault-Maps. But that is probably the case with all those commands.
-
_nearestunits = nearestObjects [<the position>,["Man","Car","Tank"],<the radius>]; _nearestfriendlies = []; if(<your side> countSide _nearestunits > 0) then{ { _unit = _x; if(side _unit == <your side>) then{_nearestfriendlies = _nearestfriendlies + [_unit]}; } foreach _nearestunits; };This will give you the array _nearestfriendlies with all friendly units within the given radius around the given position, sorted by distance (closest unit is first element in array). If there is no friendly unit nearby, the array remains empty.
Maybe not the most elegant way, but it should work.

Avoid player from moving
in ARMA 2 & OA : MISSIONS - Editing & Scripting
Posted
Perhaps not the most elegant way, but my only idea would be to set a display eventhandler on a pressed key via displayAddEventhandler (use this, not displaySetEventHandler), that handles the move keys while a certain condition is true.
Look at the example here: http://community.bistudio.com/wiki/displaySetEventHandler