filler

Arctic Crossbow

Shoot explosions that freeze players. If it hits the ground, the explosion will be bigger but have a longer cooldown. if it hits a player, it will have a smaller explosion but a shorter cooldown

← Back to main

Code Block:


api.giveItem(myId, "Iron Crossbow", 1, {
  customDisplayName: "Artic Crossbow",customDescription: "CAUSES MASSIVE EXPLOSIONS THAT FREEZES ENEMIES", customAttributes: {weaponId: 1}
})
      

World Code:


function onPlayerDamagingOtherPlayerArtic(aId, eId, damage, item){
  pos = api.getPosition(eId)
  if(item !== "Arrow"){return}
  if(api.getHeldItem(aId).name === "Arrow"){return}
  if(api.getEffects(aId).includes("Artic Freeze")){
    api.removeEffect(aId,"Artic Freeze")
    createExplosion([pos[0],pos[1]-1,pos[2]], 1)
    api.applyEffect(aId, "Artic Cooldown", 2500, {icon: "Blue Wool"})
    api.applyEffect(eId,"Frozen",2000,{inbuiltLevel: 1})
  }
}

function shotArtic(aId){
  held = api.getHeldItem(aId)
  if(check_item(held,"Iron Crossbow","Artic Crossbow",1) && !api.getEffects(aId).includes("Artic Cooldown")){
    api.applyEffect(aId, "Artic Freeze", 4000, {icon: "Ice"})
  } else {
    return
  }
}

function artic_terrain(pid,eid){
  pos = api.getPosition(eid)
  if(api.getEffects(pid).includes("Artic Freeze")){
    api.removeEffect(pid,"Artic Freeze")
    createExplosion(pos,2)
    api.applyEffect(pid, "Artic Cooldown", 5000, {icon: "Blue Wool"})
  } else{
    return false
  }
}

function check_item(item, item_name, custom_name, customId){
  return (
    item &&
    item.name === item_name &&
    item.attributes.customDisplayName === custom_name &&
    item.attributes.customAttributes.weaponId === customId
  );
}

onPlayerDamagingOtherPlayer = (attackingPlayer, damagedPlayer, damageDealt, withItem, bodyPartHit, damagerDbId)=> {
  onPlayerDamagingOtherPlayerArtic(attackingPlayer, damagedPlayer, damageDealt, withItem)
}

onPlayerUsedThrowable = (playerId, throwableName, thrownEntityId) => {
  shotArtic(playerId)
}

onPlayerThrowableHitTerrain = (playerId, throwableName, entityId) => {
  artic_terrain(playerId, entityId)
}

//the_cccccccc explosion code
despawnQueue = [] 
pendingDespawn = 1e6 

function createExplosion(pos, size) {

  m = api.attemptSpawnMob('Draugr Zombie',...pos)
  api.setMobSetting(m, 'attackItemName', size==1? "RPG": "Super RPG")
  api.setMobSetting(m, 'attackRadius', 1e6)
  api.setMobSetting(m, 'attackInterval', 1e6)
  api.setMobSetting(m, 'baseWalkingSpeed', 0)
  api.setMobSetting(m, 'baseRunningSpeed', 0)
  api.setMobSetting(m, 'attackImpulse', 0)
  api.setPlayerOpacity(m, 0)

  p = api.attemptSpawnMob('Pig',pos[0], pos[1]-2, pos[2])
  api.setMobSetting(p, 'baseWalkingSpeed', 0)
  api.setMobSetting(p, 'baseRunningSpeed', 0)
  api.setMobSetting(p, 'initialHealth', 1e6)
  api.setPlayerOpacity(p, 0)

  api.applyMeleeHit(p,m,[0,0,0])

  despawnQueue.push(m,p)
  pendingDespawn = 0
}

tick = () => {
  pendingDespawn++
  if(despawnQueue.length!=0 && pendingDespawn == 3){
    for (mob of despawnQueue) {
      api.despawnMob(mob)
      despawnQueue = despawnQueue.filter(m => m!= mob)
    }
  }
}

onMobDamagingPlayer = (attackingMob, damagedPlayer, damageDealt, withItem) => {
  if (withItem === "Super Rocket"){
    api.applyEffect(damagedPlayer,"Frozen",6000,{inbuiltLevel: 1})
    return Math.floor(damageDealt * 0.4)
  }
}