Ejemplo n.º 1
0
u32 SetYAMLSequenceFromMapping(char ***dest, char *key, ctr_yaml_context *ctx, bool StoreKey)
{
	if(*dest){
		fprintf(stderr,"[RSF ERROR] %s already set\n",key);
		ctx->error = YAML_MEM_ERROR;
		return 0;
	}

	u32 ActualCount = 0;
	u32 SlotCount = 0;
	char **tmp = *dest;
	if(!CheckMappingEvent(ctx)) return 0;
	SlotCount = 10;
	tmp = malloc((SlotCount+1)*sizeof(char*));
	if(!tmp){
		ctx->error = YAML_MEM_ERROR;
		return 0;
	}	
	memset(tmp,0,(SlotCount+1)*sizeof(char*));
	GetEvent(ctx);
	if(ctx->error || ctx->done) return 0;
	if(!EventIsScalar(ctx)){
		fprintf(stderr,"[RSF ERROR] '%s' requires a value\n",key);
		ctx->error = YAML_BAD_FORMATTING;
		return 0;
	}
	
	
	if(!GetYamlStringSize(ctx)) return 0;
	u32 InitLevel = ctx->Level;
	while(ctx->Level == InitLevel){
		if(ctx->error || ctx->done) return 0;
		if(ctx->IsKey == StoreKey){
			tmp[ActualCount] = malloc(GetYamlStringSize(ctx)+1);
			memset(tmp[ActualCount],0,GetYamlStringSize(ctx)+1);
			memcpy(tmp[ActualCount],GetYamlString(ctx),GetYamlStringSize(ctx));
			ActualCount++;
			if(ActualCount >= SlotCount){ // if Exceeding Ptr capacity, expand buffer
				SlotCount = SlotCount*2;
				char **tmp1 = malloc((SlotCount+1)*sizeof(char*)); // allocate new buffer
				if(!tmp1){
					ctx->error = YAML_MEM_ERROR;
					return 0;
				}	
				memset(tmp1,0,(SlotCount+1)*sizeof(char*));
				for(u32 i = 0; i < ActualCount; i++) tmp1[i] = tmp[i]; // Transfer ptrs
				free(tmp); // free original buffer
				tmp = tmp1; // transfer main ptr
			}
		}
		FinishEvent(ctx);
		GetEvent(ctx);
	}
	FinishEvent(ctx);
	*dest = tmp; // Give main ptr to location
	return ActualCount++; // return number of strings
}
Ejemplo n.º 2
0
bool CheckMappingEvent(ctr_yaml_context *ctx)
{
	GetEvent(ctx);
	if(!EventIsMappingStart(ctx)){
		FinishEvent(ctx);
		//fprintf(stderr,"[-] Bad formatting in Spec file (Expected Mapping)\n");
		//ctx->error = YAML_BAD_FORMATTING;
		return false;
	}
	FinishEvent(ctx);
	return true;
}
    void JustDied(Unit* pKiller)
    {
        if (Player* pPlayer = m_creature->GetMap()->GetPlayer(m_playerGuid))
            pPlayer->SendQuestFailed(QUEST_PYREWOOD_AMBUSH);

        FinishEvent();
    }
Ejemplo n.º 4
0
    void JustDied(Unit* pKiller)
    {
        if (Player* pPlayer = ((Player*)Unit::GetUnit((*m_creature), m_uiPlayerGUID)))
            pPlayer->SendQuestFailed(QUEST_PYREWOOD_AMBUSH);

        FinishEvent();
    }
Ejemplo n.º 5
0
// this method is used to check which event to activate etc.
void GameEventMgr::CheckForEvents()
{
	GameEventMap::iterator itr = m_GameEventMap.begin();
	uint32 current_time = mktime(&g_localTime);

	for( itr; itr != m_GameEventMap.end(); itr++ )
	{
		EventInfo * ev = itr->second;

		//   current time > start time        current time < end time            not active yet
		if( (ev->start_time < current_time) && (ev->end_time > current_time) && (ev->active == false) )
		{
			StartEvent(itr->first);
		}
		//            is active            end time < current time
		else if( (ev->active == true) && (ev->end_time < current_time) )
		{
			FinishEvent(itr->first);
		}
		// let's call this dirty bug fix, in very small percent of all performed actions it may happen
		else if( (ev->active == false) && ev->end_time < current_time )
		{
			// re-calculate start time :<
			// REMEMBER that in this case we must use UNIXTIME, because we use UNIXTIME relative to your time zone only for checks
			uint32 tdiff = (current_time - ev->end_time) / ev->occurence;
			ev->start_time += (tdiff + 1) * ev->occurence;

			// set the end_time again
			ev->end_time = ev->start_time + ev->length;
			sGameEventMgr.SaveEvent( itr->first );
		}

		// otherwise do nothing
	}
}
Ejemplo n.º 6
0
        void JustDied(Unit* /*pKiller*/)
        {
#if defined (CLASSIC) || defined (TBC)
            if (Player* pPlayer = (m_creature->GetMap()->GetPlayer(m_uiPlayerGUID)))
#endif
#if defined (WOTLK) || defined (CATA)
            if (Player* pPlayer = (m_creature->GetMap()->GetPlayer(ObjectGuid(m_uiPlayerGUID))))
#endif
            {
                pPlayer->SendQuestFailed(QUEST_GERENZOS_ORDERS);
            }

            FinishEvent();
        }
Ejemplo n.º 7
0
void CScript::Think()
{
    double flCurrentTime = GameServer()->GetGameTime() - m_flStartTime;

    for (size_t i = 0; i < m_aEvents.size(); i++ )
    {
        CScriptEvent* pEvent = &m_aEvents[i];

        if (flCurrentTime >= pEvent->m_flStartTime && !pEvent->m_bStarted)
            PlayEvent(i);
        else if (pEvent->m_flEndTime && pEvent->m_bStarted && !pEvent->m_bExecuted && flCurrentTime >= pEvent->m_flEndTime)
            FinishEvent(i);
        else if (pEvent->m_bStarted && pEvent->m_flEndTime && !pEvent->m_bExecuted)
            ThinkEvent(i);
    }
}
    void SummonedCreatureJustDied(Creature* pKilled)
    {
        --m_uiSummonCount;

        if (!m_uiSummonCount)
        {
            DoCastSpellIfCan(m_creature, SPELL_DRINK_POTION);

            // final wave
            if (m_uiWaveCount == 4)
            {
                DoScriptText(SAY_COMPLETED, m_creature);

                if (Player* pPlayer = m_creature->GetMap()->GetPlayer(m_playerGuid))
                    pPlayer->GroupEventHappens(QUEST_PYREWOOD_AMBUSH, m_creature);

                FinishEvent();
            }
        }
    }
Ejemplo n.º 9
0
int ParseSpecFile(rsf_settings *set, char *path, dname_struct *dname)
{
	ctr_yaml_context *ctx = malloc(sizeof(ctr_yaml_context));
	InitYamlContext(ctx);

	/* Set Specfile Type */
	
	/* Create the Parser object. */
	yaml_parser_initialize(&ctx->parser);

	/* Set a file input. */
	FILE *input = fopen(path,"rb");
	yaml_parser_set_input_file(&ctx->parser, input);
	
	
	ctx->dname = dname;
	ctx->IsSequence = false;
	ctx->IsKey = true;
	ctx->prev_event = 0;
	ctx->Level = 0;
	
	
	/* Read the event sequence. */
	while (!ctx->done) {
		/* Get the next event. */
		GetEvent(ctx);
		if(ctx->error) goto error;
		
		/* Proccess Event */
		
		
		if(EventIsScalar(ctx)){
			EvaluateRSF(set,ctx);
			if(ctx->error) goto error;
			break;
		}
		/*
		if((ctx->event.type == YAML_SEQUENCE_START_EVENT|| ctx->event.type == YAML_MAPPING_START_EVENT) && ctx->prev_event == YAML_SCALAR_EVENT) printf(":\n");
		if(ctx->event.type == YAML_SCALAR_EVENT){
			if(ctx->IsSequence){
				printf(" - %s\n",ctx->event.data.scalar.value);
			}
			else{
				if(!ctx->IsKey) printf(": %s\n",ctx->event.data.scalar.value);
				else printf("%s",ctx->event.data.scalar.value);
			}			
		}
		*/
		
		/* Finish Event */
		FinishEvent(ctx);
		if(ctx->error) goto error;
	}

	/* Destroy the Parser object. */
	yaml_parser_delete(&ctx->parser);
	fclose(input);
	return 0;

	/* On error. */
	error:
	fprintf(stderr,"[RSF ERROR] Error Proccessing RSF file\n");
	
	/* Destroy the Parser object. */
	yaml_parser_delete(&ctx->parser);
	fclose(input);
	return ctx->error;
}
Ejemplo n.º 10
0
        void UpdateAI(const uint32 uiDiff)
        {

            if (m_uiEventTimer < uiDiff)  //Event should be completed after 7 minutes even if waves are alive
            {
#if defined (CLASSIC) || defined (TBC)
                if (Player* pPlayer = (m_creature->GetMap()->GetPlayer(m_uiPlayerGUID)))
#endif
#if defined (WOTLK) || defined (CATA)
                if (Player* pPlayer = (m_creature->GetMap()->GetPlayer(ObjectGuid(m_uiPlayerGUID))))
#endif
                {
                    pPlayer->GroupEventHappens(QUEST_GERENZOS_ORDERS, m_creature);
                }

                FinishEvent();
            }


            if (m_bEventStarted && !m_uiSummonCount)
            {

                if (m_uiWaveTimer < uiDiff && m_uiWaveCount <= 2)
                {
                    switch (m_uiWaveCount)
                    {

                    case 0:
                        m_creature->SummonCreature(NPC_WINDSHEAR_VERMIN, SpawnPointsst[2].fX, SpawnPointsst[2].fY, SpawnPointsst[2].fZ, SpawnPointsst[2].fO, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                        m_creature->SummonCreature(NPC_WINDSHEAR_TUNNEL_RAT, SpawnPointsst[0].fX, SpawnPointsst[0].fY, SpawnPointsst[0].fZ, SpawnPointsst[0].fO, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                        m_creature->SummonCreature(NPC_WINDSHEAR_VERMIN, SpawnPointsst[1].fX, SpawnPointsst[1].fY, SpawnPointsst[1].fZ, SpawnPointsst[1].fO, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                        m_uiWaveTimer = 45000;
                        m_uiMoveCount = 0;
                        break;
                    case 1:
                        m_creature->SummonCreature(NPC_WINDSHEAR_GEOMANCER, SpawnPointsst[2].fX, SpawnPointsst[2].fY, SpawnPointsst[2].fZ, SpawnPointsst[2].fO, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                        m_creature->SummonCreature(NPC_WINDSHEAR_STONECUTTER, SpawnPointsst[0].fX, SpawnPointsst[0].fY, SpawnPointsst[0].fZ, SpawnPointsst[0].fO, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                        m_creature->SummonCreature(NPC_WINDSHEAR_GEOMANCER, SpawnPointsst[1].fX, SpawnPointsst[1].fY, SpawnPointsst[1].fZ, SpawnPointsst[1].fO, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                        m_creature->SummonCreature(NPC_WINDSHEAR_STONECUTTER, SpawnPointsst[3].fX, SpawnPointsst[3].fY, SpawnPointsst[3].fZ, SpawnPointsst[3].fO, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                        m_uiWaveTimer = 45000;
                        m_uiMoveCount = 0;
                        break;
                    case 2:
                        m_creature->SummonCreature(NPC_WINDSHEAR_TUNNEL_RAT, SpawnPointsst[2].fX, SpawnPointsst[2].fY, SpawnPointsst[2].fZ, SpawnPointsst[2].fO, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                        m_creature->SummonCreature(NPC_WINDSHEAR_OVERLORD, SpawnPointsst[0].fX, SpawnPointsst[0].fY, SpawnPointsst[0].fZ, SpawnPointsst[0].fO, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                        m_creature->SummonCreature(NPC_WINDSHEAR_TUNNEL_RAT, SpawnPointsst[1].fX, SpawnPointsst[1].fY, SpawnPointsst[1].fZ, SpawnPointsst[1].fO, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                        m_creature->SummonCreature(NPC_WINDSHEAR_TUNNEL_RAT, SpawnPointsst[3].fX, SpawnPointsst[3].fY, SpawnPointsst[3].fZ, SpawnPointsst[3].fO, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                        m_uiMoveCount = 0;
                        break;
                    }

                    ++m_uiWaveCount;
                }
                else
                {
                    m_uiWaveTimer -= uiDiff;
                }
                m_uiEventTimer -= uiDiff;
            }

            if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            {
                return;
            }

            DoMeleeAttackIfReady();
        }