Skip to content

3 Documentation

V E L Δ edited this page Mar 6, 2022 · 7 revisions

RATCHET & CLANK: FFA / LUA QFORCE-FFA DOCUMENTATION

This is a documentation based on what is what and what do what in the lua files of the game.

3.1 > General Game Scripts

What are the general game scripts?
The general game scripts are the universal_global.lua files.
These files are hyperlinked (handled or connected) and can communicate. Their functions are reusable and their methods too.

3.1.1 > UNIVERSAL_GLOBAL.LUA

What's in the Universal Global? Well, you'll mainly find the "global" settings and codes for the game, for example this kind of codes:

enable_end_game = Boolean -- whether we are ready to end the current level
global_cameFromPhoenix = Boolean -- whether the last load was from the phoenix
PvPLevelCheck = Boolean -- whether the current level is a PVP level
pvp_global_forfeit = Boolean -- whether the destruction of generators is due to a forfeit (for VO)

Or this kind:

-- --------------------------- EnableHeroes ------------------------------ --
function EnableHeroes(restoreHeroCam, enableEnemies, enableRadar)
	
  if (restoreHeroCam == nil) then 
    restoreHeroCam = true
  end -- Check is the camera of hero isn't restored (angle reseted)
  
  if (enableRadar == nil) then 
    enableRadar = true 
  end -- check if the radar phase is on
  
  if ((global_curLevelPhoenix ~= nil) and (global_curLevelPhoenix)) then 
    enableRadar = false
  end 
  
  if (restoreHeroCam) then 
    activate_hero_cam()
  end -- Check if hero cam is, then enable the camera of the hero, for example change from a cinematic to a gameplay camera
  
  if ((enableEnemies == nil) or (enableEnemies)) then 
    disable_enemy_awareness(false)
    UnPauseInvasion()
  end -- Check if enemies are enabled or not, returns a round of attacks
  
  --hero_enable_pad()
  protagonist_force_stand_all(false)
  hero_lockout_all(false)
  set_hud_fader(true)
  --set_gameplay_cinematic_active(false)
  if (enableRadar) then 
    radar_enable()
  end  -- if radar boolean enabler is on, then enable radar
  
end -- end EnableHeroes

but the codes you'll want to work on is mainly the global player references, everything that touch the players.

-- -------------------------- LandingSeq_GoToOpeningViewCam -------------- --
function LandingSeq_GoToOpeningViewCam(p1_index, p2_index, focusPosArray, heroArray, ratchetWrench, 
                      aphelion, openingViewCam, callback, doEnableHeroes, doEndCine, volRadarDisable)

  if (doEnableHeroes == nil) then 
    doEnableHeroes = true 
  end 
  if (doEndCine == nil) then 
    doEndCine = doEnableHeroes
  end
  
  local heroes = {get_ratchet(), get_ratchet(), get_qwark(), get_clank()}
  
  fade_to_black(0.5)
  on_elapsed(0.5, function()
    if (ShowHeroTurrets ~= nil) then 
      ShowHeroTurrets()
    end
    if (doEndCine) then 
      end_cine()
    end
    hide(ratchetWrench)
    local i;
    for i = 1, #heroArray, 1 do 
      hide(heroArray[i])
    end 
    -- bring the heroes into position 
    warp(heroes[p1_index], focusPosArray[1], true, false, false, false)
    if ((p2_index ~= nil) and (p2_index > 0)) then 
      warp(heroes[p2_index], focusPosArray[2], true, false, false, false)
    end
    
		if openingViewCam ~= nil then
			fade_from_black(0.5)
			ActivateCamera(openingViewCam)
		end
    if (doEnableHeroes) then 
      on_elapsed(0.25, function()
        set_hud_fader(true)
        if (volRadarDisable ~= nil) then 
          on_hero_exit(volRadarDisable, function()
            radar_enable()
            DeactivateCamera()
            unset_event()
          end)
          EnableHeroes(false, true, false)
        else
          EnableHeroes(false)
        end
      end)
    end
    if (callback ~= nil) then   
      on_elapsed(0.5, callback)
    end
  end)
end -- end LandingSeq_GoToOpeningViewCam

As you can see, there is a EnableHeroes(false, true, false), each boolean is a character. If you put one more Ratchet in the game (for example in the local variable local heroes = {get_ratchet(), get_ratchet(), get_qwark(), get_clank()} we created 2 Ratchets. To enable them, you'll have to set 3 false and one true (NOT SURE OF THIS, TESTS NEEDED.).

3.2 > Locale Level Scripts

What are the locale level scripts?
The locale level scripts are the global.lua, zone_whitebox_gameplay.lua and herosetup.lua

3.2.1 > GLOBAL.LUA

What is the Global.Lua ? You can find this file into the levels scripts (\assets\levels\{LEVEL}_pvp\scripts\global.lua)
This file contains mainly the weapons priority on this planet. Basically these are all the same on all the levels.
The weapon priority is the order in which you'll find in the modules.

---------------------
-- Weapon Pool 
---------------------

set_unlockable_weapon_priority(WPN_DECOY, 1)
set_unlockable_weapon_priority(WPN_ICE_BEAM, 1)
set_unlockable_weapon_priority(WPN_FLAMETHROWER, 1)
set_unlockable_weapon_priority(WPN_THUNDERSTRIKE, 1)
set_unlockable_weapon_priority(WPN_ZURKON, 1)
set_unlockable_weapon_priority(WPN_SUBWOOFER, 1)
set_unlockable_weapon_priority(WPN_TIMEFIELD, 1) -- Set the Time-bomb to unlocked.
--set_unlockable_weapon_priority(WPN_BUZZ_BLADES, 1)
--set_unlockable_weapon_priority(WPN_GROOVITRON, 1)
--set_unlockable_weapon_priority(WPN_CRITTER_STRIKE, 1)

set_defense_available(WPN_PLASMA_BARRICADE, get_defense_allowed(WPN_PLASMA_BARRICADE))
``` In this file there are run scripts commands that runs the other scripts in the same file. you can modify them like this:
- Add a new file in the level\scripts directory, for example create "new_script.lua".
- Add a run_script("new_script.lua") like this: ```lua
run_script("vo_global")
run_script("invasion_database")
run_script("herosetup")
run_script("zone_whitebox_gameplay")
run_script("music")

-- ADDED RUN SCRIPTS

run_script("new_script.lua")

If your code work, you'll see maybe the in-game difference by, for example, adding some items unlockability or even by giving it at the start of the game.