From 38df0b7e820f76cbccf01a3a2c648e01db9b2f10 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Wed, 29 Nov 2017 07:28:58 +0000 Subject: [PATCH] CON: Add "actorsound" command. Patch from Striker. git-svn-id: https://svn.eduke32.com/eduke32@6504 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/gamedef.cpp | 2 ++ source/duke3d/src/gamedef.h | 1 + source/duke3d/src/gameexec.cpp | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index 9bd3419d3..baf4c06c3 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -118,6 +118,7 @@ static tokenmap_t const vm_keywords[] = { "activatebysector", CON_ACTIVATEBYSECTOR }, { "activatecheat", CON_ACTIVATECHEAT }, { "actor", CON_ACTOR }, + { "actorsound", CON_ACTORSOUND }, { "addammo", CON_ADDAMMO }, { "addinventory", CON_ADDINVENTORY }, { "addkills", CON_ADDKILLS }, @@ -4111,6 +4112,7 @@ DO_DEFSTATE: case CON_QSTRCAT: case CON_QSTRCPY: case CON_QGETSYSSTR: + case CON_ACTORSOUND: case CON_STOPACTORSOUND: case CON_STARTTRACKSLOT: C_GetManyVars(2); diff --git a/source/duke3d/src/gamedef.h b/source/duke3d/src/gamedef.h index 21b8b11a9..137abc62c 100644 --- a/source/duke3d/src/gamedef.h +++ b/source/duke3d/src/gamedef.h @@ -1145,6 +1145,7 @@ enum ScriptKeywords_t CON_DRAWLINERGB, // 405 CON_STARTTRACKSLOT, // 406 CON_STOPALLMUSIC, // 407 + CON_ACTORSOUND, // 408 CON_END }; // KEEPINSYNC with the keyword list in lunatic/con_lang.lua diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index 05f4624fe..6fc7dc573 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -1679,6 +1679,23 @@ skip_check: continue; } + case CON_ACTORSOUND: + insptr++; + { + int const spriteNum = (*insptr++ != g_thisActorVarID) ? Gv_GetVarX(*(insptr - 1)) : vm.spriteNum; + int const soundNum = Gv_GetVarX(*insptr++); + + if (EDUKE32_PREDICT_FALSE((unsigned)soundNum >= MAXSOUNDS)) + { + CON_ERRPRINTF("invalid sound %d\n", soundNum); + continue; + } + + A_PlaySound(soundNum, spriteNum); + + continue; + } + case CON_SETACTORSOUNDPITCH: insptr++; {