amethyst / amethyst/rustrogueliketutorial

5.24 Damage Over Time Kills Don't Give XP

Đang mở
#164 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
970
Fork
166
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Because damage effects created by a DOT status condition don't include a creator, if the player uses the effect to kill a monster they don't gain any XP from the kill.

I was able to fix it with a little bit of difficulty (all thanks to a bug in specs):

In `components.rs`:
```rust
#[derive(Component, Debug, ConvertSaveload, Clone)]
pub struct DamageOverTime {
pub damage: i32,
pub creator: EntityOption,
}
```

This requires the entity-container workaround at https://github.com/amethyst/specs/issues/681#issuecomment-821274957 to store an optional entity.

In `rawmaster.rs`:

```rust
"damage_over_time" => $eb = $eb.with(DamageOverTime {
damage: effect.1.parse::().unwrap(),
creator: None.into(),
}),
```

Then, in `effects/damage.rs`, pass along the effect creator (converting to an EntityOption):

```rust
.with(DamageOverTime { damage: *damage, creator: effect.creator.into() })
```

And finally, in `ai/initiative_system.rs`, pass the status effect creator back into the effect system:

```rust
add_effect(
dot.creator.into(),
EffectType::Damage { amount: dot.damage },
Targets::Single {
target: status.target,
},
);
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.