Advertisement
Nuor

online prevention

May 8th, 2016
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.08 KB | None | 0 0
  1. -- put near top of _g.script
  2. ONLINE_EXCLUSION_DISTANCE = tonumber(axr_main.config:GetValue("mm_options","excl_dist",0,30))
  3.  
  4. -- replace function in sim_squad_scripted.script with
  5. function sim_squad_scripted:can_switch_online()
  6. --alun_utils.debug_write(strformat("sim_squad_scripted:switch_online %s",self:name()))
  7. if (not self.online and is_squad_monster[self.player_id] and not get_object_story_id(self.id)) then
  8. -- Check for exiled zones
  9. local zone
  10. for i,name in pairs(exiled_zones) do
  11. zone = db.zone_by_name[name]
  12. if (zone and zone:inside(self.position)) then
  13. return false
  14. end
  15. end
  16. if (self.current_action == 0) then
  17. if (self.player_id == "monster_predatory_day" and not in_time_interval(22,5)) then
  18. return false
  19. elseif (self.player_id == "monster_predatory_night" and not in_time_interval(5,22)) then
  20. --printf("%s not allowed to come online",self:name())
  21. return false
  22. elseif (self.player_id == "monster_zombied_day" and not in_time_interval(22,5)) then
  23. return false
  24. elseif (self.player_id == "monster_zombied_night" and not in_time_interval(5,22)) then
  25. return false
  26. end
  27. end
  28. --/ brute force prevent from coming online /--
  29. if self.first_update and atmosfear.valid_levels[level.name()] and (self.position:distance_to(alife():actor().position) <= ONLINE_EXCLUSION_DISTANCE) then
  30. return false
  31. end
  32. --/---------------------------------------/--
  33. end
  34. return cse_alife_online_offline_group.can_switch_online(self)
  35. end
  36.  
  37. -- replace function in se_stalker.script with
  38. function se_stalker:can_switch_online()
  39. if self.group_id ~= 65535 then
  40. return true
  41. end
  42. --/ brute force prevent from coming online /--
  43. if self.first_update and atmosfear.valid_levels[level.name()] and not(self.online) and (self.position:distance_to(alife():actor().position) <= ONLINE_EXCLUSION_DISTANCE) then
  44. return false
  45. end
  46. --/-----------------------------------------/--
  47. return cse_alife_human_stalker.can_switch_online(self)
  48. end
  49.  
  50.  
  51. function se_stalker:update()
  52. if not self.first_update then self.first_update = true end -- new
  53. cse_alife_human_stalker.update(self)
  54. end
  55.  
  56. -- replace function in se_monster.script with
  57. function se_monster:can_switch_online()
  58. if self.group_id ~= 65535 then
  59. return true
  60. end
  61. --/ brute force prevent from coming online /--
  62. if self.first_update and atmosfear.valid_levels[level.name()] and not(self.online) and (self.position:distance_to(alife():actor().position) <= ONLINE_EXCLUSION_DISTANCE) then
  63. return false
  64. end
  65. --/-----------------------------------------/--
  66. return cse_alife_monster_base.can_switch_online(self)
  67. end
  68.  
  69. function se_monster:update()
  70. if not self.first_update then self.first_update = true end -- new
  71. cse_alife_monster_base.update(self)
  72. end
  73.  
  74. -- added to make axr option
  75. -- axr_main_options.script change these functions
  76.  
  77. function main_menu_on_init(menu)
  78. -- axr option default config
  79. local need_save
  80. -- -- exclusion distance list
  81. if not (axr_main.config:KeyExist("mm_options","excl_dist")) then
  82. axr_main.config:SetValue("mm_options","excl_dist",30)
  83. need_save = true
  84. end
  85. --
  86. for k,v in pairs(check_box_options) do
  87. if not (axr_main.config:KeyExist("mm_options","enable_"..k)) then
  88. axr_main.config:SetValue("mm_options","enable_"..k,v.default)
  89. need_save = true
  90. end
  91. end
  92.  
  93. if (need_save) then
  94. axr_main.config:Save()
  95. end
  96. end
  97.  
  98. function opt_menu_on_init(menu)
  99. local xml = menu.xml
  100. local pos
  101. local y = 0
  102. -- -- exclusion distance list
  103. local excl_dist_list = {10,20,30,40,50,60,70,80,90,100,200,500}
  104. menu.list_excl_caption = xml:InitStatic("tab_gameplay:cap_list_excl_dist_axr", menu.dlg_gameplay)
  105. menu.list_excl_caption:TextControl():SetText(game.translate_string("ui_mm_excl_dist"))
  106. menu.list_excl_list = xml:InitComboBox("tab_gameplay:list_excl_dist_axr", menu.dlg_gameplay)
  107. menu.list_excl_list:ClearList()
  108. menu.list_excl_list:SetAutoDelete(true)
  109. for i,dist in pairs(excl_dist_list) do
  110. menu.list_excl_list:AddItem(dist.." meters", i-1)
  111. end
  112. menu:Register(menu.list_excl_list,"list_excl_dist")
  113. --
  114. for k,v in pairs(check_box_options) do
  115. if (v.debug_only ~= true or DEV_DEBUG) then
  116. if not (menu.axr_options_caption) then
  117. menu.axr_options_caption = {}
  118. end
  119. if not (menu.axr_options_check) then
  120. menu.axr_options_check = {}
  121. end
  122. -- caption
  123. menu.axr_options_caption[k] = xml:InitStatic("tab_gameplay:cap_check_axr", menu.dlg_gameplay)
  124. pos = menu.axr_options_caption[k]:GetWndPos()
  125. pos.y = pos.y + y
  126. menu.axr_options_caption[k]:SetWndPos(pos)
  127. menu.axr_options_caption[k]:TextControl():SetText(game.translate_string("ui_mm_"..k))
  128.  
  129. -- checkbox
  130. menu.axr_options_check[k] = xml:InitCheck("tab_gameplay:check_axr", menu.dlg_gameplay)
  131. pos = menu.axr_options_check[k]:GetWndPos()
  132. pos.y = pos.y + y
  133. menu.axr_options_check[k]:SetWndPos(pos)
  134. menu:Register(menu.axr_options_check[k],"ck_"..k)
  135. y = y + 25
  136. end
  137. end
  138. end
  139.  
  140. function opt_menu_on_accept(menu,optMgr,console)
  141. --
  142. if (menu.list_excl_list) then
  143. local num = string.match(menu.list_excl_list:GetText(),"([%d]+)%s%w")
  144. ONLINE_EXCLUSION_DISTANCE = tonumber(num)
  145. axr_main.config:SetValue("mm_options","excl_dist",tonumber(num))
  146. end
  147. --
  148. for k,v in pairs(check_box_options) do
  149. if (menu.axr_options_check and menu.axr_options_check[k]) then
  150. axr_main.config:SetValue("mm_options","enable_"..k,menu.axr_options_check[k]:GetCheck())
  151. end
  152. end
  153.  
  154. if (level.present() and dynamic_news_manager) then
  155. if (axr_main.config:GetValue("mm_options","enable_dynamic_news",1,true) == true) then
  156. dynamic_news_manager.get_dynamic_news()
  157. else
  158. dynamic_news_manager.destroy_dynamic_news()
  159. end
  160. end
  161.  
  162. axr_main.config:Save()
  163. end
  164.  
  165. function opt_menu_on_set_values(menu,optMgr)
  166. --
  167. if (menu.list_excl_list) then
  168. menu.list_excl_list:SetText(axr_main.config:GetValue("mm_options","excl_dist",0,30).." meters")
  169. end
  170. --
  171. for k,v in pairs(check_box_options) do
  172. if (menu.axr_options_check and menu.axr_options_check[k]) then
  173. menu.axr_options_check[k]:SetCheck(axr_main.config:GetValue("mm_options","enable_"..k,1,false))
  174. end
  175. end
  176. end
  177.  
  178. -- ui_mm_opt_16.xml these sections added or changed in "tab_gameplay"
  179.  
  180.  
  181. <cap_list_excl_dist_axr x="250" y="3" width="80" height="24">
  182. <text r="170" g="170" b="170" font="letterica16" align="r" vert_align="c">ui_mm_excl_dist</text>
  183. </cap_list_excl_dist_axr>
  184. <list_excl_dist_axr x="335" y="5" width="75" height="20">
  185. <list_font r="170" g="170" b="170" font="letterica16"/>
  186. <text_color>
  187. <e r="170" g="170" b="170"/>
  188. <d r="70" g="70" b="70"/>
  189. </text_color>
  190. </list_excl_dist_axr>
  191.  
  192. <cap_check_axr x="247" y="28" width="108" height="24">
  193. <text r="170" g="170" b="170" font="letterica16" align="r" vert_align="c"></text>
  194. </cap_check_axr>
  195. <check_axr x="364" y="25" width="35" stretch="1" height="29">
  196. <texture>ui_inGame2_checkbox</texture>
  197. </check_axr>
  198.  
  199. -- ui_st_mm.xml add section
  200.  
  201. <string id="ui_mm_excl_dist">
  202. <text>Online exclusion radius</text>
  203. </string>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement