Paste #8412: Untitled Paste

Date: 2014/08/14 15:42:33 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


#SLOTH
# THE FIRST OF SEVEN
#
# logic description:
#  talks to player
#  appears as a bat
#
# disappears at 75% hp and runs zombie gauntlet
# appears
# 
# at 25% hp zombie gauntlet runs with him active
#

Boss1:
  type: assignment
  default constants:

    ZombieSpawn1: l@-163,4,570
    ZombieSpawn2: l@-159,4,566
    ZombieSpawn3: l@-161,4,558

  actions:
    on assignment:

    - trigger name:damage state:true 

    - execute as_server "npc sel <npc.id>"
    - execute as_server "npc effect --play smoke"
    - execute as_server "npc health --respawndelay -1"
    - execute as_server "npc type bat"

    on spawn:
    - vulnerable
    - health 150 state:true
    - execute as_server "npc sel <npc.id>"
    - flag npc boss_stage:1

    # i think the health command sets a default respawn time
    - execute as_server "npc health --respawndelay -1" 
    - run Boss1_ShowHealthBar

    - run Boss1_Think

    #- inject Boss1_CleanupHP
    #- inject Boss1_CreateHP

   # - execute as_npc "npc type bat"
   # - execute as_npc "npc rename Sloth"
    #- create zombie Sloth l@-156,4,604,<npc.world.name> save:hpbar
  #  - spawn <entry[hpbar]>
 #   - flag npc hpbar:<entry[hpbar]>
 #   - wait 2s
 #   - inject Boss1_CleanupHP 

    on damaged:
    - playsound <npc.location> sound:ENDERMAN_HIT pitch:1.5
    - playsound <npc.location> sound:ENDERMAN_HIT pitch:0.5
    - run Boss1_ShowHealthBar

    on death: 
    - playsound <npc.location> sound:ENDERMAN_DEATH pitch:1.5
    - playsound <npc.location> sound:ENDERMAN_DEATH pitch:0.5

    - inject Boss1_HideHP

Boss1_ShowHealthBar:
  type: task
  script:
  - ^wait 1t
  - ^if <npc.is_spawned> {
    #- foreach <<npc.world>.players> { 
    - ^adjust <<npc.world>.players> show_boss_bar:<npc.health.percentage.mul[2]>|Sloth
     # }
    }

Boss1_HideHP:
  type: task
  script:
    # first, show empty health bar
    - ^define poop <npc.world>
    - foreach <%poop%.players> {
      - ^adjust %value% show_boss_bar:0|Sloth
      }

    # then remove it after a bit
    - wait 5s
    - foreach <%poop%.players> {
      - ^adjust %value% show_boss_bar
      }

Boss1_Think:
  type: task
  script:
    # main THINK script
    - ^while <npc.is_spawned||false> {
      - ^define stage <npc.flag[boss_stage]>
      - ^if %stage% == 1 {
        - ^foreach <<npc.world>.players> {
          - ^if <%value%.location.distance[<npc.location>]> < 5 {
            - ^inject locally startup
            - ^forloop stop
            }
          }
        } else if( %stage% == 2 ) {
        - chat no_target "FINDING TARGET1"
        - ^if <server.current_time_millis> >= <npc.flag[next_attack]> {
            # find a target
            ^define plist <<npc.world>.players>
            - ^foreach <<npc.world>.players> {
              ^if <%value%.location.distance[<npc.location>]> >= 10 {
                ^define plist <%plist%.exclude[%value%]>
              }
            - ^if !<%plist%.is_empty> {
              - chat <%plist%.as_string>
              }
            }
          }
        }
      - wait 0.1s
      }

  startup:
    - ^flag npc boss_stage:2
    # todo: format ChatBoss
    - narrate targets:<<npc.world>.players> "TESTES"
    - narrate targets:<<npc.world>.players> "TESTES"
    - narrate targets:<<npc.world>.players> "TESTES"
    - ^flag npc next_attack:<server.current_time_millis.add_int[2000]>
    - wait 1s
#    
#PlayersInWorld:
#  type: procedure
#  script:
#  - foreach <<npc.world>.players> {
#    - define players %players%|
#    - if <%value%.location.distance[<npc.location>]> < 5 {
#      - inject locally startup
#      - forloop stop
#      }
#    }
#    determine %players%
#