```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

feat(gameplay): 实现空间掉落物品系统

- 在Space结构体中添加DropItemIds字段存储掉落物品配置
- 添加GetDrop方法用于随机获取掉落物品
- 将战斗怪物掉落逻辑从地图服务改为使用空间服务
- 修复屏幕会话中断信号配置为^C

BREAKING CHANGE: 掉落物品逻辑从地图服务迁
This commit is contained in:
昔念
2026-03-03 14:04:41 +08:00
parent 834c85f0f1
commit 103bc0c232
3 changed files with 18 additions and 9 deletions

View File

@@ -184,11 +184,9 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf
}
if p.CanGetItem() {
mapinfo := service.NewMapService().GetData(p.Info.MapID)
if len(mapinfo.DropItemIds) > 0 {
item := int64(mapinfo.DropItemIds[grand.Intn(len(mapinfo.DropItemIds))])
item := p.GetSpace().GetDrop()
if item != 0 {
count := int64(grand.Intn(2) + 1)
ok := p.ItemAdd(item, count)
if ok {

View File

@@ -44,9 +44,9 @@ type Space struct {
WeatherType []uint32
TimeBoss info.S2C_2022
//Weather uint32
IsTime bool
PitS *csmap.CsMap[int, []model.MapPit]
IsTime bool
DropItemIds []uint32
PitS *csmap.CsMap[int, []model.MapPit]
}
// NewSyncMap 创建一个新的玩家同步map
@@ -189,7 +189,7 @@ func (ret *Space) init() {
r := service.NewMapService().GetData(ret.ID)
if r != nil {
ret.DropItemIds = r.DropItemIds
if r.IsTimeSpace != 0 {
ret.IsTime = true
}
@@ -278,3 +278,14 @@ func (ret *Space) GenWer() {
//}
}
func (ret *Space) GetDrop() int64 {
if len(ret.DropItemIds) > 0 {
item := int64(ret.DropItemIds[grand.Intn(len(ret.DropItemIds))])
return int64(item)
}
return 0
}

View File

@@ -284,7 +284,7 @@ echo "设置执行权限:%s{exe_path}"
chmod +x "%s{exe_path}" || { echo "❌ 设置权限失败"; exit 1; }
echo "启动Screen会话[%s{screen_name}]..."
screen -dmS "%s{screen_name}" bash -c '"%s{exe_path}" -id=%s{online_id} 2>&1 | tee -a "$HOME/run_%s{randomFileName}.log" stty intr ^_'
screen -dmS "%s{screen_name}" bash -c '"%s{exe_path}" -id=%s{online_id} 2>&1 | tee -a "$HOME/run_%s{randomFileName}.log" stty intr ^C'
sleep 2
if screen -ls | grep -q "%s{screen_name}"; then