Пример #1
0
/**
 *
 *
 *  @author OLiver
 */
void nofCarrier::RoadSplitted(RoadSegment* rs1, RoadSegment* rs2)
{
    // Bin ich schon auf meinem Arbeitsplatz (=Straße) oder bin ich erst noch auf dem Weg dorthin?
    if(state == CARRS_FIGUREWORK)
    {
        // ich gehe erst noch hin, also gucken, welche Flagge ich anvisiert habe und das jeweilige Teilstück dann als Arbeitsstraße
        if(GetGoal() == rs1->GetF1())
            workplace = rs1;
        else
            workplace = rs2;
    }
    else if(state == CARRS_CARRYWARETOBUILDING || state == CARRS_LEAVEBUILDING)
    {
        // Wenn ich in ein Gebäude gehen oder rauskomme, auf den Weg gehen, der an dieses Gebäude grenzt
        if(cur_rs->GetF1() == rs1->GetF1() || cur_rs->GetF1() == rs1->GetF2())
            workplace = rs1;
        else
            workplace = rs2;
    }
    else
    {
        // sonst wurde es ja schon entschieden
        workplace = (cur_rs == rs1) ? rs1 : rs2;
    }

    // Sonstige Sachen für jeweilige States unternehmen
    switch(state)
    {
        default:
            break;
        case CARRS_WAITFORWARE:
        {
            // Wenn wir stehen, müssen wir in die Mitte laufen
            state = CARRS_GOTOMIDDLEOFROAD;
            Walked();
        } break;
        case CARRS_FETCHWARE:
        {
            // Wenn wir zur 2. Flagge vom 1. Wegstück gelaufen sind, können wir das nun vergessen
            if(!workplace->AreWareJobs(!rs_dir, ct, false))
                state = CARRS_GOTOMIDDLEOFROAD;
        } break;
    }

    // Mich als Träger für meinen neuen Arbeitsplatz zuweisen
    workplace->setCarrier(ct == CT_DONKEY ? 1 : 0, this);

    // Für andere Straße neuen Träger/Esel rufen
    RoadSegment* uc_road = ((rs1 == workplace) ? (rs2) : (rs1));
    uc_road->setCarrier(ct == CT_DONKEY ? 1 : 0, NULL);

    if(ct == CT_NORMAL)
        gwg->GetPlayer(player)->FindCarrierForRoad(uc_road);
    else if(ct == CT_DONKEY)
        uc_road->setCarrier(1, gwg->GetPlayer(player)->OrderDonkey(uc_road));
}
Пример #2
0
/**
**  Call when animation step is "attack"
*/
/* virtual */ void COrder_SpellCast::OnAnimationAttack(CUnit &unit)
{
	CUnit *goal = GetGoal();
	if (goal && !goal->IsVisibleAsGoal(*unit.Player)) {
		unit.ReCast = 0;
	} else {
		unit.ReCast = SpellCast(unit, *this->Spell, goal, goalPos);
	}
	UnHideUnit(unit); // unit is invisible until attacks
}
//-----------------------------------------------------------------------------
// Purpose: displays achievement progress notification in the HUD
//-----------------------------------------------------------------------------
void CBaseAchievement::ShowProgressNotification()
{
	if ( !ShouldShowProgressNotification() )
		return;

#ifdef CLIENT_DLL
	CAchievementNotificationPanel *pPanel = new CAchievementNotificationPanel("AchievementNotification");
	if (pPanel)
	{
		int iCur = GetCount();
		int iMax = GetGoal();
		wchar_t szFmt[128] = L"";
		wchar_t szText[512] = L"";
		wchar_t szNumFound[16] = L"";
		wchar_t szNumTotal[16] = L"";
		_snwprintf(szNumFound, ARRAYSIZE(szNumFound), L"%i", iCur);
		_snwprintf(szNumTotal, ARRAYSIZE(szNumTotal), L"%i", iMax);

		const wchar_t *pchFmt = g_pVGuiLocalize->Find("#GameUI_Achievement_Progress_Fmt");
		if (!pchFmt || !pchFmt[0])
			return;
		Q_wcsncpy(szFmt, pchFmt, sizeof(szFmt));

		g_pVGuiLocalize->ConstructString(szText, sizeof(szText), szFmt, 3, ACHIEVEMENT_LOCALIZED_NAME_FROM_STR(GetName()), szNumFound, szNumTotal);
		pPanel->AddNotification(GetName(), ACHIEVEMENT_LOCALIZED_NAME_FROM_STR(GetName()), szText);
	}
#endif	

	/*
	IGameEvent *event = gameeventmanager->CreateEvent( "achievement_event" );
	if ( event )
	{
		event->SetString( "achievement_name", GetName() );
		event->SetInt( "cur_val", m_iCount );
		event->SetInt( "max_val", m_iGoal );
#ifdef GAME_DLL
		gameeventmanager->FireEvent( event );
#else
		gameeventmanager->FireEventClientSide( event );
#endif
	}
	*/
}
Пример #4
0
GOALID __CopyGoal(LPGOAL lpOldGoal, ITEMID idName)
{
#ifdef INFERENCE
    GOALID      idGoal;
    LPGOAL      lpGoal;
    LPEXP       lpBody;
    EXPID       idBody;

    if (GetGoal(idName) != NULLID)
        return NULLID;
    
    idGoal = KppAddItemAndName(GOAL, (LPLPSTR)&lpGoal, idName);
    if (!idGoal)
        return NULLID;
    
    NAME(lpGoal) = idName;
    FLAGS(lpGoal) = NULL;
    PRIORITY(lpGoal) = 0;
    if (! (FLAGS(lpGoal) & CBODY))
    {
        if (BODY(lpGoal) == NULLID)
            idBody = NULLID;
        else
        {
            idBody = BODY(lpGoal) = KppCopyExp(BODY(lpOldGoal),
                                (LPLPSTR)&lpBody, kPERMMODE);
            KppReleaseExp(idBody);
        }
    }
    KppReleaseItem(GOAL, idGoal);

    /* Add to KnowledgeTools */
    KppAddItemCB(GOAL, 1);

    return idGoal;
#endif
}
void CMonsterSquad::Idle_AssignAction(ENTITY_VEC &members)
{
	// получить цель лидера
	SMemberGoal &goal = GetGoal(leader);

	if (goal.type == MG_WalkGraph) {
		
		front.clear();	back.clear();	left.clear();	right.clear();

		for (ENTITY_VEC_IT IT = members.begin(); IT != members.end(); IT++) {
			if ((*IT) == leader) continue;
			
			front.push_back	(*IT);
			back.push_back	(*IT);
			left.push_back	(*IT);
			right.push_back	(*IT);
		}

		Fvector front_pos;
		Fvector back_pos;
		Fvector left_pos;
		Fvector right_pos;

		Fvector dir = leader->Direction();
		front_pos.mad(leader->Position(), dir, CENTER_CIRCLE_DIST);
		std::sort(front.begin(),front.end(), CPredicateSideSort(front_pos));

		dir.invert();
		back_pos.mad(leader->Position(), dir, CENTER_CIRCLE_DIST);
		std::sort(back.begin(),back.end(), CPredicateSideSort(back_pos));

		dir = leader->XFORM().i;
		right_pos.mad(leader->Position(), dir, CENTER_CIRCLE_DIST);
		std::sort(right.begin(),right.end(), CPredicateSideSort(right_pos));

		dir.invert();
		left_pos.mad(leader->Position(), dir, CENTER_CIRCLE_DIST);
		std::sort(left.begin(),left.end(), CPredicateSideSort(left_pos));

		SSquadCommand command;
		command.type		= SC_FOLLOW;
		command.entity		= leader;	
		command.direction	= leader->Direction();
		
		u8 cur_type = 0;
		while (!front.empty()) {
			float	random_r;
			Fvector random_dir;

			random_dir.random_dir	();
			random_r				= Random.randF(CIRCLE_RADIUS_MIN, CIRCLE_RADIUS_MAX);

			const CEntity *entity = 0;
			switch (cur_type) {
				case 0: // front
					entity = front.back	(); front.pop_back();
					for (u32 i=0; i<back.size(); i++)	if (back[i] == entity) {back[i] = back.back(); back.pop_back(); break;}
					for (u32 i=0; i<right.size(); i++)	if (right[i] == entity) {right[i] = right.back(); right.pop_back(); break;}
					for (u32 i=0; i<left.size(); i++)	if (left[i] == entity) {left[i] = left.back(); left.pop_back(); break;}
					command.position.mad	(front_pos, random_dir, random_r);
					break;
				case 1: // back
					entity = back.back	(); back.pop_back();
					for (u32 i=0; i<front.size(); i++)	if (front[i] == entity) {front[i] = front.back(); front.pop_back(); break;}
					for (u32 i=0; i<right.size(); i++)	if (right[i] == entity) {right[i] = right.back(); right.pop_back(); break;}
					for (u32 i=0; i<left.size(); i++)	if (left[i] == entity) {left[i] = left.back(); left.pop_back(); break;}
					command.position.mad	(back_pos, random_dir, random_r);
					break;
				case 2: // left
					entity = left.back	(); left.pop_back();
					for (u32 i=0; i<front.size(); i++)	if (front[i] == entity) {front[i] = front.back(); front.pop_back(); break;}
					for (u32 i=0; i<right.size(); i++)	if (right[i] == entity) {right[i] = right.back(); right.pop_back(); break;}
					for (u32 i=0; i<back.size(); i++)	if (back[i] == entity) {back[i] = back.back(); back.pop_back(); break;}
					command.position.mad	(left_pos, random_dir, random_r);
					break;
				case 3: // right
					entity = right.back	(); right.pop_back();
					for (u32 i=0; i<front.size(); i++)	if (front[i] == entity) {front[i] = front.back(); front.pop_back(); break;}
					for (u32 i=0; i<left.size(); i++)	if (left[i] == entity) {left[i] = left.back(); left.pop_back(); break;}
					for (u32 i=0; i<back.size(); i++)	if (back[i] == entity) {back[i] = back.back(); back.pop_back(); break;}
					command.position.mad	(right_pos, random_dir, random_r);
					break;
				default:
					NODEFAULT;
			}
			
			cur_type++;
			if (cur_type > 3) cur_type = 0;

			UpdateCommand(entity, command);
		}
	
	} else if (goal.type == MG_Rest) {
		// пересчитать положение в команде в соответствие с целью лидера
		for (ENTITY_VEC_IT it = members.begin(); it != members.end(); it++) {
			if ((*it) == leader) continue;

			SSquadCommand command;
			command.type		= SC_REST;
			command.position	= leader->Position();
			command.node		= leader->ai_location().level_vertex_id();
			command.entity		= 0;
			
			UpdateCommand		(*it, command);
		}
	}
}
Пример #6
0
/******************************************************************************
* 関数名:UpdateShadow
* 
* 引数  :
* 戻り値:
* 説明  :
******************************************************************************/
void UpdateShadow( void )
{
	MODEL *pModel = GetModel();
	BOX *pBox = GetBox();
	ENEMY *pEnemy = GetEnemy();
	ACORN *pAcorn = GetAcorn();
	GOAL *pGoal = GetGoal();

	for( int cntShadow = 0 ; cntShadow < SHADOW_MAX ; cntShadow++ )
	{
		VERTEX_3D *pVtx;
		g_Shadow[cntShadow].pVtxBuffShadow -> Lock( 0 , 0 , ( void** ) &pVtx , 0 );

		//影を誰が使っているか分岐させる/////////////////////////////////////////////////////////////
		if( g_Shadow[cntShadow].shadowUse == true )
		{
			switch( g_Shadow[cntShadow].shadowPattarn )
			{
			case SHADOW_PLAYER:
				{
					g_Shadow[cntShadow].posShadow.x = pModel -> posModel.x;
					g_Shadow[cntShadow].posShadow.z = pModel -> posModel.z;

					g_Shadow[cntShadow].shadowHeight = 30.0f;
					g_Shadow[cntShadow].shadowWidth = 30.0f;
					break;
				}
			case SHADOW_ENEMY:
				{
					
					g_Shadow[cntShadow].posShadow.x = pEnemy -> posEnemy.x;
					g_Shadow[cntShadow].posShadow.y = 0.5f;
					g_Shadow[cntShadow].posShadow.z = pEnemy -> posEnemy.z;

					g_Shadow[cntShadow].shadowHeight = 30.0f;
					g_Shadow[cntShadow].shadowWidth = 30.0f;
					
					if( pEnemy ->useEnemy == false )
					{
						g_Shadow[cntShadow].shadowUse = false;
					}

					pEnemy++;
					break;
				}

			case SHADOW_BOX:
				{
					
					g_Shadow[cntShadow].posShadow.x = pBox -> posBox.x;
					g_Shadow[cntShadow].posShadow.y = 0.5f;
					g_Shadow[cntShadow].posShadow.z = pBox -> posBox.z;

					g_Shadow[cntShadow].shadowHeight = 40.0f;
					g_Shadow[cntShadow].shadowWidth = 40.0f;

					if( pBox -> boxUse == false )
					{
						g_Shadow[cntShadow].shadowUse = false;

					}

					pBox += 6;
				break;
				}

			case SHADOW_ACORN:
				{
					
					g_Shadow[cntShadow].posShadow.x = pAcorn -> posAcorn.x;
					g_Shadow[cntShadow].posShadow.y = 0.5f;
					g_Shadow[cntShadow].posShadow.z = pAcorn -> posAcorn.z;

					g_Shadow[cntShadow].shadowHeight = 10.0f;
					g_Shadow[cntShadow].shadowWidth = 10.0f;

					if( pAcorn->acornUse == false)
					{
						g_Shadow[cntShadow].shadowUse = false;
					}
					pAcorn++;
					break;
				}
			case SHADOW_GOAL:
				{
					g_Shadow[cntShadow].posShadow.x = pGoal -> posGoal.x;
					g_Shadow[cntShadow].posShadow.y = 0.5f;
					g_Shadow[cntShadow].posShadow.z = pGoal -> posGoal.z;

					g_Shadow[cntShadow].shadowHeight = 10.0f;
					g_Shadow[cntShadow].shadowWidth = 10.0f;
					break;
				}
			}
		}

		//設定の更新///////////////////////////////////////////////////////////////////////
		//座標更新
		pVtx[0].pos     = D3DXVECTOR3( - g_Shadow[cntShadow].shadowWidth / 2 , 0.0f ,   g_Shadow[cntShadow].shadowHeight / 2 );
		pVtx[1].pos = D3DXVECTOR3(   g_Shadow[cntShadow].shadowWidth / 2 , 0.0f ,   g_Shadow[cntShadow].shadowHeight / 2 );
		pVtx[2].pos = D3DXVECTOR3( - g_Shadow[cntShadow].shadowWidth / 2 , 0.0f , - g_Shadow[cntShadow].shadowHeight / 2 );
		pVtx[3].pos = D3DXVECTOR3(   g_Shadow[cntShadow].shadowWidth / 2 , 0.0f , - g_Shadow[cntShadow].shadowHeight / 2 );

		//頂点カラー設定
		pVtx[0].col     = D3DXCOLOR( 1.0f , 1.0f , 1.0f, 0.5f );
		pVtx[1].col = D3DXCOLOR( 1.0f , 1.0f , 1.0f , 0.5f );
		pVtx[2].col = D3DXCOLOR( 1.0f , 1.0f , 1.0f , 0.5f );
		pVtx[3].col = D3DXCOLOR( 1.0f , 1.0f , 1.0f , 0.5f );

		g_Shadow[cntShadow].pVtxBuffShadow -> Unlock();
	}
	
}