Browse Source

Handling custom properties of resources (except of guards).

Michał W. Urbańczyk 18 years ago
parent
commit
f518ffdfac
2 changed files with 20 additions and 11 deletions
  1. 1 1
      CCallback.h
  2. 19 10
      CLua.cpp

+ 1 - 1
CCallback.h

@@ -95,7 +95,7 @@ public:
 
 	//do sth
 	static void changePrimSkill(int ID, int which, int val);
-	void showInfoDialog(int player, std::string text, std::vector<SComponent*> * components);
+	void showInfoDialog(int player, std::string text, std::vector<SComponent*> * components); //TODO: obslugiwac nulle
 	void showSelDialog(int player, std::string text, std::vector<CSelectableComponent*>*components, IChosen * asker);
 	void giveResource(int player, int which, int val);
 	void showCompInfo(int player, SComponent * comp);

+ 19 - 10
CLua.cpp

@@ -478,19 +478,28 @@ void CPickable::onHeroVisit(CGObjectInstance *os, int heroID)
 	{
 	case 79:
 		{
+			//TODO: handle guards (when battles are finished)
+			CResourceObjInfo * t2 = static_cast<CResourceObjInfo *>(os->info);
 			int val;
-			switch(os->subID)
+			if(t2->amount)
+				val = t2->amount;
+			else
 			{
-			case 6:
-				val = 500 + (rand()%6)*100;
-				break;
-			case 0: case 2:
-				val = 6 + (rand()%5);
-				break;
-			default:
-				val = 3 + (rand()%3);
-				break;
+				switch(os->subID)
+				{
+				case 6:
+					val = 500 + (rand()%6)*100;
+					break;
+				case 0: case 2:
+					val = 6 + (rand()%5);
+					break;
+				default:
+					val = 3 + (rand()%3);
+					break;
+				}
 			}
+			if(t2->message.length())
+				cb->showInfoDialog(cb->getHeroOwner(heroID),t2->message,&std::vector<SComponent*>());
 			SComponent ccc(SComponent::resource,os->subID,val);
 			ccc.description = CGI->objh->advobtxt[113];
 			boost::algorithm::replace_first(ccc.description,"%s",CGI->objh->restypes[os->subID]);