예제 #1
0
void CMapzoneEdit::SetZoneProps(CBaseEntity *pEnt)
{
    CTriggerTimerStart *pStart = dynamic_cast<CTriggerTimerStart *>(pEnt);
    if (pStart)
    {
        if (mom_zone_start_maxleavespeed.GetFloat() > 0.0)
        {
            pStart->SetMaxLeaveSpeed(mom_zone_start_maxleavespeed.GetFloat());
            pStart->SetIsLimitingSpeed(true);
        }
        else
        {
            pStart->SetIsLimitingSpeed(false);
        }

        pStart->SetIsLimitingSpeedOnlyXY(mom_zone_start_limitspdmethod.GetBool());

        return;
    }

    CTriggerStage *pStage = dynamic_cast<CTriggerStage *>(pEnt);
    if (pStage)
    {
        if (mom_zone_stage_num.GetInt() > 0)
        {
            pStage->SetStageNumber(mom_zone_stage_num.GetInt());
        }
        else
        {
            int higheststage = 1;
            CTriggerStage *pTempStage;

            CBaseEntity *pTemp = gEntList.FindEntityByClassname(NULL, "trigger_momentum_timer_stage");
            while (pTemp)
            {
                pTempStage = static_cast<CTriggerStage *>(pTemp);

                if (pTempStage && pTempStage->GetStageNumber() > higheststage)
                {
                    higheststage = pTempStage->GetStageNumber();
                }

                pTemp = gEntList.FindEntityByClassname(pTemp, "trigger_momentum_timer_stage");
            }

            pStage->SetStageNumber(higheststage + 1);
        }

        return;
    }


    /*CTriggerCheckpoint *pCP = dynamic_cast<CTriggerCheckpoint *>( pEnt );
    if ( pCP )
    {
    if ( mom_zone_cpnum.GetInt() > 0 )
    {
    pCP->SetCheckpointNumber( mom_zone_cpnum.GetInt() );
    }
    else
    {
    int highestcp = 0;
    CTriggerCheckpoint *pTempCP;

    CBaseEntity *pTemp = gEntList.FindEntityByClassname( NULL, "trigger_momentum_timer_checkpoint" );
    while ( pTemp )
    {
    pTempCP = dynamic_cast<CTriggerCheckpoint *>( pTemp );

    if ( pTempCP && pTempCP->GetCheckpointNumber() > highestcp )
    {
    highestcp = pTempCP->GetCheckpointNumber();
    }

    pTemp = gEntList.FindEntityByClassname( pTemp, "trigger_momentum_timer_checkpoint" );
    }

    pStage->SetStageNumber( highestcp + 1 );
    }

    return;
    }*/
}
예제 #2
0
static void saveZonFile(const char* szMapName)
{
    KeyValues* zoneKV = new KeyValues(szMapName);
    CBaseEntity* pEnt = gEntList.FindEntityByClassname(NULL, "trigger_momentum_*");
    while (pEnt)
    {
        KeyValues* subKey = NULL;
        if (pEnt->ClassMatches("trigger_momentum_timer_start"))
        {
            CTriggerTimerStart* pTrigger = dynamic_cast<CTriggerTimerStart*>(pEnt);
            subKey = new KeyValues("start");
            if (pTrigger)
            {
                subKey->SetFloat("leavespeed", pTrigger->GetMaxLeaveSpeed());
                subKey->SetBool("limitingspeed", pTrigger->IsLimitingSpeed());
            }
        }
        else if (pEnt->ClassMatches("trigger_momentum_timer_stop"))
        {
            subKey = new KeyValues("end");
        }
        else if (pEnt->ClassMatches("trigger_momentum_timer_checkpoint"))
        {
            CTriggerCheckpoint* pTrigger = dynamic_cast<CTriggerCheckpoint*>(pEnt);
            if (pTrigger)
            {
                subKey = new KeyValues("checkpoint");
                subKey->SetInt("number", pTrigger->GetCheckpointNumber());
            }
        }
        else if (pEnt->ClassMatches("trigger_momentum_onehop"))
        {
            CTriggerOnehop* pTrigger = dynamic_cast<CTriggerOnehop*>(pEnt);
            if (pTrigger)
            {
                subKey = new KeyValues("onehop");
                //subKey->SetInt("destination", pTrigger->GetDestinationIndex());
                subKey->SetBool("stop", pTrigger->ShouldStopPlayer());
                subKey->SetBool("resetang", pTrigger->ShouldResetAngles());
                subKey->SetFloat("hold", pTrigger->GetHoldTeleportTime());
                subKey->SetString("destinationname", pTrigger->m_target.ToCStr());
            }
        }
        else if (pEnt->ClassMatches("trigger_momentum_resetonehop"))
        {
            subKey = new KeyValues("resetonehop");
        }
        else if (pEnt->ClassMatches("trigger_momentum_teleport_checkpoint"))
        {

            CTriggerTeleportCheckpoint* pTrigger = dynamic_cast<CTriggerTeleportCheckpoint*>(pEnt);
            if (pTrigger)
            {
                subKey = new KeyValues("checkpoint_teleport");
                //subKey->SetInt("destination", pTrigger->GetDestinationCheckpointNumber());
                subKey->SetBool("stop", pTrigger->ShouldStopPlayer());
                subKey->SetBool("resetang", pTrigger->ShouldResetAngles());
                subKey->SetString("destinationname", pTrigger->m_target.ToCStr());
            }
        }
        else if (pEnt->ClassMatches("trigger_momentum_multihop"))
        {
            CTriggerMultihop* pTrigger = dynamic_cast<CTriggerMultihop*>(pEnt);
            if (pTrigger)
            {
                subKey = new KeyValues("multihop");
                //subKey->SetInt("destination", pTrigger->GetDestinationIndex());
                subKey->SetBool("stop", pTrigger->ShouldStopPlayer());
                subKey->SetFloat("hold", pTrigger->GetHoldTeleportTime());
                subKey->SetBool("resetang", pTrigger->ShouldResetAngles());
                subKey->SetString("destinationname", pTrigger->m_target.ToCStr());
            }
        }
        else if (pEnt->ClassMatches("trigger_momentum_timer_stage"))
        {
            CTriggerStage *pTrigger = dynamic_cast<CTriggerStage*>(pEnt);
            if (pTrigger)
            {
                subKey = new KeyValues("stage");
                subKey->SetInt("number", pTrigger->GetStageNumber());
            }
        }
        if (subKey)
        {
            subKey->SetFloat("xPos", pEnt->GetAbsOrigin().x);
            subKey->SetFloat("yPos", pEnt->GetAbsOrigin().y);
            subKey->SetFloat("zPos", pEnt->GetAbsOrigin().z);
            subKey->SetFloat("xRot", pEnt->GetAbsAngles().x);
            subKey->SetFloat("yRot", pEnt->GetAbsAngles().y);
            subKey->SetFloat("zRot", pEnt->GetAbsAngles().z);
            subKey->SetFloat("xScaleMins", pEnt->WorldAlignMins().x);
            subKey->SetFloat("yScaleMins", pEnt->WorldAlignMins().y);
            subKey->SetFloat("zScaleMins", pEnt->WorldAlignMins().z);
            subKey->SetFloat("xScaleMaxs", pEnt->WorldAlignMaxs().x);
            subKey->SetFloat("yScaleMaxs", pEnt->WorldAlignMaxs().y);
            subKey->SetFloat("zScaleMaxs", pEnt->WorldAlignMaxs().z);
            zoneKV->AddSubKey(subKey);
        }
        pEnt = gEntList.FindEntityByClassname(pEnt, "trigger_momentum_*");
    }
    if (zoneKV->GetFirstSubKey())//not empty 
    {
        char zoneFilePath[MAX_PATH];
        Q_strcpy(zoneFilePath, "maps/");
        Q_strcat(zoneFilePath, szMapName, MAX_PATH);
        Q_strncat(zoneFilePath, ".zon", MAX_PATH);
        zoneKV->SaveToFile(filesystem, zoneFilePath, "MOD");
        zoneKV->deleteThis();
    }
}