Friday 22 May 2020

Functions from "Animation" and "Script" modules in Far Cry




 Attention! It is not info about my project, it's a backup of my article from Moddb!

This tutorial is for those who are a bit versed in scripts. At the end of this tutorial, there are examples of writing functions. This is for those who have not used them before. - IDL

Functions from "Animation" module.
Functions:
1.      Animation:ClearDecals();
2.      Animation:DumpAnims();
3.      Animation:DumpDecals();
4.      Animation:DumpModels();
5.      Animation:DumpStates();
6.      Animation:TrashAnims();
As you can see, this functions they don 't require arguments. These fuctions using for debugs.
Functions from "Script" module.
Functions:
1.      Script:ReloadScript(path);
2.      Script:LoadScript(path,reload);
Arguments:
1.      path - path to script.
2.      path - path to script, reload (optional) - should the script be reloaded if it already is loaded? Set 1 if you want to reload.
Examples.
1.      Animation:ClearDecals();
2.      Animation:DumpAnims();
3.      Animation:DumpDecals();
4.      Animation:DumpModels();
5.      Animation:DumpStates();
6.      Animation:TrashAnims();
7.      Script:ReloadScript("scripts/common.lua"); - reload given script.
8.      Script:LoadScript("scripts/materials/commoneffects.lua",1); - load the given script and after loading reload it.

Use this functions in LUA scripts. Have fun with coding!
Author of this tutorial - IDL
Also sorry, if my English is bad.

Functions from "Sound" module in Far Cry

Attention! It is not info about my project, it's a backup of my article from Moddb!


This tutorial is for those who are a bit versed in scripts. At the end of this tutorial, there are examples of writing functions. This is for those who have not used them before. - IDL


Functions for load sound.

Functions:

  1. Sound:LoadSound(sound,flags);
  2. Sound:Load3DSound(sound, arg2, arg3, arg4, arg5);
  3. Sound:LoadStreamSound(sound,flags);

Arguments:

  1. sound - path to sound, flags - some settings for sound (optional).
  2. sound - path to sound, arg2 - some settings for sound (number or flag), arg3, arg4, arg5 - some number.
  3. sound - path to sound, flags - some settings for sound (optional).

Functions for play sound.
Functions:
  1. Sound:PlaySound(sound);
  2. Sound:StopSound(sound);
Arguments:
  1. sound - loaded sound.
  2. sound - loaded sound.
Functions for editing sound.
Functions:
  1. Sound:SetSoundVolume(sound,volume);
  2. Sound:SetSoundPitching(sound, pitch);
  3. Sound:SetGroupScale(flag1, flag2);
  4. Sound:SetMinMaxDistance(sound, min, max);
  5. Sound:SetSoundLoop(sound, loop);
  6. Sound:AddToScaleGroup(sound, flag);
  7. Sound:SetSoundFrequency(sound, frequency);
  8. Sound:SetSoundProperties(sound,properties);
  9. Sound:SetSoundPosition(sound,position);
  10. Sound:SetDirectionalAttenuation(position, angles, fov);
  11. Sound:RemoveFromScaleGroup(sound, flag);
Arguments:
  1. sound - loaded sound, volume - some number from 0 to 255.
  2. sound - loaded sound, pitch - some number.
  3. flag1 - some flag, flag2 - some flag or number.
  4. sound - loaded sound, min - minimum radius of sound, max - maximum radius of sound.
  5. sound - loaded sound, loop - number.
  6. sound - loaded sound, flag - some flag.
  7. sound - loaded sound, frequency - some number.
  8. sound - loaded sound, properties - some properties (like fade).
  9. sound - loaded sound, position - some position.
  10. position - some position., angles - some angles, fov - field of vision.
  11. sound - loaded sound, flag - some flag.
Functions for get some information about sound.
Functions:
  1. Sound:IsPlaying(sound);
Arguments:
  1. sound - loaded sound.
Functions for music system.
Functions:
  1. Sound:AddMusicMoodEvent(mood, timeout);
  2. Sound:SetDefaultMusicMood(mood);
  3. Sound:SetMusicMood(mood);
  4. Sound:SetMusicTheme(theme);
  5. Sound:ResetMusicThemeOverride();
  6. Sound:IsInMusicMood(mood);
Arguments:
  1. mood - name of mood, timeout - itself timeout (in seconds).
  2. mood - name of mood.
  3. mood - name of mood.
  4. theme - name of theme.
  5. ... (no arguments)
  6. mood - name of mood.
Functions for EAX system.
Functions:
  1. Sound:SetEaxEnvironment(eax,flags);
Arguments:
  1. eax - name of EAX effect, flags - some flags.
Some flags for sounds.
Flags:
  1. SOUND_RADIUS
  2. SOUND_OCCLUSION
  3. SOUND_UNSCALABLE
  4. SOUND_RELATIVE
  5. SOUND_NO_SW_ATTENUATION
  6. SOUND_MUSIC
  7. SOUNDSCALE_UNDERWATER
  8. SOUNDSCALE_MISSIONHINT
  9. SOUND_VOLUMESCALEMISSIONHINT
  10. SOUNDSCALE_DEAFNESS
  11. SOUND_INDOOR
  12. SOUND_OUTDOOR
  13. SOUND_LOOP
Some music moods for music system.
  1. Sneaking
  2. Combat
  3. Suspense
  4. NearSuspense
  5. Alert
  6. Victory
  7. Vehicle
  8. Observe
Examples (starting with the fourth point, sounds must be loaded).
  1. local snd = Sound:LoadSound("sounds/player/water/swim2.wav"); - loading sound using path in 2D space (few formats work like "wav", "mp3").
  2. local snd = Sound:Load3DSound("sounds/player/water/WaterSplash.wav", SOUND_RADIUS, 160, 3, 50); - loading sound using path and optional properties in 3D space (few formats work like "wav").
  3. local snd = Sound:LoadStreamSound("sounds/player/water/swim2.wav",SOUND_INDOOR); - loading sound using path in 2D space (many formats work like "ogg", "wav", "mp3").
  4. Sound:PlaySound(self.SwimSound); - play loaded sound.
  5. Sound:StopSound(self.SwimSound); - stop playing loaded sound.
  6. Sound:SetSoundVolume(self.SwimSound,70); - set volume from 255 (by default) to 70.
  7. Sound:SetSoundPitching(CurrSound, 100); - set pitch to 100.
  8. Sound:SetGroupScale(SOUNDSCALE_DEAFNESS, 1); - all sounds other than this will not be heard.
  9. Sound:SetMinMaxDistance(CurSnd, .2, 200); - set minimum radius of sound to 0.2 and set maximum radius of sound to 200 in 3D space.
  10. Sound:SetSoundLoop(self.SwimSound, 1); - set loop mode for this sound.
  11. Sound:AddToScaleGroup(self.Sounds[i].Sound, SOUNDSCALE_UNDERWATER); - set for this sound flag SOUNDSCALE_UNDERWATER.
  12. Sound:SetSoundFrequency(self.LastPhysicsSounds.Roll, Volume*400+800); - set frequency for this sound.
  13. Sound:SetSoundProperties(self.sound,self.Properties.fFadeValue); - set fade effect for this sound in 3D space.
  14. Sound:SetSoundPosition(self.sndBreathIn,System:GetViewCameraPos()); - set position for this sound in 3D space (in this case I get the position of player 's camera).
  15. Sound:SetDirectionalAttenuation(_localplayer:GetPos(), _localplayer:GetAngles(), Game:GetCameraFov()); - set directional attenuation (this effect used for binocular).
  16. Sound:RemoveFromScaleGroup(self.EarRinging, SOUNDSCALE_DEAFNESS); - make a default sound.
  17. local getsnd = Sound:IsPlaying(sound); - check this sound for load.
  18. Sound:AddMusicMoodEvent("Sneaking", 1); - set time out for mood "Sneaking" to 1.
  19. Sound:SetDefaultMusicMood("Sneaking"); - set default music mood to Sneaking.
  20. Sound:SetMusicMood("Sneaking"); - change current music mood to Sneaking.
  21. Sound:SetMusicTheme("Forest"); - set music theme to "Forest".
  22. Sound:ResetMusicThemeOverride(); - unused function for vehicles.
  23. local mood = Sound:IsInMusicMood("Combat"); - mood "Combat" is playing?
  24. Sound:SetEaxEnvironment("Cave" ,0); - set EAX environment to OFF mode (default).
Use this functions in LUA scripts. Have fun with coding!
Author of this tutorial - IDL
Also sorry, if my English is bad.