1. ВКонтакте
  2. Facebook

EnergyAutoDrain

Супер Админ
  1. Оффлайн
  2. VIP
  3. 117 сообщений
  4. Сообщение
  5. Личные данные
Полезность: 0 | сообщение № 1 отправлено 08:53, 19.10.2011
EnergyAutoDrain


php code:
  1. -- ===============================================
  2. -- Name: EnergyAutoDrain
  3. -- Author: treter
  4. -- Email: finfarenath@googlemail.com
  5. -- ===============================================
  6.  
  7. --[[
  8. Here is the actual Version of the AutomatedEnergyDrain system, changing the
  9. rules for a PowerStruggle game to automatically transfer energy from the
  10. opposing faction on science factory ownage as well as automatically draining
  11. energy if you are unable to hold energypoints and science facility for a given
  12. amount of time.
  13.  
  14. Automatic Energy Transfer and Drain system.
  15. You can config this system to automatically transfer eh gained amount of energy
  16. from one team to the other team when the gaining team owns energypoints and a
  17. science facility. This will spice the game up as for every energypoint gained
  18. the opponent team will loose the same amount. Hence motivating the parties to
  19. still fight for energy sites as well as the science facility, after gaining
  20. 100% once.
  21.  
  22. Additionally you can enable a timed energy drain, which means, that if one team
  23. has not owned a science facility nor an energy point for a given amount of
  24. seconds, the energy will slowly start to drain until it reaches zero level.
  25.  
  26. Both rules are individually configurable via chatcommand. Command will go into
  27. extensions/EnergyAutoDrain.lua.
  28.  
  29. Compatible with SSM Patriot 1.1.0, 1.1.1.
  30.  
  31. Have fun using this extension. Comments and Ideas please go to FinFarenath
  32. (@FinFarenath.com)
  33. --]]
  34. --[ code ]----------------------------------------
  35.  
  36. conf.Energy = {
  37.     enableTransfer = true; --Enable transfer of energy of opponent energy store, when increasing energy?
  38.     enableDrain = true; --Enable times energydrain, draining your energy  if you aren't able to recaputre an energypoint ot science facility after a given amount of time.
  39.    timedDecreaseStart = 30; --Number of seconds after wich a timed decrease in energy will start.
  40.    timedDecreaseAmount = 0.5; --Amount of timed decrease of energy each second.
  41. };
  42.  
  43.  
  44. EnergyDrain = {
  45.    teamName = {"NK", "US"};    
  46.    teamOpponent = {2,1};    
  47.    lastIncrease = {0.0, 0.0};    
  48.    timer = 0;    
  49.    currentEnergy = {};    
  50.    deltaEnergy = {};    
  51.    lastEnergy = {};    
  52.    lastTeamEnergyDrain = {false, false}; --Last team that has a draining energy    
  53.    lastTeamEnergyIncrease = 0; --Last team that has an increase in energy
  54. };
  55.  
  56. AddTimerTrigger("#decreaseEnergy()", 1);
  57.  
  58. EnergyDrain.lastEnergy[1] = g_gameRules:GetTeamPower(1);
  59. EnergyDrain.lastEnergy[2] = g_gameRules:GetTeamPower(2);
  60.  
  61. function decreaseEnergy(player)    
  62.    EnergyDrain.timer = EnergyDrain.timer + 1; --Calculate deltas from past mesurement    
  63.    
  64.    for team=1, 2 do          
  65.        EnergyDrain.currentEnergy[team] = g_gameRules:GetTeamPower(team);          
  66.        EnergyDrain.deltaEnergy[team] = EnergyDrain.currentEnergy[team] - EnergyDrain.lastEnergy[team];    
  67.    end --Determin which one is increased to decrease the counter one    
  68.    
  69.    local teamEnergyIncrease = 0; --Which team has an energy increase and thusfor potentially a science facility?    
  70.    for team=1, 2 do          
  71.        if (EnergyDrain.deltaEnergy[team] > 0.0) then              
  72.            if (EnergyDrain.lastTeamEnergyIncrease ~= team and conf.Energy.enableTransfer) then                    
  73.                EnergyDrain.lastTeamEnergyIncrease = team; -- We only want the message to appear once.                    
  74.                ConsoleMessage:ToAdmins("$9[$3NRG$9] Energy increment on "..EnergyDrain.teamName[team].." team detected.");              
  75.            end              
  76.            EnergyDrain.lastIncrease[team] = EnergyDrain.timer;              
  77.            if (conf.Energy.enableTransfer) then                    
  78.                g_gameRules:SetTeamPower(EnergyDrain.teamOpponent[team], math.max(EnergyDrain.currentEnergy[EnergyDrain.teamOpponent[team]] - EnergyDrain.deltaEnergy[team], 0.0));              
  79.            end              
  80.            teamEnergyIncrease = team;          
  81.        end    
  82.    end    
  83.    
  84.    if (teamEnergyIncrease == 0) then          
  85.        EnergyDrain.lastTeamEnergyIncrease = team;      
  86.    end --Overtime decreases    
  87.    
  88.    local EnergySites = {0, 0};    
  89.    local AlienEnergySites = System.GetEntitiesByClass("AlienEnergyPoint");    
  90.    
  91.    for i, AlienEnergySite in ipairs(AlienEnergySites) do
  92.        local team = g_gameRules.game:GetTeam(AlienEnergySite.id);        
  93.        if (team and (team==1 or team==2)) then              
  94.            EnergySites[team]=EnergySites[team]+1;          
  95.        end    
  96.    end --If you have no powerplant AND the others increase power AND you havent increased power for X seconds, your power will start to drain.    
  97.    
  98.    local energyDraingedThisTime = false;    
  99.    for team=1, 2 do          
  100.        if ((EnergyDrain.timer - EnergyDrain.lastIncrease[team]) > conf.Energy.timedDecreaseStart and EnergySites[team] == 0) then              
  101.            if ((not EnergyDrain.lastTeamEnergyDrain[team]) and conf.Energy.enableDrain) then                    
  102.                EnergyDrain.lastTeamEnergyDrain[team] = true; -- We only want the message to appear once.      
  103.                ConsoleMessage:ToAdmins("$9[$3NRG$9] Energydrain on "..EnergyDrain.teamName[team].." team detected.");  
  104.            end              
  105.            if (conf.Energy.enableDrain) then                    
  106.                g_gameRules:SetTeamPower(team, math.max(g_gameRules:GetTeamPower(team) - conf.Energy.timedDecreaseAmount, 0.0));                    
  107.            end              
  108.            energyDraingedThisTime = true;          
  109.        else              
  110.            EnergyDrain.lastTeamEnergyDrain[team] = false;          
  111.        end              
  112.    end    
  113.    
  114.    if (not energyDraingedThisTime) then          
  115.        EnergyDrain.lastTeamEnergyDrain[1] = false;          
  116.        EnergyDrain.lastTeamEnergyDrain[2] = false;    
  117.    end    
  118.    
  119.    for team=1, 2 do          
  120.        EnergyDrain.lastEnergy[team] = g_gameRules:GetTeamPower(team);    
  121.    end    
  122.    
  123.    return true;    
  124. end
  125.  
  126. --[ code ]----------------------------------------

У Вас недостаточно прав для скачивания файлов.


------------------------------------------
DDR3 8G (4*2G), 1600МГц Это мало?
 
Поделиться темой:
Перейти

Доступ закрыт.

  1. Вам запрещено отвечать в темах данного форума.

Последние темы

  1. Настройка серверного мода Crysis
    Автор: dimas824 18:04, 12.01.2013
  2. Crysis 2 обсуждение
    Автор: PGJA44 23:01, 07.01.2013
  3. Crysis 2 Настройка Servera (Вопросы)
    Автор: seregas 13:18, 29.12.2012
  4. Crysis Wars обсуждение
    Автор: coody55 12:22, 21.11.2012
  5. AEGISX Как убрать бесконечные (40) патро...
    Автор: coody55 12:10, 21.11.2012
  6. Pioneer
    Автор: coody55 18:05, 08.11.2012

Изменения статуса

  1. профиль Воин будущего 20:35, 10.12.2012
  2. профиль ИЩЮ КЛЮЧЬ НА CRYSIS 2 ЕСЛИ ЕСТЬ ТО ДАЙ 23:39, 04.05.2012
  3. профиль как делать серийный номер ключ 23:56, 24.02.2012
  4. профиль ыца! 11:04, 30.01.2012
  5. профиль DDR3 8G (4*2G), 1600МГц Это мало? 22:56, 29.01.2012
  6. профиль i5-2500k gigabyte z68x GTX 580 msi 8 гб оперативной памят... 23:14, 21.12.2011

За последние 10 минут эту тему посетило 1 человек (0 пользователей, 1 гостей, 0 скрытых пользователей)
Полный список по: последнему действию или именам пользователей