int UpdateControlsWindow(HUDInfo *self,int pressID) { switch(pressID) { case 0: HideMouse(); UnPause(); PopWindow(self->Handle); return 1; } return 0; }
int UpdateNPCQuestWindow(HUDInfo *self,int pressID) { int c; char text[80]; int i; int fail; Progress *p; NPC *npc; npc = (NPC *)self->ib; c = GetQuestCount(npc); switch(pressID) { case 0: PopWindow(self->Handle); return 1; break; } if((pressID >= 1)&&(pressID <= c)) { /*if already complete, thank the player for it again*/ p = GetProgressByNameIndexMap(level.name,npc->quests[pressID - 1].name,self->state); if((p != NULL)&&(strcmp(p->value,"complete") == 0)) { NewMsg("Yes, you were very helpful with that one, thank you."); return 1; } /*check for fail condiitions*/ /*if player has met the win conditions, give player reward and mark complete*/ if(p != NULL) { fail = 0; for(i = 0; i < 4;i++) { if(!IsConditionMet(npc->quests[pressID - 1].wincond[i]))fail =1; } if(!fail) { sprintf(text,"Complete Quest %s?",npc->quests[pressID - 1].name); QuestID = pressID - 1; NPCID = self->state; QuestNPC = npc; YesNo(text,CompleteQuest,NULL); return 1; } } /*otherwise the the player about it*/ TextBlockWindow(npc->quests[pressID - 1].desc); SetPlayerProgress(level.name,npc->quests[pressID - 1].name, self->state,"offered"); return 1; } return 0; }
//This is a boolean for ReleaseWindow from WindowManager. bool WindowManager::ReleaseWindow(Window* window) { if(windows.count(window->GetWindowHandle()) == 1) { sceneMap.erase(window); PopWindow(window); return true; } else { return false; } }
void NPCDialogWindow(NPC *npc,int id) { int c = 0; HUDInfo *self; self = Pushwindow(); if(self == NULL) { fprintf(stdout,"Big problem here, can't make NPC Dialog window.\n"); return; } self->state = id; self->stealinput = 1; self->windowupdate = UpdateNPCDialogWindow; self->windowdraw = DrawNPCDialogWindow; self->box.w = Camera.w/3; self->box.x = Camera.w/2 - self->box.w/2; self->box.y = Camera.h * 0.2; self->ib = (void *)npc; /*Talk Option, if available*/ if(GetDialogCount(npc)) { c++; PicButton(self,1,SDLK_1,"Talk",self->box.x + self->box.w/2 - (BUTTON_W/2),self->box.y + (BUTTON_H + 4)*c,BUTTON_W,BUTTON_H); } /*Shop Option, if Available*/ if(GetShopCount(npc)) { c++; PicButton(self,2,SDLK_2,"Shop",self->box.x + self->box.w/2 - (BUTTON_W/2),self->box.y + (BUTTON_H + 4)*c,BUTTON_W,BUTTON_H); } /*Quests Option, if Available*/ if(GetQuestCount(npc)) { c++; PicButton(self,3,SDLK_3,"Quests",self->box.x + self->box.w/2 - (BUTTON_W/2),self->box.y + (BUTTON_H + 4)*c,BUTTON_W,BUTTON_H); } if(c == 0) { PopWindow(self->Handle); return; } self->box.h = (BUTTON_H + 4)*(c + 2); PicButton(self,0,SDLK_RETURN,"Done",self->box.x + self->box.w/2 - (BUTTON_W/2),self->box.y + self->box.h - BUTTON_H - 4,BUTTON_W,BUTTON_H); Pausing++; ShowMouse(); }
int UpdateNPCDialogWindow(HUDInfo *self,int pressID) { switch(pressID) { case 3: NPCQuestWindow((NPC *)self->ib,self->state); return 1; case 2: NPCShopWindow((NPC *)self->ib); return 1; case 1: NPCTalkWindow((NPC *)self->ib); return 1; case 0: HideMouse(); Pausing--; PopWindow(self->Handle); return 1; } return 0; }
int UpdateNPCTalkWindow(HUDInfo *self,int pressID) { int c; NPC *npc; npc = (NPC *)self->ib; c = GetDialogCount(npc); switch(pressID) { case 0: PopWindow(self->Handle); return 1; break; } if((pressID >= 1)&&(pressID <= c)) { TextBlockWindow(npc->dialog[pressID - 1].dialog); /* NewMsg(npc->dialog[pressID - 1].dialog);*/ return 1; } return 0; }
int UpdateNPCShopWindow(HUDInfo *self,int pressID) { char text[80]; int c; int Good; NPC *npc; P_Skill *skill; Item *item; npc = (NPC *)self->ib; c = GetShopCount(npc); switch(pressID) { case 0: PopWindow(self->Handle); return 1; break; } if((pressID >= 1)&&(pressID <= c)) { if(strcmp(npc->shop[pressID - 1].type,"item")==0) { item = GetItemByName(npc->shop[pressID - 1].name); if(item == NULL)return 0; if(PDat.gold >= (item->cost * npc->shop[pressID - 1].markup)) { BuyingPrice = (item->cost * npc->shop[pressID - 1].markup); strcpy(BuyingItem,item->name); sprintf(text,"Buy %s for %iG?",BuyingItem,BuyingPrice); YesNo(text,PurchaseItem,NULL); } else { NewMessage("You can't afford this!",IndexColor(White)); NewMessage("Come back when you have more money!",IndexColor(White)); } } else if(strcmp(npc->shop[pressID - 1].type,"service")==0) { if(strcmp(npc->shop[pressID - 1].name,"Rest")==0) { /*TODO:advance the clock some time...*/ /*TODO address status effects*/ NewMsg("After some rest, you feel better."); PlayerEnt->health = PlayerEnt->healthmax; PlayerEnt->mana = PlayerEnt->manamax; PlayerEnt->stamina = PlayerEnt->staminamax; } else if(strcmp(npc->shop[pressID - 1].name,"Inventory")==0) { /*TODO Open up Stockpile menu*/ NewMsg("To Be Added."); } else if(strcmp(npc->shop[pressID - 1].name,"Upgrade")==0) { /*TODO Open up Stockpile menu*/ NewMsg("To Be Added."); } } else if(strcmp(npc->shop[pressID - 1].type,"spell")==0) { skill = GetSpellByName(npc->shop[pressID - 1].name); if(skill == NULL)return 0; if(PDat.gold >= (skill->price * npc->shop[pressID - 1].markup)) { if(strcmp(skill->type,"favor")==0) { if(GetPlayerItemByName("Wood Relic")!= NULL)/*TODO add other favor castors as needed*/ { BuyingPrice = (skill->price * npc->shop[pressID - 1].markup); strcpy(BuyingItem,skill->name); sprintf(text,"Learn the divine favor %s for %iG?",BuyingItem,BuyingPrice); YesNo(text,PurchaseSpell,NULL); } else { NewMsg("In order to learn this, you will need a Holy Relic"); } } if(strcmp(skill->type,"alchemy")==0) { if(GetPlayerItemByName("White Stone")!= NULL)/*TODO add other favor castors as needed*/ { BuyingPrice = (skill->price * npc->shop[pressID - 1].markup); strcpy(BuyingItem,skill->name); sprintf(text,"Learn how to make %ss for %iG?",BuyingItem,BuyingPrice); YesNo(text,PurchaseSpell,NULL); } else { NewMsg("In order to learn this, you will need a Philosopher's Stone!"); } } } else { NewMsg("I'm afraid I can't afford to teach for free."); } } else if(strcmp(npc->shop[pressID - 1].type,"skill")==0) { skill = GetSkillByName(npc->shop[pressID - 1].name); if(skill == NULL)return 0; Good = 1; if(PDat.gold >= (skill->price * npc->shop[pressID - 1].markup)) { if(SkillHasSpecial(skill,"Strength")) { if(PDat.attr[A_Str].score < 10) { Good = 0; NewMsg("You will need to have more strength than that to learn this skill."); } } if(SkillHasSpecial(skill,"Endurance")) { if(PDat.attr[A_End].score < 10) { Good = 0; NewMsg("I'm sorry, you just are not tough enough to handle this skill."); } } if(SkillHasSpecial(skill,"Agility")) { if(PDat.attr[A_Agi].score < 10) { Good = 0; NewMsg("You will need to work on your footwork before I can teach you this."); } } if(SkillHasSpecial(skill,"Dexterity")) { if(PDat.attr[A_Dex].score < 10) { Good = 0; NewMsg("I'm sorry, but you have stupid hands. If you get new ones come back."); } } if(SkillHasSpecial(skill,"Focus")) { if(PDat.attr[A_Foc].score < 10) { Good = 0; NewMsg("If you can't concentrate, I can't teach you."); } } if(SkillHasSpecial(skill,"Spirit")) { if(PDat.attr[A_Str].score < 10) { Good = 0; NewMsg("You lack the strength of will to understand what I haave to teach you."); } } if(Good) { BuyingPrice = (skill->price * npc->shop[pressID - 1].markup); strcpy(BuyingItem,skill->name); sprintf(text,"Learn the %s skill for %iG?",BuyingItem,BuyingPrice); YesNo(text,PurchaseSkill,NULL); } } else { NewMsg("Training Takes time and MONEY. Come back when you have more of the later."); } } return 1; } return 0; }