Skip to content

Commit

Permalink
feat: Trigger options relating to changing palette and wavy/quake vfx
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyV99 committed Apr 14, 2024
1 parent 4917cea commit 9220aff
Show file tree
Hide file tree
Showing 15 changed files with 230 additions and 19 deletions.
9 changes: 9 additions & 0 deletions resources/docs/ZScript_Additions.txt
Expand Up @@ -7840,6 +7840,15 @@ int TrigTintG;
int TrigTintB;
* The R/G/B values to tint the palette by when triggered. -63 to 63.

int TrigLvlPal;
* The level palette to change to when triggered. -1 for none.
int TrigBossPal;
* The boss palette to change to when triggered. -1 for none.
int TrigQuakeTimer;
* The quake timer to set when triggered. -1 for none.
int TrigWavyTimer;
* The wavy timer to set when triggered. -1 for none.

int TrigGenScript;
* When triggered, this generic script will be run in the 'RunFrozen' mode.

Expand Down
8 changes: 8 additions & 0 deletions src/base/combo.cpp
Expand Up @@ -68,6 +68,10 @@ bool newcombo::is_blank(bool ignoreEff)
if(trigdmlevel > -1) return false;
for(int q = 0; q < 3; ++q)
if(trigtint[q]) return false;
if(triglvlpalette > -1) return false;
if(trigbosspalette > -1) return false;
if(trigquaketime > -1) return false;
if(trigwavytime > -1) return false;
if(!label.empty()) return false;
for(auto q = 0; q < NUM_COMBO_ATTRIBYTES; ++q)
if(attribytes[q]) return false;
Expand Down Expand Up @@ -223,6 +227,10 @@ void newcombo::advpaste(newcombo const& other, bitstring const& flags)
trigdmlevel = other.trigdmlevel;
for(int q = 0; q < 3; ++q)
trigtint[q] = other.trigtint[q];
triglvlpalette = other.triglvlpalette;
trigbosspalette = other.trigbosspalette;
trigquaketime = other.trigquaketime;
trigwavytime = other.trigwavytime;
}
if(flags.get(CMB_ADVP_LIFTING))
{
Expand Down
2 changes: 2 additions & 0 deletions src/base/combo.h
Expand Up @@ -99,6 +99,8 @@ struct newcombo
byte trig_levelitems;
int16_t trigdmlevel = -1;
int8_t trigtint[3]; //r,g,b range [-63,63]
int16_t triglvlpalette = -1, trigbosspalette = -1;
int16_t trigquaketime = -1, trigwavytime = -1;
byte liftflags;
byte liftlvl;
byte liftsfx;
Expand Down
58 changes: 56 additions & 2 deletions src/dialog/comboeditor.cpp
Expand Up @@ -3251,8 +3251,8 @@ std::shared_ptr<GUI::Widget> ComboEditorDialog::view()
TRIGFLAG(111, "TrigGroup Greater->")
)
)),
TabRef(name = "Graphics", Column(
Frame(title = "Tint", Column(
TabRef(name = "Graphics", Rows<2>(
Frame(title = "Tint", fitParent = true, Column(
Row(
Label(text = "Tint Palette R/G/B:", fitParent = true),
TextField(
Expand Down Expand Up @@ -3290,6 +3290,60 @@ std::shared_ptr<GUI::Widget> ComboEditorDialog::view()
" Runs before the above 'Tint Palette' effect, if both are set."),
TRIGFLAG(125,"->ClearTint")
)
)),
Frame(title = "Palette", fitParent = true, Rows<3>(
Label(text = "Load Level Palette", fitParent = true),
TextField(
fitParent = true, padding = 0_px,
type = GUI::TextField::type::NOSWAP_ZSINT,
swap_type = nswapLDEC,
low = -1, high = 512, val = local_comboref.triglvlpalette,
onValChangedFunc = [&](GUI::TextField::type,std::string_view,int32_t val)
{
local_comboref.triglvlpalette = val;
}),
INFOBTN("Loads the specified level palette over the current level palette."
" '-1' for 'none'."),
//
Label(text = "Load Boss Palette", fitParent = true),
TextField(
fitParent = true, padding = 0_px,
type = GUI::TextField::type::NOSWAP_ZSINT,
swap_type = nswapLDEC,
low = -1, high = 29, val = local_comboref.trigbosspalette,
onValChangedFunc = [&](GUI::TextField::type,std::string_view,int32_t val)
{
local_comboref.trigbosspalette = val;
}),
INFOBTN("Loads the specified level palette over the current boss palette."
" '-1' for 'none'.")
)),
Frame(title = "VFX", fitParent = true, Rows<3>(
Label(text = "Quake", fitParent = true),
TextField(
fitParent = true, padding = 0_px,
type = GUI::TextField::type::NOSWAP_ZSINT,
swap_type = nswapLDEC,
low = -1, high = 999999, val = local_comboref.trigquaketime,
onValChangedFunc = [&](GUI::TextField::type,std::string_view,int32_t val)
{
local_comboref.trigquaketime = val;
}),
INFOBTN("Sets the quake timer to the specified duration."
" '-1' for 'none'."),
//
Label(text = "Wavy", fitParent = true),
TextField(
fitParent = true, padding = 0_px,
type = GUI::TextField::type::NOSWAP_ZSINT,
swap_type = nswapLDEC,
low = -1, high = 999999, val = local_comboref.trigwavytime,
onValChangedFunc = [&](GUI::TextField::type,std::string_view,int32_t val)
{
local_comboref.trigwavytime = val;
}),
INFOBTN("Sets the wavy timer to the specified duration."
" '-1' for 'none'.")
))
))
);
Expand Down
5 changes: 5 additions & 0 deletions src/parser/ByteCode.cpp
Expand Up @@ -2501,6 +2501,11 @@ string ZScript::VarToString(int32_t ID)
case COMBODTRIGTINTG: return "COMBODTRIGTINTG";
case COMBODTRIGTINTB: return "COMBODTRIGTINTB";

case COMBODTRIGLVLPAL: return "COMBODTRIGLVLPAL";
case COMBODTRIGBOSSPAL: return "COMBODTRIGBOSSPAL";
case COMBODTRIGQUAKETIME: return "COMBODTRIGQUAKETIME";
case COMBODTRIGWAVYTIME: return "COMBODTRIGWAVYTIME";

default:
{
sprintf(temp, "d%d", ID);
Expand Down
7 changes: 6 additions & 1 deletion src/parser/ByteCode.h
Expand Up @@ -1779,7 +1779,12 @@
#define COMBODTRIGTINTG 1663
#define COMBODTRIGTINTB 1664

#define LAST_BYTECODE 1665
#define COMBODTRIGLVLPAL 1665
#define COMBODTRIGBOSSPAL 1666
#define COMBODTRIGQUAKETIME 1667
#define COMBODTRIGWAVYTIME 1668

#define LAST_BYTECODE 1669

//} END OF BYTECODE

Expand Down
24 changes: 20 additions & 4 deletions src/parser/symbols/CombosPtrSymbols.cpp
Expand Up @@ -128,10 +128,18 @@ static AccessorTable CombosTable[] =
{ "setTrigDMapLvl", 0, ZTID_VOID, COMBODTRIGDMAPLVL, 0, { ZTID_COMBOS, ZTID_FLOAT },{} },
{ "getTrigTintR", 0, ZTID_FLOAT, COMBODTRIGTINTR, 0, { ZTID_COMBOS },{} },
{ "setTrigTintR", 0, ZTID_VOID, COMBODTRIGTINTR, 0, { ZTID_COMBOS, ZTID_FLOAT },{} },
{ "getTrigTintG", 0, ZTID_FLOAT, COMBODTRIGTINTR, 0, { ZTID_COMBOS },{} },
{ "setTrigTintG", 0, ZTID_VOID, COMBODTRIGTINTR, 0, { ZTID_COMBOS, ZTID_FLOAT },{} },
{ "getTrigTintB", 0, ZTID_FLOAT, COMBODTRIGTINTR, 0, { ZTID_COMBOS },{} },
{ "setTrigTintB", 0, ZTID_VOID, COMBODTRIGTINTR, 0, { ZTID_COMBOS, ZTID_FLOAT },{} },
{ "getTrigTintG", 0, ZTID_FLOAT, COMBODTRIGTINTG, 0, { ZTID_COMBOS },{} },
{ "setTrigTintG", 0, ZTID_VOID, COMBODTRIGTINTG, 0, { ZTID_COMBOS, ZTID_FLOAT },{} },
{ "getTrigTintB", 0, ZTID_FLOAT, COMBODTRIGTINTB, 0, { ZTID_COMBOS },{} },
{ "setTrigTintB", 0, ZTID_VOID, COMBODTRIGTINTB, 0, { ZTID_COMBOS, ZTID_FLOAT },{} },
{ "getTrigLvlPal", 0, ZTID_FLOAT, COMBODTRIGLVLPAL, 0, { ZTID_COMBOS },{} },
{ "setTrigLvlPal", 0, ZTID_VOID, COMBODTRIGLVLPAL, 0, { ZTID_COMBOS, ZTID_FLOAT },{} },
{ "getTrigBossPal", 0, ZTID_FLOAT, COMBODTRIGBOSSPAL, 0, { ZTID_COMBOS },{} },
{ "setTrigBossPal", 0, ZTID_VOID, COMBODTRIGBOSSPAL, 0, { ZTID_COMBOS, ZTID_FLOAT },{} },
{ "getTrigQuakeTimer", 0, ZTID_FLOAT, COMBODTRIGQUAKETIME, 0, { ZTID_COMBOS },{} },
{ "setTrigQuakeTimer", 0, ZTID_VOID, COMBODTRIGQUAKETIME, 0, { ZTID_COMBOS, ZTID_FLOAT },{} },
{ "getTrigWavyTimer", 0, ZTID_FLOAT, COMBODTRIGWAVYTIME, 0, { ZTID_COMBOS },{} },
{ "setTrigWavyTimer", 0, ZTID_VOID, COMBODTRIGWAVYTIME, 0, { ZTID_COMBOS, ZTID_FLOAT },{} },


{ "getLiftGFXCombo", 0, ZTID_FLOAT, COMBODLIFTGFXCOMBO, 0, { ZTID_COMBOS },{} },
Expand Down Expand Up @@ -227,6 +235,14 @@ static AccessorTable CombosTable[] =
{ "setTriggerTintG", 0, "setTrigTintG", 0 },
{ "getTriggerTintB", 0, "getTrigTintB", 0 },
{ "setTriggerTintB", 0, "setTrigTintB", 0 },
{ "getTriggerLvlPal", 0, "getTrigLvlPal", 0 },
{ "setTriggerLvlPal", 0, "setTrigLvlPal", 0 },
{ "getTriggerBossPal", 0, "getTrigBossPal", 0 },
{ "setTriggerBossPal", 0, "setTrigBossPal", 0 },
{ "getTriggerQuakeTimer", 0, "getTrigQuakeTimer", 0 },
{ "setTriggerQuakeTimer", 0, "setTrigQuakeTimer", 0 },
{ "getTriggerWavyTimer", 0, "getTrigWavyTimer", 0 },
{ "setTriggerWavyTimer", 0, "setTrigWavyTimer", 0 },

{ "_getPosX", 0, ZTID_FLOAT, COMBOXR, 0, { ZTID_COMBOS },{} },
{ "_getPosY", 0, ZTID_FLOAT, COMBOYR, 0, { ZTID_COMBOS },{} },
Expand Down
8 changes: 8 additions & 0 deletions src/qst.cpp
Expand Up @@ -18124,6 +18124,14 @@ int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
for(int q = 0; q < 3; ++q)
if(!p_getc(&temp_combo.trigtint[q],f))
return qe_invalid;
if(!p_igetw(&temp_combo.triglvlpalette,f))
return qe_invalid;
if(!p_igetw(&temp_combo.trigbosspalette,f))
return qe_invalid;
if(!p_igetw(&temp_combo.trigquaketime,f))
return qe_invalid;
if(!p_igetw(&temp_combo.trigwavytime,f))
return qe_invalid;
}
}
if(combo_has_flags&CHAS_LIFT)
Expand Down
5 changes: 5 additions & 0 deletions src/zasm_table.cpp
Expand Up @@ -2935,6 +2935,11 @@ script_variable variable_list[]=
{ "COMBODTRIGTINTG", COMBODTRIGTINTG, 0, 0 },
{ "COMBODTRIGTINTB", COMBODTRIGTINTB, 0, 0 },

{ "COMBODTRIGLVLPAL", COMBODTRIGLVLPAL, 0, 0 },
{ "COMBODTRIGBOSSPAL", COMBODTRIGBOSSPAL, 0, 0 },
{ "COMBODTRIGQUAKETIME", COMBODTRIGQUAKETIME, 0, 0 },
{ "COMBODTRIGWAVYTIME", COMBODTRIGWAVYTIME, 0, 0 },

{ " ", -1, 0, 0 }
};

Expand Down
8 changes: 8 additions & 0 deletions src/zc/combos.cpp
Expand Up @@ -2794,6 +2794,14 @@ void handle_trigger_results(newcombo const& cmb, int32_t cx, int32_t cy, bool& h
doClearTint();
if(cmb.trigtint[0] || cmb.trigtint[1] || cmb.trigtint[2])
doTint(cmb.trigtint[0], cmb.trigtint[1], cmb.trigtint[2]);
if(cmb.triglvlpalette > -1)
loadlvlpal(cmb.triglvlpalette);
if(cmb.trigbosspalette > -1)
loadpalset(csBOSS,pSprite(cmb.trigbosspalette));
if(cmb.trigquaketime > -1)
quakeclk = cmb.trigquaketime;
if(cmb.trigwavytime > -1)
wavy = cmb.trigwavytime;
}

if(cmb.exstate > -1 && trigexstate)
Expand Down
76 changes: 76 additions & 0 deletions src/zc/ffscript.cpp
Expand Up @@ -12758,6 +12758,46 @@ int32_t get_register(int32_t arg)
else ret = (combobuf[ri->combosref].trigtint[2]) * 10000;
break;
}
case COMBODTRIGLVLPAL:
{
ret = -10000;
if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
{
Z_scripterrlog("Invalid Combo ID passed to combodata->TrigLvlPal: %d\n", (ri->combosref*10000));
}
else ret = 10000 * combobuf[ri->combosref].triglvlpalette;
break;
}
case COMBODTRIGBOSSPAL:
{
ret = -10000;
if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
{
Z_scripterrlog("Invalid Combo ID passed to combodata->TrigBossPal: %d\n", (ri->combosref*10000));
}
else ret = 10000 * combobuf[ri->combosref].trigbosspalette;
break;
}
case COMBODTRIGQUAKETIME:
{
ret = -10000;
if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
{
Z_scripterrlog("Invalid Combo ID passed to combodata->TrigQuakeTimer: %d\n", (ri->combosref*10000));
}
else ret = 10000 * combobuf[ri->combosref].trigquaketime;
break;
}
case COMBODTRIGWAVYTIME:
{
ret = -10000;
if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
{
Z_scripterrlog("Invalid Combo ID passed to combodata->TrigWavyTimer: %d\n", (ri->combosref*10000));
}
else ret = 10000 * combobuf[ri->combosref].trigwavytime;
break;
}
case COMBODLIFTGFXCOMBO:
{
ret = -10000;
Expand Down Expand Up @@ -25697,6 +25737,42 @@ void set_register(int32_t arg, int32_t value)
else combobuf[ri->combosref].trigtint[2] = vbound(value/10000, -63, 63);
break;
}
case COMBODTRIGLVLPAL:
{
if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
{
Z_scripterrlog("Invalid Combo ID passed to combodata->TrigLvlPal: %d\n", (ri->combosref*10000));
}
else combobuf[ri->combosref].triglvlpalette = vbound(value/10000, -1, 512);
break;
}
case COMBODTRIGBOSSPAL:
{
if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
{
Z_scripterrlog("Invalid Combo ID passed to combodata->TrigBossPal: %d\n", (ri->combosref*10000));
}
else combobuf[ri->combosref].trigbosspalette = vbound(value/10000, -1, 29);
break;
}
case COMBODTRIGQUAKETIME:
{
if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
{
Z_scripterrlog("Invalid Combo ID passed to combodata->TrigQuakeTimer: %d\n", (ri->combosref*10000));
}
else combobuf[ri->combosref].trigquaketime = zc_max(value/10000, -1);
break;
}
case COMBODTRIGWAVYTIME:
{
if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
{
Z_scripterrlog("Invalid Combo ID passed to combodata->TrigWavyTimer: %d\n", (ri->combosref*10000));
}
else combobuf[ri->combosref].trigwavytime = zc_max(value/10000, -1);
break;
}
case COMBODLIFTGFXCOMBO:
{
if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
Expand Down
7 changes: 6 additions & 1 deletion src/zc/ffscript.h
Expand Up @@ -5016,7 +5016,12 @@ enum ASM_DEFINE
#define COMBODTRIGTINTG 0x15B4
#define COMBODTRIGTINTB 0x15B5

#define NUMVARIABLES 0x15B6
#define COMBODTRIGLVLPAL 0x15B6
#define COMBODTRIGBOSSPAL 0x15B7
#define COMBODTRIGQUAKETIME 0x15B8
#define COMBODTRIGWAVYTIME 0x15B9

#define NUMVARIABLES 0x15BA

//} End variables

Expand Down
12 changes: 11 additions & 1 deletion src/zq/zq_class.cpp
Expand Up @@ -9705,6 +9705,8 @@ int32_t writecombo_loop(PACKFILE *f, word section_version, newcombo const& tmp_c
|| tmp_cmb.trig_genscr || tmp_cmb.trig_group
|| tmp_cmb.trig_group_val || tmp_cmb.trig_levelitems
|| tmp_cmb.trigdmlevel > -1
|| tmp_cmb.triglvlpalette > -1 || tmp_cmb.trigbosspalette > -1
|| tmp_cmb.trigquaketime > -1 || tmp_cmb.trigwavytime > -1
|| tmp_cmb.prompt_cid || tmp_cmb.prompt_cs
|| tmp_cmb.prompt_x != 12 || tmp_cmb.prompt_y != -8)
combo_has_flags |= CHAS_TRIG;
Expand Down Expand Up @@ -9890,7 +9892,15 @@ int32_t writecombo_loop(PACKFILE *f, word section_version, newcombo const& tmp_c
return 92;
for(int q = 0; q < 3; ++q)
if(!p_putc(tmp_cmb.trigtint[q],f))
return 92;
return 93;
if(!p_iputw(tmp_cmb.triglvlpalette,f))
return 94;
if(!p_iputw(tmp_cmb.trigbosspalette,f))
return 95;
if(!p_iputw(tmp_cmb.trigquaketime,f))
return 96;
if(!p_iputw(tmp_cmb.trigwavytime,f))
return 97;
}
if(combo_has_flags&CHAS_LIFT)
{
Expand Down

0 comments on commit 9220aff

Please sign in to comment.