Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

LNX-69 Add bear #14

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

LNX-69 Add bear #14

wants to merge 10 commits into from

Conversation

alpinus4
Copy link
Contributor

@alpinus4 alpinus4 commented Jan 19, 2023

Added new enemy bear, as well as new actions prepare_to_slam and slam.

For now bear does 3 to 4 actions in one tick

{ "base_class_name" : "Action", "class_name" : "Idle", "properties" : {"object_id": 6} } 
{ "base_class_name" : "Action", "class_name" : "Move", "properties" : {"object_id": 6, "direction": "WEST"} } 
{ "base_class_name" : "Action", "class_name" : "PrepareToSlam", "properties" : {"object_id": 6} } 
{ "base_class_name" : "Action", "class_name" : "Slam", "properties" : {"object_id": 6, "points": ["(0,1)", "(-1,0)", "(0,-1)", "(1,0)"]} }

idk if it is possible to make machine dependent on ticks, so that one state is executed per tick, to be done later

@alpinus4 alpinus4 changed the title [WiP] Add bear, start working on a state machine [WiP] Add bear Jan 19, 2023
@alpinus4 alpinus4 changed the title [WiP] Add bear [WiP] LNX-69 Add bear Jan 19, 2023
@alpinus4 alpinus4 changed the title [WiP] LNX-69 Add bear LNX-69 Add bear Jan 20, 2023
@alpinus4
Copy link
Contributor Author

I changed external state machine to written by me.
It was overly complicated.

Also bear behavior was implemented.
Sample logs:

{ "base_class_name" : "Action", "class_name" : "NextScene", "properties" : {} } 
{ "base_class_name" : "Object", "class_name" : "Floor", "properties" : {"id": 0, "position": "(0,0)"} } 
{ "base_class_name" : "Object", "class_name" : "Floor", "properties" : {"id": 1, "position": "(0,1)"} } 
{ "base_class_name" : "Object", "class_name" : "Floor", "properties" : {"id": 2, "position": "(1,0)"} } 
{ "base_class_name" : "Object", "class_name" : "Floor", "properties" : {"id": 3, "position": "(1,1)"} } 
{ "base_class_name" : "Object", "class_name" : "Floor", "properties" : {"id": 4, "position": "(0,2)"} } 
{ "base_class_name" : "Object", "class_name" : "Floor", "properties" : {"id": 5, "position": "(1,2)"} } 
{ "base_class_name" : "Object", "class_name" : "Bear", "properties" : {"id": 6, "position": "(1,0)"} } 
{ "base_class_name" : "Object", "class_name" : "Agent", "properties" : {"id": 7, "position": "(0,0)"} } 
{ "base_class_name" : "Action", "class_name" : "Idle", "properties" : {"object_id": 6} } 
{ "base_class_name" : "Action", "class_name" : "Move", "properties" : {"object_id": 7, "direction": "NORTH"} } 
{ "base_class_name" : "Action", "class_name" : "PrepareToSlam", "properties" : {"object_id": 6} } 
{ "base_class_name" : "Action", "class_name" : "Move", "properties" : {"object_id": 7, "direction": "NORTH"} } 
{ "base_class_name" : "Action", "class_name" : "Slam", "properties" : {"object_id": 6, "points": ["(1,1)", "(0,0)", "(1,-1)", "(2,0)"]} } 
{ "base_class_name" : "Action", "class_name" : "Idle", "properties" : {"object_id": 6} } 
{ "base_class_name" : "Action", "class_name" : "Move", "properties" : {"object_id": 6, "direction": "NORTH"} } 
{ "base_class_name" : "Action", "class_name" : "Move", "properties" : {"object_id": 6, "direction": "NORTH"} } 
{ "base_class_name" : "Action", "class_name" : "PrepareToSlam", "properties" : {"object_id": 6} } 
{ "base_class_name" : "Action", "class_name" : "Slam", "properties" : {"object_id": 6, "points": ["(1,3)", "(0,2)", "(1,1)", "(2,2)"]} } 
{ "base_class_name" : "Action", "class_name" : "DealDmg", "properties" : {"object_id": 7, "dmg": 10} } 
{ "base_class_name" : "Action", "class_name" : "Idle", "properties" : {"object_id": 6} } 
{ "base_class_name" : "Action", "class_name" : "PrepareToSlam", "properties" : {"object_id": 6} } 
{ "base_class_name" : "Action", "class_name" : "Slam", "properties" : {"object_id": 6, "points": ["(1,3)", "(0,2)", "(1,1)", "(2,2)"]} } 
{ "base_class_name" : "Action", "class_name" : "DealDmg", "properties" : {"object_id": 7, "dmg": 10} } 
{ "base_class_name" : "Action", "class_name" : "Idle", "properties" : {"object_id": 6} } 
{ "base_class_name" : "Action", "class_name" : "PrepareToSlam", "properties" : {"object_id": 6} } 
{ "base_class_name" : "Action", "class_name" : "Slam", "properties" : {"object_id": 6, "points": ["(1,3)", "(0,2)", "(1,1)", "(2,2)"]} } 

@blazej-smorawski
Copy link
Contributor

Added some improvements to the multi-field stuff. Seems to be working properly on the front-end.

src/objects/npcs/enemies/bear.py Outdated Show resolved Hide resolved
super().__init__()
self.properties.object_id = object.properties.id
self.object = object
self.properties.points = points
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This thing is a little tricky. Right now front-end does not support deserialization of lists but I think it should not be a problem to add something like that. I guess it will be enough to have some helper function in Deserializer to call strtok.

src/common/state_machine.py Show resolved Hide resolved
src/common/state_machine.py Outdated Show resolved Hide resolved
src/objects/object.py Outdated Show resolved Hide resolved
src/objects/object.py Show resolved Hide resolved
src/objects/npcs/enemies/bear.py Outdated Show resolved Hide resolved
@alpinus4
Copy link
Contributor Author

Possible bug after

commit 975e99fd7bb0d4743639b580d372961bed1f6b91  Improve multiple-fields objects

After Destroy() action on agent, Bear should wander around :
image

But everything stops:
image

To be checked after multiple fields are fully implemented.

@alpinus4
Copy link
Contributor Author

alpinus4 commented Jan 26, 2023

Bear was killing itself, not an issue anymore

@alpinus4
Copy link
Contributor Author

alpinus4 commented Feb 9, 2023

Rebased onto master

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants