Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #######################
- ## HellJump 0.1 ##
- ## by DPOH-VAR(c) ##
- ## 2012 ##
- #######################
- ######## Настройки
- ######## Текст
- "\c6[\c4\clHell\c6\cl\cnJ\c4\clump\c6]\cr " %%text_prefix
- "\cbДобро пожаловать в игру\nХостер: \c6" %%text_greet
- "\cbИгра завершена\cr" %%text_endgame
- "\cbВы начали игру\nЧтобы исключить игрока, введите \c6-r ник\cb\nДля начала игры введите \c6-s\cb\nДля просмотра игроков введите \c6-p\cb\nДля отмены введите \c6-c\cr"
- %%text_admin_greet
- "\cbИгроки: \c6" %%text_players
- " \cc- игрок не найден\cr" %%text_error_playernotfound
- "\ccНевозможно исключить себя из списка\cr" %%text_error_playerrmself
- "\ccИгра уже запущена\cr" %%text_error_alreadyplaying
- "\ccСлишком много игроков\cr" %%text_error_toomanyplayers
- " \ccпокинул игру\cr" %%text_action_live
- " \ccВы проиграли! счет игры: \c6" %%text_action_gameover
- " \ccВышел из игры: \c6" %%text_action_playerleave
- " \cbСчет: \c6" %%text_action_sendscore
- ######## Текст команды
- "-r" %%text_cmd_c
- "-p" %%text_cmd_p
- "-s" %%text_cmd_start
- "-c" %%text_cmd_cancel
- ######## Текст метадаты
- "game:start" %%meta_block_playflag
- "game:score" %%meta_player_score
- "game:gm" %%meta_player_gm
- "game:food" %%meta_player_food
- "game:hp" %%meta_player_hp
- "game:loc" %%meta_player_loc
- ######## Мета-данные блока
- EVENT(BLOCK) %%mainBlock
- [] %%metadataNames
- :WriteMeta{ ## запись мета-данных ## value string ->
- DUP @@metadataNames SWAP AHAS !IF ## если нет в списке
- DUP *metadataNames (@@)RAW(22) SWAP (ADD)RAW(6D) DROP ## то пишем в список
- THEN
- @@mainBlock ROT ROT >META DROP
- }
- :ReadMeta{ ## чтение мета-данных ## string -> value
- @@mainBlock SWAP META
- }
- :ClearMeta{ ## очистка всех мета-данных ## ->
- @@metadataNames @@mainBlock << RMMETA DROP
- }
- ######## игроки
- :SendMsg{ ## [player] text ->
- @@text_prefix SWAP CONCAT
- SWAP
- 25 PlaySound
- &{ OVER MSG DROP} DROP
- }
- :AddToPlayers{ ## player ->
- <P @@players SWAP RAW(6D) %%players
- }
- :ViewPlayers{ ## player ->
- @@text_players @@players S+
- SendMsg
- }
- :RemoveFromPlayers{ ## player ->
- <P *players RAW(22) SWAP RAW(6C) (remove)
- LEN 0 = IF EndGame THEN
- }
- :TryRemovePlayer{ ## string ->
- DUP <P @@players SWAP AHAS IF
- DUP <P ME = IF
- ME @@text_error_playerrmself SendMsg
- ELSE
- DUP RemoveFromPlayers
- ME ViewPlayers
- THEN
- ELSE
- ME OVER @@text_error_playernotfound S+ SendMsg
- THEN
- DROP
- }
- :EndGame{
- @@players @@text_endgame SendMsg
- FALSE %%game
- 2 WAIT
- ClearMeta
- @@platforms &{
- ${ @@supermaterial SETBLOCK } DROP
- }
- END
- }
- :PlaySound{ ## [player] sound -> [player]
- SWAP ##(snd [pl])
- ${
- OVER ##(snd pl snd)
- OVER ##(snd pl snd pl)
- SWAP ##(snd pl pl snd)
- 1 SWAP ##(snd pl pl 1 snd)
- 1 ##(snd pl pl 1 snd 1)
- SENDSOUND ##(snd pl)
- } ##(snd [pl])
- SWAP DROP
- }
- ##(5 - хрип)
- ##(6 - рыгун)
- ##(22 - чел)
- ##(25 27 62 - бульк)
- ##(28 звонок)
- ##(34 громкий дзынь)
- ##(35 хороший дзынь)
- ##(41 снежок или стрела)
- ##(56 противный мяу)
- ######## Хандлеры
- :H_chat_admin_lobby{
- EVENT(PLAYER) ME = ! IF RETURN THEN
- EVENT(TEXT) %t
- @t @@text_cmd_c " " S+ STARTS IF
- EVENT(CANCEL)
- @t " " SPLIT 1 AGET TryRemovePlayer
- RETURN
- THEN
- @t @@text_cmd_cancel = IF EVENT(CANCEL) EndGame THEN
- @t @@text_cmd_start = IF EVENT(CANCEL) SEND(adm_start) THEN
- }
- :H_chat_player_lobby{
- EVENT(PLAYER) %p
- @@players @p AHAS !IF RETURN THEN
- EVENT(TEXT) %t
- @t @@text_cmd_p = IF EVENT(CANCEL) @p ViewPlayers RETURN THEN
- ()@t @@text_cmd_c =
- ()@p ME = !
- AND IF
- EVENT(CANCEL)
- @p @@text_action_live S+ @@players &{OVER SendMsg} DROP
- RETURN
- THEN
- }
- ######## проверка
- @@meta_block_playflag ReadMeta UUID = IF
- ME
- 5 PlaySound
- @@text_error_alreadyplaying SendMsg
- END
- THEN
- ######## инициализация лобби
- UUID @@meta_block_playflag WriteMeta
- ME 5 SPHERE PLAYERS INSIDE &AddToPlayers
- @@players ME AREM &{ @@text_greet ME S+ SendMsg }
- ME @@text_admin_greet SendMsg
- @@players &ViewPlayers
- *H_chat_admin_lobby REG(CHAT) %adm_chat
- *H_chat_player_lobby REG(CHAT) %plr_chat
- AWAIT(adm_start)
- @adm_chat UNREG @plr_chat UNREG
- ######## еще немного настройки
- ^JUKEBOX %%material
- ^SPONGE %%supermaterial
- 4 %%fuse
- 0.9 %%period
- 0.4 %%chance
- TRUE %%game
- ######## игра
- "Сканирование арены..." .
- @@mainBlock 10 SPHERE ?{ID @@supermaterial ID =}
- "Сканирование завершено, найдено " OVER LEN S+ " блоков" S+ .
- "Поиск платформ..." .
- [0:0:0,0:0:1,1:0:1,1:0:0] %plate
- ## отсеиваем только блоки, являющиеся началом платформы
- ## (bb)| b true (vv)| t
- ?{ @plate TRUE << {3 RAW(15)(pick 3th) SWAP LV+ <B ID @@supermaterial ID = AND} SWAP DROP }
- "Поиск платформ завершен" .
- [] %%platforms ## платформы
- &{ ## poll blocks
- @plate ${OVER SWAP V+ <B} SWAP DROP *platforms RAW(22) SWAP (ADD)RAW(6D) DROP
- ## [bbbb]
- }
- "найдено платформ: " @@platforms LEN S+ .
- @@players LEN @@platforms LEN > IF
- @@players @@text_error_toomanyplayers SendMsg
- EndGame
- THEN
- [] %%platstate ## записываем состояние платформы (есть или нет)
- [] %%platrevstate ## записываем состояние платформы (восстановлена ли)
- @@platforms LEN 0 DO {
- @@platstate I ADD %%platstate
- }
- :CenterPlatform{ ## Array(blocks) -> Location
- FIRST 1:1:1 LV+
- }
- :_RmEntAfterTime{ ## time [ents]
- SWAP WAIT &RM
- }
- :RmEntAfterTime{ ## [ents] time ->
- *_RmEntAfterTime START(2) DROP
- }
- :RebuildPlatform{ ## int(platform-id) ->
- @@platstate OVER ADD %%platstate
- @@platforms SWAP AGET RebuildPlatformByBlocks
- }
- :RebuildPlatformByBlocks{ ## Array(blocks) ->
- ${ @@material SETBLOCK } DROP
- }
- :DestroyPlatform{ ## int(platform-id) ->
- @@platforms SWAP AGET
- DUP CenterPlatform 0 EXPLODE
- SWAP
- ${
- 0 >BL
- @@material SPAWNFALLINGBLOCK
- FALSE >FALLDROP ##(loc,fb)
- OVER OVER ##(loc,fb,loc,fb)
- BETWEEN ##(loc,fb,vec)
- 2 VY+ 0.2 V* THROW ##(loc,fb)
- }
- 0.5 RmEntAfterTime
- DROP
- }
- :GetScore{ ## player -> int
- <P @@meta_player_score META
- }
- :SetScore{ ## player int -> player
- SWAP <P SWAP @@meta_player_score >META
- }
- :PlayerStore{ ## player -> player
- <P
- DUP GM @@meta_player_gm SETMETA
- DUP FOOD @@meta_player_food SETMETA
- DUP HP @@meta_player_hp SETMETA
- DUP <L @@meta_player_loc SETMETA
- 0 @@meta_player_score SETMETA
- }
- :PlayerRestore{ ## player -> player
- <P
- DUP @@meta_player_gm META SETGM
- DUP @@meta_player_food META SETFOOD
- DUP @@meta_player_hp META SETHP
- DUP @@meta_player_loc META TP
- }
- :PlayerDefeat{ ##player ->
- DUP @@text_action_gameover OVER GetScore S+ SendMsg
- DUP PlayerRestore RemoveFromPlayers
- @@text_action_playerleave SWAP S+ @@players SWAP SendMsg
- }
- :H_dmg_playerdamage{
- EVENT(ENTITY) %p
- @@players @p AHAS ! IF RETURN THEN
- EVENT(REASON) %r
- EVENT(CANCEL) RELEASE
- @r "FALL" =! IF RETURN THEN
- @@platforms ${CenterPlatform @p DISTANCE 2 < }
- () FALSE << OR IF
- RETURN THEN
- @p @@score @@meta_player_score SETMETA PlayerDefeat
- }
- :PreparePlayers{
- @@platforms %_p
- @@players ${
- PlayerStore
- 1 >GM
- @_p ARND %_t
- @_t CenterPlatform TP
- @_p @_t AREM %_p
- } DROP
- }
- :_StartDestroyPlatform{ ## ent int ->
- @@fuse WAIT
- @@game !IF RETURN THEN
- SWAP
- RM
- DUP DestroyPlatform
- @@period 2 7 RNDF D* WAIT
- StartRebuildPlatform DROP
- }
- :StartDestroyPlatform{ ## int ->
- @@platstate OVER AREM %%platstate
- @@platforms OVER AGET CenterPlatform 2 LY+ "primed_tnt" SPAWNMOB
- 0 SETYIELD
- *_StartDestroyPlatform START(2) DROP
- }
- :_StartRebuildPlatform{ ## ents int ->
- 0.4 WAIT
- SWAP
- &RM
- RebuildPlatform
- }
- :StartRebuildPlatform{ ## int -> int
- @@game !IF RETURN THEN
- DUP @@platforms OVER AGET ${
- -2 LY+
- @@material SPAWNFALLINGBLOCK
- FALSE >FALLDROP
- 0.45 THROW
- }
- *_StartRebuildPlatform START(2) DROP
- }
- @@platforms &RebuildPlatformByBlocks
- PreparePlayers
- 0 %%score
- *H_dmg_playerdamage REG(DMG) %plr_dmg
- 2 WAIT
- BEGIN @@players LEN 0 > @@game AND WHILE
- @@platstate LEN 1 > IF
- RANDOM @@chance > IF
- @@platstate ARND StartDestroyPlatform
- @@score 1 + %%score
- @@score RAW(4A05) 0 = IF
- @@chance 0.7 D* %%chance
- THEN
- @@score RAW(4A0A) 0 = @@score 100 <= AND IF
- @@players @@text_action_sendscore @@score S+ SendMsg
- THEN
- @@score RAW(4A14) 0 = IF
- @@chance 0.95 D* %%chance
- @@fuse 0.95 D* %%fuse
- THEN
- @@score RAW(4A32) 0 = @@score 100 > AND IF
- @@players @@text_action_sendscore @@score S+ SendMsg
- THEN
- THEN
- THEN
- @@period WAIT
- REPEAT
- 4 WAIT
- @@players $ PlayerRestore DROP
- EndGame
Add Comment
Please, Sign In to add comment