您的当前位置:首页正文

Screeps游戏脚本基础实现

2024-12-02 来源:个人技术集锦

功能:

        1.自动迭代 builder、upgrader、harvester,无需手动创建。

        2.分工职责完善

        3.防御塔修建 供给 攻击 修复

汉化

<script src="https://screeps-cn.gitee.io/screeps-chinese-pack-release/main.js" async defer></script> 

模型

Game.spawns['Spawn1'].spawnCreep( [WORK, CARRY, MOVE], 'Harvester1' );
Game.spawns['Spawn1'].spawnCreep( [WORK, CARRY, MOVE], 'Upgrader1' );
​
Game.creeps['Harvester2'].memory.role = 'harvester';
Game.creeps['Upgrader1'].memory.role = 'upgrader';

安全模式

被攻击时可以暂停攻击,前提你要有安全模式

Game.spawns['Spawn1'].room.controller.activateSafeMode();

2.防御塔

Game.spawns['Spawn1'].room.createConstructionSite( 23, 22, STRUCTURE_TOWER );

3.builder

1.创建一个用于建造建筑的新 creep

Game.spawns['Spawn1'].spawnCreep( [WORK, CARRY, MOVE], 'Builder1',
    { memory: { role: 'builder' } } );Game.spawns['Spawn1'].spawnCreep( [WORK, CARRY, MOVE], 'Builder1',
显示全文