void ControlItemSliderbar::mouseClickEvent(GLint x, GLint y, GLint state, bool stillOverControlItemSliderbar){ if(state == 1){ // check if the click is on the slider if((sliderXPos<x && x<sliderXPos+sliderWidth) && (sliderYPos-sliderHeight<y && y<sliderYPos)){ this->isSliderClicked = true; } // check if the click is either left or right side from the slider else if((barXPos<x && x<sliderXPos) && (sliderYPos-sliderHeight-5.5<y && y<sliderYPos+5.5)){ playSFX(SMALL_CLICK); sliderXPos -= interval; this->menuState--; if(this->menuState<0) //wrap around check this->menuState+=numberOfOptions; this->setOptionText(menuState); } else if((sliderXPos+sliderWidth<x && x<barXPos+barWidth) && (sliderYPos-sliderHeight-5.5<y && y<sliderYPos+5.5)){ playSFX(SMALL_CLICK); sliderXPos += interval; this->menuState++; if(this->menuState==this->numberOfOptions) //wrap around check this->menuState-=numberOfOptions; this->setOptionText(menuState); } }else{ this->isSliderClicked = false; } }
void updateDoor(door_struct* d) { if(!d || !d->used)return; if(d->active) { if(d->modelInstance.currentAnim==0) { changeAnimation(&d->modelInstance, 2, false); changeAnimation(&d->modelInstance, 1, true); playSFX(doorOpenSFX); }else if(d->modelInstance.oldAnim==1 && d->modelInstance.currentAnim==2) { if(d->rectangle[0]){d->rectangle[0]->collides=false;toggleAAR(d->rectangle[0]->AARid);} if(d->rectangle[1]){d->rectangle[1]->collides=false;toggleAAR(d->rectangle[1]->AARid);} } }else { if(d->modelInstance.currentAnim==2) { changeAnimation(&d->modelInstance, 0, false); changeAnimation(&d->modelInstance, 3, true); playSFX(doorCloseSFX); if(d->rectangle[0]){d->rectangle[0]->collides=true;toggleAAR(d->rectangle[0]->AARid);} if(d->rectangle[1]){d->rectangle[1]->collides=true;toggleAAR(d->rectangle[1]->AARid);} } } updateAnimation(&d->modelInstance); d->active=false; }
void updatePlayer(player_s* p, room_s* r) { if(!p)return; md2InstanceUpdate(&p->gunInstance); md2InstanceUpdate(&p->ratmanInstance); if(!p->flying) p->object.speed = vaddf(p->object.speed, vmulf(normGravityVector, 0.04f)); vect3Df_s prevPosition = p->object.position; collideObjectRoom(&p->object, r); if(p->inPortal && !p->oldInPortal)playSFX(portalEnterSFX[rand()%2]); else if(!p->inPortal && p->oldInPortal)playSFX(portalExitSFX[rand()%2]); int i; for(i=0; i < NUM_PORTALS; i++) { if(portals[i].target)checkPortalPlayerWarp(p, &portals[i]); } updateCamera(&p->camera); float alignment = -vdotf(vect3Df(p->camera.orientation[0][0],p->camera.orientation[0][1],p->camera.orientation[0][2]), normGravityVector); // printf("alignment : %f \n",alignment); { if(alignment>0.001) { if(alignment>0.125)rotateMatrixZ((float*)p->camera.orientation, -0.5f*0.15f, true); else if(alignment>0.0625)rotateMatrixZ((float*)p->camera.orientation, -0.25f*0.15f, true); else if(alignment>0.03125)rotateMatrixZ((float*)p->camera.orientation, -0.125f*0.07f, true); }else if(alignment<-0.001) { if(alignment<-0.125)rotateMatrixZ((float*)p->camera.orientation, 0.5f*0.15f, true); else if(alignment<-0.0625)rotateMatrixZ((float*)p->camera.orientation, 0.25f*0.15f, true); else if(alignment<-0.03125)rotateMatrixZ((float*)p->camera.orientation, 0.125f*0.07f, true); } } // fixMatrix(c->orientation); //compensate floating point errors p->camera.position = vaddf(p->object.position, vect3Df(0.0f, cos(p->walkCnt1)*0.14f, 0.0f)); if(vmagf(p->object.speed) < 0.03f || !p->object.contact)md2InstanceChangeAnimation(&p->ratmanInstance, 0, false); if(p->flying) p->object.speed = vect3Df(0,0,0); //TEMP p->tempAngle = vmulf(p->tempAngle, 0.65f); }
void LuaProxy::playSFXSDL(const std::string& filename) { #ifndef NO_SDL std::string full_paths = Audio::getSfxPath(filename); PGE_Sounds::SND_PlaySnd(full_paths.c_str()); #else playSFX(filename); #endif }
void Item::playSoundByState(ItemSound soundState) { switch (soundState) { case APPEAR: playSFX(this->soundData.getAppearSoundStr().c_str()); break; case DISAPPEAR: playSFX(this->soundData.getDisappearSoundStr().c_str()); break; case DESTROY: playSFX(this->soundData.getDestroySoundStr().c_str()); break; case CONSUME: playSFX(this->soundData.getConsumeSoundStr().c_str()); break; default: break; } }
void controlShootYellow(player_struct* p, bool down, bool held) { if(!p || !down)return; if(!p->modelInstance.oneshot) { playSFX(gunSFX1); shootPlayerGun(p,true,255); changeAnimation(&p->modelInstance,1,true); } }
void controlUse(player_struct* p, bool down, bool held) { if(!p || !down)return; if(!p->modelInstance.oneshot) { playSFX(gunSFX2); shootPlayerGun(p,false,1|2); changeAnimation(&p->modelInstance,1,true); } }
void controlShootAll(player_struct* p, bool down, bool held) { if(!p || !down)return; if(!p->modelInstance.oneshot) { playSFX(currentPortalColor?gunSFX1:gunSFX2); shootPlayerGun(p,currentPortalColor,255); changeAnimation(&p->modelInstance,1,true); } }
void ControlItemSliderbar::updateMouse(int x, int y){ if(isSliderClicked){ // check if the mouse pointer is either left or right side from the slider if(barXPos<x && x<sliderXPos-interval/2){ sliderXPos -= interval; this->menuState--; if(this->menuState<0) //wrap around check this->menuState+=numberOfOptions; this->setOptionText(menuState); playSFX(SMALL_CLICK); } else if(sliderXPos+interval/2 + sliderWidth<x && x<barXPos+barWidth){ sliderXPos += interval; this->menuState++; if(this->menuState==this->numberOfOptions) //wrap around check this->menuState-=numberOfOptions; this->setOptionText(menuState); playSFX(SMALL_CLICK); } } }
void AbstractSkill::playSoundByState(SkillState soundState, SkillSoundData data) { switch (soundState) { case EXCUTE: { playSFX(data.getExcuteSoundStr().c_str()); } break; case STOP: { playSFX(data.getStopSoundStr().c_str()); } break; case HIT: { playSFX(data.getHitSoundStr().c_str()); } break; default: break; } }
void initEmancipator(emancipator_s* e, md2_instance_t* mi, vect3Df_s pos, float* m) { if(!e)return; e->position=pos; e->modelInstance=*mi; if(m)memcpy(e->transformationMatrix,m,sizeof(float)*9); else{ m=e->transformationMatrix; m[0]=m[4]=m[8]=1.0f; m[1]=m[2]=m[3]=0; m[5]=m[6]=m[7]=0; } e->counter=0; e->angle=0; e->velocity=vect3Df(randFloat(-1.0f, 1.0f),1.0f,randFloat(-1.0f, 1.0f)); e->velocity=vdivf(vnormf(e->velocity),16); e->axis=vect3Df(randFloat(-1.0f, 1.0f),randFloat(-1.0f, 1.0f),randFloat(-1.0f, 1.0f)); e->axis=vnormf(e->axis); playSFX(emancipationSFX); e->used=true; }
void updateTurret(turret_struct* t) { if(!t || !t->used)return; if(!t->OBB || !t->OBB->used){t->OBB=NULL;t->used=false;return;} t->counter+=2;t->counter%=63; //TEMP if(t->dead)t->counter=31; editPalette((u16*)t->OBB->modelInstance.palette,0,RGB15(abs(31-t->counter),0,0)); //TEMP int32* m=t->OBB->transformationMatrix; room_struct* r=getPlayer()->currentRoom; if(!r)return; int32 angle, d; bool b=pointInTurretSight(t, getPlayer()->object->position, &angle, &d); if(b) { vect3D u=vectDifference(getPlayer()->object->position,t->laserOrigin); int32 d=magnitude(u); u=divideVect(u,d); if(collideLineMap(&gameRoom, NULL, t->laserOrigin, u, d, NULL, NULL))b=false; } switch(t->state) { case TURRET_CLOSED: changeAnimation(&t->OBB->modelInstance, 0, false); t->drawShot[0]=t->drawShot[1]=0; if(b && !t->dead){t->state=TURRET_OPENING; playSFX(turretDeploySFX);} break; case TURRET_OPENING: if(t->OBB->modelInstance.currentAnim==2) { t->state=TURRET_OPEN; }else if(t->OBB->modelInstance.currentAnim!=1) { changeAnimation(&t->OBB->modelInstance, 2, false); changeAnimation(&t->OBB->modelInstance, 1, true); } t->drawShot[0]=t->drawShot[1]=0; break; case TURRET_OPEN: { if(angle>mulf32(sinLerp(TURRET_SIGHTANGLE/3),d))changeAnimation(&t->OBB->modelInstance, 4, false); else if(angle<-mulf32(sinLerp(TURRET_SIGHTANGLE/3),d))changeAnimation(&t->OBB->modelInstance, 5, false); else changeAnimation(&t->OBB->modelInstance, 2, false); int i; for(i=0;i<2;i++) { if(!t->drawShot[i] && !(rand()%3)) { t->drawShot[i]=rand()%8; t->shotAngle[i]=rand(); shootPlayer(NULL, normalize(vectDifference(t->laserDestination,t->laserOrigin)), 6); playSFX(turretFireSFX); } if(t->drawShot[i])t->drawShot[i]--; } if(!b || t->dead){t->state=TURRET_CLOSING; playSFX(turretRetractSFX);} } break; case TURRET_CLOSING: if(t->OBB->modelInstance.currentAnim==0) { t->state=TURRET_CLOSED; }else if(t->OBB->modelInstance.currentAnim!=3) { changeAnimation(&t->OBB->modelInstance, 0, false); changeAnimation(&t->OBB->modelInstance, 3, true); } t->drawShot[0]=t->drawShot[1]=0; break; } if(!t->dead) { t->laserOrigin=addVect(vectDivInt(t->OBB->position,4),evalVectMatrix33(m,laserOrigin)); t->laserDestination=addVect(t->laserOrigin,vect(m[2],m[5],m[8])); if(b)t->laserDestination=getPlayer()->object->position; vect3D dir=normalize(vectDifference(t->laserDestination,t->laserOrigin)); t->laserThroughPortal=false; laserProgression(r, &t->laserOrigin, &t->laserDestination, dir); int32 x, y, z; vect3D v; portal_struct* portal=NULL; if(isPointInPortal(&portal1, t->laserDestination, &v, &x, &y, &z))portal=&portal1; if(abs(z)>=32)portal=NULL; if(!portal) { if(isPointInPortal(&portal2, t->laserDestination, &v, &x, &y, &z))portal=&portal2; if(abs(z)>=32)portal=NULL; } if(portal) { t->laserDestination=addVect(t->laserDestination,vectMult(dir,TILESIZE)); t->laserThroughPortal=true; dir=warpVector(portal,dir); t->laserOrigin2=addVect(portal->targetPortal->position, warpVector(portal, vectDifference(t->laserDestination, portal->position))); t->laserDestination2=addVect(t->laserOrigin2,dir); laserProgression(r, &t->laserOrigin2, &t->laserDestination2, dir); t->laserOrigin2=addVect(t->laserOrigin2,vectMult(dir,-TILESIZE)); } if(m[4]<sinLerp(8192/2))t->dead=true; } updateAnimation(&t->OBB->modelInstance); }
/** * A particular event has been triggered. * Process all of this event's components. * * @param eid The triggered event id */ void MapIso::executeEvent(int eid) { Event_Component *ec; for (int i=0; i<events[eid].comp_num; i++) { ec = &events[eid].components[i]; if (ec->type == "requires_status") { if (!camp->checkStatus(ec->s)) return; } else if (ec->type == "requires_not") { if (camp->checkStatus(ec->s)) return; } else if (ec->type == "requires_item") { if (!camp->checkItem(ec->x)) return; } else if (ec->type == "set_status") { camp->setStatus(ec->s); } else if (ec->type == "unset_status") { camp->unsetStatus(ec->s); } if (ec->type == "intermap") { teleportation = true; teleport_mapname = ec->s; teleport_destination.x = ec->x * UNITS_PER_TILE + UNITS_PER_TILE/2; teleport_destination.y = ec->y * UNITS_PER_TILE + UNITS_PER_TILE/2; } else if (ec->type == "mapmod") { if (ec->s == "collision") { collision[ec->x][ec->y] = ec->z; collider.colmap[ec->x][ec->y] = ec->z; } else if (ec->s == "object") { object[ec->x][ec->y] = ec->z; } else if (ec->s == "background") { background[ec->x][ec->y] = ec->z; } } else if (ec->type == "soundfx") { playSFX(ec->s); } else if (ec->type == "loot") { loot.push(*ec); } else if (ec->type == "msg") { log_msg = ec->s; } else if (ec->type == "shakycam") { shaky_cam_ticks = ec->x; } else if (ec->type == "remove_item") { camp->removeItem(ec->x); } else if (ec->type == "reward_xp") { camp->rewardXP(ec->x); } } if (events[eid].type == "run_once") { removeEvent(eid); } }
void ItemExtraBattery::playUseSFX(){ playSFX(ITEM_USE3); }
TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// bool AdEntity::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY) TOKEN_TABLE(SPRITE) TOKEN_TABLE(X) TOKEN_TABLE(Y) TOKEN_TABLE(TEMPLATE) TOKEN_TABLE(NAME) TOKEN_TABLE(SCALABLE) TOKEN_TABLE(REGISTRABLE) TOKEN_TABLE(INTERACTIVE) TOKEN_TABLE(SHADOWABLE) TOKEN_TABLE(COLORABLE) TOKEN_TABLE(ACTIVE) TOKEN_TABLE(EVENTS) TOKEN_TABLE(FONT) TOKEN_TABLE(TALK_SPECIAL) TOKEN_TABLE(TALK) TOKEN_TABLE(CURSOR) TOKEN_TABLE(REGION) TOKEN_TABLE(BLOCKED_REGION) TOKEN_TABLE(EDITOR_SELECTED) TOKEN_TABLE(SCRIPT) TOKEN_TABLE(SOUND_START_TIME) TOKEN_TABLE(SOUND_VOLUME) TOKEN_TABLE(SOUND_PANNING) TOKEN_TABLE(SOUND) TOKEN_TABLE(SUBTYPE) TOKEN_TABLE(CAPTION) TOKEN_TABLE(PROPERTY) TOKEN_TABLE(WAYPOINTS) TOKEN_TABLE(IGNORE_ITEMS) TOKEN_TABLE(ROTABLE) TOKEN_TABLE(ROTATABLE) TOKEN_TABLE(ALPHA_COLOR) TOKEN_TABLE(SCALE) TOKEN_TABLE(RELATIVE_SCALE) TOKEN_TABLE(ALPHA) TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE(ITEM) TOKEN_TABLE(WALK_TO_X) TOKEN_TABLE(WALK_TO_Y) TOKEN_TABLE(WALK_TO_DIR) TOKEN_TABLE(SAVE_STATE) TOKEN_TABLE_END byte *params; int cmd; BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { _gameRef->LOG(0, "'ENTITY' keyword expected."); return STATUS_FAILED; } buffer = params; } AdGame *adGame = (AdGame *)_gameRef; BaseSprite *spr = nullptr; int ar = 0, ag = 0, ab = 0, alpha = 0; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (DID_FAIL(loadFile((char *)params))) { cmd = PARSERR_GENERIC; } break; case TOKEN_X: parser.scanStr((char *)params, "%d", &_posX); break; case TOKEN_Y: parser.scanStr((char *)params, "%d", &_posY); break; case TOKEN_SPRITE: { delete _sprite; _sprite = nullptr; spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile((char *)params))) { cmd = PARSERR_GENERIC; } else { _sprite = spr; } } break; case TOKEN_TALK: { spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) { cmd = PARSERR_GENERIC; } else { _talkSprites.add(spr); } } break; case TOKEN_TALK_SPECIAL: { spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) { cmd = PARSERR_GENERIC; } else { _talkSpritesEx.add(spr); } } break; case TOKEN_NAME: setName((char *)params); break; case TOKEN_ITEM: setItem((char *)params); break; case TOKEN_CAPTION: setCaption((char *)params); break; case TOKEN_FONT: setFont((char *)params); break; case TOKEN_SCALABLE: parser.scanStr((char *)params, "%b", &_zoomable); break; case TOKEN_SCALE: { int s; parser.scanStr((char *)params, "%d", &s); _scale = (float)s; } break; case TOKEN_RELATIVE_SCALE: { int s; parser.scanStr((char *)params, "%d", &s); _relativeScale = (float)s; } break; case TOKEN_ROTABLE: case TOKEN_ROTATABLE: parser.scanStr((char *)params, "%b", &_rotatable); break; case TOKEN_REGISTRABLE: case TOKEN_INTERACTIVE: parser.scanStr((char *)params, "%b", &_registrable); break; case TOKEN_SHADOWABLE: case TOKEN_COLORABLE: parser.scanStr((char *)params, "%b", &_shadowable); break; case TOKEN_ACTIVE: parser.scanStr((char *)params, "%b", &_active); break; case TOKEN_CURSOR: delete _cursor; _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = nullptr; cmd = PARSERR_GENERIC; } break; case TOKEN_EDITOR_SELECTED: parser.scanStr((char *)params, "%b", &_editorSelected); break; case TOKEN_REGION: { if (_region) { _gameRef->unregisterObject(_region); } _region = nullptr; BaseRegion *rgn = new BaseRegion(_gameRef); if (!rgn || DID_FAIL(rgn->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; } else { _region = rgn; _gameRef->registerObject(_region); } } break; case TOKEN_BLOCKED_REGION: { delete _blockRegion; _blockRegion = nullptr; delete _currentBlockRegion; _currentBlockRegion = nullptr; BaseRegion *rgn = new BaseRegion(_gameRef); BaseRegion *crgn = new BaseRegion(_gameRef); if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { delete _blockRegion; _blockRegion = nullptr; delete _currentBlockRegion; _currentBlockRegion = nullptr; cmd = PARSERR_GENERIC; } else { _blockRegion = rgn; _currentBlockRegion = crgn; _currentBlockRegion->mimic(_blockRegion); } } break; case TOKEN_WAYPOINTS: { delete _wptGroup; _wptGroup = nullptr; delete _currentWptGroup; _currentWptGroup = nullptr; AdWaypointGroup *wpt = new AdWaypointGroup(_gameRef); AdWaypointGroup *cwpt = new AdWaypointGroup(_gameRef); if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { delete _wptGroup; _wptGroup = nullptr; delete _currentWptGroup; _currentWptGroup = nullptr; cmd = PARSERR_GENERIC; } else { _wptGroup = wpt; _currentWptGroup = cwpt; _currentWptGroup->mimic(_wptGroup); } } break; case TOKEN_SCRIPT: addScript((char *)params); break; case TOKEN_SUBTYPE: { if (scumm_stricmp((char *)params, "sound") == 0) { delete _sprite; _sprite = nullptr; if (_gameRef->_editorMode) { spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile("entity_sound.sprite"))) { cmd = PARSERR_GENERIC; } else { _sprite = spr; } } if (_gameRef->_editorMode) { _editorOnly = true; } _zoomable = false; _rotatable = false; _registrable = _gameRef->_editorMode; _shadowable = false; _subtype = ENTITY_SOUND; } } break; case TOKEN_SOUND: playSFX((char *)params, false, false); break; case TOKEN_SOUND_START_TIME: parser.scanStr((char *)params, "%d", &_sFXStart); break; case TOKEN_SOUND_VOLUME: parser.scanStr((char *)params, "%d", &_sFXVolume); break; case TOKEN_SOUND_PANNING: parser.scanStr((char *)params, "%b", &_autoSoundPanning); break; case TOKEN_SAVE_STATE: parser.scanStr((char *)params, "%b", &_saveState); break; case TOKEN_PROPERTY: parseProperty(params, false); break; case TOKEN_IGNORE_ITEMS: parser.scanStr((char *)params, "%b", &_ignoreItems); break; case TOKEN_ALPHA_COLOR: parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); break; case TOKEN_ALPHA: parser.scanStr((char *)params, "%d", &alpha); break; case TOKEN_EDITOR_PROPERTY: parseEditorProperty(params, false); break; case TOKEN_WALK_TO_X: parser.scanStr((char *)params, "%d", &_walkToX); break; case TOKEN_WALK_TO_Y: parser.scanStr((char *)params, "%d", &_walkToY); break; case TOKEN_WALK_TO_DIR: { int i; parser.scanStr((char *)params, "%d", &i); if (i < 0) { i = 0; } if (i >= NUM_DIRECTIONS) { i = DI_NONE; } _walkToDir = (TDirection)i; } break; } } if (cmd == PARSERR_TOKENNOTFOUND) { _gameRef->LOG(0, "Syntax error in ENTITY definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { _gameRef->LOG(0, "Error loading ENTITY definition"); if (spr) { delete spr; } return STATUS_FAILED; } if (_region && _sprite) { _gameRef->LOG(0, "Warning: Entity '%s' has both sprite and region.", getName()); } updatePosition(); if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { ar = ag = ab = 255; } _alphaColor = BYTETORGBA(ar, ag, ab, alpha); _state = STATE_READY; if (_item && ((AdGame *)_gameRef)->isItemTaken(_item)) { _active = false; } return STATUS_OK; }
void Operation::play_sfx(ScenarioRunner* sr) { playSFX(sr); sr->getDWORD(); sr->getDWORD(); }
/** * A particular event has been triggered. * Process all of this event's components. * * @param eid The triggered event id */ void MapIso::executeEvent(int eid) { Event_Component *ec; for (int i=0; i<events[eid].comp_num; i++) { ec = &events[eid].components[i]; if (ec->type == "requires_status") { if (!camp->checkStatus(ec->s)) return; } else if (ec->type == "requires_not") { if (camp->checkStatus(ec->s)) return; } else if (ec->type == "requires_item") { if (!camp->checkItem(ec->x)) return; } else if (ec->type == "set_status") { camp->setStatus(ec->s); } else if (ec->type == "unset_status") { camp->unsetStatus(ec->s); } if (ec->type == "intermap") { teleportation = true; teleport_mapname = ec->s; teleport_destination.x = ec->x * UNITS_PER_TILE + UNITS_PER_TILE/2; teleport_destination.y = ec->y * UNITS_PER_TILE + UNITS_PER_TILE/2; } else if (ec->type == "mapmod") { if (ec->s == "collision") { collision[ec->x][ec->y] = ec->z; collider.colmap[ec->x][ec->y] = ec->z; } else if (ec->s == "object") { object[ec->x][ec->y] = ec->z; } else if (ec->s == "background") { background[ec->x][ec->y] = ec->z; } } else if (ec->type == "soundfx") { playSFX(ec->s); } else if (ec->type == "loot") { loot.push(*ec); } else if (ec->type == "msg") { log_msg = ec->s; } else if (ec->type == "shakycam") { shaky_cam_ticks = ec->x; } else if (ec->type == "remove_item") { camp->removeItem(ec->x); } else if (ec->type == "reward_xp") { camp->rewardXP(ec->x); } else if (ec->type == "power") { int power_index = ec->x; StatBlock *dummy = new StatBlock(); dummy->accuracy = 1000; //always hits its target dummy->pos.x = events[eid].power_src.x * UNITS_PER_TILE; dummy->pos.y = events[eid].power_src.y * UNITS_PER_TILE; dummy->dmg_melee_min = dummy->dmg_ranged_min = dummy->dmg_ment_min = events[eid].damagemin; dummy->dmg_melee_max = dummy->dmg_ranged_max = dummy->dmg_ment_max = events[eid].damagemax; Point target; if (events[eid].targetHero){ target.x = cam.x; target.y = cam.y; } else { target.x = events[eid].power_dest.x * UNITS_PER_TILE; target.y = events[eid].power_dest.y * UNITS_PER_TILE; } if (events[eid].cooldown_ticks > 0) events[eid].cooldown_ticks--; else { events[eid].cooldown_ticks = events[eid].power_cooldown; powers->activate(power_index, dummy, target); } } } if (events[eid].type == "run_once") { removeEvent(eid); } }
////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SkipTo ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SkipTo") == 0) { stack->correctParams(2); _posX = stack->pop()->getInt(); _posY = stack->pop()->getInt(); afterMove(); stack->pushNULL(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Caption") == 0) { stack->correctParams(1); stack->pushString(getCaption(stack->pop()->getInt())); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // SetCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetCursor") == 0) { stack->correctParams(1); if (DID_SUCCEED(setCursor(stack->pop()->getString()))) { stack->pushBool(true); } else { stack->pushBool(false); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // RemoveCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveCursor") == 0) { stack->correctParams(0); if (!_sharedCursors) { delete _cursor; _cursor = nullptr; } else { _cursor = nullptr; } stack->pushNULL(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetCursor") == 0) { stack->correctParams(0); if (!_cursor || !_cursor->getFilename()) { stack->pushNULL(); } else { stack->pushString(_cursor->getFilename()); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetCursorObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetCursorObject") == 0) { stack->correctParams(0); if (!_cursor) { stack->pushNULL(); } else { stack->pushNative(_cursor, true); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // HasCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HasCursor") == 0) { stack->correctParams(0); if (_cursor) { stack->pushBool(true); } else { stack->pushBool(false); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // SetCaption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetCaption") == 0) { stack->correctParams(2); setCaption(stack->pop()->getString(), stack->pop()->getInt()); stack->pushNULL(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // LoadSound ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadSound") == 0) { stack->correctParams(1); const char *filename = stack->pop()->getString(); if (DID_SUCCEED(playSFX(filename, false, false))) { stack->pushBool(true); } else { stack->pushBool(false); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // PlaySound ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlaySound") == 0) { stack->correctParams(3); const char *filename; bool looping; uint32 loopStart; ScValue *val1 = stack->pop(); ScValue *val2 = stack->pop(); ScValue *val3 = stack->pop(); if (val1->_type == VAL_BOOL) { filename = nullptr; looping = val1->getBool(); loopStart = val2->getInt(); } else { if (val1->isNULL()) { filename = nullptr; } else { filename = val1->getString(); } looping = val2->isNULL() ? false : val2->getBool(); loopStart = val3->getInt(); } if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) { stack->pushBool(false); } else { stack->pushBool(true); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // PlaySoundEvent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlaySoundEvent") == 0) { stack->correctParams(2); const char *filename; const char *eventName; ScValue *val1 = stack->pop(); ScValue *val2 = stack->pop(); if (val2->isNULL()) { filename = nullptr; eventName = val1->getString(); } else { filename = val1->getString(); eventName = val2->getString(); } if (DID_FAIL(playSFX(filename, false, true, eventName))) { stack->pushBool(false); } else { stack->pushBool(true); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // StopSound ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StopSound") == 0) { stack->correctParams(0); if (DID_FAIL(stopSFX())) { stack->pushBool(false); } else { stack->pushBool(true); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // PauseSound ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PauseSound") == 0) { stack->correctParams(0); if (DID_FAIL(pauseSFX())) { stack->pushBool(false); } else { stack->pushBool(true); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // ResumeSound ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ResumeSound") == 0) { stack->correctParams(0); if (DID_FAIL(resumeSFX())) { stack->pushBool(false); } else { stack->pushBool(true); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // IsSoundPlaying ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsSoundPlaying") == 0) { stack->correctParams(0); if (_sFX && _sFX->isPlaying()) { stack->pushBool(true); } else { stack->pushBool(false); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // SetSoundPosition ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetSoundPosition") == 0) { stack->correctParams(1); uint32 time = stack->pop()->getInt(); if (DID_FAIL(setSFXTime(time))) { stack->pushBool(false); } else { stack->pushBool(true); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetSoundPosition ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSoundPosition") == 0) { stack->correctParams(0); if (!_sFX) { stack->pushInt(0); } else { stack->pushInt(_sFX->getPositionTime()); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // SetSoundVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetSoundVolume") == 0) { stack->correctParams(1); int volume = stack->pop()->getInt(); if (DID_FAIL(setSFXVolume(volume))) { stack->pushBool(false); } else { stack->pushBool(true); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetSoundVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSoundVolume") == 0) { stack->correctParams(0); if (!_sFX) { stack->pushInt(_sFXVolume); } else { stack->pushInt(_sFX->getVolumePercent()); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // SoundFXNone ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SoundFXNone") == 0) { stack->correctParams(0); _sFXType = SFX_NONE; _sFXParam1 = 0; _sFXParam2 = 0; _sFXParam3 = 0; _sFXParam4 = 0; stack->pushNULL(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // SoundFXEcho ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SoundFXEcho") == 0) { stack->correctParams(4); _sFXType = SFX_ECHO; _sFXParam1 = (float)stack->pop()->getFloat(0); // Wet/Dry Mix [%] (0-100) _sFXParam2 = (float)stack->pop()->getFloat(0); // Feedback [%] (0-100) _sFXParam3 = (float)stack->pop()->getFloat(333.0f); // Left Delay [ms] (1-2000) _sFXParam4 = (float)stack->pop()->getFloat(333.0f); // Right Delay [ms] (1-2000) stack->pushNULL(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // SoundFXReverb ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SoundFXReverb") == 0) { stack->correctParams(4); _sFXType = SFX_REVERB; _sFXParam1 = (float)stack->pop()->getFloat(0); // In Gain [dB] (-96 - 0) _sFXParam2 = (float)stack->pop()->getFloat(0); // Reverb Mix [dB] (-96 - 0) _sFXParam3 = (float)stack->pop()->getFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) _sFXParam4 = (float)stack->pop()->getFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) stack->pushNULL(); return STATUS_OK; } else { return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); } }
//Audio void Operation::play_uncategorized(ScenarioRunner* sr) { playSFX(sr); sr->getDWORD(); sr->getDWORD(); }