| 赞 | 4 |
| VIP | |
| 好人卡 | |
| 积分 | 64 |
| 经验 | |
| 最后登录 | 2026-9-27 |
| 在线时间 | 1700 小时 |
- 梦石
- 0
- 星屑
- 6412
- 在线时间
- 1700 小时
- 注册时间
- 2018-1-16
- 回帖
- 364
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
使用方法:
在游戏中调用脚本$gameActors.actor(1).setName($gameActors.actor(1).generateRandomName());
脚本中有两个1,前面一个代表角色的ID编号,第二个1代表的性别
[pre lang="ruby" file="RandomNameGenerator.js"]//=============================================================================
// RandomNameGenerator.js
//=============================================================================
(function() {
// 姓氏列表
const familyNames = ["李", "王", "张", "刘", "陈", "杨", "赵", "黄", "周", "吴"];
// 名字列表(男)
const maleGivenNames = ["伟", "强", "军", "磊", "勇", "杰", "涛", "明", "超", "刚"];
// 名字列表(女)
const femaleGivenNames = ["芳", "娜", "敏", "静", "丽", "艳", "娟", "婷", "雪", "慧"];
// 中性名字列表
const neutralGivenNames = ["晨", "阳", "雨", "天", "明", "月", "星", "海", "山", "风"];
// 生成随机姓名
Game_Actor.prototype.generateRandomName = function() {
const familyName = familyNames[Math.floor(Math.random() * familyNames.length)];
let givenName;
// 通过角色ID或其他方式确定性别
// 这里假设我们通过角色ID的奇偶性来判断性别(奇数为男,偶数为女)
// 你可以根据需要修改这个逻辑
if (this.actorId() % 2 === 1) { // 奇数ID为男性
givenName = maleGivenNames[Math.floor(Math.random() * maleGivenNames.length)];
} else { // 偶数ID为女性
givenName = femaleGivenNames[Math.floor(Math.random() * femaleGivenNames.length)];
}
return familyName + givenName;
};
// 覆盖默认的名称设置
Game_Actor.prototype.setName = function(name) {
if (name === "随机") {
this._name = this.generateRandomName();
} else {
this._name = name;
}
};
})();[/pre]
|
|