home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2005 January / Gamestar_69_2005-01_dvd.iso / Dema / theprojectv1-0.exe / FCData / Scripts.pak / Scripts / main.lua < prev    next >
Encoding:
Text File  |  2004-09-01  |  9.2 KB  |  269 lines

  1. -- some defines for the music-moods: time in seconds how long it takes to switch the mood if an specific mood event arrives continuesly
  2. MM_COMBAT_TIMEOUT=1;    -- Combat
  3. MM_SNEAKING_TIMEOUT=3;    -- Sneaking (crouching, proning, moving slow, not seen by AI)
  4. MM_SNIPER_TIMEOUT=2;    -- Sniper (looking through sniper-scope)
  5. MM_OBSERVE_TIMEOUT=2;    -- Observe (using binocular)
  6. MM_SUSPENSE_TIMEOUT=2;    -- Suspense (AI near)
  7. MM_ALERT_TIMEOUT=2.5;    -- AI is alerted
  8. MM_NEARSUSPENSE_TIMEOUT=2;    -- AI is very near
  9.  
  10. BULLET_REJECT_TYPE_NONE=0;
  11. BULLET_REJECT_TYPE_SINGLE=1;
  12. BULLET_REJECT_TYPE_RAPID=2;
  13.  
  14. function Init()
  15.     --System:LoadFont("radiosta");
  16.     --System:LoadFont("hud");
  17.     Script:ReloadScript("scripts/common.lua");
  18.     Script:ReloadScript("scripts/Map.lua");
  19.     --Script:ReloadScript("scripts/StateMachine.lua");
  20.     --Script:ReloadScript("SCRIPTS/Default/Inventory.lua");
  21.     Script:ReloadScript("scripts/EntityGroupMgr.lua");
  22.     --Script:ReloadScript("scripts/methoddispatcher.lua");
  23.     --Script:ReloadScript("scripts/saveutils.lua" );
  24.     Script:ReloadScript("scripts/sounds/PresetDB.lua" );
  25.     Script:ReloadScript("scripts/sounds/EAXPresetDB.lua" );
  26.     --Script:ReloadScript("scripts/Multiplayer/AvailableMods.lua");            -- AvailableMODList
  27.  
  28.  
  29. --    Script:LoadScript( "scripts/default/hud/nightvision.lua" );
  30. --    NightVision.OnInit( NightVision );
  31. --    Script:LoadScript( "scripts/default/hud/heatvision.lua" );
  32. --    HeatVision.OnInit( HeatVision );
  33.  
  34.     --Script:ReloadScript( "Scripts/Default/Entities/Player/BasicPlayer.lua" );
  35.     --Script:ReloadScript( "SCRIPTS/Default/Entities/AI/BasicAI.lua");
  36.  
  37.     --Script:ReloadScript( "SCRIPTS/BALANCING.lua");
  38.  
  39.     --Script:ReloadScript("scripts/Default/Entities/Weapons/BasicWeapon.lua");
  40.     --Script:ReloadScript("scripts/Default/Entities/Weapons/MountedWeaponBase.lua");
  41.  
  42.     --Script:LoadScript("Scripts/AI/Behaviors/AIBehaviour.lua");
  43.     --Script:LoadScript("Scripts/AI/Characters/AICharacter.lua");
  44.     --Script:LoadScript( "Scripts/Default/Entities/Pickups/BasicPickup.lua" );
  45.  
  46.     -----------------------------------------------------------------
  47.     -- loading of the game mission list
  48.     ------------------------------------------------------------
  49.     --Script:ReloadScript("scripts/defiant.lua");
  50.     --Script:ReloadScript("scripts/DebugTagPointsMgr.lua");
  51.  
  52.     --Script:ReloadScript("scripts/Multiplayer/MultiplayerUtils.lua");
  53.     --Script:ReloadScript("scripts/Multiplayer/CreateVariables.lua");
  54.     --Script:ReloadScript("scripts/Multiplayer/MPStatistics.lua");
  55.     --Script:ReloadScript("scripts/Multiplayer/ModelList.lua");
  56.     
  57.     --explosion effects
  58. --    Script:LoadScript("scripts/materials/commoneffects.lua");
  59.  
  60.     -- dynamically apply physics and automatic settings based on sys_spec
  61.     ApplySysSpecSettings();
  62. end
  63.  
  64. function ApplySysSpecSettings()
  65.       local sysspec = getglobal( "sys_spec" );
  66.     if( sysspec ) then
  67.         local quality = tonumber( sysspec );
  68.           ApplyPhysicsQuality( quality );
  69.           ApplyAutomaticSettings( quality );
  70.     end
  71. end
  72.  
  73. function ApplyPhysicsQuality( qual )
  74.       if( qual >= 2 ) then
  75.         setglobal( "physics_quality", 2 );
  76.         setglobal( "p_max_contacts", 150 );
  77.         setglobal( "p_max_MC_iters", 6000 );
  78.         setglobal( "p_max_MC_iters_hopeless", 6000 );
  79.         setglobal( "p_max_LCPCG_iters", 5 );
  80.         setglobal( "p_max_LCPCG_subiters", 70 );
  81.         setglobal( "p_max_LCPCG_subiters_final", 180 );
  82.         setglobal( "p_max_LCPCG_microiters", 14000 );
  83.         setglobal( "p_max_LCPCG_microiters_final", 30000 );
  84.         setglobal( "p_max_substeps", 5 );
  85.         setglobal( "p_max_contact_gap", 0.01 );
  86.       elseif( qual == 1 ) then
  87.         setglobal( "physics_quality", 1 );
  88.         setglobal( "p_max_contacts", 90 );
  89.         setglobal( "p_max_MC_iters", 4000 );
  90.         setglobal( "p_max_MC_iters_hopeless", 4000 );
  91.         setglobal( "p_max_LCPCG_iters", 4 );
  92.         setglobal( "p_max_LCPCG_subiters", 50 );
  93.         setglobal( "p_max_LCPCG_subiters_final", 130 );
  94.         setglobal( "p_max_LCPCG_microiters", 10000 );
  95.         setglobal( "p_max_LCPCG_microiters_final", 20000 );
  96.         setglobal( "p_max_substeps", 4 );
  97.         setglobal( "p_max_contact_gap", 0.01 );
  98.       else
  99.         setglobal( "physics_quality", 0 );
  100.         setglobal( "p_max_contacts", 90 );
  101.         setglobal( "p_max_MC_iters", 2800 );
  102.         setglobal( "p_max_MC_iters_hopeless", 2800 );
  103.         setglobal( "p_max_LCPCG_iters", 0 );
  104.         setglobal( "p_max_LCPCG_subiters", 0 );
  105.         setglobal( "p_max_LCPCG_subiters_final", 0 );
  106.         setglobal( "p_max_substeps", 3 );
  107.         setglobal( "p_max_contact_gap", 0.015 );
  108.     end
  109.     System:LogToConsole( "Physics quality settings set to : "..qual );
  110. end
  111.  
  112. function ApplyAutomaticSettings( qual )
  113.       if( qual == 0 ) then
  114.         setglobal( "ai_update_interval", 0.2 );
  115.         setglobal( "w_underwaterbubbles", 0 );
  116.         setglobal( "ai_max_vis_rays_per_frame", 50 );
  117.         System:LogToConsole( "Automatic settings set to low spec..." );
  118.     elseif( qual == 1 ) then
  119.         setglobal( "ai_update_interval", 0.1 );
  120.         setglobal( "w_underwaterbubbles", 1 );
  121.         setglobal( "ai_max_vis_rays_per_frame", 100 );
  122.         System:LogToConsole( "Automatic settings set to medium spec..." );
  123.     elseif( qual == 2 ) then
  124.         setglobal( "ai_update_interval", 0.1 );
  125.         setglobal( "w_underwaterbubbles", 1 );
  126.         setglobal( "ai_max_vis_rays_per_frame", 150 );
  127.         System:LogToConsole( "Automatic settings set to high spec..." );
  128.       else
  129.         setglobal( "ai_update_interval", 0.1 );
  130.         setglobal( "w_underwaterbubbles", 1 );
  131.         setglobal( "ai_max_vis_rays_per_frame", 300 );
  132.         System:LogToConsole( "Automatic settings set to very high spec..." );
  133.     end
  134. end
  135.  
  136. function Shutdown()
  137.     Game:SaveConfiguration();
  138. end
  139.  
  140.  
  141. function DebugDumpPlayer( playerent )
  142.     if not playerent then
  143.         System:Log("  nil");
  144.         return;
  145.     end
  146.  
  147.     if playerent.type~="Player" then
  148.         return;
  149.     end
  150.  
  151.     local pos=playerent:GetPos();
  152.     local angles=playerent:GetAngles();
  153.  
  154.     System:Log("{");
  155.     System:Log("  pos=("..tostring(pos.x)..","..tostring(pos.y)..","..tostring(pos.z)..")");
  156.     System:Log("  angles=("..tostring(angles.x)..","..tostring(angles.y)..","..tostring(angles.z)..")");
  157.     System:Log("  id="..tostring(playerent.id));
  158.     System:Log("  name="..tostring(playerent:GetName()));
  159.     System:Log("  team="..tostring(Game:GetEntityTeam(playerent.id)));
  160.     System:Log("  health="..tostring(playerent.cnt.health).."/"..tostring(playerent.cnt.max_health));
  161.     System:Log("  invulnerabilityTimer="..tostring(playerent.invulnerabilityTimer));
  162.     System:Log("  GetState()="..tostring(playerent:GetState()));
  163.     System:Log("}");
  164. end
  165.  
  166.  
  167.  
  168. function DebugDump()
  169.     System:Log("-------------------------------------------------");
  170.     System:Log("- DebugDump -------------------------------------");
  171.     System:Log("-------------------------------------------------");
  172.  
  173.     System:Log("_localplayer=");
  174.     DebugDumpPlayer(_localplayer);
  175.  
  176.     System:Log("-------------------------------------------------");
  177.     local ents=System:GetEntities();
  178.     for idx,ent in ents do
  179.         if ent and ent.type=="Player" then
  180.             System:Log("entity player=");
  181.             DebugDumpPlayer(ent);
  182.         end
  183.     end
  184.  
  185.     System:Log("-------------------------------------------------");
  186.     if Server then
  187.         local slots = Server:GetServerSlotMap();
  188.         for i, slot in slots do
  189.             local ent = System:GetEntity(slot:GetPlayerId());
  190.             System:Log("serverslot "..tostring(i).." player=");
  191.             DebugDumpPlayer(ent);
  192.         end
  193.     else
  194.         System:Log("Server=nil");
  195.      end
  196.  
  197.      System:Log("-------------------------------------------------");
  198.      System:Log("gr_InvulnerabilityTimer="..tostring(gr_InvulnerabilityTimer));
  199.  
  200.      System:Log("-------------------------------------------------");
  201.  
  202.     System:Log("g_GameType="..tostring(getglobal("g_GameType")));
  203.     System:Log("GameRules "..tostring(getglobal("GameRules")));
  204.     System:Log("ClientStuff "..tostring(getglobal("ClientStuff")));
  205.  
  206.     if getglobal("GameRules") then
  207.         if getglobal("GameRules").GetState then
  208.             System:Log("GameRules state="..tostring(getglobal("GameRules"):GetState()));
  209.         else
  210.             System:Log("GameRules:GetState() failed");
  211.         end
  212.     else
  213.         System:Log("GameRules=nil");
  214.      end
  215. end
  216.  
  217. --  deactivated because it's not needed right now
  218. ---------------------------------------------------------------------------------
  219. -- is called by C/C++ when we successfully loaded the gamerules file but before the GameRules:OnInit() was called
  220. --function OnAfterLoadGameRules( newGameType )
  221. --
  222. --    if newGameType=="" or newGameType=="Default" then
  223. --        MultiplayerUtils:OnSinglePlayer();
  224. --    else
  225. --        MultiplayerUtils:OnMultiplayer();
  226. --    end
  227. --end
  228.  
  229.  
  230. function Game:SetSensitivity(sens)
  231.     if (sens and tonumber(sens)) then
  232.         sens = tonumber(sens);
  233.         
  234.         if (sens < 1.0) then
  235.             sens = 1.0;
  236.         end
  237.         
  238.         if (Input) then
  239.             Input:SetMouseSensitivity(sens);
  240.         end
  241.     elseif (Input) then
  242.         System:Log("\001sensitivity = "..Input:GetMouseSensitivity());
  243.     end
  244. end
  245.  
  246. function SProfile_run(szName)
  247.     
  248.     Game:Disconnect();
  249.     
  250.     if (SProfile_load(szName)) then
  251.         Game:LoadLevelListen(getglobal('gr_NextMap'));
  252.         
  253.         return 1;
  254.     end
  255.     return nil;
  256. end
  257.  
  258. function SProfile_load(szName)
  259.     if (Script:LoadScript('profiles/server/'..tostring(szName)..'_server.cfg', 1, 0)) then
  260.         return 1;
  261.     elseif (Script:LoadScript(tostring(szName), 1, 0)) then
  262.         return 1;
  263.     end
  264.     
  265.     System:Log("\001failed to load profile '"..szName.."'.");
  266.     
  267.     return nil;
  268. end
  269.