summaryrefslogtreecommitdiffhomepage
path: root/app/systems/ai/randomize_ai.rb
blob: f27218129b00b3a6dc77943fcaaf4649a0ecfc76 (plain)
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
FF::Scn::BoidRules.add(
  FF::Sys.new('RandomizeAI', priority: 50) do
    timer = FF::Cmp::SingletonAITimer[0]
    timer.timer += 1
    if timer.timer > timer.interval
      random_ai_pick = FF::Cmp::SingletonRandomAIPick[0]
      random_ai_pick.entities.reverse_each do |entity|
        entity.remove random_ai_pick
        #puts 'remove pick'
      end
      FF::Cmp::BoidsSeparation.each do |sep|
        if rand < 0.3
          sep.entities[0].add random_ai_pick
          #puts 'pick'
        end
      end
      x = rand 3
      if x == 0
        FF::Sys::Scatter.call
        #puts 'scatter'
      elsif x == 1
        FF::Sys::Rejoin.call
        #puts 'rejoin'
      elsif x == 2
        FF::Sys::TargetPlayer.call
        #puts 'target'
      end
      #timer.interval = (300..1200).to_a.sample
      timer.interval = 60
      #puts timer.interval
      timer.timer = 0
    end
  end
)