Home   Help Search Login Register  

Author Topic: (Accepted) Script for Shaking  (Read 3969 times)

0 Members and 1 Guest are viewing this topic.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
(Accepted) Script for Shaking
« on: 10 Jun 2007, 12:19:39 »
Welcome to my master piece.  i called this the 'Violence Level'. because the level of shake is easily adjustable:

;You start of with a camera, and you set it to track a certain object.  this can be anything, such a a soldier or a plane.  so long as it is tracking from the correct angle.  It uses a follow, which you loop and then a tracking shake, that you can loop for as long as you like, and as many times as you like.  by setting the variable _shake you can change in effect the number of seconds the shake lasts, and by changing the _violence you can set how much it shakes.  to copy the concept again, you copy the cam position and the shake script, thn change the name of the loop.

enjoy, it is not a complete version, and it is still not as flexible as i would like it, but i am still working on it, any anyone willing to post further info will be gratified.

Code: [Select]
_cam = "camera" camcreate [0,0,0]
_cam cameraeffect ["internal", "back"]

_cam camsettarget ob1
_cam camsetrelpos [5,10,3]
_cam camcommit 0

titlecut [" ","BLACK IN",2]

_violence = 1

_tfollow = 0.1
_follow = 2

#follow1
_follow = _follow - _tfollow
_cam camsetrelpos [5,5,3]
_cam camcommit 0
@camcommitted _cam
~0.1
? _follow > 0.1 : goto "follow1"

;==SHAKE START==
_tshake = 0.1
_shake = 2
_x = _violence
_y = _violence
_z = _violence
#shake1

_shake = _shake - _tshake
_cam camSetRelPos [5 + random _x,5 + random _y,3 + random _z]
_x = _x - 0.
_y = _y - 0.
_z = _z - 0.
_cam camCommit 0.1
~0.1
? _shake > 0.1 : goto "shake1"
;==SHAKE END==

_cam camsettarget ob2
_cam camsetrelpos [10,-5,3]
_cam camcommit 0.5

;==SHAKE START==
_tshake = 0.1
_shake = 2
_x = _violence
_y = _violence
_z = _violence
#shake2

_shake = _shake - _tshake
_cam camSetRelPos [10 + random _x,-5 + random _y,3 + random _z]
_x = _x - 0.
_y = _y - 0.
_z = _z - 0.
_cam camCommit 0.1
~0.1
? _shake > 0.1 : goto "shake2"
;==SHAKE END==


Please use code tags to enclose code, it makes it so much easier to read separately from the normal text.
I have edited your post accordingly.
   Planck  :cool2:





PS. if you know ho to track the current position of a camera from another script and shake whenever something happens without  needed to put directly in the code, that would be genius.

surdus
« Last Edit: 02 Sep 2007, 05:08:47 by hoz »
Campaigns are hard, I'll stick with scripting for now!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Script for Shaking
« Reply #1 on: 10 Jun 2007, 13:05:23 »
May you make:
obl, _shake, _violence, _follow and initial camera relative position arguments of your script? (and dont forget to add explanations in the header about their meanins  :P )

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: Script for Shaking
« Reply #2 on: 10 Jun 2007, 13:09:04 »
im working on a better version atm, thats just a rough sketch.  i might add more to this thread
Campaigns are hard, I'll stick with scripting for now!

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Screen Shaking Codes and Test Files
« Reply #3 on: 10 Jun 2007, 18:15:52 »
===this comes from a previous discussion, i decided to show my findings===

this is what i've done so far, this is the Movement Capsule, its the target for my shaker:

;==Movement Start==
x = ###
y = ###
z = ###
cam camsettarget ###
cam camsetrelpos [x,y,z]
cam camcommit ###
;==Movement End==

Use it as you would use any camera position.  what this does is sets the values to an alternative path.  This will allow you to use the shaker more effectively.

This is my shaker, i called it the Violence Factor:
Code: [Select]
; *****************************************************
; ** Violence Factor - Advanced Shake
; *****************************************************

;Execute = [Camera Name] exec "Advanced_Shake.sqs"

;--Do Not Modify--
_cam = _this select 0
_tshake = 0.1
;--Do Not Modify--

;Initial Pause - Required to Synchronize with Explosion
~0.5

;Duration - Time Until Shake Ends
_shake = 2

;Violence Level - Level of Shake Distance
_v = 0.8

;Positions - Standard x,y,z (According to Movement Capsules)
_x = x
_y = y
_z = z

;Loop Name
#shake1

;--Do Not Modify--
_shake = _shake - _tshake
_cam camSetRelPos [_x + random _v,_y + random _v,_z + random _v]
;--Do Not Modify--

;Cool Down - Fading Shake Duration (Use at own Risk)
_v = _v - 0.

;Loop Duration - Modifies the speed of shake (Use at own Risk)
_cam camCommit 0.025
~0.025

;End Loop - Modify "goto" target only (Use is Necessary)
? _shake > 0.1 : goto "shake1"




So far i have created a basic version which can be implemented directly into the camera script, but its not as effective with explosions as my advanced version.  this version allows a great amount of flexibility, and it automatically refers to the camera script, it is important however that if you use this shaker, you must use the movement capsule, but you only need to use them when you gonna do the shake (although the capsule may have other oppotunities)

The only problem with this shaker is that it doesnt work when the camera is moving from position to position.  How ever it does work with what i call a Follower, a Basic Tracker, this is a Follower:

Code: [Select]
;==TRACK START==
_tfollow = 0.1
_follow = 2

;Positions
_x = ###
_y = ###
_z = ###

#follow1
_follow = _follow - _tfollow
_cam camsetrelpos [_x,_y,_x]
_cam camcommit 0.01
~0.01
? _follow > 0.1 : goto "follow1"
;==TRACK END==

Because the positions are reset every 0.01 seconds, the shaker will work just fine with this.



My final goal now, is to make a shaker that can work on cameras which are moving positions.  Because what my shaker will do if the camera is not still (or not tracking), it will jump to the destinate position, and will not look that good.

you will find a .rar pbo of a test file that uses thuis concept, its a little cutscene showing the basics behind how to shake on explosions, or shake in general as part of a cutscene.

there are also my templates of movement and shaking, as well as tracking.


Once again, please use code tags to enclose code, it makes it so much easier to read separately from the normal text.
I have edited your post accordingly.
I will also merge this with your previous topic on the same subject
Planck
« Last Edit: 31 Oct 2008, 08:42:00 by bedges »
Campaigns are hard, I'll stick with scripting for now!