When a quest must be tested, it is often necessary to preset a situation. Some examples:
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():
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 }