#The Npc will hit the player once if it is a sentry and back off. After 15 seconds it will reingage.
#The meganism for this part of the script uses the sentry ignore add and remove commands.
#During the SpawnProtection the player will also be automaticly healed each 0.5 seconds.
#You dont need to make any changes for this update. Put it in your scripts file and it will work!
Spawnprotection:
type: world
debug: false
events:
on player death:
- flag spawnprotectiondeath:true duration:20s
on back command:
- if <player.flag[spawnprotectionactive]> == null {
- if <player.flag[spawnprotectiondeath]> == true {
- flag spawnprotectionactive:true
- run s@SpawnProtectionInvincible
}
}
on player damaged:
- if <context.entity.as_player.flag[spawnprotection]> == true {
- determine CANCELLED
}
on entity damages player:
- if <context.entity.as_player.flag[spawnprotection]> == true {
- determine CANCELLED
}
on player damages entity:
- if <context.entity.as_player.flag[spawnprotection]> == true {
- determine CANCELLED
}
on entity targets player:
- if <context.target.as_player.flag[spawnprotection]> == true {
- determine CANCELLED
}
on player damages player:
- if <context.entity.as_player.flag[spawnprotection]> == true {
- determine CANCELLED
}
on npc damages player:
- if <context.entity.as_player.flag[spawnprotection]> == true {
- run s@NPCSpawnProtection player:<context.entity>
}
on player damages npc:
- if <context.entity.as_player.flag[spawnprotection]> == true {
- determine CANCELLED
}
NPCSpawnProtection:
type: task
debug: false
script:
- ^execute as_npc "npc select <npc.id>"
- ^execute as_npc "sentry ignore add player:<player.name>"
- ^wait 5
- ^execute as_npc "npc select <npc.id>"
- ^execute as_npc "sentry ignore remove player:<player.name>"
SpawnProtectionInvincible:
type: task
debug: false
script:
- cooldown 10s s:SpawnProtectionInvincible
- ^flag <player> SpawnProtection:true
- ^narrate ""
- ^narrate "<bold>You have 10 seconds spawn protection"
- ^narrate ""
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^playeffect <player.location.add[0,0,0]> effect:ENCHANTMENT_TABLE qty:100
- ^heal <player>
- ^wait 0.5
- ^narrate "<bold>Spawn protection ended."
- ^flag <player> SpawnProtection:null
- ^flag spawnprotectionactive:null