1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package game
import (
"fmt"
"thehouseoficarus/internal/behavior"
"thehouseoficarus/internal/net"
"thehouseoficarus/internal/player"
)
func (g *Game) startTriggerModule(sess *net.Session, p *player.Player, mod *ModDef) {
if p.Action != nil {
g.cancelAction(p)
}
p.Action = &behavior.Action{
Type: behavior.TypeTriggerModule,
TargetID: mod.ID,
TargetName: mod.Name,
WaitLeft: 0,
Data: &behavior.TriggerModuleData{
ModID: mod.ID,
Steps: mod.Sequence,
StepIndex: 0,
},
}
g.writePrompt(sess)
}
func (g *Game) advanceTriggerModule(sess *net.Session, p *player.Player) {
data := p.Action.Data.(*behavior.TriggerModuleData)
mod := GetMod(data.ModID)
if mod == nil {
g.cancelAction(p)
sess.WriteLine("The module has vanished.")
return
}
if data.StepIndex < len(data.Steps) {
step := data.Steps[data.StepIndex]
sess.WriteLine(step.Message)
data.StepIndex++
p.Action.WaitLeft = step.Delay
} else {
g.triggerModReward(sess, p, mod, 1.0)
if g.Combat.Get(p.Name) != nil {
g.Combat.Leave(p.Name)
}
switch mod.Category {
case ModTransport:
g.executeTransportEffect(sess, p, mod)
if mod.ID == "transport_home" {
p.HomeTransportCooldown = 3000
}
default:
sess.WriteLine(fmt.Sprintf("%s completes.", mod.Name))
}
g.cancelAction(p)
g.writePrompt(sess)
}
}
|