Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seeking AI behaviour #18

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3d72012
Skeleton
EtienneDesticourt Aug 8, 2016
e9913c3
Seek logic rework, removed channel callback
EtienneDesticourt Aug 9, 2016
59fa130
Fixed seek logic and added tests, fixed movement update, added ref to…
EtienneDesticourt Aug 10, 2016
3792cbd
Minor rename for clarity
EtienneDesticourt Aug 10, 2016
1fd1a23
Modified Seek to listen for :entity_change on Position
EtienneDesticourt Aug 10, 2016
239f2cc
:pos -> :coord
EtienneDesticourt Aug 10, 2016
165397c
Modified way AI behaviours are chosen for an npc
EtienneDesticourt Aug 10, 2016
f382506
Removed added whitespace
EtienneDesticourt Aug 10, 2016
e9c9693
Merge remote-tracking branch 'refs/remotes/origin/master' into AI_Pro…
EtienneDesticourt Aug 10, 2016
6fdee5b
:pos -> :coord
EtienneDesticourt Aug 10, 2016
f15a24f
Whitespace removal
EtienneDesticourt Aug 11, 2016
b2a2252
Added auto pos update skeleton
EtienneDesticourt Aug 11, 2016
12af7b6
Cleaned up seeking handler, fixed movement update handler
EtienneDesticourt Aug 15, 2016
260666f
Removed excess linebreak
EtienneDesticourt Aug 15, 2016
f718ddf
Naming changes
EtienneDesticourt Aug 16, 2016
38b65ca
Updated deps
EtienneDesticourt Oct 10, 2016
f819c1d
Put better default aggro/escape dist
EtienneDesticourt Oct 10, 2016
f7ab019
Set seeking as default npc behaviour, started auto updates at behavio…
EtienneDesticourt Oct 10, 2016
0c18581
Fixed tests
EtienneDesticourt Oct 10, 2016
d93eeb8
Changed event from map to atom, fixed seeks option
EtienneDesticourt Oct 11, 2016
e6dc0a6
Added geom deps, replaced Coord with Vector2D, added NavMesh to maps
EtienneDesticourt Oct 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Naming changes
  • Loading branch information
EtienneDesticourt committed Aug 16, 2016
commit f718ddf87e3495a2c4d373d897e7ae04a59f84ac
11 changes: 8 additions & 3 deletions lib/entice/logic/movement.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ defmodule Entice.Logic.Movement do
alias Entice.Logic.{Movement, Player.Position}


@update_interval 50


@doc """
Note that velocity is actually a coefficient for the real velocity thats used inside
the client, but for simplicities sake we used velocity as a name.
"""
defstruct goal: %Coord{}, plane: 1, move_type: 9, velocity: 1.0, update_self: false, update_delay: 1
defstruct goal: %Coord{}, plane: 1, move_type: 9, velocity: 1.0, auto_updating?: false


def register(entity),
Expand All @@ -30,6 +33,8 @@ defmodule Entice.Logic.Movement do
end)
end

def update_interval, do: @update_interval


defmodule Behaviour do
use Entice.Entity.Behaviour
Expand All @@ -44,9 +49,9 @@ defmodule Entice.Logic.Movement do
do: {:ok, entity |> put_attribute(%Movement{})}

def handle_event({:movement_calculate_next},
%Entity{attributes: %{Movement => %Movement{update_self: update_self, update_delay: update_delay}}} = entity) do
%Entity{attributes: %{Movement => %Movement{auto_updating?: auto_updating?}}} = entity) do
#TODO: implement once the whole collision business is handled
if update_self, do: self |> Process.send_after(:movement_calculate_next, update_delay)
if auto_updating?, do: self |> Process.send_after(:movement_calculate_next, Movement.update_interval)
{:ok, entity}
end

Expand Down