Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int damageBlock(WorldContext& context, float x, float y, int damages, bool remote, bool back)
- {
- World& world = *context.world;
- int i=x/16, j=y/16;
- //damages = 255;
- Tile & t = world.at(i, j);
- //printf("life:%d\n", t.life);
- if(t.front < Tile::FirstBlockIndex) // classes spéciales
- {
- if(t.back == Tile::Void)
- return t.front;
- // @todo faire des backwalls breakable
- // on regarde si au moins un block est 'vide'
- bool bounds = back? true: (
- world.at(i-1, j).back < Tile::FirstBlockIndex ||
- world.at(i+1, j).back < Tile::FirstBlockIndex ||
- world.at(i, j-1).back < Tile::FirstBlockIndex ||
- world.at(i, j+1).back < Tile::FirstBlockIndex );
- if(!bounds)
- return t.front;
- if(t.life != Tile::LifeMax && !t.indestructible())
- {
- if(!remote)
- networkSendDamageBlock(i, j, damages);
- if(t.life <= damages)
- {
- int ret = t.back;
- if(getCurrentAdminGameMode() != GameMode::Building)
- spawnDrops(context, od::Pos(i*16+2, j*16+2), BlockInfo::get(t.back).drops());
- t.slopeBack = 38;
- t.back = Tile::Void;
- t.life = 0;
- return ret;
- }
- t.life -= damages;
- }
- return t.back;
- }
- // check ore
- Ore & ore = world.findOre(i, j);
- if(ore.valid())
- {
- if(!remote)
- networkSendDamageBlock(i, j, damages);
- if(ore.life > damages)
- ore.life -= damages;
- else
- {
- OreInfo & info = OreInfo::get(ore.ind);
- if(getCurrentAdminGameMode() != GameMode::Building)
- spawnDrops(context, od::Pos(i*16+2, j*16+2), info.drops());
- world.removeOre(i, j);
- }
- }
- else if(world.at(i, j-1).front == Tile::LockDown)
- {
- return t.front;
- }
- else
- {
- if(!remote)
- networkSendDamageBlock(i, j, damages); /// opti possible
- Ground & ground = world.findGround(i, j);
- if(ground.valid())
- {
- world.removeGround(i, j);
- }
- if(t.life != Tile::LifeMax && !t.indestructible())
- {
- if(t.life <= damages)
- {
- int ret = t.front;
- removeBlock(context, x, y);
- return ret;
- }
- t.life -= damages;
- }
- }
- return t.front;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement