ConPrice
Member-
Content Count
4 -
Joined
-
Last visited
-
Medals
Everything posted by ConPrice
-
How to constantly spin/rotate an object in Multiplayer
ConPrice posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi everyone! ( This is a repost, because I have some debug and video demo) I have a problem. I have been trying to create a script that will let me spin/rotate an object real fast. The object in question is LightHouse (tall) (Land_LightHouse_F). But I had one problem. the lighthouse's pivot point is at its door, not at its centre. So I have been using this code. Which got rid of the problem of lighthouse spinning around its door instead of its centre: params ["_objectToSpin", "_spinSpeedMin", "_spinSpeedMax", "_timeToReachMaxSpeed"]; // Initialize parameters _spinSpeedMin = _spinSpeedMin; // Initial rotation speed in degrees per second _spinSpeedMax = _spinSpeedMax; // Maximum rotation speed in degrees per second _timeToReachMaxSpeed = _timeToReachMaxSpeed; // Time to reach maximum speed in seconds // Get the initial position of the object _initialPosition = position _objectToSpin; // Ensure the object is initially on the ground _initialPosition set [2, (_initialPosition select 2) + 0.1]; _objectToSpin setPos _initialPosition; // Calculate model's center offset (adjust these values based on your model's pivot) _modelCenter = [0, 0, 0]; // Replace with the actual offset if known // Initialize rotation and time _lastTime = diag_tickTime; _startTime = _lastTime; // Record the start time _initialHeight = (_initialPosition select 2); _currentRotationSpeed = _spinSpeedMin; // Initial rotation speed // Main loop to handle rotation while {alive _objectToSpin} do { _currentTime = diag_tickTime; _deltaTime = _currentTime - _lastTime; // Calculate elapsed time since start _elapsedTime = _currentTime - _startTime; // Calculate current rotation speed based on elapsed time if (_elapsedTime < _timeToReachMaxSpeed) then { _currentRotationSpeed = _spinSpeedMin + (_spinSpeedMax - _spinSpeedMin) * (_elapsedTime / _timeToReachMaxSpeed); } else { _currentRotationSpeed = _spinSpeedMax; }; // Calculate new rotation angle _rotationIncrement = _currentRotationSpeed * _deltaTime; _currentDir = getDir _objectToSpin; _newDir = _currentDir + _rotationIncrement; _newDir = _newDir % 360; // Ensure the angle stays within 0-360 degrees // Calculate the current position _currentPos = position _objectToSpin; _newPos = [ (_currentPos select 0) - (_modelCenter select 0), (_currentPos select 1) - (_modelCenter select 1), _initialHeight // Maintain consistent height ]; // Apply rotation _objectToSpin setDir _newDir; // Set the new position _objectToSpin setPos [_newPos select 0, _newPos select 1, _newPos select 2]; _lastTime = _currentTime; // Update the last time // Sleep to yield to other processes sleep 0.01; }; This script was working fine until I tested it on a dedicated server. On a dedicated server lighthouse spins around its door instead of its centre. I am not good at math, so most of the code is just bits and pieces I got from the internet and put together. I call the script this way: I have an object with addAction: this addaction["Spin it", { [_this select 0,_this select 2] remoteExec ["removeAction", 0, true]; null = [] execVM "scripts\end.sqf"; }, [], 6, false, true, "", "", 5]; and end.sqf has the line: null = [object_to_levitate, 0, 120, 20] execVM "scripts\spin.sqf"; at the top. I don't know how to solve this issue. I appreciate any help. Video demonstration of what is happening instead of what is supposed to happen: I run the code with debug messages: Singleplayer: Current position : [8684.5,10613.9,0.1], New position after adjustment: [8684.5,10613.9,0.1] Object rotated to NewDir = 284.013 and moved to NewPos = [8684.5,10613.9,0.1] and position numbers never change. They stay the same. Only things that change are direction, rotations speed/increment and elapsed time. And this is the result when I run this mission on multiplayer server: Current position : [8683.16,10611.3,0.1], New position after adjustment: [8683.16,10611.3,0.1] Object rotated to NewDir = 324.629 and moved to NewPos = [8683.14,10611.2,0.1] Notice the difference between position numbers? And positions numbers constantly change unlike single player where they would stay constant. -
Cannot activate Triggers via addAction
ConPrice posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello, everyone! I have a problem related to addAction and triggers on Dedicated servers. In my mission there is an objective where players have to go to a laptop_1 and make mines online which in turn sets the boolean isMineSet to TRUE. And I have a Trigger_1 and isMineSet is in the condition field of Trigger_1. In the activation field of Trigger_1 is this code: laptop_2 addaction["Blow it up!", { (_this select 0) removeAction(_this select 2); canBlowUp = true; }, [], 6, false, true, "", "", 5]; and in the second Trigger_2 I have canBlowUp in the condition field and I have this code in the activation: [] spawn { sleep 1; charge_1 setDamage 1; hint "Yes2!!"; sleep 1; charge_2 setDamage 1; }; and I know that boolean values get set because addAction works and the hint "Yes2!!" also works. But there is no explosion. But if I set an area for Trigger_2 and set Activation to Any Player and step into the trigger, the explosion happens I also tried this code in addAction, but it also does not work, but if I add this code to a trigger and activate it by stepping in it, it works: Laptop_2 addaction["Blow it up!", { (_this select 0) removeAction(_this select 2); null = [napalm1] execVM "AL_napalm\alias_obj_sing.sqf"; sleep 1; null = [napalm2] execVM "AL_napalm\alias_obj_sing.sqf"; sleep 1; }, [], 6, false, true, "", "", 5]; all the above mentioned code works properly when I host it as multiplayer in the editor. Does anyone have any Idea what might cause this? I appreciate your help. Thank you! -
Cannot activate Triggers via addAction
ConPrice replied to ConPrice's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi, Mrcurry! Thank you for responding. my addactions only set the booleans to true. I have booleans in init.sqf for example: canBlowUp = false; publicVariable "canBlowUp"; canEnd = false; publicVariable "canEnd"; and even when I try to activate the setDamage code via script using booleans as condition. Hint in between setDamage codes shows up, but there is no explosion but If I activate that trigger by stepping into it, it works and explosion happens. Am I supposed figure out a way to set a boolean for every machine on the server? setVariable? I still don't understand why setdamage works when the trigger is activated by a player, but when the same trigger is activated by a boolean it does not work ( hint "Yes2!!" still works so that means boolean gets set). If you need more details, I will happily provide