Paste #47849: Untitled Paste

Date: 2018/06/12 16:04:02 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


"YAML Anti-Farm Script":
    type: world
    debug: false
    events:
        on server start:
        - yaml create id:antifarm-flags
        on shutdown:
        - yaml unload id:antifarm-flags

        on entity dies:
        # Check to see if entity was a player
        - if <context.entity.is_player>
        {
            # If so, cancel all below checks
            - queue clear
        }

        # Check to see if any timers exist on this block
        - if <yaml[antifarm-flags].contains[expirations.<context.entity.location.simple>]>

        # If yes, clear any old timers
        {
            - yaml id:antifarm-flags set expirations.<context.entity.location.simple>:<yaml[antifarm-flags].read[expirations.<context.entity.location.simple>].as_list.filter[in_seconds.is[more].than[<util.date.time.duration.in_seconds>]]>
        }

        # Add a timer for this mob's death
        - yaml id:antifarm-flags set expirations.<context.entity.location.simple>:<list[<util.date.time.duration.add[30m]>].include[<yaml[antifarm-flags].read[expirations.<context.entity.location.simple>]||li@>]>

        # Check to see whether there are too many timers on this block
        - if <yaml[antifarm-flags].read[expirations.<context.entity.location.simple>].as_list.size||0> >= 3

        {
            # Debug messages
#            - announce to_console "[DEBUG] Normal mobs YAML same location: <context.entity.location.simple>"
#            - announce to_console "[DEBUG] Normal mobs YAML same location size: <yaml[antifarm-flags].read[expirations.<context.entity.location.simple>].as_list.size>"

            # Cancel drops and experience
            - determine NO_DROPS_OR_XP
            - queue clear
        }

        on mm denizen death:

        # Check to see if any timers exist on this block
        - if <yaml[antifarm-flags].contains[expirations.<context.activemob.location.simple>]>

        # If yes, clear any old timers
        {
            - yaml id:antifarm-flags set expirations.<context.activemob.location.simple>:<yaml[antifarm-flags].read[expirations.<context.activemob.location.simple>].as_list.filter[in_seconds.is[more].than[<util.date.time.duration.in_seconds>]]>
        }

        # Add a timer for this mob's death
        - yaml id:antifarm-flags set expirations.<context.activemob.location.simple>:<list[<util.date.time.duration.add[30m]>].include[<yaml[antifarm-flags].read[expirations.<context.activemob.location.simple>]||li@>]>

        # Check to see whether there are too many timers on this block
        - if <yaml[antifarm-flags].read[expirations.<context.activemob.location.simple>].as_list.size||0> >= 3

        {
            # Debug messages
#            - announce to_console "[DEBUG] MythicMobs YAML same location: <context.activemob.location.simple>"
#            - announce to_console "[DEBUG] MythicMobs YAML same location size: <yaml[antifarm-flags].read[expirations.<context.activemob.location.simple>].as_list.size>"

            # Cancel drops and experience
            - determine drops:li@;money:0;exp:0
            - queue clear
        }

        # Check for and cancel an empty gold message
        on player receives message:
        - if <context.message> contains "dropped 0.0 gold" 
        {
            - determine CANCELLED
        }

"YAML Anti-Spawner Script":
    type: world
    debug: true
    events:
        on server start:
        - yaml create id:antispawner-flags
        on shutdown:
        - yaml unload id:antispawner-flags

        on entity spawns:
        - if <context.entity.is_player>
        {
            - queue clear
        }
#        - announce to_console "[DEBUG] context.entity.location.find.blocks[mob_spawner].within[8] is <context.entity.location.find.blocks[mob_spawner].within[8]>"
        - if <context.entity.location.find.blocks[mob_spawner].within[8]> !== li@
        {
            - wait 1t
#            - announce to_console "[DEBUG] Mob spawned within 8 blocks of spawner, reason is <context.reason>"
            - yaml id:antispawner-flags set entities.spawned-by-spawner:->:<context.entity.uuid>
        }
        - if '<context.reason>' == 'SPAWNER'
        {
            - wait 1t
            - yaml id:antispawner-flags set entities.spawned-by-spawner:->:<context.entity.uuid>
        }
#        - if '<context.reason>' == 'CUSTOM'
#        {
#            - wait 1t
#            - yaml id:antispawner-flags set entities.spawned-by-spawner:->:<context.entity.uuid>
#        }

        on entity dies:
        - if <context.entity.is_player>
        {
            - queue clear
        }

        - if <yaml[antispawner-flags].read[entities.spawned-by-spawner].contains[<context.entity.uuid>]>
        {
#            - announce to_console "[DEBUG] Normal mobs YAML spawner"
            - determine NO_DROPS_OR_XP
            - yaml id:antispawner-flags set entities.spawned-by-spawner:<-:<context.entity.uuid>
        }

        on mm denizen death:

        - if <yaml[antispawner-flags].read[entities.spawned-by-spawner].contains[<context.activemob.uuid>]>
        {
#            - announce to_console "[DEBUG] MythicMobs YAML spawner"
            - determine drops:li@;money:0;exp:0
            - yaml id:antispawner-flags set entities.spawned-by-spawner:->:<context.activemob.uuid>
        }