aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-01-10 14:53:08 -0500
committerClyne Sullivan <tullivan99@gmail.com>2016-01-10 14:53:08 -0500
commit66c99350e63ab6b32ec7fcda45e2e6b8c9f658da (patch)
tree5b701841559307d07417f5fe5505e98ca4933006 /src
parent5227bcfa382b914fff3f01e856a433a7f841b943 (diff)
xml: more npc functionality
Diffstat (limited to 'src')
-rw-r--r--src/gameplay.cpp35
-rw-r--r--src/world.cpp4
2 files changed, 33 insertions, 6 deletions
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 9cae698..aede91a 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -46,6 +46,7 @@ int commonAIFunc(NPC *speaker){
XMLDocument xml;
XMLElement *exml,*oxml;
unsigned int idx;
+ bool stop = false;
for(auto &n : npcd){
if(n.npc == speaker){
@@ -102,6 +103,22 @@ int commonAIFunc(NPC *speaker){
ui::dialogBox(speaker->name,"",false,exml->GetText());
ui::waitForDialog();
}
+ if(exml->Attribute("call")){
+ for(auto &n : currentWorld->npc){
+ if(!strcmp(n->name,exml->Attribute("call"))){
+ if(exml->QueryUnsignedAttribute("callid",&idx) == XML_NO_ERROR){
+ for(auto &n2 : npcd){
+ if(n2.npc == n){
+ n2.index = idx;
+ break;
+ }
+ }
+ }
+ n->addAIFunc(commonAIFunc,false);
+ break;
+ }
+ }
+ }
if(exml->QueryUnsignedAttribute("nextid",&idx) == XML_NO_ERROR){
for(auto &n : npcd){
if(n.npc == speaker){
@@ -109,7 +126,11 @@ int commonAIFunc(NPC *speaker){
break;
}
}
- return 1;
+ if(exml->QueryBoolAttribute("stop",&stop) == XML_NO_ERROR && stop)
+ return 0;
+ else if(exml->QueryBoolAttribute("pause",&stop) == XML_NO_ERROR && stop)
+ return 1;
+ else return commonAIFunc(speaker);
}
return 0;
}
@@ -127,6 +148,7 @@ void initEverything(void){
std::vector<std::string> xmlFiles;
static char *file;
bool dialog;
+ float spawnx;
XMLDocument xml;
XMLElement *wxml;
@@ -158,9 +180,16 @@ void initEverything(void){
earth.back()->generate(wxml->UnsignedAttribute("width"));
}
}else if(!strcmp(name,"mob")){
- earth.back()->addMob(wxml->UnsignedAttribute("type"),wxml->FloatAttribute("x"),wxml->FloatAttribute("y"));
+ if(wxml->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR)
+ earth.back()->addMob(wxml->UnsignedAttribute("type"),getRand() % earth.back()->getTheWidth() / 2,100);
+ else
+ earth.back()->addMob(wxml->UnsignedAttribute("type"),wxml->FloatAttribute("x"),wxml->FloatAttribute("y"));
}else if(!strcmp(name,"npc")){
- earth.back()->addNPC(wxml->FloatAttribute("x"),wxml->FloatAttribute("y"));
+ if(wxml->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR)
+ earth.back()->addNPC(getRand() % earth.back()->getTheWidth() / 2.0f,100);
+ else
+ earth.back()->addNPC(wxml->FloatAttribute("x"),wxml->FloatAttribute("y"));
+
if(wxml->Attribute("name")){
delete[] earth.back()->npc.back()->name;
earth.back()->npc.back()->name = new char[strlen(wxml->Attribute("name"))+1];
diff --git a/src/world.cpp b/src/world.cpp
index e97ec56..68d5d2f 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -770,11 +770,9 @@ LOOP2:
cline[i].y-=(yoff-DRAW_Y_OFFSET);
}
//glEnd();
- //glUseProgram(0);
+ glUseProgram(0);
glDisable(GL_TEXTURE_2D);
- //glUseProgram(0);
-
/*
* Draw non-structure entities.
*/