Aller au contenu

Photo

How to involve 2 teams in 1 condition?


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
Ldfxf

Ldfxf
  • Members
  • 5 messages
I put 2 teams to an area, and I want to play a cutscene after the 2 teams be killed.
Here is the script, it can't work.

#include "events_h"
#include "plt_quest"
#include "wrappers_h"
#include "global_objects_h"
#include "utility_h"
void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);
    switch(nEventType)
    {
         case EVENT_TYPE_TEAM_DESTROYED:
         {
            if(GetEventInteger(ev,0) == 1 && GetEventInteger(ev,0) == 2)
            {
                   WR_SetPlotFlag(PLT_QUEST, QUEST_COMPLETE, TRUE);
                   resource rCutscene = R"quest_complete.cut";
                CS_LoadCutscene(rCutscene);
            PlayCutscene();
              }
              break;
         }
    HandleEvent(ev, RESOURCE_SCRIPT_AREA_CORE);
    }
}

// I also tried this:

if(GetEventInteger(ev,0) == 1
{
if(GetEventInteger(ev,0) == 2
{


NOthing happend.
How can I put two teams in one condition?
Thanks!

Modifié par Ldfxf, 17 août 2010 - 01:18 .


#2
TimelordDC

TimelordDC
  • Members
  • 923 messages

Ldfxf wrote...

I put 2 teams to an area, and I want to play a cutscene after the 2 teams be killed.


Easiest way is to use a separate plot.
PLOT NAME: check_teams_killed
MAIN FLAG 1 : Team_1_killed
MAIN FLAG 2 : Team_2_killed

Your area script would look like:
#include "events_h"
#include "plt_check_teams_killed"
#include "wrappers_h"
#include "global_objects_h"
#include "utility_h"
void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);
    switch(nEventType)
    {
        case EVENT_TYPE_TEAM_DESTROYED:
        {
            if(GetEventInteger(ev,0) == 1)
            {
                WR_SetPlotFlag(PLT_CHECK_TEAMS_KILLED, TEAM_1_KILLED, TRUE);
            }
            if (GetEventInteger(ev,0) == 2)
            {
                WR_SetPlotFlag(PLT_CHECK_TEAMS_KILLED, TEAM_2_KILLED, TRUE);
            }
            break;
         }
    HandleEvent(ev, RESOURCE_SCRIPT_AREA_CORE);
    }
}

Your plot script will handle the cutscene.

Insert headers and other stuff
if(nType == EVENT_TYPE_SET_PLOT) // actions -> normal flags only
{
    switch(nFlag)
    {
        case TEAM_1_KILLED:
        {
            if (WR_GetPlotFlag(PLT_CHECK_TEAMS_KILLED, TEAM_2_KILLED)
            {
                resource rCutscene = R"quest_complete.cut";
                CS_LoadCutscene(rCutscene);
            }
            break;
        }

        case TEAM_2_KILLED:
            if (WR_GetPlotFlag(PLT_CHECK_TEAMS_KILLED, TEAM_1_KILLED)
            {
                resource rCutscene = R"quest_complete.cut";
                CS_LoadCutscene(rCutscene);
            }
            break;
        }
    }
}
insert rest of standard plot script code to complete


#3
FergusM

FergusM
  • Members
  • 460 messages
It's worth pointing out that the reason why your script doesn't work is that you're asking for one event to have two values.



if(GetEventInteger(ev,0) == 1 && GetEventInteger(ev,0) == 2)



GetEventInteger(ev,0) is either going to be 1, or 2, or something else. It's never going to be both at the same time.



How the system works is that when things happen, the game fires events, which then run the code under that case. But none of it sticks around unless you store that information in something like a plot.



In this case, when a team is destroyed, the event gets fired with their team attached. The script asks 'is the team id both 1 and 2?' Then says 'no, it's just 1.' Then the second event fires and asks the same question, decides 'no, it's just 2.'

#4
aWT

aWT
  • Members
  • 9 messages

FergusM wrote...

It's worth pointing out that the reason why your script doesn't work is that you're asking for one event to have two values.

if(GetEventInteger(ev,0) == 1 && GetEventInteger(ev,0) == 2)

GetEventInteger(ev,0) is either going to be 1, or 2, or something else. It's never going to be both at the same time.


Exactly, in this case all you have to do is replace the and operator (&&) by an or (||), resulting:
if(GetEventInteger(ev,0) == 1 || GetEventInteger(ev,0) == 2)

Idk what you are trying to achieve, but depending on IF the following code will be executed not to both but to each, you can add a case to select the resulting id.
switch(GetEventInteger(ev,0))
{
    case 1:
    {
        // Resulting event int equals 1
       break;
    }
    case 2:
    {
        // Resulting event int equals 2
        break;
    }
    default:
    {
        // Neither 1 or 2
    }
}