Seriously!

Go Back   Seriously! Forums > Serious Sam Series > Serious Sam Classic > Serious Sam Classic Workshop > Serious Sam Classic SDK

Serious Sam Classic SDK Discuss coding ideas & problems or show tutorials and code snippets.

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 06-30-2013, 12:23 AM   #1   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Get weapon to fire a beam

Hello I am having trouble trying to get my weapon to fire a beam. I tried using the ghost buster's ray but the projectile is frozen when i fire it, so I did it this way where it fires a laser beam - but it crashes serious sam.

Code:
void FireBeamWeapon (FLOAT fX, FLOAT fY, FLOAT fRange, FLOAT fDamage, FLOAT fJitter, FLOAT fBulletSize)
  {
    fJitter*=fRange;  // jitter relative to range
    PrepareBullet(fX, fY, fDamage);
    ((CBullet&)*penBullet).CalcTarget(fRange);
    ((CBullet&)*penBullet).m_fBulletSize = fBulletSize;
    ((CBullet&)*penBullet).CalcJitterTarget(fJitter);
    ((CBullet&)*penBullet).LaunchBullet(TRUE, FALSE, TRUE);
    ((CBullet&)*penBullet).DestroyBullet();

		FLOATmatrix3D m;
		FLOAT m_fBeamTarget;
		m_fBeamTarget = fJitter;

		CPlacement3D plPlayer, plProjectile;
		CalcWeaponPosition(FLOAT3D(wpn_fFX[WEAPON_RAILDRIVER],wpn_fFY[WEAPON_RAILDRIVER], 0), plProjectile, TRUE);

		plPlayer = GetLerpedPlacement();
		MakeRotationMatrix(m, plPlayer.pl_OrientationAngle);

		FLOAT3D vSource =  plPlayer.pl_PositionVector;
		Particles_PUGLaser(GetPlayerEntity(iPlayer), vSource, fRange);



  };
I tried to use the exotech lava's laser beam method but it wouldn't work. Is they're anything wrong with this code?

The Particles_PUGLaser has a couple of issues in it.

Or can someone give me instructions to how to activate the ghost busters beam for my particle gun?
thanks
  Reply With Quote
Old 06-30-2013, 06:14 AM   #2   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
 
Scratch's Avatar
 
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
 
Scratch is offline
Default Re: Get weapon to fire a beam

Code:
Particles_PUGLaser(GetPlayerEntity(iPlayer), vSource, fRange);
I'm suspecting something here is going wrong. GetPlayerEntity(iPlayer) might not return the right entity? What is iPlayer? I don't see it defined anywhere in PlayerWeapons.es.

Maybe you should post the source code for Particles_PUGLaser, too.

Why not just do this? m_penPlayer is the player that owns the CPlayerWeapons.

Code:
Particles_PUGLaser(m_penPlayer, vSource, fRange);
Or maybe you have to do this, I don't know what your function takes: (m_penPlayer is a CEntityPointer)

Code:
Particles_PUGLaser((CPlayer*)&*m_penPlayer, vSource, fRange);
__________________
I'm a cat by the way. I'm also everyone's most hated critic.
(Opinions expressed are my own)

Nimble Writer - now available on Steam, Itch.io.
CodeCat, my blog that I need to update - I also have a showcase, which I barely update.
(I do not respond to PM's about Serious Sam Revolution or Bogus Detour. Please use the appropriate community hubs for that.)
  Reply With Quote
Old 06-30-2013, 07:32 AM   #3   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: Get weapon to fire a beam

Thank you for the fix

Here are source code:


Particles.h
Code:
void DECL_DLL Particles_PUGLaser(CEntity *pen, FLOAT3D vSource, FLOAT3D vTarget);
Particles.cpp
Code:
void Particles_PUGLaser(CEntity *pen, FLOAT3D vSource, FLOAT3D vTarget)
{
  Particle_PrepareTexture(&_toPUGLaser, PBT_ADD);
  Particle_SetTexturePart( 512, 512, 0, 0);
  
  COLOR colColor;
  FLOAT3D vMid;
  
  vMid = (vSource - vTarget).Normalize();
  vMid = vTarget + vMid * 2.5f;

  colColor = C_BLUE|0xff;
  Particle_RenderLine( vSource, vMid, 0.5f, colColor);
  Particle_RenderLine( vMid, vTarget, 0.5f, colColor);
  
  Particle_Flush();

  // begin-end flares
  Particle_PrepareTexture(&_toWater, PBT_ADDALPHA);
  Particle_SetTexturePart( 512, 512, 0, 0);
  Particle_RenderSquare( vSource, 0.5, 0.0f, colColor);
  Particle_RenderSquare( vTarget, 0.5, 0.0f, colColor);
  Particle_Flush();
  
}
This is based much off the Exotech larva laser (since that's the only enemy that fires a instant-hit laser).

I'm not sure if this works. It keeps crashing the game when I fire the weapon. :/
I hope to achieve the same effect as if the EXOTECH LARVA BOSS shoots a red laser at the player, except it's the player that shoots the laser at the target.

I'm not too sure about the target if it's correct. But I'm pretty sure the source is okay.

Last edited by Buzzy; 06-30-2013 at 07:34 AM.
  Reply With Quote
Old 06-30-2013, 07:53 AM   #4   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
 
Scratch's Avatar
 
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
 
Scratch is offline
Default Re: Get weapon to fire a beam

A few things:

Are you sure _toPUGLaser is set to a texture?

You're not using pen at all in Particles_PUGLaser. Why bother even passing it?

Why are you giving a float value as argument to a 3D vector? (FLOAT3D) Doing that will cause the vector to have that float (fRange) on all axes, which is definitely not what you want.
__________________
I'm a cat by the way. I'm also everyone's most hated critic.
(Opinions expressed are my own)

Nimble Writer - now available on Steam, Itch.io.
CodeCat, my blog that I need to update - I also have a showcase, which I barely update.
(I do not respond to PM's about Serious Sam Revolution or Bogus Detour. Please use the appropriate community hubs for that.)

Last edited by Scratch; 06-30-2013 at 07:58 AM.
  Reply With Quote
Old 07-01-2013, 03:23 AM   #5   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: Get weapon to fire a beam

Yes the texture is fine (it exists).

Is not using a pen or something causing the game to crash?

The float arguement (fRange) - that one i'm not sure if that value controls where you aim your weapon. Basically, i'm trying to find the variable used to where you point your gun (about the crosshair).

All I want is something like a beam, or if there's a way to 'activate' and use the ghost busters beam then i'll like to use it.
  Reply With Quote
Old 07-01-2013, 10:19 AM   #6   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
 
Scratch's Avatar
 
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
 
Scratch is offline
Default Re: Get weapon to fire a beam

You'll need a bit more programming experience to get the ghostbuster code to work, but it's definitely doable.

The direction in which the bullet goes is done by:

Code:
((CBullet&)*penBullet).CalcTarget(fRange);
You could write similar code from that function to position the laser:

Code:
  // calc jitter target
  void CalcTarget(FLOAT fRange) {
    // destination in bullet direction
    AnglesToDirectionVector(GetPlacement().pl_OrientationAngle, m_vTarget);
    m_vTarget *= fRange;
    m_vTarget += GetPlacement().pl_PositionVector;
    m_vTargetCopy = m_vTarget;
  };
Also check out void PostMoving(void) in CGhostBusterRay:

Code:
  void PostMoving(void) {
    if (!IsOfClass(m_penOwner, "Player Weapons")) { return; }

    // from current owner position move away
    CPlacement3D plSource;
    ((CPlayerWeapons&)*m_penOwner).GetGhostBusterSourcePlacement(plSource);
    FLOAT3D vDirection, vDesired;
    AnglesToDirectionVector(plSource.pl_OrientationAngle, vDirection);
    vDesired = vDirection*HIT_DISTANCE;
    vDesired = plSource.pl_PositionVector + vDesired;

    // cast a ray to find if any brush is hit
    CCastRay crRay( ((CPlayerWeapons&)*m_penOwner).m_penPlayer, plSource.pl_PositionVector, vDesired);
    m_vSrcOld = m_vSrc;
    m_vSrc = plSource.pl_PositionVector;
    crRay.cr_bHitTranslucentPortals = FALSE;
    crRay.cr_ttHitModels = CCastRay::TT_COLLISIONBOX;
    GetWorld()->CastRay(crRay);

    // if hit anything set new position
    if (crRay.cr_penHit!=NULL) {
      vDesired = crRay.cr_vHit;
    }
    vDesired -= vDirection/10.0f;

    m_vDstOld = m_vDst;
    m_vDst = vDesired;

    // stretch model
    FLOAT fStretch = (plSource.pl_PositionVector - vDesired).Length();
    //GetModelObject()->mo_Stretch(3) = fStretch;
    GetModelObject()->mo_Stretch(3) = 0.001f;
    // set your new placement
    CPlacement3D plSet;
    plSet.pl_PositionVector = vDesired;
    plSet.pl_OrientationAngle = plSource.pl_OrientationAngle;
    SetPlacement(plSet);
    m_ctPasses++;
  };
__________________
I'm a cat by the way. I'm also everyone's most hated critic.
(Opinions expressed are my own)

Nimble Writer - now available on Steam, Itch.io.
CodeCat, my blog that I need to update - I also have a showcase, which I barely update.
(I do not respond to PM's about Serious Sam Revolution or Bogus Detour. Please use the appropriate community hubs for that.)

Last edited by Scratch; 07-01-2013 at 10:22 AM.
  Reply With Quote
Old 07-02-2013, 07:24 AM   #7   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: Get weapon to fire a beam

The post moving in ghost buster was the thing that was troubling me a lot before, that's why I switched to exotech larva laser method.
But when I compile the code it comes up with an error that says that "GetGhostBusterSourcePlacement" does not exist in CPlayerWeapons. I searched with "Find in files" and it cannot be found.

Is there an alternate way around this error or an alternate piece of code?

In the mean time I can see if I can get the laser NOT to crash the game.

I just need to get the laser to the point so that it does not crash and the source and target is right.
  Reply With Quote
Old 07-02-2013, 07:35 AM   #8   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: Get weapon to fire a beam

Crap! I deleted it! How dumb of me
At least I got the SDK 1.07 so I can re-add the stuff I deleted. Because before, I thought the ghost buster was left overs that did not work but it apparently ended up did. I'll see if it works later, and post here for any more issues.
  Reply With Quote
Old 07-02-2013, 12:45 PM   #9   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
 
Scratch's Avatar
 
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
 
Scratch is offline
Default Re: Get weapon to fire a beam

You should really try setting up the debugger so you can step through your code and see where it crashes.
__________________
I'm a cat by the way. I'm also everyone's most hated critic.
(Opinions expressed are my own)

Nimble Writer - now available on Steam, Itch.io.
CodeCat, my blog that I need to update - I also have a showcase, which I barely update.
(I do not respond to PM's about Serious Sam Revolution or Bogus Detour. Please use the appropriate community hubs for that.)
  Reply With Quote
Old 07-03-2013, 04:37 AM   #10   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: Get weapon to fire a beam

It's working now : the ghost buster on my particle weapon. Thank you angelo.
But anyway I debugged it before once and it was Particle_Flush causing all this terror.

Now changing the topic after I did that code I noticed strange things happening. Everytime I load a save game I saved, shells and bullets empty out - other weapons keep their amount. If i'm on easy mode, when I type give-all, bullets go to 500 not 999 ammo! But it starts off at 999 though. I also have two new ammo types and I don't know if it's causing it. I'll add another ammunition type too see what happens. Other than that does anybody know what is going on?
  Reply With Quote
Old 07-03-2013, 08:19 AM   #11   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
 
Scratch's Avatar
 
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
 
Scratch is offline
Default Re: Get weapon to fire a beam

You probably forgot something when adding the new ammo type. I hope you're familiar with the concept of bit masks
__________________
I'm a cat by the way. I'm also everyone's most hated critic.
(Opinions expressed are my own)

Nimble Writer - now available on Steam, Itch.io.
CodeCat, my blog that I need to update - I also have a showcase, which I barely update.
(I do not respond to PM's about Serious Sam Revolution or Bogus Detour. Please use the appropriate community hubs for that.)
  Reply With Quote
Old 07-03-2013, 08:30 AM   #12   Add To Ignore List  
bad avatar edition
 
T-ReXx's Avatar
 
Joined: Dec 2012
Location: Croatia
 
T-ReXx is offline
Default Re: Get weapon to fire a beam

I bet you're remaking the Ghostbuster
__________________
I'm T-ReXx, otherwise known as Solid Snake.
I used to mod the classic Sams but now I just shitpost. If you need to contact me for whatever reason, please use one of the apps listed on my Steam account (link above).

The hand has five fingers, capable and powerful,
with the ability to destroy as well as create.
Open your eyes, open your mouths,
Close your hands and make a fist.


22:06 - ♠T-ReXx: it's bain's amazing trap
22:06 - ♠Jetroid: Is it amazing?
22:06 - ♠T-ReXx: no
  Reply With Quote
Old 07-03-2013, 09:17 AM   #13   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: Get weapon to fire a beam

Not really, i'm just using the ghost buster's beam for a particle accelerator but i can add the ghost buster as well just don't have the model
  Reply With Quote
Old 07-05-2013, 12:52 AM   #14   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: Get weapon to fire a beam

Quote:
Originally Posted by Buzzy View Post
It's working now : the ghost buster on my particle weapon. Thank you angelo.
But anyway I debugged it before once and it was Particle_Flush causing all this terror.

Now changing the topic after I did that code I noticed strange things happening. Everytime I load a save game I saved, shells and bullets empty out - other weapons keep their amount. If i'm on easy mode, when I type give-all, bullets go to 500 not 999 ammo! But it starts off at 999 though. I also have two new ammo types and I don't know if it's causing it. I'll add another ammunition type too see what happens. Other than that does anybody know what is going on?
That strange issue of the shells and bullets being empty has been solved... weird...
  Reply With Quote
Old 07-05-2013, 03:57 AM   #15   Add To Ignore List  
</3
 
Mkbewe's Avatar
 
King of the Cathedral
Joined: Dec 2011
Location: Poland
 
Mkbewe is offline
Default Re: Get weapon to fire a beam

Are You create new mod with ghostbuster?
  Reply With Quote
Old 07-05-2013, 04:51 AM   #16   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: Get weapon to fire a beam

No, not really I'm just using the ghost buster's beam for a particle weapon.

Anyways I don't have the ghost buster model.
  Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Under Fire RiZlA Serious Sam Classic Mods 64 02-19-2002 03:22 PM


All times are GMT -4. The time now is 08:38 AM.