Author Topic: Game Code That Removes idDebris  (Read 312 times)

0 Members and 1 Guest are viewing this topic.

Phrozo

  • Mr. Phrozo
  • Jr. Member
  • **
  • Posts: 89
  • Karma: +15/-1
  • :3
    • View Profile
    • Mod Page
Re: Game Code That Removes idDebris
« Reply #15 on: June 22, 2017, 12:05:38 AM »
You need to re-read the code you modified. I'll detail the errors:

Code: [Select]
/*
================
idExplodingBarrel::Killed
================
*/
void idExplodingBarrel::Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location ) {

if ( IsHidden() || state == EXPLODING || state == BURNING ) {
return;
}

float f = spawnArgs.GetFloat( "burn" );
if ( f > 0.0f && state == NORMAL ) {
state = BURNING;
PostEventSec( &EV_Explode, f );
StartSound( "snd_burn", SND_CHANNEL_ANY, 0, false, NULL );
AddParticles( spawnArgs.GetString ( "model_burn", "" ), true );
return;
} else {
state = EXPLODING;
if ( gameLocal.isServer ) {
idBitMsg msg;
byte msgBuf[MAX_EVENT_PARAM_SIZE];

msg.Init( msgBuf, sizeof( msgBuf ) );
msg.WriteLong( gameLocal.time );
ServerSendEvent( EVENT_EXPLODE, &msg, false, -1 );
}
}

// do this before applying radius damage so the ent can trace to any damagable ents nearby
Hide();
physicsObj.SetContents( 0 );

const char *splash = spawnArgs.GetString( "def_splash_damage", "damage_explosion" );
if ( splash && *splash ) {
gameLocal.RadiusDamage( GetPhysics()->GetOrigin(), this, attacker, this, this, splash );
}

ExplodingEffects( );

//FIXME: need to precache all the debris stuff here and in the projectiles
const idKeyValue *kv = spawnArgs.MatchPrefix( "def_debris" );
// bool first = true;
while ( kv ) {
const idDict *debris_args = gameLocal.FindEntityDefDict( kv->GetValue(), false );
if ( debris_args ) {
idEntity *ent;
idVec3 dir;
idDebris *debris;     // error 1a
//RPS idMoveable *debris; //error 1b
//if ( first ) {
dir = physicsObj.GetAxis()[1];
// first = false;
//} else {
dir.x += gameLocal.random.CRandomFloat() * 4.0f;
dir.y += gameLocal.random.CRandomFloat() * 4.0f;
//dir.z = gameLocal.random.RandomFloat() * 8.0f;
//}
dir.Normalize();

gameLocal.SpawnEntityDef( *debris_args, &ent, false );
if ( !ent || !ent->IsType( idDebris::Type ) ) { // error2a
//RPS if ( !ent || !ent->IsType( idMoveable::Type ) ) { // error 2b
gameLocal.Error( "'projectile_debris' is not an idDebris" ); // error 3
}

debris = static_cast<idDebris *>(ent); // error 4a
//RPS debris = static_cast<idMoveable *>(ent); // error 4b
debris->Create( this, physicsObj.GetOrigin(), dir.ToMat3() );
debris->Launch();
//RPS debris->GetRenderEntity()->shaderParms[ SHADERPARM_TIME_OF_DEATH ] = ( gameLocal.time + 1500 ) * 0.001f;
debris->UpdateVisuals();

}
kv = spawnArgs.MatchPrefix( "def_debris", kv );
}

physicsObj.PutToRest();
CancelEvents( &EV_Explode );
CancelEvents( &EV_Activate );

f = spawnArgs.GetFloat( "respawn" );
if ( f > 0.0f ) {
PostEventSec( &EV_Respawn, f );
} else {
PostEventMS( &EV_Remove, 5000 );
}

if ( spawnArgs.GetBool( "triggerTargets" ) ) {
ActivateTargets( this );
}
}

error 1: you declared debris to be of the type idMoveable* but commented it out and left it like it originally was
error 2: you modifed the type check to check for idMoveable::Type but comment it out and left it like it origionally was
error 3: you did not update the error message that you just saw printed to better reflect the changes you intended to make
error 4: you commented out the static_cast to type idMoveable* but commented it out

Your code still behaves like it did before you modified it, and the code did exactly what it was supposed to.

spamclark15

  • id Enthusiast
  • Jr. Member
  • **
  • Posts: 95
  • Karma: +10/-3
  • A missile-launching skyscraper with goat legs.
    • View Profile
Re: Game Code That Removes idDebris
« Reply #16 on: June 22, 2017, 01:30:26 AM »
I'm not sure if I wanted to mark the changed lines and put the comment on the wrong side or if I wanted to go back to original behavior for some reason... It has a couple of unresolved symbols in class idMoveable, Create and Launch, and I'm not sure if they're added to the wrong place in Moveable.h:

Code: [Select]
class idMoveable : public idEntity {
public:
CLASS_PROTOTYPE( idMoveable );

idMoveable( void );
~idMoveable( void );

void Spawn( void );

void Create( idEntity *owner, const idVec3 &start, const idMat3 &axis ); //RPS
void Launch( void ); //RPS
void Fizzle( void ); //RPS

Code: [Select]
error LNK2019: unresolved external symbol "public: void __thiscall idMoveable::Launch(void)" referenced in function "public: virtual void __thiscall idExplodingBarrel::Killed(class idEntity *,class idEntity *,int,class idVec3 const &,int)"

error LNK2019: unresolved external symbol "public: void __thiscall idMoveable::Create(class idEntity *,class idVec3 const &,class idMat3 const &)" referenced in function "public: virtual void __thiscall idExplodingBarrel::Killed(class idEntity *,class idEntity *,int,class idVec3 const &,int)"


Phrozo

  • Mr. Phrozo
  • Jr. Member
  • **
  • Posts: 89
  • Karma: +15/-1
  • :3
    • View Profile
    • Mod Page
Re: Game Code That Removes idDebris
« Reply #17 on: June 22, 2017, 02:00:40 AM »
That is the right place to declare members for class idMoveable, but you still need to define the methods in idMoveable.cpp

spamclark15

  • id Enthusiast
  • Jr. Member
  • **
  • Posts: 95
  • Karma: +10/-3
  • A missile-launching skyscraper with goat legs.
    • View Profile
Re: Game Code That Removes idDebris
« Reply #18 on: June 22, 2017, 02:45:28 AM »
Getting angry yet? The whole reason I asked for help is because this is alien to me.

I added idDebris::Launch and idDebris::Fizzle as idMoveable::Launch and idMoveable::Debris from Projectile.cpp into Moveable.cpp and added EV_Fizzle under the CLASS_DECLARATION as it showed an error about that, and now EV_Fizzle is listed as an undeclared identifier and Event_Fizzile not a member of idMoveable, added EV_Fizzle as a constant at the top of idMoveable from idProjectile and Event_Fizzle in Moveable.h under 'protected:' where the rest of the Event_ lines are listed as

void               Event_Fizzle( void );

and now running into protected: void __thiscall idMoveable:Event_Fizile(void)* and public: void __thiscall idMoveable::Create as unresolved symbols.

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 852
  • Karma: +41/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Game Code That Removes idDebris
« Reply #19 on: June 22, 2017, 08:02:54 AM »
Is it possible to not use the debris or C++ code at all and attach a script to the barrel def that spawns and throws out func_movables?

spamclark15

  • id Enthusiast
  • Jr. Member
  • **
  • Posts: 95
  • Karma: +10/-3
  • A missile-launching skyscraper with goat legs.
    • View Profile
Re: Game Code That Removes idDebris
« Reply #20 on: June 22, 2017, 10:44:56 AM »
I'm just trying to do what I need to do however it takes to get this working. Coding is not something I know but then none of the details of the game I know very well which is why I asked for help.

Phrozo

  • Mr. Phrozo
  • Jr. Member
  • **
  • Posts: 89
  • Karma: +15/-1
  • :3
    • View Profile
    • Mod Page
Re: Game Code That Removes idDebris
« Reply #21 on: June 22, 2017, 11:11:49 AM »
What you want requires refactoring the code which is not a small task, so it is essential you understand what you are doing. Most of your errors are from declaring a function in the class definition but not later defining it. Again, you need to define idMoveable:Event_Fizzle( void ) and idMoveable::Create( idEntity *owner, const idVec3 &start, const idMat3 &axis ). If you don't know the difference between a declaration and a definition you really should consider picking up a beginners book in C++.

I also took a second look at this problem and you also need to define events which I'm not sure how well they work. In all honesty this is not the right approach. Modify idDebris or try THF's new idea...

spamclark15

  • id Enthusiast
  • Jr. Member
  • **
  • Posts: 95
  • Karma: +10/-3
  • A missile-launching skyscraper with goat legs.
    • View Profile
Re: Game Code That Removes idDebris
« Reply #22 on: June 22, 2017, 12:57:21 PM »
Alright, moveables.def contains the 4 pieces of debris, what is involved?