2025-07-17 23:56 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000573Spring engineGeneralpublic2007-10-29 20:47
Reporteryuritch 
Assigned Totvo 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000573: [patch] Aircraft crashing control via COB set/get
DescriptionThis patch allows to control aircraft crashing state with COB set/get commands. A new set/get constant CRASHING=96 is introduced for this. Get CRASHING returnt wheter a unit is crashing or not, set CRASHING to 1 makes a unit start crashing, I'm not sure if set CRASHING to 0 will abort the crashing sequence or not. All of the above only makes sence for aircraft though.
Additional InformationI made that at work, so I cannot test it here. It's quite simple though.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • patch file icon crashing.patch (1,081 bytes) 2007-07-30 08:31 -
    Index: rts/Sim/Units/COB/CobInstance.cpp
    ===================================================================
    --- rts/Sim/Units/COB/CobInstance.cpp	(revision 4109)
    +++ rts/Sim/Units/COB/CobInstance.cpp	(working copy)
    @@ -98,6 +98,7 @@
     #define CURRENT_FUEL             93 // set or get
     #define TRANSPORT_ID             94 // get
     #define SHIELD_POWER             95 // set or get
    +#define CRASHING                 96 // set or get, aircraft crashing state, useless for non-aircraft
     
     // * NOTE: [LUA0 - LUA9] are defined in CobThread.cpp as [110 - 119]
     
    @@ -1106,6 +1107,8 @@
     		const CPlasmaRepulser* shield = (CPlasmaRepulser*)unit->shieldWeapon;
     		return int(shield->curPower * float(COBSCALE));
     	}
    +	case CRASHING:
    +		return !!unit->crashing;
     	default:
     		logOutput.Print("CobError: Unknown get constant %d  (params = %d %d %d %d)",
     		                val, p1, p2, p3, p4);
    @@ -1298,6 +1301,10 @@
     			}
     			break;
     		}
    +		case CRASHING: {
    +			unit->crashing=!!param;
    +			break;
    +		}
     		default: {
     			logOutput.Print("CobError: Unknown set constant %d", val);
     		}
    
    patch file icon crashing.patch (1,081 bytes) 2007-07-30 08:31 +
  • patch file icon crashing_4661.patch (2,061 bytes) 2007-10-29 19:28 -
    Index: rts/Sim/MoveTypes/AirMoveType.cpp
    ===================================================================
    --- rts/Sim/MoveTypes/AirMoveType.cpp	(revision 4661)
    +++ rts/Sim/MoveTypes/AirMoveType.cpp	(working copy)
    @@ -1038,7 +1038,7 @@
     
     void CAirMoveType::SetState(CAirMoveType::AircraftState state)
     {
    -	if(aircraftState==AIRCRAFT_CRASHING || state==aircraftState)
    +	if(/*aircraftState==AIRCRAFT_CRASHING || */state==aircraftState)
     		return;
     
     /*	if (state == AIRCRAFT_LANDING)
    Index: rts/Sim/Units/COB/CobInstance.cpp
    ===================================================================
    --- rts/Sim/Units/COB/CobInstance.cpp	(revision 4661)
    +++ rts/Sim/Units/COB/CobInstance.cpp	(working copy)
    @@ -13,6 +13,7 @@
     #include "Rendering/UnitModels/3DOParser.h"
     #include "Rendering/UnitModels/s3oParser.h"
     #include "Sim/Misc/RadarHandler.h"
    +#include "Sim/MoveTypes/AirMoveType.h"
     #include "Sim/MoveTypes/MoveType.h"
     #include "Sim/Projectiles/ExplosionGenerator.h"
     #include "Sim/Projectiles/PieceProjectile.h"
    @@ -99,6 +100,7 @@
     #define TRANSPORT_ID             94 // get
     #define SHIELD_POWER             95 // set or get
     #define STEALTH                  96 // set or get
    +#define CRASHING                 97 // set or get, returns whether aircraft isCrashing state
     #define COB_ID                  100 // get
     #define ALPHA_THRESHOLD         103 // set or get
     
    @@ -1122,6 +1124,8 @@
     	case STEALTH: {
     		return unit->stealth ? 1 : 0;
     	}
    +	case CRASHING:
    +		return !!unit->crashing;
     	case ALPHA_THRESHOLD: {
     		return int(unit->alphaThreshold * 255);
     	}
    @@ -1339,6 +1343,17 @@
     			unit->stealth = !!param;
     			break;
     		}
    +		case CRASHING: {
    +			if(dynamic_cast<CAirMoveType*>(unit->moveType)){
    +				if(!!param){
    +					((CAirMoveType*)unit->moveType)->SetState(CAirMoveType::AIRCRAFT_CRASHING);
    +				} else {
    +					((CAirMoveType*)unit->moveType)->SetState(CAirMoveType::AIRCRAFT_FLYING);
    +					unit->crashing=false;
    +				}
    +			}
    +			break;
    +		}
     		case ALPHA_THRESHOLD: {
     			unit->alphaThreshold = float(param) / 255.0f;
     			break;
    
    patch file icon crashing_4661.patch (2,061 bytes) 2007-10-29 19:28 +

-Relationships
+Relationships

-Notes

~0001369

tvo (reporter)

Any chance you could test it after all?

I'm not quite fond of committing untested changes to complex statemachines like the (Air)MoveTypes.

~0001372

KDR_11k (reporter)

Making a plane crash can be done with Spring.DestroyUnit in Lua, too.

~0001374

yuritch (reporter)

Last edited: 2007-10-29 08:07

Ok, I'll test it today. I forgot about this patch, else I'd have it tested long ago.
Lua is good, but COB is simpler most of the time.

~0001375

yuritch (reporter)

Last edited: 2007-10-29 19:33

Ok, I tested the patch and had to update it (get/set ID 96 was already taken by STEALTH, now I'm using ID 97 for CRASHING). Now it works fully - get CRASHING returns if the aircraft is crashing or not, set CRASHING to 1 makes it start crashing, set CRASHING to 0 aborts crashing sequence (and makes it targettable by weapons again if the mod has FireAtCrashing=0). My tests confirmed that all of the above works, and existing aircraft crashing behaviours (that is, without using set CRASHING) seem to be unaffected.
The patch is made against svn revision 4661.

~0001376

tvo (reporter)

Committed, thank you.

Note though that it won't for for CTAAirMoveType aircraft, but I forgot what the difference was (with CAirMoveType aircraft).
+Notes

-Issue History
Date Modified Username Field Change
2007-07-30 08:31 yuritch New Issue
2007-07-30 08:31 yuritch File Added: crashing.patch
2007-10-28 13:22 tvo Note Added: 0001369
2007-10-28 13:22 tvo Status new => feedback
2007-10-28 14:34 KDR_11k Note Added: 0001372
2007-10-29 08:03 yuritch Note Added: 0001374
2007-10-29 08:07 yuritch Note Edited: 0001374
2007-10-29 19:28 yuritch File Added: crashing_4661.patch
2007-10-29 19:32 yuritch Note Added: 0001375
2007-10-29 19:33 yuritch Note Edited: 0001375
2007-10-29 20:46 tvo Status feedback => assigned
2007-10-29 20:46 tvo Assigned To => tvo
2007-10-29 20:47 tvo Status assigned => resolved
2007-10-29 20:47 tvo Resolution open => fixed
2007-10-29 20:47 tvo Note Added: 0001376
+Issue History