summaryrefslogtreecommitdiffhomepage
path: root/app/systems/ai
diff options
context:
space:
mode:
Diffstat (limited to 'app/systems/ai')
-rw-r--r--app/systems/ai/randomize_ai.rb34
-rw-r--r--app/systems/ai/rejoin.rb14
-rw-r--r--app/systems/ai/scatter.rb15
-rw-r--r--app/systems/ai/target_player.rb8
4 files changed, 55 insertions, 16 deletions
diff --git a/app/systems/ai/randomize_ai.rb b/app/systems/ai/randomize_ai.rb
new file mode 100644
index 0000000..f272181
--- /dev/null
+++ b/app/systems/ai/randomize_ai.rb
@@ -0,0 +1,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
+)
diff --git a/app/systems/ai/rejoin.rb b/app/systems/ai/rejoin.rb
index 606a0be..9e06eb7 100644
--- a/app/systems/ai/rejoin.rb
+++ b/app/systems/ai/rejoin.rb
@@ -1,14 +1,14 @@
FF::Sys.new("Rejoin", priority: 40) do
- FF::Cmp::BoidsSeparation.each do |sep|
- #puts 'add align/cohesion'.upcase
- sep.distance = 150
- alignment_mgr = sep.entities[0].components[FF::Cmp::BoidsAlignment]
- cohesion_mgr = sep.entities[0].components[FF::Cmp::BoidsCohesion]
+ FF::Cmp::SingletonRandomAIPick[0].entities.each do |entity|
+ sep = entity.components[FF::Cmp::BoidsSeparation][0]
+ sep.distance = Factory::SampleEnemy.defaults[:boids_seperation_distance]
+ alignment_mgr = entity.components[FF::Cmp::BoidsAlignment]
+ cohesion_mgr = entity.components[FF::Cmp::BoidsCohesion]
if alignment_mgr.nil? || alignment_mgr.empty?
- sep.entities[0].add FF::Cmp::BoidsAlignment.new(strength: 10)
+ entity.add FF::Cmp::BoidsAlignment.new(strength: Factory::SampleEnemy.defaults[:boids_alignment_strength])
end
if cohesion_mgr.nil? || cohesion_mgr.empty?
- sep.entities[0].add FF::Cmp::BoidsCohesion.new(strength: 1000)
+ entity.add FF::Cmp::BoidsCohesion.new(strength: Factory::SampleEnemy.defaults[:boids_cohesion_strength])
end
end
end
diff --git a/app/systems/ai/scatter.rb b/app/systems/ai/scatter.rb
index 1469fd9..82bcb65 100644
--- a/app/systems/ai/scatter.rb
+++ b/app/systems/ai/scatter.rb
@@ -1,10 +1,15 @@
FF::Sys.new("Scatter", priority: 40) do
- FF::Cmp::BoidsSeparation.each do |sep|
- sep.distance = 200
+ FF::Cmp::SingletonRandomAIPick[0].entities.each do |entity|
+ sep = entity.components[FF::Cmp::BoidsSeparation][0]
+ # I did times 3 becase then it will always be greater then
+ # what it was before and that means it will force a
+ # seperation to happen even if the default value is
+ # changed and you forget to update this number here
+ sep.distance = Factory::SampleEnemy.defaults[:boids_seperation_distance] * 3
#puts 'remove align/cohesion/follow'.upcase
- alignment_mgr = sep.entities[0].components[FF::Cmp::BoidsAlignment]
- cohesion_mgr = sep.entities[0].components[FF::Cmp::BoidsCohesion]
- follow_mgr = sep.entities[0].components[FF::Cmp::Follow]
+ alignment_mgr = entity.components[FF::Cmp::BoidsAlignment]
+ cohesion_mgr = entity.components[FF::Cmp::BoidsCohesion]
+ follow_mgr = entity.components[FF::Cmp::Follow]
unless follow_mgr.nil? || follow_mgr.empty?
follow_mgr[0].delete
end
diff --git a/app/systems/ai/target_player.rb b/app/systems/ai/target_player.rb
index 8e715eb..1e4a3ea 100644
--- a/app/systems/ai/target_player.rb
+++ b/app/systems/ai/target_player.rb
@@ -1,11 +1,11 @@
FF::Sys.new("TargetPlayer", priority: 40) do
- FF::Cmp::BoidsSeparation.each do |sep|
- #puts 'target player'.upcase
+ FF::Cmp::SingletonRandomAIPick[0].entities.each do |entity|
+ sep = entity.components[FF::Cmp::BoidsSeparation][0]
sep.distance = 200
- follow_mgr = sep.entities[0].components[FF::Cmp::Follow]
+ follow_mgr = entity.components[FF::Cmp::Follow]
player_boid = FF::Cmp::SingletonPlayer[0].entities[0].components[FF::Cmp::Boid][0]
if follow_mgr.nil? || follow_mgr.empty?
- sep.entities[0].add FF::Cmp::Follow.new(target: player_boid, strength: 500)
+ entity.add FF::Cmp::Follow.new(target: player_boid, strength: 1.2)
end
end
end