From 9fcc2d286d4444e8527e81424672bdb8d1cbbc7b Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Mon, 20 Jul 2020 11:27:06 -0700 Subject: [PATCH] Soviets will now have paratroopers at the start of soviet mission 1, modified lua GiveSpecialWeapon and super code to allow perputual usage of script granted super weapons even if the prereq requirements aren't met. --- code/redalert/mapscript.cpp | 2 +- code/redalert/newblit.cpp | 8 ++++++++ code/redalert/newblit.h | 1 + code/redalert/super.cpp | 6 ++++-- code/redalert/super.h | 3 ++- scripts/SCU01EA.MAP.script | 2 +- 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/code/redalert/mapscript.cpp b/code/redalert/mapscript.cpp index 8787fb7..3a4e7f2 100644 --- a/code/redalert/mapscript.cpp +++ b/code/redalert/mapscript.cpp @@ -948,7 +948,7 @@ static int Script_GiveSpecialWeapon(lua_State* L) { if (house->ID == houseType || houseType == -1) { - house->SuperWeapon[weaponType].Enable(TACTION_FULL_SPECIAL, true); + house->SuperWeapon[weaponType].Enable(false, true, false, true); if (immediate) { house->SuperWeapon[weaponType].Forced_Charge(true); diff --git a/code/redalert/newblit.cpp b/code/redalert/newblit.cpp index 010c016..88c0d47 100644 --- a/code/redalert/newblit.cpp +++ b/code/redalert/newblit.cpp @@ -170,6 +170,14 @@ void GL_DrawForegroundText(int color, int x, int y, char* text) { ImGui::GetForegroundDrawList()->AddText(pos, ImGui::ColorConvertFloat4ToU32(ImVec4(r, g, b, 1)), text); } +void GL_DrawForegroundText(int color, float fontsize, float r, float g, float b, int x, int y, char* text) { + ImVec2 pos(x, y); + float _r = r / 255.0f; + float _g = r / 255.0f; + float _b = r / 255.0f; + ImGui::GetForegroundDrawList()->AddText(NULL, fontsize, pos, ImGui::ColorConvertFloat4ToU32(ImVec4(_r, _g, _b, 1)), text); +} + void GL_DrawLine(int color, int x, int y, int dx, int dy) { ImVec2 pos(x, y); ImVec2 pos2(dx, dy); diff --git a/code/redalert/newblit.h b/code/redalert/newblit.h index 4225c2e..d296c8b 100644 --- a/code/redalert/newblit.h +++ b/code/redalert/newblit.h @@ -20,6 +20,7 @@ void GL_ResetClipRect(void); void GL_SetClipRect(int x, int y, int width, int height); void GL_ForceForegroundRender(bool force); void GL_DrawForegroundText(int color, int x, int y, char* text); +void GL_DrawForegroundText(int color, float fontsize, float r, float g, float b, int x, int y, char* text); void GL_SetColor(float r, float g, float b); void GL_SetRenderTexture(RenderTexture* renderTexture); void GL_EnableBlend(GLBlendType blendType); diff --git a/code/redalert/super.cpp b/code/redalert/super.cpp index f3ac697..2e9f8b2 100644 --- a/code/redalert/super.cpp +++ b/code/redalert/super.cpp @@ -70,6 +70,7 @@ SuperClass::SuperClass(int recharge, bool powered, VoxType charging, VoxType rea IsPresent(false), IsOneTime(false), IsReady(false), + IsNoPreq(false), Control(0), OldStage(-1), VoxRecharge(ready), @@ -139,11 +140,12 @@ bool SuperClass::Suspend(bool on) * HISTORY: * * 07/28/1995 JLB : Created. * *=============================================================================================*/ -bool SuperClass::Enable(bool onetime, bool player, bool quiet) +bool SuperClass::Enable(bool onetime, bool player, bool quiet, bool skipPreReq) { if (!IsPresent) { IsPresent = true; IsOneTime = onetime; + IsNoPreq = skipPreReq; bool retval = Recharge(player && !quiet); if (quiet) Suspend(true); return(retval); @@ -170,7 +172,7 @@ bool SuperClass::Enable(bool onetime, bool player, bool quiet) *=============================================================================================*/ bool SuperClass::Remove(void) { - if (IsPresent && !IsOneTime) { + if (IsPresent && !IsOneTime && !IsNoPreq) { IsReady = false; IsPresent = false; return(true); diff --git a/code/redalert/super.h b/code/redalert/super.h index b9838bc..4ef84ca 100644 --- a/code/redalert/super.h +++ b/code/redalert/super.h @@ -44,7 +44,7 @@ class SuperClass { SuperClass(int recharge, bool powered, VoxType charging=VOX_NONE, VoxType ready=VOX_NONE, VoxType impatient=VOX_NONE, VoxType suspend=VOX_NONE); bool Suspend(bool on); - bool Enable(bool onetime = false, bool player=false, bool quiet=false); + bool Enable(bool onetime = false, bool player=false, bool quiet=false, bool skipPreReq = false); void Forced_Charge(bool player=false); bool AI(bool player=false); bool Remove(void); @@ -66,6 +66,7 @@ class SuperClass { unsigned IsPresent:1; unsigned IsOneTime:1; unsigned IsReady:1; + unsigned IsNoPreq : 1; CDTimerClass Control; int OldStage; diff --git a/scripts/SCU01EA.MAP.script b/scripts/SCU01EA.MAP.script index a1df232..a216040 100644 --- a/scripts/SCU01EA.MAP.script +++ b/scripts/SCU01EA.MAP.script @@ -6,7 +6,7 @@ function map_briefing() end function map_start() - + GiveSpecialWeapon(SpecialWeapons.Paratroops, Houses.USSR, 1) end function map_frame()