| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391 |
- /*
- ** Command & Conquer Red Alert(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /* $Header: /CounterStrike/SUPER.CPP 1 3/03/97 10:25a Joe_bostic $ */
- /***********************************************************************************************
- *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
- ***********************************************************************************************
- * *
- * Project Name : Command & Conquer *
- * *
- * File Name : SUPER.CPP *
- * *
- * Programmer : Joe L. Bostic *
- * *
- * Start Date : 07/28/95 *
- * *
- * Last Update : October 11, 1996 [JLB] *
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * SuperClass::AI -- Process the super weapon AI. *
- * SuperClass::Anim_Stage -- Fetches the animation stage for this super weapon. *
- * SuperClass::Discharged -- Handles discharged action for special super weapon. *
- * SuperClass::Enable -- Enable this super special weapon. *
- * SuperClass::Forced_Charge -- Force the super weapon to full charge state. *
- * SuperClass::Impatient_Click -- Called when player clicks on unfinished super weapon. *
- * SuperClass::Recharge -- Starts the special super weapon recharging. *
- * SuperClass::Remove -- Removes super weapon availability. *
- * SuperClass::SuperClass -- Constructor for special super weapon objects. *
- * SuperClass::Suspend -- Suspend the charging of the super weapon. *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "function.h"
- /***********************************************************************************************
- * SuperClass::SuperClass -- Constructor for special super weapon objects. *
- * *
- * This is the constructor for the super weapons. *
- * *
- * INPUT: recharge -- The recharge delay time (in game frames). *
- * *
- * charging -- Voice to announce that the weapon is charging. *
- * *
- * ready -- Voice to announce that the weapon is fully charged. *
- * *
- * impatient -- Voice to announce current charging state. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 07/28/1995 JLB : Created. *
- *=============================================================================================*/
- SuperClass::SuperClass(int recharge, bool powered, VoxType charging, VoxType ready, VoxType impatient, VoxType suspend) :
- IsPowered(powered),
- IsPresent(false),
- IsOneTime(false),
- IsReady(false),
- Control(0),
- OldStage(-1),
- VoxRecharge(ready),
- VoxCharging(charging),
- VoxImpatient(impatient),
- VoxSuspend(suspend),
- RechargeTime(recharge)
- {
- }
- /***********************************************************************************************
- * SuperClass::Suspend -- Suspend the charging of the super weapon. *
- * *
- * This will temporarily put on hold the charging of the special weapon. This might be the *
- * result of insufficient power. *
- * *
- * INPUT: on -- Should the weapon charging be suspended? Else, it will unsuspend. *
- * *
- * OUTPUT: Was the weapon suspend state changed? *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 07/28/1995 JLB : Created. *
- *=============================================================================================*/
- bool SuperClass::Suspend(bool on)
- {
- if (IsPresent && !IsReady && !IsOneTime && on == Control.Is_Active()) {
- if (!on) {
- Control.Start();
- } else {
- Control.Stop();
- }
- // if (on != IsSuspended) {
- // if (on) {
- // SuspendTime = Control;
- // } else {
- // Control = SuspendTime;
- // }
- // IsSuspended = on;
- return(true);
- // }
- }
- return(false);
- }
- /***********************************************************************************************
- * SuperClass::Enable -- Enable this super special weapon. *
- * *
- * This routine is called when the special weapon needs to be activated. This is used for *
- * both the normal super weapons and the special one-time super weapons (from crates). *
- * *
- * INPUT: onetime -- Is this a special one time super weapon? *
- * *
- * player -- Is this weapon for the player? If true, then there might be a voice *
- * announcement of this weapon's availability. *
- * *
- * quiet -- Request that the weapon start in suspended state (quiet mode). *
- * *
- * OUTPUT: Was the special super weapon enabled? Failure might indicate that the weapon was *
- * already available. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 07/28/1995 JLB : Created. *
- *=============================================================================================*/
- bool SuperClass::Enable(bool onetime, bool player, bool quiet)
- {
- if (!IsPresent) {
- IsPresent = true;
- IsOneTime = onetime;
- bool retval = Recharge(player && !quiet);
- if (quiet) Suspend(true);
- return(retval);
- }
- return(false);
- }
- /***********************************************************************************************
- * SuperClass::Remove -- Removes super weapon availability. *
- * *
- * Call this routine when the super weapon should be removed because of some outside *
- * force. For one time special super weapons, they can never be removed except as the *
- * result of discharging them. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: Was the special weapon removed and disabled? *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 07/28/1995 JLB : Created. *
- *=============================================================================================*/
- bool SuperClass::Remove(void)
- {
- if (IsPresent && !IsOneTime) {
- IsReady = false;
- IsPresent = false;
- return(true);
- }
- return(false);
- }
- /***********************************************************************************************
- * SuperClass::Recharge -- Starts the special super weapon recharging. *
- * *
- * This routine is called when the special weapon is allowed to recharge. Suspension will *
- * be disabled and the animation process will begin. *
- * *
- * INPUT: player -- Is this for a player owned super weapon? If so, then a voice *
- * announcement might be in order. *
- * *
- * OUTPUT: Was the super weapon begun charging up? *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 07/28/1995 JLB : Created. *
- *=============================================================================================*/
- bool SuperClass::Recharge(bool player)
- {
- if (IsPresent && !IsReady) {
- // IsSuspended = false;
- OldStage = -1;
- Control.Start();
- Control = RechargeTime;
- #ifdef CHEAT_KEYS
- if (Special.IsSpeedBuild) {
- Control = 1;
- }
- #endif
- if (player) {
- Speak(VoxCharging);
- }
- return(true);
- }
- return(false);
- }
- /***********************************************************************************************
- * Superclass::Discharged -- Handles discharged action for special super weapon. *
- * *
- * This routine should be called when the special super weapon has been discharged. The *
- * weapon will either begin charging anew or will be removed entirely -- depends on the *
- * one time flag for the weapon. *
- * *
- * INPUT: player -- Is this special weapon for the player? If so, then there might be a *
- * voice announcement. *
- * *
- * OUTPUT: Should the sidebar be reprocessed because the special weapon has been eliminated? *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 07/28/1995 JLB : Created. *
- *=============================================================================================*/
- bool SuperClass::Discharged(bool player)
- {
- if (Control.Is_Active() && IsPresent && IsReady) {
- IsReady = false;
- if (IsOneTime) {
- IsOneTime = false;
- return(Remove());
- } else {
- Recharge(player);
- }
- }
- return(false);
- }
- /***********************************************************************************************
- * SuperClass::AI -- Process the super weapon AI. *
- * *
- * This routine will process the charge up AI for this super weapon object. If the weapon *
- * has advanced far enough to change any sidebar graphic that might represent it, then *
- * "true" will be returned. Use this return value to intelligently update the sidebar. *
- * *
- * INPUT: player -- Is this for the player? If it is and the weapon is now fully charged, *
- * then this fully charged state will be announced to the player. *
- * *
- * OUTPUT: Was the weapon's state changed such that a sidebar graphic update will be *
- * necessary? *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 07/28/1995 JLB : Created. *
- *=============================================================================================*/
- bool SuperClass::AI(bool player)
- {
- if (IsPresent && !IsReady) {
- if (!Control.Is_Active()) {
- if (OldStage != -1) {
- OldStage = -1;
- return(true);
- }
- } else {
- if (Control == 0) {
- IsReady = true;
- if (player) {
- Speak(VoxRecharge);
- }
- return(true);
- } else {
- if (Anim_Stage() != OldStage) {
- OldStage = Anim_Stage();
- return(true);
- }
- }
- }
- }
- return(false);
- }
- /***********************************************************************************************
- * SuperClass::Anim_Stage -- Fetches the animation stage for this super weapon. *
- * *
- * This will return the current animation stage for this super weapon. The value will be *
- * between zero (uncharged) to ANIMATION_STAGES (fully charged). Use this value to render *
- * the appropriate graphic on the sidebar. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: Returns with the current animation stage for this special super weapon powerup. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 07/28/1995 JLB : Created. *
- * 10/11/1996 JLB : Doesn't show complete until really complete. *
- *=============================================================================================*/
- int SuperClass::Anim_Stage(void) const
- {
- if (IsPresent) {
- if (IsReady) {
- return(ANIMATION_STAGES);
- }
- // int time = Control;
- // if (IsSuspended) {
- // time = SuspendTime;
- // }
- int stage = ANIMATION_STAGES * fixed(RechargeTime-Control.Value(), RechargeTime);
- stage = min(stage, ANIMATION_STAGES-1);
- return(stage);
- }
- return(0);
- }
- /***********************************************************************************************
- * SuperClass::Impatient_Click -- Called when player clicks on unfinished super weapon. *
- * *
- * This routine is called when the player clicks on the super weapon icon on the sidebar *
- * when the super weapon is not ready yet. This results in a voice message feedback to the *
- * player. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 07/28/1995 JLB : Created. *
- *=============================================================================================*/
- void SuperClass::Impatient_Click(void) const
- {
- if (!Control.Is_Active()) {
- Speak(VoxSuspend);
- } else {
- Speak(VoxImpatient);
- }
- }
- /***********************************************************************************************
- * SuperClass::Forced_Charge -- Force the super weapon to full charge state. *
- * *
- * This routine will force the special weapon to full charge state. Call it when the weapon *
- * needs to be instantly charged. The airstrike (when it first becomes available) is a *
- * good example. *
- * *
- * INPUT: player -- Is this for the player? If true, then the full charge state will be *
- * announced. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 07/29/1995 JLB : Created. *
- *=============================================================================================*/
- void SuperClass::Forced_Charge(bool player)
- {
- if (IsPresent) {
- IsReady = true;
- Control.Start();
- Control = 0;
- // IsSuspended = false;
- if (player) {
- Speak(VoxRecharge);
- }
- }
- }
|