/// <summary>Generates a ScriptCommand from the node</summary> /// <param name="n">Node</param> void CommandGenerator::VisitNode(CommandNode* n) { try { ParameterArray params; // Compile parameters for (auto& p : n->Parameters) { // Goto/Gosub: Change label number dataType from DT_STRING (ie. label name) into DT_INTEGER. if (p.Syntax.Type == ParameterType::LABEL_NUMBER && !n->CmdComment) p.Type = DataType::INTEGER; // parameter ctor resolves 'label' token type to DT_STRING // Compile p.Generate(Script, n->JumpAddress, n->CmdComment); } // Command: Provide compiled parameters in display order if (!n->Syntax.Is(CMD_EXPRESSION)) Script.Commands.AddOutput(ScriptCommand(n->LineText, n->Syntax, n->Parameters, n->CmdComment)); else { // Compile postfix parameters for (auto& p : n->Postfix) p.Generate(Script, n->JumpAddress, n->CmdComment); // Expression: Provide compiled parameters in infix & postfix order Script.Commands.AddOutput(ScriptCommand(n->LineText, n->Syntax, n->Parameters, n->Postfix, n->CmdComment)); } } catch (ExceptionBase& e) { Errors += n->MakeError(GuiString(L"Compile failed: ") + e.Message); } }
CVehicle::CVehicle(int iType, float fPosX, float fPosY, float fPosZ, float fRotation) { DWORD dwRetID=0; m_pVehicle = 0; m_dwGTAId = 0; if(!pGame->IsModelLoaded(iType)) { pGame->RequestModel(iType); while(!pGame->IsModelLoaded(iType)) Sleep(2); } ScriptCommand(&create_car,iType,fPosX,fPosY,fPosZ,&dwRetID); ScriptCommand(&set_car_z_angle,dwRetID,fRotation); m_pVehicle = GamePool_Vehicle_GetAt(dwRetID); m_dwGTAId = dwRetID; m_pVehicle->entity.mat.vPos.Z = fPosZ; m_pVehicle->dwDoorsLocked = 0; //m_pVehicle->entity.byteLockedFlags = 1; ScriptCommand(&set_car_immunities,m_dwGTAId,1,1,1,1,1); m_bIsInvulnerable = TRUE; m_bHasBeenDriven = FALSE; m_dwTimeSinceLastDriven = GetTickCount(); }
void CVehicle::SetInvulnerable(BOOL bInv) { if(!m_pVehicle) return; if(!GamePool_Vehicle_GetAt(m_dwGTAId)) return; if(bInv && m_bIsInvulnerable == FALSE) { ScriptCommand(&set_car_immunities,m_dwGTAId,1,1,1,1,1); m_bIsInvulnerable = TRUE; } else if(!bInv && m_bIsInvulnerable == TRUE) { ScriptCommand(&set_car_immunities,m_dwGTAId,0,0,0,0,0); m_bIsInvulnerable = FALSE; } }
int CPlayerObjects::HasObjectBeenDamaged( ) { int iDamage; ScriptCommand(&get_object_state, m_dwGTAId, iDamage); return iDamage; }
void cmdSavePos(PCHAR szCmd) { CPlayerPed *pPlayer = pGame->FindPlayerPed(); FILE *fileOut; DWORD dwVehicleID; float fZAngle; if(!tSettings.bDebug) return; fileOut = fopen("savedpositions.txt","a"); if(!fileOut) { pChatWindow->AddDebugMessage("I can't open the savepositions.txt file for append."); return; } // incar savepos if(pPlayer->IsInVehicle()) { VEHICLE_TYPE *pVehicle = pPlayer->GetGtaVehicle(); dwVehicleID = GamePool_Vehicle_GetIndex(pVehicle); ScriptCommand(&get_car_z_angle,dwVehicleID,&fZAngle); fprintf(fileOut,"Vehicle = %u %.4f %.4f %.4f %.4f %u %u\n", pVehicle->entity.nModelIndex,pVehicle->entity.mat.vPos.X,pVehicle->entity.mat.vPos.Y,pVehicle->entity.mat.vPos.Z, fZAngle,pVehicle->byteColor1,pVehicle->byteColor2); fclose(fileOut); return; } // onfoot savepos PED_TYPE *pActor = pPlayer->GetGtaActor(); ScriptCommand(&get_player_z_angle,0,&fZAngle); fprintf(fileOut,"Class = 0 0 %.4f %.4f %.4f %.4f 0 0 0 0 0 0\n", pActor->entity.mat.vPos.X,pActor->entity.mat.vPos.Y,pActor->entity.mat.vPos.Z,fZAngle); fclose(fileOut); }
void CVehicle::VehicleJump(float ForwardDistance, float UpDistance) { VECTOR vecMoveSpeed; GetMoveSpeedVector(&vecMoveSpeed); float rotZ = 0; ScriptCommand(&get_car_z_angle,m_dwGTAId,&rotZ); rotZ += 90; float X = (float)cos(rotZ/180*PI)*ForwardDistance; float Y = (float)sin(rotZ/180*PI)*ForwardDistance; vecMoveSpeed.X = vecMoveSpeed.X + X; vecMoveSpeed.Y = vecMoveSpeed.Y + Y; vecMoveSpeed.Z = vecMoveSpeed.Z + UpDistance; SetMoveSpeedVector(vecMoveSpeed); }
void CCamera::Fade(int iInOut) { ScriptCommand(&fade,500,iInOut); }
void CCamera::Restore() { ScriptCommand(&restore_camera_jumpcut); }
void CCamera::LookAtPoint(float fX, float fY, float fZ, int iType) { ScriptCommand(&point_camera,fX,fY,fZ,iType); }
void CCamera::SetPosition(float fX, float fY, float fZ, float fRotationX, float fRotationY, float fRotationZ) { ScriptCommand(&set_camera_position,fX,fY,fZ,fRotationX,fRotationY,fRotationZ); }
void CCamera::SetBehindPlayer() { ScriptCommand(&set_camera_behind_player); ScriptCommand(&restore_camera_jumpcut); //ScriptCommand(&restore_camera); }
void CPlayerObjects::SetObjectTargetable( ) { ScriptCommand(&set_target_state, m_dwGTAId); }
void CPlayerObjects::Delete() { ScriptCommand(&destroy_object, m_dwGTAId); }
void CPlayerObjects::Create(int iModel, float fX, float fY, float fZ) { ScriptCommand(&create_object, iModel, fX, fY, fZ, m_dwGTAId); }
HRESULT CWMPEventDispatch::Invoke( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult, EXCEPINFO FAR* pExcepInfo, unsigned int FAR* puArgErr ) { if (!pDispParams) return E_POINTER; if (pDispParams->cNamedArgs != 0) return DISP_E_NONAMEDARGS; HRESULT hr = DISP_E_MEMBERNOTFOUND; switch (dispIdMember) { case DISPID_WMPCOREEVENT_OPENSTATECHANGE: OpenStateChange(pDispParams->rgvarg[0].lVal /* NewState */ ); break; case DISPID_WMPCOREEVENT_PLAYSTATECHANGE: PlayStateChange(pDispParams->rgvarg[0].lVal /* NewState */); break; case DISPID_WMPCOREEVENT_AUDIOLANGUAGECHANGE: AudioLanguageChange(pDispParams->rgvarg[0].lVal /* LangID */); break; case DISPID_WMPCOREEVENT_STATUSCHANGE: StatusChange(); break; case DISPID_WMPCOREEVENT_SCRIPTCOMMAND: ScriptCommand(pDispParams->rgvarg[1].bstrVal /* scType */, pDispParams->rgvarg[0].bstrVal /* Param */ ); break; case DISPID_WMPCOREEVENT_NEWSTREAM: NewStream(); break; case DISPID_WMPCOREEVENT_DISCONNECT: Disconnect(pDispParams->rgvarg[0].lVal /* Result */ ); break; case DISPID_WMPCOREEVENT_BUFFERING: Buffering(pDispParams->rgvarg[0].boolVal /* Start */); break; case DISPID_WMPCOREEVENT_ERROR: Error(); break; case DISPID_WMPCOREEVENT_WARNING: Warning(pDispParams->rgvarg[1].lVal /* WarningType */, pDispParams->rgvarg[0].lVal /* Param */, pDispParams->rgvarg[2].bstrVal /* Description */); break; case DISPID_WMPCOREEVENT_ENDOFSTREAM: EndOfStream(pDispParams->rgvarg[0].lVal /* Result */ ); break; case DISPID_WMPCOREEVENT_POSITIONCHANGE: PositionChange(pDispParams->rgvarg[1].dblVal /* oldPosition */, pDispParams->rgvarg[0].dblVal /* newPosition */); break; case DISPID_WMPCOREEVENT_MARKERHIT: MarkerHit(pDispParams->rgvarg[0].lVal /* MarkerNum */); break; case DISPID_WMPCOREEVENT_DURATIONUNITCHANGE: DurationUnitChange(pDispParams->rgvarg[0].lVal /* NewDurationUnit */); break; case DISPID_WMPCOREEVENT_CDROMMEDIACHANGE: CdromMediaChange(pDispParams->rgvarg[0].lVal /* CdromNum */); break; case DISPID_WMPCOREEVENT_PLAYLISTCHANGE: PlaylistChange(pDispParams->rgvarg[1].pdispVal /* Playlist */, (WMPPlaylistChangeEventType) pDispParams->rgvarg[0].lVal /* change */); break; case DISPID_WMPCOREEVENT_CURRENTPLAYLISTCHANGE: CurrentPlaylistChange((WMPPlaylistChangeEventType) pDispParams->rgvarg[0].lVal /* change */); break; case DISPID_WMPCOREEVENT_CURRENTPLAYLISTITEMAVAILABLE: CurrentPlaylistItemAvailable(pDispParams->rgvarg[0].bstrVal /* bstrItemName */); break; case DISPID_WMPCOREEVENT_MEDIACHANGE: MediaChange(pDispParams->rgvarg[0].pdispVal /* Item */); break; case DISPID_WMPCOREEVENT_CURRENTMEDIAITEMAVAILABLE: CurrentMediaItemAvailable(pDispParams->rgvarg[0].bstrVal /* bstrItemName */); break; case DISPID_WMPCOREEVENT_CURRENTITEMCHANGE: CurrentItemChange(pDispParams->rgvarg[0].pdispVal /* pdispMedia */); break; case DISPID_WMPCOREEVENT_MEDIACOLLECTIONCHANGE: MediaCollectionChange(); break; case DISPID_WMPCOREEVENT_MEDIACOLLECTIONATTRIBUTESTRINGADDED: MediaCollectionAttributeStringAdded(pDispParams->rgvarg[1].bstrVal /* bstrAttribName */, pDispParams->rgvarg[0].bstrVal /* bstrAttribVal */ ); break; case DISPID_WMPCOREEVENT_MEDIACOLLECTIONATTRIBUTESTRINGREMOVED: MediaCollectionAttributeStringRemoved(pDispParams->rgvarg[1].bstrVal /* bstrAttribName */, pDispParams->rgvarg[0].bstrVal /* bstrAttribVal */ ); break; case DISPID_WMPCOREEVENT_MEDIACOLLECTIONATTRIBUTESTRINGCHANGED: MediaCollectionAttributeStringChanged(pDispParams->rgvarg[2].bstrVal /* bstrAttribName */, pDispParams->rgvarg[1].bstrVal /* bstrOldAttribVal */, pDispParams->rgvarg[0].bstrVal /* bstrNewAttribVal */); break; case DISPID_WMPCOREEVENT_PLAYLISTCOLLECTIONCHANGE: PlaylistCollectionChange(); break; case DISPID_WMPCOREEVENT_PLAYLISTCOLLECTIONPLAYLISTADDED: PlaylistCollectionPlaylistAdded(pDispParams->rgvarg[0].bstrVal /* bstrPlaylistName */ ); break; case DISPID_WMPCOREEVENT_PLAYLISTCOLLECTIONPLAYLISTREMOVED: PlaylistCollectionPlaylistRemoved(pDispParams->rgvarg[0].bstrVal /* bstrPlaylistName */ ); break; case DISPID_WMPCOREEVENT_PLAYLISTCOLLECTIONPLAYLISTSETASDELETED: PlaylistCollectionPlaylistSetAsDeleted(pDispParams->rgvarg[1].bstrVal /* bstrPlaylistName */, pDispParams->rgvarg[0].boolVal /* varfIsDeleted */); break; case DISPID_WMPCOREEVENT_MODECHANGE: ModeChange(pDispParams->rgvarg[1].bstrVal /* ModeName */, pDispParams->rgvarg[0].boolVal /* NewValue */); break; case DISPID_WMPCOREEVENT_MEDIAERROR: MediaError(pDispParams->rgvarg[0].pdispVal /* pMediaObject */); break; case DISPID_WMPCOREEVENT_OPENPLAYLISTSWITCH: OpenPlaylistSwitch(pDispParams->rgvarg[0].pdispVal /* pItem */); break; case DISPID_WMPCOREEVENT_DOMAINCHANGE: DomainChange(pDispParams->rgvarg[0].bstrVal /* strDomain */); break; case DISPID_WMPOCXEVENT_SWITCHEDTOPLAYERAPPLICATION: SwitchedToPlayerApplication(); break; case DISPID_WMPOCXEVENT_SWITCHEDTOCONTROL: SwitchedToControl(); break; case DISPID_WMPOCXEVENT_PLAYERDOCKEDSTATECHANGE: PlayerDockedStateChange(); break; case DISPID_WMPOCXEVENT_PLAYERRECONNECT: PlayerReconnect(); break; case DISPID_WMPOCXEVENT_CLICK: Click(pDispParams->rgvarg[3].iVal /* nButton */, pDispParams->rgvarg[2].iVal /* nShiftState */, pDispParams->rgvarg[1].lVal /* fX */, pDispParams->rgvarg[0].lVal /* fY */); break; case DISPID_WMPOCXEVENT_DOUBLECLICK: DoubleClick(pDispParams->rgvarg[3].iVal /* nButton */, pDispParams->rgvarg[2].iVal /* nShiftState */, pDispParams->rgvarg[1].lVal /* fX */, pDispParams->rgvarg[0].lVal /* fY */); break; case DISPID_WMPOCXEVENT_KEYDOWN: KeyDown(pDispParams->rgvarg[1].iVal /* nKeyCode */, pDispParams->rgvarg[0].iVal /* nShiftState */); break; case DISPID_WMPOCXEVENT_KEYPRESS: KeyPress(pDispParams->rgvarg[0].iVal /* nKeyAscii */); break; case DISPID_WMPOCXEVENT_KEYUP: KeyUp(pDispParams->rgvarg[1].iVal /* nKeyCode */, pDispParams->rgvarg[0].iVal /* nShiftState */); break; case DISPID_WMPOCXEVENT_MOUSEDOWN: MouseDown(pDispParams->rgvarg[3].iVal /* nButton */, pDispParams->rgvarg[2].iVal /* nShiftState */, pDispParams->rgvarg[1].lVal /* fX */, pDispParams->rgvarg[0].lVal /* fY */); break; case DISPID_WMPOCXEVENT_MOUSEMOVE: MouseMove(pDispParams->rgvarg[3].iVal /* nButton */, pDispParams->rgvarg[2].iVal /* nShiftState */, pDispParams->rgvarg[1].lVal /* fX */, pDispParams->rgvarg[0].lVal /* fY */); break; case DISPID_WMPOCXEVENT_MOUSEUP: MouseUp(pDispParams->rgvarg[3].iVal /* nButton */, pDispParams->rgvarg[2].iVal /* nShiftState */, pDispParams->rgvarg[1].lVal /* fX */, pDispParams->rgvarg[0].lVal /* fY */); break; } return( hr ); }
CVehicle::~CVehicle() { ScriptCommand(&destroy_car,m_dwGTAId); }