ScreepsDiplomacy
The screeps diplomacy module for your screeps needs!
Install / Use
/learn @DissiNL/ScreepsDiplomacyREADME
ScreepsDiplomacy
Main diplomacy module shared by all screepers.
Allows you to implement and act according to the diplomacy rules set by the worlds inhabitants.
- Global functions to see diplomacy requests
- Publish said data onto enemy/friendly creeps ( becomes available under creep.diplomacy )
- Keep track of CPU used on Diplomacy-actions based per user
- Give players a Maximum bucket to work with (default is 1 CPU per player, see Functions), every action can be configured to consume X CPU. Or use real-life CPU limits.
- Track hostility of users (ranging from -10 to 10) based on their actions.
This module is not designed to do any actions on itself, a user script should always handle diplomacy actions. It's merely a communication tool
Version
1.0.0
Specifications
Protocol
Available at Protocol.md.
Modifies following screeps data
This module will create, and manage, the following memory entry:
Memory.__diplomacy__- The Creep.diplomacy will be added when a creep performed a diplomatic action
Functions
| Action | Function | Description|
|---------------------|:----------------------------------------------|:---------------------------------------------------------------|
| User CPU management | diplomacy.setMaxCpuUsage('theUsername', 1); | Sets the maximum amount of CPU a user can useMy Account| Change diplomacy state | diplomacy.setDiplomacyScore('theUsername', CONST_DIPLOMACY_USER_RATING_*); | Sets the diplomacy score of a player to friendly, based on one of the CONST_DIPLOMACY_USER_RATING_* constants |
All setters have an equivalent getter.
Installation
If you're using grunt-screeps:
Checkout in your DIST folder.
Edit the src property the following to your gruntfile.js:
src: ['dist/*.js','dist/ScreepsDiplomacy/src/*.js']
Optional If you want to support "custom" user-based actions you can also choose to include
src: ['dist/*.js','dist/ScreepsDiplomacy/src/*.js', 'dist/ScreepsDiplomacy/src/users/diplomacy_*.js']
Adding it to your main script:
var diplomacy = require('diplomacy');
module.exports.loop = function() {
diplomacy.init(); // Must be called on every iteration you want to use the diplomacy module
var randomHostileCreep = getHostileCreepFromSomeLocation();
diplomacy.process(randomHostileCreep);
if(randomHostileCreep.diplomacy) {
console.log(JSON.stringify(randomHostileCreep.diplomacy));
}
}
Code conventions
The diplomacy scripts requires you to free up the global CONST_DIPLOMACY_* namesapce. Constants will be published to this list.
- Globals are to be defined in the diplomacy.globals.js file
- User scripts are placed inside the users/ folder and be named diplomacy.[usernamehere].js
- Naming of parameters must start with the* (theCreep, theAction) This makes for easier to distinguish between variables and parameters
Related Skills
node-connect
348.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
348.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
348.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
