Guest User

Untitled

a guest
Dec 10th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 9.13 KB | None | 0 0
  1. #######################
  2. ##  HellJump 0.1     ##
  3. ##  by DPOH-VAR(c)   ##
  4. ##  2012             ##
  5. #######################
  6.  
  7.  
  8. ######## Настройки
  9.  
  10. ######## Текст
  11. "\c6[\c4\clHell\c6\cl\cnJ\c4\clump\c6]\cr " %%text_prefix
  12. "\cbДобро пожаловать в игру\nХостер: \c6"     %%text_greet
  13. "\cbИгра завершена\cr"                         %%text_endgame
  14. "\cbВы начали игру\nЧтобы исключить игрока, введите \c6-r ник\cb\nДля начала игры введите \c6-s\cb\nДля просмотра игроков введите \c6-p\cb\nДля отмены введите \c6-c\cr"
  15.                                             %%text_admin_greet
  16. "\cbИгроки: \c6"                          %%text_players
  17. " \cc- игрок не найден\cr"                     %%text_error_playernotfound
  18. "\ccНевозможно исключить себя из списка\cr"  %%text_error_playerrmself
  19. "\ccИгра уже запущена\cr"                    %%text_error_alreadyplaying
  20. "\ccСлишком много игроков\cr"                %%text_error_toomanyplayers
  21. " \ccпокинул игру\cr"                        %%text_action_live
  22. " \ccВы проиграли! счет игры: \c6"           %%text_action_gameover
  23. " \ccВышел из игры: \c6"                 %%text_action_playerleave
  24. " \cbСчет: \c6"                             %%text_action_sendscore
  25. ######## Текст команды
  26. "-r"                %%text_cmd_c
  27. "-p"                %%text_cmd_p
  28. "-s"                %%text_cmd_start
  29. "-c"                %%text_cmd_cancel
  30. ######## Текст метадаты
  31. "game:start"        %%meta_block_playflag
  32. "game:score"        %%meta_player_score
  33. "game:gm"           %%meta_player_gm
  34. "game:food"         %%meta_player_food
  35. "game:hp"           %%meta_player_hp
  36. "game:loc"          %%meta_player_loc
  37.  
  38. ######## Мета-данные блока
  39. EVENT(BLOCK) %%mainBlock
  40. [] %%metadataNames
  41. :WriteMeta{ ## запись мета-данных ## value string ->
  42.     DUP @@metadataNames SWAP AHAS !IF ## если нет в списке
  43.         DUP *metadataNames (@@)RAW(22)  SWAP (ADD)RAW(6D) DROP ## то пишем в список
  44.         THEN
  45.     @@mainBlock ROT ROT >META DROP
  46.    
  47. }
  48. :ReadMeta{ ## чтение мета-данных ## string -> value
  49.     @@mainBlock SWAP META
  50. }
  51. :ClearMeta{ ## очистка всех мета-данных ## ->
  52.     @@metadataNames @@mainBlock << RMMETA  DROP
  53. }
  54.  
  55.  
  56. ######## игроки
  57. :SendMsg{ ## [player] text ->
  58.     @@text_prefix SWAP CONCAT
  59.      SWAP
  60.      25 PlaySound
  61.      &{ OVER MSG DROP} DROP
  62. }
  63. :AddToPlayers{ ## player ->
  64.     <P @@players SWAP RAW(6D) %%players
  65. }
  66. :ViewPlayers{ ## player ->
  67.     @@text_players @@players S+
  68.     SendMsg
  69. }
  70. :RemoveFromPlayers{ ## player ->
  71.     <P *players RAW(22) SWAP RAW(6C) (remove)
  72.      LEN 0 = IF EndGame THEN
  73. }
  74. :TryRemovePlayer{ ## string ->  
  75.      DUP <P @@players SWAP AHAS IF
  76.         DUP <P ME = IF
  77.             ME @@text_error_playerrmself SendMsg
  78.             ELSE
  79.             DUP RemoveFromPlayers
  80.             ME ViewPlayers
  81.             THEN
  82.         ELSE
  83.         ME OVER @@text_error_playernotfound S+ SendMsg
  84.         THEN
  85.      DROP
  86. }
  87. :EndGame{
  88.     @@players @@text_endgame SendMsg
  89.     FALSE %%game
  90.     2 WAIT
  91.     ClearMeta
  92.     @@platforms &{
  93.         ${ @@supermaterial SETBLOCK } DROP
  94.     }
  95.     END
  96. }
  97. :PlaySound{ ## [player] sound -> [player]
  98.     SWAP ##(snd [pl])
  99.     ${
  100.         OVER ##(snd pl snd)
  101.         OVER ##(snd pl snd pl)
  102.         SWAP ##(snd pl pl snd)
  103.         1 SWAP ##(snd pl pl 1 snd)
  104.         1 ##(snd pl pl 1 snd 1)
  105.         SENDSOUND ##(snd pl)
  106.     } ##(snd [pl])
  107.     SWAP DROP  
  108. }
  109. ##(5 - хрип)
  110. ##(6 - рыгун)
  111. ##(22 - чел)
  112. ##(25 27 62 - бульк)
  113. ##(28 звонок)
  114. ##(34 громкий дзынь)
  115. ##(35 хороший дзынь)
  116. ##(41 снежок или стрела)
  117. ##(56 противный мяу)
  118. ######## Хандлеры
  119. :H_chat_admin_lobby{
  120.     EVENT(PLAYER) ME = ! IF RETURN THEN
  121.     EVENT(TEXT) %t
  122.     @t @@text_cmd_c " " S+ STARTS IF
  123.         EVENT(CANCEL)
  124.         @t " " SPLIT 1 AGET TryRemovePlayer
  125.         RETURN
  126.         THEN
  127.     @t @@text_cmd_cancel = IF EVENT(CANCEL) EndGame THEN
  128.     @t @@text_cmd_start = IF EVENT(CANCEL) SEND(adm_start) THEN
  129. }
  130. :H_chat_player_lobby{
  131.     EVENT(PLAYER) %p
  132.     @@players @p AHAS !IF RETURN THEN
  133.     EVENT(TEXT) %t
  134.     @t @@text_cmd_p = IF EVENT(CANCEL) @p ViewPlayers RETURN THEN
  135.     ()@t @@text_cmd_c =
  136.     ()@p ME = !
  137.       AND IF
  138.         EVENT(CANCEL)
  139.         @p @@text_action_live S+ @@players &{OVER SendMsg} DROP
  140.         RETURN
  141.         THEN
  142. }
  143.  
  144. ######## проверка
  145. @@meta_block_playflag ReadMeta UUID = IF
  146.     ME
  147.      5 PlaySound
  148.      @@text_error_alreadyplaying SendMsg
  149.     END
  150.     THEN
  151. ######## инициализация лобби
  152. UUID @@meta_block_playflag WriteMeta
  153. ME 5 SPHERE PLAYERS INSIDE &AddToPlayers
  154. @@players ME AREM &{ @@text_greet ME S+ SendMsg }
  155. ME @@text_admin_greet SendMsg
  156. @@players &ViewPlayers
  157. *H_chat_admin_lobby REG(CHAT) %adm_chat
  158. *H_chat_player_lobby REG(CHAT) %plr_chat
  159. AWAIT(adm_start)
  160. @adm_chat UNREG @plr_chat UNREG
  161.  
  162.  
  163.  
  164.  
  165. ######## еще немного настройки
  166. ^JUKEBOX %%material
  167. ^SPONGE %%supermaterial
  168. 4 %%fuse
  169. 0.9 %%period
  170. 0.4 %%chance
  171. TRUE %%game
  172.  
  173. ######## игра
  174. "Сканирование арены..." .
  175.  
  176. @@mainBlock 10 SPHERE ?{ID @@supermaterial ID =}
  177. "Сканирование завершено, найдено " OVER LEN S+ " блоков" S+ .
  178. "Поиск платформ..." .
  179. [0:0:0,0:0:1,1:0:1,1:0:0] %plate
  180. ## отсеиваем только блоки, являющиеся началом платформы
  181. ##  (bb)| b true (vv)| t
  182. ?{ @plate TRUE << {3 RAW(15)(pick 3th) SWAP LV+ <B ID @@supermaterial ID = AND} SWAP DROP }
  183. "Поиск платформ завершен" .
  184. [] %%platforms ## платформы
  185. &{ ## poll blocks
  186.     @plate ${OVER SWAP V+ <B} SWAP DROP *platforms RAW(22) SWAP (ADD)RAW(6D) DROP
  187.     ## [bbbb]
  188. }
  189. "найдено платформ: " @@platforms LEN S+ .
  190. @@players LEN @@platforms LEN > IF
  191.     @@players @@text_error_toomanyplayers SendMsg
  192.     EndGame
  193.     THEN
  194. [] %%platstate ## записываем состояние платформы (есть или нет)
  195. [] %%platrevstate ## записываем состояние платформы (восстановлена ли)
  196. @@platforms LEN 0 DO {
  197.     @@platstate I ADD %%platstate
  198. }
  199.  
  200. :CenterPlatform{ ## Array(blocks) -> Location
  201.     FIRST 1:1:1 LV+
  202. }
  203. :_RmEntAfterTime{ ## time [ents]
  204.     SWAP WAIT &RM
  205. }
  206. :RmEntAfterTime{ ## [ents] time ->
  207.     *_RmEntAfterTime START(2) DROP
  208. }
  209. :RebuildPlatform{ ## int(platform-id) ->
  210.     @@platstate OVER ADD %%platstate
  211.     @@platforms SWAP AGET RebuildPlatformByBlocks
  212. }
  213. :RebuildPlatformByBlocks{ ## Array(blocks) ->
  214.     ${ @@material SETBLOCK } DROP
  215. }
  216. :DestroyPlatform{ ## int(platform-id) ->
  217.     @@platforms SWAP AGET
  218.      DUP CenterPlatform 0 EXPLODE
  219.      SWAP
  220.      ${
  221.         0 >BL
  222.         @@material SPAWNFALLINGBLOCK
  223.         FALSE >FALLDROP ##(loc,fb)
  224.         OVER OVER ##(loc,fb,loc,fb)
  225.         BETWEEN ##(loc,fb,vec)
  226.         2 VY+ 0.2 V* THROW  ##(loc,fb)
  227.      }
  228.      0.5 RmEntAfterTime
  229.      DROP
  230. }
  231. :GetScore{ ## player -> int
  232.     <P @@meta_player_score META
  233. }
  234. :SetScore{ ## player int  -> player
  235.     SWAP <P SWAP @@meta_player_score >META
  236. }
  237. :PlayerStore{ ## player -> player
  238.     <P
  239.     DUP GM @@meta_player_gm SETMETA
  240.     DUP FOOD @@meta_player_food SETMETA
  241.     DUP HP @@meta_player_hp SETMETA
  242.     DUP <L @@meta_player_loc SETMETA
  243.     0 @@meta_player_score SETMETA
  244. }
  245. :PlayerRestore{ ## player -> player
  246.     <P
  247.     DUP @@meta_player_gm META SETGM
  248.     DUP @@meta_player_food META SETFOOD
  249.     DUP @@meta_player_hp META SETHP
  250.     DUP @@meta_player_loc META TP
  251. }
  252. :PlayerDefeat{ ##player ->
  253.     DUP @@text_action_gameover OVER GetScore S+ SendMsg
  254.     DUP PlayerRestore RemoveFromPlayers
  255.     @@text_action_playerleave SWAP S+ @@players SWAP SendMsg
  256. }
  257. :H_dmg_playerdamage{
  258.     EVENT(ENTITY) %p
  259.     @@players @p AHAS ! IF RETURN THEN
  260.     EVENT(REASON) %r
  261.     EVENT(CANCEL) RELEASE
  262.     @r "FALL" =! IF RETURN THEN
  263.     @@platforms ${CenterPlatform @p DISTANCE 2 < }
  264.     () FALSE << OR IF
  265.         RETURN THEN
  266.     @p @@score @@meta_player_score SETMETA PlayerDefeat
  267. }
  268. :PreparePlayers{
  269.     @@platforms %_p
  270.     @@players ${
  271.         PlayerStore
  272.         1 >GM
  273.         @_p ARND %_t
  274.         @_t CenterPlatform TP
  275.         @_p @_t AREM %_p
  276.     } DROP
  277. }
  278. :_StartDestroyPlatform{ ## ent int ->
  279.     @@fuse WAIT
  280.     @@game !IF RETURN THEN
  281.     SWAP
  282.     RM
  283.     DUP DestroyPlatform
  284.     @@period 2 7 RNDF D* WAIT
  285.     StartRebuildPlatform DROP
  286. }
  287. :StartDestroyPlatform{ ## int ->
  288.     @@platstate OVER AREM %%platstate
  289.     @@platforms OVER AGET CenterPlatform 2 LY+ "primed_tnt" SPAWNMOB
  290.     0 SETYIELD
  291.     *_StartDestroyPlatform START(2) DROP
  292. }
  293. :_StartRebuildPlatform{ ## ents int ->
  294.     0.4 WAIT
  295.     SWAP
  296.     &RM
  297.     RebuildPlatform
  298. }
  299. :StartRebuildPlatform{ ## int -> int
  300.     @@game !IF RETURN THEN
  301.     DUP @@platforms OVER AGET ${
  302.         -2 LY+
  303.         @@material SPAWNFALLINGBLOCK
  304.         FALSE >FALLDROP
  305.         0.45 THROW
  306.     }
  307.     *_StartRebuildPlatform START(2) DROP
  308. }
  309. @@platforms &RebuildPlatformByBlocks
  310. PreparePlayers
  311. 0 %%score
  312. *H_dmg_playerdamage REG(DMG) %plr_dmg
  313. 2 WAIT
  314. BEGIN @@players LEN 0 > @@game AND WHILE
  315.     @@platstate LEN 1 > IF
  316.         RANDOM @@chance > IF
  317.             @@platstate ARND StartDestroyPlatform
  318.             @@score 1 + %%score
  319.             @@score RAW(4A05) 0 = IF
  320.                 @@chance 0.7 D* %%chance
  321.                 THEN
  322.             @@score RAW(4A0A) 0 = @@score 100 <= AND IF
  323.                 @@players @@text_action_sendscore @@score S+ SendMsg
  324.                 THEN
  325.             @@score RAW(4A14) 0 = IF
  326.                 @@chance 0.95 D* %%chance
  327.                 @@fuse 0.95 D* %%fuse
  328.                 THEN
  329.             @@score RAW(4A32) 0 = @@score 100 > AND IF
  330.                 @@players @@text_action_sendscore @@score S+ SendMsg
  331.                 THEN
  332.             THEN
  333.         THEN
  334.     @@period WAIT
  335.     REPEAT
  336. 4 WAIT
  337. @@players $ PlayerRestore DROP
  338. EndGame
Add Comment
Please, Sign In to add comment