@@ -31,7 +31,8 @@ class CheckAll : public compositNode
{
public:
virtual bool run(actor* testingCharacter, std::vector<std::vector<std::vector<tile*> > > &_map, std::vector<item*> &localItems, std::vector<actor*> & actors, announcements & announcementList) override
{
{
std::cout << "bich" << testingCharacter->memory.x << "," << testingCharacter->memory.y << std::endl;
for (Node* child : getChildren()){
child->run(testingCharacter,_map,localItems,actors,announcementList);
}
@@ -158,10 +159,11 @@ class findDoorNode : public Node
public:
virtual bool run(actor* testingCharacter, std::vector<std::vector<std::vector<tile*> > > &_map, std::vector<item*> &localItems, std::vector<actor*> & actors, announcements & announcementList) override
{
coordinate temp = testingCharacter->findTile(_map,true,false);
coordinate temp = testingCharacter->findTile(_map,true,false,false);
std::cout << "Looking for a door...\n";
if (temp!= coordinate(-1,-1) and !_map[1][temp.y][temp.x]->isOpen()){
testingCharacter->goal = temp;
testingCharacter->goal = temp;
testingCharacter->memory = testingCharacter->goal;
std::cout << "Found a door...\n";
if (testingCharacter->findDistance(testingCharacter->goal)<=1.4){
testingCharacter->openDoor(_map);
@@ -174,13 +176,30 @@ class findDoorNode : public Node
return false;
}
}
};

class findHidingSpot : public Node
{
public:
virtual bool run(actor* testingCharacter, std::vector<std::vector<std::vector<tile*> > > &_map, std::vector<item*> &localItems, std::vector<actor*> & actors, announcements & announcementList) override
{
coordinate temp = testingCharacter->findTile(_map,false,true,false);
if (temp!= coordinate(-1,-1)){
testingCharacter->goal = temp;
return true;
}
else{
return false;
}
}
};

class openDoorNode : public Node
{
public:
virtual bool run(actor* testingCharacter, std::vector<std::vector<std::vector<tile*> > > &_map, std::vector<item*> &localItems, std::vector<actor*> & actors, announcements & announcementList) override
{
{
if (!testingCharacter->opensdoors)return false;
std::cout << "Opening the door...\n";
if (testingCharacter->openDoor(_map)){
std::cout << "Opened the door...\n";
@@ -199,9 +218,13 @@ class lookForItemNode : public Node
public:
virtual bool run(actor* testingCharacter, std::vector<std::vector<std::vector<tile*> > > &_map, std::vector<item*> &localItems, std::vector<actor*> & actors, announcements & announcementList) override
{
std::cout << "Looking for new items...\n";
if (testingCharacter->findItem(_map, localItems)){
std::cout << "Found item(s)\n";
std::cout << "Looking for new items...\n";

if (testingCharacter->findItem(_map, localItems)){
if (testingCharacter->goal!=testingCharacter->memory){
testingCharacter->memory = testingCharacter->goal;
announcementList.addAnnouncement("I see a " + testingCharacter->itemToPickUp->name);
}
return true;
}
else{
@@ -227,6 +250,23 @@ class pickUpItemNode : public Node
}
}
};

class lookForEnemiesNode : public Node
{
public:
virtual bool run(actor* testingCharacter, std::vector<std::vector<std::vector<tile*> > > &_map, std::vector<item*> &localItems, std::vector<actor*> & actors, announcements & announcementList) override
{
for (actor* _a : actors){
std::cout << _a->EVIL << std::endl;
if (!_a->EVIL and testingCharacter->EVIL){
testingCharacter->inDanger = true;
return true;
}
}
testingCharacter->inDanger = false;
return false;
}
};

class decideIfCanAttackNode : public Node
{
@@ -239,11 +279,13 @@ class decideIfCanAttackNode : public Node
return true;
}
else{
std::cout << "No I don't think so...\n";
std::cout << "No I don't think so...\n";
std::cout << "I want to hide\n";
if (testingCharacter->inDanger)return true;
return false;
}
}
};
};

class attackNode : public Node
{
@@ -258,8 +300,44 @@ class attackNode : public Node
return true;
}
}
if (testingCharacter->inDanger)return true;
return false;
}
};

class herdNode : public Node
{
public:
virtual bool run(actor* testingCharacter, std::vector<std::vector<std::vector<tile*> > > &_map, std::vector<item*> &localItems, std::vector<actor*> & actors, announcements & announcementList) override
{
if (testingCharacter->actorFollowing != NULL){
if (testingCharacter->findDistance(coordinate(testingCharacter->actorFollowing->col(),testingCharacter->actorFollowing->row()))>6){
testingCharacter->goal = coordinate(testingCharacter->actorFollowing->col(),testingCharacter->actorFollowing->row());
return false;
}
else{
int temp = rand()%9;
if (temp == 8){testingCharacter->goal = coordinate(-1,-1);return false;}
coordinate directions[8] = {{coordinate(0,-1)},{coordinate(1,0)},{coordinate(0,1)},{coordinate(-1,0)},{coordinate(1,-1)},{coordinate(1,1)},{coordinate(-1,1)},{coordinate(-1,-1)}};
testingCharacter->goal = coordinate(testingCharacter->col()+directions[temp].x,testingCharacter->row()+directions[temp].y);
return false;
}
}
else if (testingCharacter->social and testingCharacter->memory == coordinate(-1,-1)){
testingCharacter->findTile(_map,false,false,true);
if (testingCharacter->findDistance(testingCharacter->goal)>2){
return false;
}
else{
int temp = rand()%9;
if (temp == 8){testingCharacter->goal = coordinate(-1,-1);return false;}
coordinate directions[8] = {{coordinate(0,-1)},{coordinate(1,0)},{coordinate(0,1)},{coordinate(-1,0)},{coordinate(1,-1)},{coordinate(1,1)},{coordinate(-1,1)},{coordinate(-1,-1)}};
testingCharacter->goal = coordinate(testingCharacter->col()+directions[temp].x,testingCharacter->row()+directions[temp].y);
return false;
}
}
return false;
}
};

#endif // BEHAVIORTREE_H_INCLUDED

Large diffs are not rendered by default.

@@ -1,169 +1,169 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug" />
<File name="light.h" open="0" top="0" tabpos="21" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="RSL.h" open="1" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="278" topLine="0" />
<Cursor1 position="579" topLine="0" />
</Cursor>
</File>
<File name="main.cpp" open="1" top="1" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="behaviorTree.h" open="1" top="0" tabpos="16" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6411" topLine="153" />
<Cursor1 position="9132" topLine="233" />
</Cursor>
</File>
<File name="generateCity.cpp" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
<File name="include\dungeon.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3010" topLine="65" />
<Cursor1 position="2134" topLine="74" />
</Cursor>
</File>
<File name="materials.cpp" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="interactionsWithWorld.cpp" open="1" top="0" tabpos="17" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="117" topLine="0" />
<Cursor1 position="6529" topLine="155" />
</Cursor>
</File>
<File name="actor.h" open="1" top="0" tabpos="16" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="item.cpp" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1059" topLine="55" />
<Cursor1 position="27" topLine="2" />
</Cursor>
</File>
<File name="materials.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="item.h" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2424" topLine="18" />
<Cursor1 position="731" topLine="0" />
</Cursor>
</File>
<File name="RSL.cpp" open="1" top="0" tabpos="20" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="drawGame.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="16544" topLine="421" />
<Cursor1 position="315" topLine="0" />
</Cursor>
</File>
<File name="menu.cpp" open="1" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="drawGame.cpp" open="1" top="0" tabpos="22" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9545" topLine="220" />
<Cursor1 position="1447" topLine="0" />
</Cursor>
</File>
<File name="RSL.h" open="1" top="0" tabpos="19" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="light.h" open="0" top="0" tabpos="21" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="579" topLine="0" />
<Cursor1 position="278" topLine="0" />
</Cursor>
</File>
<File name="menu.h" open="1" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="aStar.h" open="0" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="334" topLine="0" />
<Cursor1 position="293" topLine="0" />
</Cursor>
</File>
<File name="behaviorTree.h" open="0" top="0" tabpos="19" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="main.cpp" open="1" top="1" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1928" topLine="21" />
<Cursor1 position="1971" topLine="123" />
</Cursor>
</File>
<File name="playerActions.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="generateCity.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1078" topLine="22" />
<Cursor1 position="579" topLine="16" />
</Cursor>
</File>
<File name="node.h" open="0" top="0" tabpos="23" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="materials.cpp" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="48" topLine="0" />
<Cursor1 position="117" topLine="0" />
</Cursor>
</File>
<File name="shadowcasting.cpp" open="1" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="actor.cpp" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="7050" topLine="105" />
<Cursor1 position="9297" topLine="213" />
</Cursor>
</File>
<File name="shadowcasting.h" open="0" top="0" tabpos="24" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="materials.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="416" topLine="0" />
<Cursor1 position="1027" topLine="6" />
</Cursor>
</File>
<File name="tile.cpp" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="aStar.cpp" open="1" top="0" tabpos="20" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="342" topLine="6" />
<Cursor1 position="4640" topLine="94" />
</Cursor>
</File>
<File name="tile.h" open="1" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="menu.cpp" open="1" top="0" tabpos="23" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="611" topLine="0" />
<Cursor1 position="5525" topLine="109" />
</Cursor>
</File>
<File name="window.cpp" open="0" top="0" tabpos="17" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="bodyParts.cpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
<Cursor1 position="2939" topLine="71" />
</Cursor>
</File>
<File name="window.h" open="1" top="0" tabpos="17" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="playerActions.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="224" topLine="0" />
<Cursor1 position="5221" topLine="64" />
</Cursor>
</File>
<File name="drawGame.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="menu.h" open="1" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="315" topLine="0" />
<Cursor1 position="334" topLine="0" />
</Cursor>
</File>
<File name="drawGame.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="bodyParts.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="661" topLine="0" />
<Cursor1 position="1979" topLine="35" />
</Cursor>
</File>
<File name="aStar.h" open="0" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="shadowcasting.cpp" open="1" top="0" tabpos="21" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="293" topLine="0" />
<Cursor1 position="516" topLine="0" />
</Cursor>
</File>
<File name="generateCity.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="node.h" open="0" top="0" tabpos="23" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="579" topLine="16" />
<Cursor1 position="48" topLine="0" />
</Cursor>
</File>
<File name="include\dungeon.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="actorConstructors.cpp" open="1" top="0" tabpos="19" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2134" topLine="74" />
<Cursor1 position="1633" topLine="48" />
</Cursor>
</File>
<File name="actor.cpp" open="1" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="shadowcasting.h" open="0" top="0" tabpos="24" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="8384" topLine="188" />
<Cursor1 position="416" topLine="0" />
</Cursor>
</File>
<File name="aStar.cpp" open="0" top="0" tabpos="16" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="actorMenus.cpp" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5175" topLine="121" />
<Cursor1 position="400" topLine="325" />
</Cursor>
</File>
<File name="bodyParts.cpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="tile.cpp" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2939" topLine="153" />
<Cursor1 position="342" topLine="6" />
</Cursor>
</File>
<File name="interactionsWithWorld.cpp" open="0" top="0" tabpos="17" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="tile.h" open="1" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1365" topLine="16" />
<Cursor1 position="1157" topLine="3" />
</Cursor>
</File>
<File name="bodyParts.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="generateCity.cpp" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
<Cursor>
<Cursor1 position="1979" topLine="43" />
<Cursor1 position="3010" topLine="65" />
</Cursor>
</File>
<File name="item.cpp" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="actor.h" open="1" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1327" topLine="0" />
<Cursor1 position="3818" topLine="126" />
</Cursor>
</File>
<File name="actorConstructors.cpp" open="1" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="window.cpp" open="0" top="0" tabpos="17" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="793" topLine="12" />
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="item.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="RSL.cpp" open="1" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="731" topLine="0" />
<Cursor1 position="981" topLine="0" />
</Cursor>
</File>
<File name="actorMenus.cpp" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="window.h" open="1" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3542" topLine="96" />
<Cursor1 position="224" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>
@@ -1,27 +1,27 @@
[HUMAN]
[Q1]Under the light of a full moon, your parents prayed to what constellation?;
[Q1]Under the light of a full moon, your parents prayed to what constellation? ;
[A1]strength:Aries ;
[A2]intelligence:Apollo ;
[A3]dexterity:Athena ;
[A4]accuracy:Artemis ;
[A5]defense:Hephaestus ;
[Q2]As a child, you grew up as a...;
[Q2]As a child, you grew up as a... ;
[A1]strength:farmer ;
[A2]intelligence:scholar ;
[A3]dexterity:thief ;
[A4]accuracy:hunter ;
[A5]defense:swordsman ;
[Q3]When you reached your teenage years, your village was attacked. What did you do?;
[Q3]When you reached your teenage years, your village was attacked. What did you do? ;
[A1]strength:Fight the attackers ;
[A2]defense:Protect my family ;
[A3]dexterity:Find and kill the leader ;
[A4]accuracy:Use my bow to shoot them from afar ;
[A5]intelligence:Run and hide, of course! ;
[Q4]Your village was defeated in the attack, and you were caught and imprisoned.;
[Q4]Your village was defeated in the attack, and you were caught and imprisoned. ;
[A1]intelligence:I waited and planned my escape ;
[A2]strength:I knocked out a guard and stole the keys to leave ;
[A3]dexterity:I snuck out during dinner when the guards stopped looking ;
[Q5]After You left the prison, what did you do?;
[Q5]After You left the prison, what did you do? ;
[A1]strength:I would brawl to make my money, until I took a hit to the head and lost my memory ;
[A2]intelligence:I worked in the castle library, until I fell off a shelf and struck my head ;
[A3]dexterity:I grew into my destiny as a thief, until I took it too far and was nearly killed. ;
@@ -1,4 +1,5 @@
[HUMAN];
[HOME]village;
[NAME]human;
[DESCRIPTION]An average, intelligent creature.;
[TAGS];
@@ -10,6 +11,9 @@
[HAIRTYPES]{short:long:bald:afro:mohawk:};
[STRENGTH]2:5:7:9:10:;
[DEXTERITY]10:15:20:25:30:;
[OPENDOORS]true;
[EQUIPS]true;
[SOCIAL]true;

[SKIN]10;
[FAT]5;
@@ -18,16 +22,20 @@
[ENDSPECIES]

[GOBLIN];
[HOME]cave;
[NAME]goblin;
[DESCRIPTION]A small cruel creature.;
[TAGS]EVIL;
[EVIL]true;
[OPENDOORS]true;
[EQUIPS]true;
[SOCIAL]true;
[LIMBS]{01,02,11,head:02,00,4,neck:03,01,1,Leye:0C,01,1,eye:00,00,100,torso:04,00,8,Larm:05,00,8,arm:06,00,26,Lleg:07,00,26,leg:08,06,4,Lfoot:09,07,4,foot:0A,05,4,Lhand:0B,04,4,hand:};
[SKINCOLOR]{green:};
[HAIRCOLOR]{black:};
[EYECOLOR]{grey:black:yellow:};
[HAIRTYPES]{short:bald:mohawk:};
[STRENGTH]3;
[DEXTERITY]15;
[STRENGTH]3:;
[DEXTERITY]15:;

[SKIN]10;
[FAT]5;
@@ -0,0 +1,12 @@
[GREETING]
[TEXT]{Hey!:Hello:Good day:};
[END]
[NEGATIVE]
[TEXT]{bad:awful:miserable:depressing:};
[END]
[POSITIVE]
[TEXT]{good:wonderful:decent:pleasant:};
[END]
[HUMAN]
[TEXT]{Oh, what a time to be alive.:My farm is prospering lately.:The madam is doing well.:A story my father told me years ago has been on my mind.:My mother worries me some times.:I'm going to hit up the pub in the city tonight!:};
[END]
@@ -31,15 +31,17 @@ void announcements::drawAnnouncements(sf::RenderWindow & window)
font.loadFromFile("data/PressStart2P-Regular.ttf");
sf::Text menuText;
menuText.setCharacterSize(8);
menuText.setFont(font);
menuText.setFont(font);
int counter = 0;

int x = window.getSize().x*.60+6,y = window.getSize().y - 15;
for (int i = 29; i >-1;i--){
if (i > announcementList.size())return;
menuText.setString(announcementList[i]);
if (counter > announcementList.size()-1 or announcementList.size() == 0)return;
menuText.setString(announcementList[counter]);
menuText.setPosition(x,y);
window.draw(menuText);
y-=15;
counter++;
}
}

@@ -57,6 +57,7 @@ bool actor::canSee(std::vector<std::vector<std::vector<tile*> > > _map, coordina

error += delta_y;
x1 += ix;
if (coordinate(x1,y1) == goal)return true;
if (_map[1][y1][x1]->movementCost==-1 or (_map[1][y1][x1]->isDoor==true and _map[1][y1][x1]->isOpen()==false)){
return false;
}
@@ -78,6 +79,7 @@ bool actor::canSee(std::vector<std::vector<std::vector<tile*> > > _map, coordina

error += delta_x;
y1 += iy;
if (coordinate(x1,y1) == goal)return true;
if (_map[1][y1][x1]->movementCost==-1 or (_map[1][y1][x1]->isDoor==true and _map[1][y1][x1]->isOpen()==false)){
return false;
}
@@ -86,6 +88,138 @@ bool actor::canSee(std::vector<std::vector<std::vector<tile*> > > _map, coordina
return true;
}

void actor::dialogue(std::vector<std::vector<std::vector<tile*> > > &_map, std::vector<actor*> &actors, std::vector<item*> &localItems, announcements & announcementList, sf::RenderWindow &window)
{
sf::Font font;
font.loadFromFile("data/PressStart2P-Regular.ttf");

sf::Text text;
text.setFont(font);
int questionOn = 0;
bool answered = false;
bool keyreleased = false;

std::string questions[4] = {"Can you come with me?","Do you see any items nearby?","Do you see any monsters nearby?","Do you have anything I can buy?"};
std::string temp = RSL::getStringData("data/dialogue/dialogue.raw","human.text");

sf::Event event;

while (1){
text.setCharacterSize(20);
text.setPosition(10,10);
text.setString(temp);
text.setCharacterSize(12);

window.clear(sf::Color::Black);
window.draw(text);

if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad2) and keyreleased == true and answered == false){questionOn++; keyreleased = false;}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad8) and keyreleased == true and answered == false){questionOn--; keyreleased = false;}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad5) and keyreleased == true and answered == false){
if (questionOn == 0){
if ((rand()%100)<10){
temp = "Yes! That sounds like fun!";
for (actor* _a : actors){
if (_a->controlled == true)actorFollowing = _a;
}
}
else{
temp = "No, that's too dangerous.";
}
}
if (questionOn == 1){
bool helpful = false;
for (actor* _a : actors){
if (_a->controlled == true){
if (actorFollowing == _a){
if (findItem(_map,localItems) == true){
temp = "I see a few that are interesting";
}
else{
temp = "No, none that I'd consider interesting.";
}
helpful = true;
}
}
}
if (helpful == false){
temp = "Why would I help you?";
}
}
if (questionOn == 2){
bool helpful = false;
for (actor* _a : actors){
if (_a->controlled == true){
if (actorFollowing == _a){
if (inDanger == true){
temp = "Yes I saw something dangerous not too long ago.";
}
else{
temp = "Last I checked I wasn't in danger.";
}
helpful = true;
}
}
}
if (helpful == false){
temp = "Why would I help you?";
}
}
if (questionOn == 3){
bool selling = false;
for (item* _i : inventory){
if (_i->value >= 50){
selling = true;
}
}
if (selling == false){
temp = "I have nothing of value.";
}
else{
temp = "I have a few things, maybe.";
}
}
answered = true;
keyreleased = false;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad5) and keyreleased == true and answered == true){return;}
if (questionOn == 4)questionOn = 0;
if (questionOn < 0)questionOn = 3;

while (window.pollEvent(event)){
if (event.type == sf::Event::KeyReleased)keyreleased = true;
}

if (answered == false){
for (int i = 0;i<4;i++){

if (i == questionOn)text.setStyle(sf::Text::Underlined);

text.setString(questions[i]);
text.setPosition(50,50+i*20);
window.draw(text);
text.setStyle(sf::Text::Regular);

}
}
else {

text.setStyle(sf::Text::Underlined);

text.setString("Ok.");
text.setPosition(50,50);
window.draw(text);
text.setStyle(sf::Text::Regular);
}



window.display();
}


}

void monster::moveOnPath()
{
if (path.size()!=0){
@@ -22,73 +22,79 @@ int main()
coordinate viewSizeInTiles = coordinate(view.getSize().x/16,view.getSize().y/16);

sf::Shader lightingShader;
sf::RenderStates renderState;
sf::RenderStates renderState;;;;;;;;;;;;;;


int counter = 0;

gameWorld gameworld(window);
srand(time(NULL));
srand(rand()%time(NULL));
CheckAll * root = new CheckAll;
announcements announcementList;

Selector* decisionMaker = new Selector;
Selector* actionPerformer = new Selector;

Sequence * doorSequence = new Sequence;
doorSequence->addChild(new findDoorNode);

Sequence * itemSequence = new Sequence;
itemSequence->addChild(new lookForItemNode);
itemSequence->addChild(new isItemBetterNode);

Sequence * attackSequence = new Sequence;
attackSequence->addChild(new decideIfCanAttackNode);

Selector * movement = new Selector;
movement->addChild(new moveOnPathNode);
movement->addChild(new findPathNode);
srand(time(NULL));
srand(rand()%time(NULL));

actionPerformer->addChild(new attackNode);
actionPerformer->addChild(new pickUpItemNode);
actionPerformer->addChild(new openDoorNode);
actionPerformer->addChild(movement);

CheckAll * root = new CheckAll;

Selector * thoughtProcess = new Selector;


Sequence * danger = new Sequence;
danger->addChild(new lookForEnemiesNode);
Selector * fightOrFlight = new Selector;
Sequence * tryToAttack = new Sequence;
tryToAttack->addChild(new decideIfCanAttackNode);
tryToAttack->addChild(new attackNode);
fightOrFlight->addChild(tryToAttack);
fightOrFlight->addChild(new findHidingSpot);
danger->addChild(fightOrFlight);

Sequence * lookForItems = new Sequence;
lookForItems->addChild(new lookForItemNode);
lookForItems->addChild(new pickUpItemNode);

Sequence * openDoors = new Sequence;
openDoors->addChild(new findDoorNode);
openDoors->addChild(new openDoorNode);

//thoughtProcess->addChild(danger);
thoughtProcess->addChild(lookForItems);
//thoughtProcess->addChild(openDoors);

root->addChild(thoughtProcess);
root->addChild(new herdNode);
root->addChild(new findPathNode);
root->addChild(new moveOnPathNode);




decisionMaker->addChild(attackSequence);
decisionMaker->addChild(itemSequence);
decisionMaker->addChild(doorSequence);

root->addChild(decisionMaker);
root->addChild(actionPerformer);


//window.setFramerateLimit(60);


// bool keyrelease=true;
std::vector<actor*> actors;
actors.push_back(characterCreationMenu(window));
//actors.push_back(characterCreationMenu(window));
actors.push_back(new player("human"));
actors.push_back(new monster("goblin"));



//char ch;

actors[0]->pos(1,1);
actors[1]->pos(8,8);
actors[1]->pos(4,7);




std::vector<item*> globalItems;
std::vector<item*> localItems;
localItems.push_back(new weapon("Sword",'/',10,18,7));
localItems.push_back(new clothing("platearmor",'C',5,5,0,"iron"));
localItems.push_back(new clothing("plateleg",'C',5,5,0,"iron"));
localItems.push_back(new clothing("plateleg",'C',5,5,0,"iron"));
localItems.push_back(new clothing("plateboot",'C',5,5,0,"iron"));
// localItems.push_back(new weapon("Sword",'/',10,18,7));
// localItems.push_back(new clothing("platearmor",'C',5,5,0,"iron"));
// localItems.push_back(new clothing("plateleg",'C',5,5,0,"iron"));
// localItems.push_back(new clothing("plateleg",'C',5,5,0,"iron"));
// localItems.push_back(new clothing("plateboot",'C',5,5,0,"iron"));
std::vector<lightSource*> lights;
lights.push_back(new lightSource);
lights[0]->intensity = 1;
@@ -129,7 +135,7 @@ actors.push_back(new monster("goblin"));
_map[1][y].resize(20);
for (int x=0;x<20;x++){
if (x >= 14 and y == 16){
if (x == 17)_map[1][y][x] = new door(true,closeddoor,0,"wood");
if (x == 17)_map[1][y][x] = new door(false,closeddoor,0,"wood");
else _map[1][y][x] = new tile(stonewall,-1,"stone");
}
else if (x == 14 and y >=16){
@@ -146,7 +152,11 @@ actors.push_back(new monster("goblin"));
}
_map[1][y][x]->position = coordinate(x,y);
}
}
}

_map[1][10][10] = new socialTile(closeddoor,-1,"wood");
_map[1][10][10]->position = coordinate(10,10);

std::default_random_engine ew(time(0));
std::uniform_int_distribution<int> numberOfEnemies(2,10);
std::uniform_int_distribution<int> enemyPos(1,17);
@@ -169,50 +179,63 @@ actors.push_back(new monster("goblin"));


//DUNGEON SETUP CODE
// dungeon map_t;
// _map.resize(map_t.dungeon_grid.size());
// _map.resize(map_t.dungeon_grid.size());
// dungeon map_t;
// _map.resize(2);
// _map[0].resize(map_t.dungeon_grid.size());
// _map[1].resize(map_t.dungeon_grid.size());
// for (int y=0;y<map_t.dungeon_grid.size();y++)
// {
// _map[y].resize(map_t.dungeon_grid[0].size());
// _map[0][y].resize(map_t.dungeon_grid[0].size());
// _map[1][y].resize(map_t.dungeon_grid[0].size());
// for (int x=0;x<map_t.dungeon_grid[0].size();x++)
// {
// if (map_t.dungeon_grid[y][x]==1)
// {
// _map[y][x]= new tile(stonewall,0,"stone");
// actors[0]->pos(y,x);
// _map[1][y][x]= new tile(stonewall,0,"stone");
// _map[0][y][x]= new tile(stonefloor,-1,"stone");
// _map[1][y][x]->position = coordinate(x,y);
// _map[0][y][x]->position = coordinate(x,y);
// }
// else
// {
// _map[y][x]= new tile(stonefloor,-1,"stone");
// }
// _map[y][x]->position = coordinate(x,y);
// _map[1][y][x]= new tile;
// _map[0][y][x]= new tile(stonefloor,-1,"stone");
// _map[0][y][x]->position = coordinate(x,y);
// actors[0]->pos(y,x);
// }
// }
// }


bool keyrelease = true;
bool waitforplayer = false;
sf::Event event;
while (window.isOpen())
{


sf::Event event;

std::cout << keyrelease << std::endl;

if (actors[0]->col()*16 - view.getSize().x/2 >= 0)view.setCenter(actors[0]->col()*16,view.getCenter().y);
if (actors[0]->row()*16 - view.getSize().y/2 >= 0)view.setCenter(view.getCenter().x, actors[0]->row()*16);

while (view.getCenter().x != (actors[0]->col()*16)){
view.setCenter(view.getCenter().x-1,view.getCenter().y);
}
while (view.getCenter().y != (actors[0]->row()*16)){
view.setCenter(view.getCenter().x,view.getCenter().y-1);
}

actors[0]->movement(_map, localItems, actors, window, keyrelease, announcementList);
if (actors[0]->counter >= actors[0]->speed())waitforplayer = true;
else waitforplayer = false;

while (view.getCenter().x - view.getSize().x/2 < 0){
view.setCenter(view.getCenter().x+1,view.getCenter().y);
}
while (view.getCenter().y - view.getSize().y/2 < 0){
view.setCenter(view.getCenter().x,view.getCenter().y+1);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Add) and keyrelease == true){view.zoom(.5);keyrelease=false;}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Subtract) and keyrelease == true){view.zoom(1.5f);keyrelease=false;}

if (waitforplayer == false and keyrelease == false){
actors[0]->movement(_map, localItems, actors, window, keyrelease, announcementList, waitforplayer);

for (int i=0;i<actors.size();i++){
if (waitforplayer == false){
for (int i=1;i<actors.size();i++){
if (actors[i]->counter >= actors[i]->speed() and actors[i]->controlled == false){
std::cout << "_______________________________________\n";
root->run(actors[i],_map,localItems,actors,announcementList);
@@ -222,7 +245,6 @@ bool waitforplayer = false;
}
}


// lightmap = &_map;
// do_fov(lightmap,localItems,actors,actors[0]->col(),actors[0]->row(),1/.1,window,renderState,true,1,.1);
// for (lightSource * _l : lights){
@@ -263,8 +285,7 @@ bool waitforplayer = false;
// }
// }
window.setView(view);
gameworld.drawGameworld(_map, actors, localItems,window,announcementList, renderState);
std::cout << keyrelease << std::endl;
gameworld.drawGameworld(_map, actors, localItems,window,announcementList, renderState);
}


BIN +56 Bytes (100%) curses/obj/Debug/generateCity.o
Binary file not shown.
BIN -80 Bytes (100%) curses/obj/Debug/shadowcasting.o
Binary file not shown.
BIN +789 Bytes (100%) curses/obj/Debug/tile.o
Binary file not shown.
@@ -1,6 +1,6 @@
#include "actor.h"

void player::movement(std::vector<std::vector<std::vector<tile*> > > &_map,std::vector<item*> &localItems, std::vector<actor*> &actors, sf::RenderWindow &window, bool &keyrelease, announcements & announcementList)
void player::movement(std::vector<std::vector<std::vector<tile*> > > &_map,std::vector<item*> &localItems, std::vector<actor*> &actors, sf::RenderWindow &window, bool &keyrelease, announcements & announcementList, bool &waitforplayer)
{
/*
0 = NORTH
@@ -30,13 +30,13 @@ void player::movement(std::vector<std::vector<std::vector<tile*> > > &_map,std::
char closeDirection;
char examineDirection;
std::vector<item*> itemsExamining;

sf::Event event;

tile tempFuckdebugging;
coordinate tempShit=coordinate(x,y);
customSpeed=speed();
if (counter>=customSpeed and keyrelease == true){
customSpeed=speed();
if (counter>=customSpeed) waitforplayer = true;
if (counter>=customSpeed and keyrelease == true){

while (window.pollEvent(event)){
if (event.type == sf::Event::KeyPressed){
@@ -53,6 +53,8 @@ void player::movement(std::vector<std::vector<std::vector<tile*> > > &_map,std::
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad1)){temp.y++;temp.x--;keyrelease=false;}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad7)){temp.y--;temp.x--;keyrelease=false;}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad9)){temp.y--;temp.x++;keyrelease=false;}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad5)){keyrelease=false;}

if (sf::Keyboard::isKeyPressed(sf::Keyboard::I)){openInventory(window,localItems, keyrelease);}

else if (sf::Keyboard::isKeyPressed(sf::Keyboard::C)){
@@ -72,6 +74,29 @@ void player::movement(std::vector<std::vector<std::vector<tile*> > > &_map,std::
}
}
_map[1][temp.y][temp.x]->interactWithDoor(false);
}

else if (sf::Keyboard::isKeyPressed(sf::Keyboard::T)){
while (pressedKey == false){
while (window.pollEvent(event)){
if (event.type == sf::Event::KeyPressed){
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad6)){temp.x++;keyrelease=false;}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad4)){temp.x--;keyrelease=false;}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad8)){temp.y--;keyrelease=false;}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad2)){temp.y++;keyrelease=false;}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad3)){temp.y++;temp.x++;keyrelease=false;}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad1)){temp.y++;temp.x--;keyrelease=false;}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad7)){temp.y--;temp.x--;keyrelease=false;}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Numpad9)){temp.y--;temp.x++;keyrelease=false;}
pressedKey = true;
}
}
}
for (actor* _a : actors){
if (coordinate(_a->col(),_a->row()) == temp){
_a->dialogue(_map,actors,localItems,announcementList,window);
}
}
}

else if (sf::Keyboard::isKeyPressed(sf::Keyboard::E)){
@@ -121,9 +146,10 @@ void player::movement(std::vector<std::vector<std::vector<tile*> > > &_map,std::
}
attackEnemy(_map,announcementList,localItems,window);
actorAttacking = NULL;
}
}
waitforplayer = false;
}
else if (_map[1][temp.y][temp.x]->movementCost != -1){
else if (_map[1][temp.y][temp.x]->movementCost != -1 and keyrelease == false){
if (_map[1][temp.y][temp.x]->isDoor){
moveThroughDoor = _map[1][temp.y][temp.x]->interactWithDoor(true);
}
@@ -138,7 +164,8 @@ void player::movement(std::vector<std::vector<std::vector<tile*> > > &_map,std::
if (moveThroughDoor == true){
pos(temp.y,temp.x);
counter=0;
}
}
waitforplayer = false;
}
else{

@@ -149,8 +176,9 @@ void player::movement(std::vector<std::vector<std::vector<tile*> > > &_map,std::
sprite.setPosition(x*16,y*16);
counter = 0;
return;
}
counter++;
}
else counter++;

}

void player::attackEnemy(std::vector<std::vector<std::vector<tile*> > >& _map, announcements& announcementList, std::vector<item*> &localItems, sf::RenderWindow &window)
@@ -9,7 +9,7 @@ void cast_light(std::vector<std::vector<std::vector<tile*> > > &_map, std::vecto
float next_start_slope = start_slope;


_map[actors[0]->zReturn()-1][y][x]->drawTile(window,renderState);
_map[0][y][x]->drawTile(window,renderState);
for (unsigned int i = row; i <= radius; i++){
bool blocked = false;
int dy = -i;
@@ -36,8 +36,8 @@ void cast_light(std::vector<std::vector<std::vector<tile*> > > &_map, std::vecto
else{

if ((unsigned int)(dx * dx + dy * dy) < radius2 /*and _map[actors[0]->zReturn()-1][ay][ax]->litHere == false*/){
_map[actors[0]->zReturn()-1][ay][ax]->drawTile(window, renderState);
_map[actors[0]->zReturn()-1][ay][ax]->litHere = true;
_map[0][ay][ax]->drawTile(window, renderState);
_map[0][ay][ax]->litHere = true;
for (item* _i : localItems){
if (_i->x == ax and _i->y == ay){
_i->draw(window);
@@ -37,6 +37,15 @@ class tile : public node
virtual bool interactWithDoor(bool opening){}
virtual bool isOpen(){}
virtual void openContainer(){}
virtual bool isSocial(){return false;}
};

class socialTile : public tile
{
public:
bool emitsLight;
virtual bool isSocial(){return true;}
socialTile(int dc, int mv, std::string mat){defaultchar = dc;movementCost = mv; _material = mat;}
};

class door : public tile