Example #1
0
static int ActionFunction(struct Agent* _Agent, void* _Data) {
	struct Retinue* _Retinue = BigGuyRetinue(_Agent->Agent, PersonHome(_Agent->Agent->Person)); 
	struct Settlement* _Home = PersonHome(_Agent->Agent->Person);
	int* _State = _Agent->PlanData;
	
	switch(*_State) {
		case ACTSTATE_INIT:
			if(_Retinue == NULL) {
				_Retinue = CreateRetinue(_Agent->Agent);
				SettlementAddRetinue(_Home, _Retinue);
			}
			_Retinue->IsRecruiting = 1;
			*_State = ACTSTATE_CHECK;
		case ACTSTATE_CHECK:
			if(_Home->FreeWarriors.Size == 0) {
				*_State = ACTSTATE_END;
			}
			break;
		case ACTSTATE_END:
			_Retinue->IsRecruiting = 0;
			break;

	}
	return 1;
}
Example #2
0
static int ActionUtility(const struct Agent* _Agent, int* _Min, int* _Max, struct WorldState* _State, void* _Data) {
	const struct Settlement* _Settlement = PersonHome(_Agent->Agent->Person);
	struct Retinue* _Retinue = NULL;
	struct BigGuy* _Actor = NULL;
	int _TotalBG = 0;
	double _PartUtiliy = 0.0f;
	int _Utility = 0;

	for(struct LnkLst_Node* _Itr = _Settlement->BigGuys.Front; _Itr != NULL; _Itr = _Itr->Next) {
		struct BigGuy* _Guy = _Itr->Data;

		if(BigGuyRelAtLeast(BigGuyGetRelation(_Actor, _Guy), BGREL_LIKE) == 0)
			++_TotalBG;
	}
	_Retinue = BigGuyRetinue(_Actor, PersonHome(_Actor->Person));
	_PartUtiliy += _TotalBG / _Settlement->BigGuys.Size * 128;
	_PartUtiliy += _Retinue->Warriors.Size / (_Settlement->MaxWarriors) * 128;
	_Utility = _PartUtiliy;
	*_Min = 0;
	*_Max = 255;
	return _Utility;
}
Example #3
0
void RetinueThink(struct Retinue* _Retinue) {
	if(NEWYEAR(g_GameWorld.Date) != 0) {
		RetinuePayWarriors(_Retinue);		
	}
	if(_Retinue->IsRecruiting != 0) {
		struct Settlement* _Home = PersonHome(_Retinue->Leader->Person);
		if(_Home->FreeWarriors.Size <= 0)
			goto not_recruit;
		if(BigGuySkillCheck(_Retinue->Leader, BGSKILL_CHARISMA, SKILLCHECK_DEFAULT) == 0)
			goto not_recruit;
		RetinueAddWarrior(_Retinue, _Home->FreeWarriors.Front->Data);
		LnkLstPopFront(&_Home->FreeWarriors);	
	}
	not_recruit:
	return;
}
Example #4
0
struct Retinue* CreateRetinue(struct BigGuy* _Leader) {
	struct Retinue* _Retinue = malloc(sizeof(struct Retinue));
	struct Settlement* _Home = PersonHome(_Leader->Person);

	_Retinue->Happiness = 50;
	_Retinue->Leader = _Leader;
	_Retinue->IsRecruiting = 0;
	_Retinue->FamilySz = 0;
	ConstructArray(&_Retinue->Warriors, 8);
	for(struct LnkLst_Node* _Itr = _Home->FreeWarriors.Front; _Itr != NULL; _Itr = _Itr->Next) {
		if(_Leader->Person == _Itr->Data) {
			LnkLstRemove(&_Home->FreeWarriors, _Itr);
			break;
		}
	}
	_Retinue->RecruitMod = 0;
	return _Retinue;
}