Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   Compound Members   Related Pages  

Advanced - Quest Debugging

Testing, Force() and test variables

When a quest must be tested, it is often necessary to preset a situation. Some examples:

  • The player's ship may have to be in a specific sector
  • He/she must own a certain amount of money
  • The player must be of a certain strength
  • Or have a hight or low notoriety towards a race
  • Have a number of wingmen
  • Must be in the vicinity of a pirate ship
  • THQ wants to get external gametesters to be able to test single quests ASAP. To make this a bit easier a function is added called Force().

    This function will be called if somebody wants to test a mission (by selecting it in the quest menu and pressing E).

    Force() should modify / cheat the player in every necessary way so that he can test the quest (even quick warp him to another sector). Everything so that the quest will be offered soon.
    So, following things must be done by the Force():

  • Make sure it sets everything so that the quest's Evaluate() function will return a TRUE.when called by the Questmaster program
  • Make sure the quest's priority will be the highest of all
  • Make sure the Questmaster program starts looking for a quest
  • The Force() function can be placed anywhere in the quest class; between Set() and Evaluate() would be a logical place.

    An example Force():

        void Force()
        {
            //make quest priority so high that it will be chosen as first
            qu_Priority = 300;
    
            // quickwarp player ship to Argon sector
            OBJ_CLIENT.SetWarpSector(2,3);
            OBJ_CLIENT.QuickWarp();
    
            //Give player some weapons, speed and shield 
            Q_PLAYERSHIP.AddRocket(SG_WR_ROCKET_E, 4); //hornets
            Q_PLAYERSHIP.SetCurrentRocketType(SG_WR_ROCKET_E);
              
            Q_PLAYERSHIP.AddShield(
                SA_GetShipTypeMaxShieldType(SA_GetSubType(Q_PLAYERSHIP.GetObjectId())),
                SA_GetShipTypeMaxNumShields(SA_GetSubType(Q_PLAYERSHIP.GetObjectId())));     
            SA_SetShield(Q_PLAYERSHIP.GetObjectId(), SA_GetMaxShield(Q_PLAYERSHIP.GetObjectId()));
    
            Q_PLAYERSHIP.InstallLaser(SG_WR_PL_GAMMA, 0); //left gun
            Q_PLAYERSHIP.InstallLaser(SG_WR_PL_GAMMA, 1); //right gun
    
            Q_PLAYERSHIP.AddWare(SGTYPE_W_TECH, SG_WR_TECH213, 10); //speed
            SA_SetExtraSpeed(Q_PLAYERSHIP.GetObjectId(), 10); //speed
    
            Q_PLAYERSHIP.AddWare(SGTYPE_W_TECH, SG_WR_TECH246, 10); //rudder
            SA_SetExtraRotSpeed(Q_PLAYERSHIP.GetObjectId(), 10); //rudder
    
            SE_DMprintf(0, "QUESTOBJ(%d).Force() upgraded player ship\n", qu_ID);
            
    
            //force the Questmaster program to start looking for new quests
            OBJ_QUESTMASTER.FindQuest();
        }
    
    

    For some quests, it must be possible to enter variables that are used by the Force() function. In these cases you want yourself or the tester to be able to influence the start position.

    For this, a special menu program can be used, the Variables Menu.

    For the developers to use this menu they will need to create two(2) functions in their OBJ_QUEST

    1. GetVariableItems(array vm_Vars)

    This routine is required to supply the strings and values for the menu in a 2 dimensional array. The 2 dimension array is allocated/deallocated by the menu and should not be done in this routine. Any values passed in the array are removed by the menu.

    The first dimension is a pointer to the lines array and should not be modified by this routine.
    The Second dimension requires information supplied by the developer and holds the contents of the line. It has 5 parts:

    0 - String to be displayed
    1 - Initial Value
    2 - Minimum value (can be negative)
    3 - Maximum value
    4 - Step increments

    Example:

    
        int GetVariableItems(array vm_Vars)
        {
            int cnt = 0;
            //               String          Value         Min    Max   Step
            //              --------------   ------------  -----  ----  ----
            vm_Vars[cnt++]={"qq_Variable1",  qq_Variable1, 0,     5000, 10};
            vm_Vars[cnt++]={"Variable 2",    qq_Variable2, -5000, 5000, 10};
            vm_Vars[cnt++]={"call fuctionX", 0,            0,    1,    1};
            return cnt; // Number of lines used
        }
    

    2. SetVariableItem(int arraypos,int NewValue) This routine is called by the menu to inform the quest that a value has changed. It can be used to do anything the developer wants, however, this routine should at least modify the variable to the new value passed(although this is not essential).

    Example:

        void SetVariableItem(int arraypos,int NewValue)
        {
            switch(arraypos){
              case 0:  qq_Variable1=NewValue; break;
              case 1:  qq_Variable2=NewValue; break;
              case 2:  if(NewValue==1)this.functionX(); break;
            }
        }
        
        functionX()
        { //just an example function
        }
    

    The way to test

  • If variables must be set, select the variables menu from the main menu.
  • Use the '-' and '=' keys in the VarMenu to change the quest pointer in the title bar.
    This will jump to quests that have the GetVariableItems() defined in the current compile.
  • Select the variable to change by using up/down buttons and change the variable's value with left/right buttons.
  • Press Escape to go back to the main menu, and select the quest menu.
  • Use up/down buttons to select the quest to be Force tested, and press the E button briefly (it takes a second to see the priority jump up). The quest will start now.


    Generated on Mon Aug 26 18:26:35 2002 for X² KC by doxygen1.2.17