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-06-2014, 11:51 PM   #1   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default black hole weapon

Hi guys
I was planning to make a projectile that acts like a black hole and sucks nearby objects into it, damage and kill it. I am using the GiveImpulseTranslationAbsolute function. Currently the player gets sucked into the projectile fine. It's the enemy that doesn't really work.
I use the variable m_penLauncher or m_penEnemy to suck the player up. However, i am trying to make it get the enemy. I made a new variable called m_penThisEnemy (to supposedly grab the enemy's coordinates).

Here is the code I made:

Code:
class CEnemyBase *GetEnemy(void)
{
      ASSERT (m_penThisEnemy!=NULL);
      return (CEnemyBase*)&*m_penThisEnemy;
}
But I don't know why the enemy isn't getting sucked into the projectile. Or unless there is an already predefined code I could use that if the enemy goes near this projectile, it sucks the enemy up.

For anyone who is expierenced at coding could help me please?
  Reply With Quote
Old 06-07-2014, 09:42 AM   #2   Add To Ignore List  
Awww
 
SLAwww's Avatar
 
Joined: Apr 2005
Location: Kiev, Ukraine
 
SLAwww is offline Send a message via ICQ to SLAwww
Default Re: black hole weapon

Wait, let's break this up into parts. First, the projectile gets shot. And then what? Does it suck in enemies while flying, or does it create a black hole when touched the wall?
  Reply With Quote
Old 06-07-2014, 11:01 AM   #3   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
 
Scratch's Avatar
 
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
 
Scratch is offline
Default Re: black hole weapon

You could always step into the code and see if GiveImpulseTranslationAbsolute is ever being called on enemies..
__________________
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-07-2014, 10:13 PM   #4   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: black hole weapon

It works for the player. I shot it and it worked just like a grappling hook. Now all I need is to apply to enemies, but i am having trouble creating an entity pointer for the enemy. I know the function "3 CEntityPointer m_penEnemy" points towards the player. I dont know if i am doing anything wrong or not.

Code (I know it's based off someone elses code from this forum-the grappling hook)

Code:
if (m_penThisEnemy!=NULL) {

FLOAT3D Enemy_Dist;
Enemy_Dist = (GetEnemy()->m_penMe)->GetPlacement().plPositionVector - GetPlacement().pl_PositionVector;
Enemy_Dist *= -1;
((CMovableEntity*)(CEntity *) GetEnemy()->m_penMe)->GiveImpulseTranslationAbsolute ((Enemy_Dist)); }

m_penThisEnemy is a pointer that I wrote earlier and exists in Projectile.es

m_penMe is the enemy's pointer that exists in EnemyBase.es. It has same code as before but changed to m_penMe. It's function is also named GetEnemy.

The script compiles, the game loads but the enemies getting attracted to the projectile doesn't.

All I just need to know is how to point to an enemy properly.

Both EnemyBase and Projectile are used nothin else.

But thanks for reply.
  Reply With Quote
Old 06-08-2014, 07:10 AM   #5   Add To Ignore List  
Awww
 
SLAwww's Avatar
 
Joined: Apr 2005
Location: Kiev, Ukraine
 
SLAwww is offline Send a message via ICQ to SLAwww
Default Re: black hole weapon

You didn't reply neither to my question nor to Angelo's advice, so I'll repeat them:
1) Is the "black hole" projectile supposed to suck in entities while it's flying?
2) Did you try debugging your code?
  Reply With Quote
Old 06-08-2014, 06:34 PM   #6   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: black hole weapon

Debug - how do you debug the code I haven't tried this yet. And the black-hole is only suppose to suck the enemy when it hits the wall. That's all the code is. So when it hits the wall (and explodes) it should create a sucking effect.
  Reply With Quote
Old 06-09-2014, 06:19 AM   #7   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
 
Scratch's Avatar
 
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
 
Scratch is offline
Default Re: black hole weapon

You get debug binaries with the SDK, just build with debug (link to those debug libraries instead). Then just set breakpoints and hit them. That also makes the assertions actually do stuff, instead of just sit there.
__________________
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-09-2014, 08:53 AM   #8   Add To Ignore List  
Awww
 
SLAwww's Avatar
 
Joined: Apr 2005
Location: Kiev, Ukraine
 
SLAwww is offline Send a message via ICQ to SLAwww
Default Re: black hole weapon

In fact, you don't even have to do that if you're lazy, just hit Debug - Attach to process and attach to SeriousEditor.exe or SeriousSam.exe, then open your .es file and put breakpoints.
  Reply With Quote
Old 06-09-2014, 09:04 AM   #9   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
 
Scratch's Avatar
 
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
 
Scratch is offline
Default Re: black hole weapon

Uh.. debugging release binaries? That will cause lots of optimization problems.
__________________
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-09-2014, 09:21 AM   #10   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: black hole weapon

Okay. I got the debugger attached to Serious sam, and it comes with the Disassembly. I suppose i load (e.g. projectile.es) and add the breakpoint to the line i want to debug (in which case the code i supplied above). It gets to that part and crashes (in which case is frozen). Now I know to put it in window not fullscreen. So it came up with the information i needed so I'll look through the details and post any updates.
This is actually first time I successfully debugged serious sam; other times i didn't
  Reply With Quote
Old 06-09-2014, 09:37 AM   #11   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: black hole weapon

Actually I found the snippet:

m_penThisEnemy

ep_pen is set to 0x00.




Also, To define the enemy, I use:

Quote:
CEnemyBase &pl = (CEnemyBase&)*m_penThisEnemy;
But it's saying it's part of CEntity?! and not CEnemyBase??

Last edited by Buzzy; 06-09-2014 at 11:35 AM.
  Reply With Quote
Old 06-09-2014, 09:53 AM   #12   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
 
Scratch's Avatar
 
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
 
Scratch is offline
Default Re: black hole weapon

Well... no... you know m_penLauncher is actually set, right..? You have to set m_penThisEnemy somewhere too.
__________________
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-09-2014, 11:44 AM   #13   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: black hole weapon

I updated code:

Code:
CEnemyBase &pl = (CEnemyBase&)*m_penThisEnemy

if (m_penThisEnemy!=NULL) {

FLOAT3D Enemy_Dist;
Enemy_Dist = m_penThisEnemy->GetPlacement().plPositionVector - GetPlacement().pl_PositionVector;
Enemy_Dist *= -1;
((CMovableEntity*)(CEntity *) m_penThisEnemy)->GiveImpulseTranslationAbsolute ((Enemy_Dist)); }
Result? No enemies sucked in. It means that m_penThisEnemy is 0 right now. But I need to know a way to set CEnemyBase to m_penThisEnemy.
  Reply With Quote
Old 06-09-2014, 12:16 PM   #14   Add To Ignore List  
Awww
 
SLAwww's Avatar
 
Joined: Apr 2005
Location: Kiev, Ukraine
 
SLAwww is offline Send a message via ICQ to SLAwww
Default Re: black hole weapon

Angelo, it's perfectly fine to debug the release binaries. In fact, you can only test your optimization quality in release.
Buzzy, I don't get how you're trying to acquire an enemy pointer. Normally, all you'd need to do is check penOther pointer in ETouch event when it's received.
  Reply With Quote
Old 06-09-2014, 12:20 PM   #15   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: black hole weapon

I will attempt to check the penOther see what happens to the enemy. Also penLauncher works for player or enemy so I don't know if that will work (by seeing where it gets the enemy from; what code). But I will see how it goes..
  Reply With Quote
Old 06-09-2014, 12:24 PM   #16   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
 
Scratch's Avatar
 
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
 
Scratch is offline
Default Re: black hole weapon

Quote:
Originally Posted by SLAwww View Post
Angelo, it's perfectly fine to debug the release binaries. In fact, you can only test your optimization quality in release.
Well yes, but you'll only be able to debug your compiled dll's if you actually built them against debug is what I'm saying.
__________________
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-09-2014, 01:02 PM   #17   Add To Ignore List  
Awww
 
SLAwww's Avatar
 
Joined: Apr 2005
Location: Kiev, Ukraine
 
SLAwww is offline Send a message via ICQ to SLAwww
Default Re: black hole weapon

Normally yes, but for some reason SE1 DLLs can be debugged fine even when they're built for "Release".
  Reply With Quote
Old 06-09-2014, 02:11 PM   #18   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
 
Scratch's Avatar
 
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
 
Scratch is offline
Default Re: black hole weapon

Quote:
Originally Posted by SLAwww View Post
Normally yes, but for some reason SE1 DLLs can be debugged fine even when they're built for "Release".
Well they certainly can't when they're built with MSVC10, so I guess VC6 optimization sucked ass
__________________
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-09-2014, 02:19 PM   #19   Add To Ignore List  
Awww
 
SLAwww's Avatar
 
Joined: Apr 2005
Location: Kiev, Ukraine
 
SLAwww is offline Send a message via ICQ to SLAwww
Default Re: black hole weapon

It appears that Rev binaries were built with debug information as well.
  Reply With Quote
Old 06-09-2014, 07:33 PM   #20   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: black hole weapon

Hi again,
I came up with another code that assumably works; as I tried all other options (penOther), but this seems to work:

Code:
{FOREACHINDYNAMICCONTAINER(m_penLauncher->GetWorld()->wo_cenEntities, CEntity, iten) {
    CEntity *pen = iten;

	 if (IsDerivedFromClass(pen, "Enemy Base")) {
		CEnemyBase *penEnemy = (CEnemyBase *)pen;

	
FLOAT3D Enemy_Dist;
Enemy_Dist = penEnemy->GetPlacement().plPositionVector - GetPlacement().pl_PositionVector;
Enemy_Dist *= -1;
((CMovableEntity*)(CEntity *)penEnemy)->GiveImpulseTranslationAbsolute ((Enemy_Dist)); }	

			}
	 }

	}}
The game has FINALLY picked up the enemy's code and recognized it. I used it on the blackhole gun projectile. Nothing. But I used it on my other heat seeking rocket (based off the beast's heat seeking projectile code), and the projectiles followed the enemy and the targetting worked, so I know that part is right (penEnemy).

I'm not too sure if GiveImpulseTranslationAbsolute works on an enemy though; i'm still trying to figure it out.
  Reply With Quote
Old 06-10-2014, 03:04 AM   #21   Add To Ignore List  
Awww
 
SLAwww's Avatar
 
Joined: Apr 2005
Location: Kiev, Ukraine
 
SLAwww is offline Send a message via ICQ to SLAwww
Default Re: black hole weapon

That's actually a bad decision. The code you posted will iterate through all the entities in the world, which might harm the framerate when there's a large amount of such projectiles. Instead, inflict a range damage when your projectile hits the wall, then check the penInflictor in ReceiveDamage method of the Enemy Base class and push that enemy towards the projectile, though I'm not entirely sure that range damage doesn't iterate through all the entities as well. You may also try using FakeJump instead of GiveImpulseTranslationAbsolute.
  Reply With Quote
Old 06-10-2014, 06:02 AM   #22   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
 
Scratch's Avatar
 
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
 
Scratch is offline
Default Re: black hole weapon

Why not just send an event in range?
__________________
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-10-2014, 06:08 AM   #23   Add To Ignore List  
Awww
 
SLAwww's Avatar
 
Joined: Apr 2005
Location: Kiev, Ukraine
 
SLAwww is offline Send a message via ICQ to SLAwww
Default Re: black hole weapon

That's basically the same thing. Range damage is equal to sending EDamage in range, isn't it?
  Reply With Quote
Old 06-10-2014, 06:12 AM   #24   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
 
Scratch's Avatar
 
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
 
Scratch is offline
Default Re: black hole weapon

Yes, except then you can send your own event such as ESuckIntoBlackHole or something, which is much clearer..
__________________
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-10-2014, 06:24 AM   #25   Add To Ignore List  
Awww
 
SLAwww's Avatar
 
Joined: Apr 2005
Location: Kiev, Ukraine
 
SLAwww is offline Send a message via ICQ to SLAwww
Default Re: black hole weapon

I presume a projectile should be damaging all live entities, including ModelHolders, brushes etc. That's why I recommended using range damage. In this way, everyone who doesn't get sucked into the black hole can still be damaged by it.
  Reply With Quote
Old 06-10-2014, 06:31 AM   #26   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
 
Scratch's Avatar
 
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
 
Scratch is offline
Default Re: black hole weapon

Fair enough, that might be a sensible solution then, depending on what you want. I am imagining a black hole where enemies get sucked into and just disappear, lol
__________________
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-10-2014, 06:33 AM   #27   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: black hole weapon

Im not sure if it does affect modelholders, etc, as the pen links to the enemy base. Anyway I haven't heard of fake jump before, though i'll skim through the sdk for an example and then replicate it for this. I will find a function that affects enemies within range.
  Reply With Quote
Old 06-10-2014, 06:35 AM   #28   Add To Ignore List  
🐱 Kitty 💘💙💚💛💜
 
Scratch's Avatar
 
Crackshell Developer
Joined: May 2007
Location: Heiloo, Netherlands
 
Scratch is offline
Default Re: black hole weapon

FakeJump is what is used to make enemies and players jump on bouncers and does quite a few different things when compared to GiveImpulse. I suggest experimenting
__________________
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-10-2014, 06:37 AM   #29   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: black hole weapon

Ah Thank you guys
I think i will look into the bouncer for the code and then test it out / experiment. I will post of any changes
  Reply With Quote
Old 06-11-2014, 05:35 AM   #30   Add To Ignore List  
The Purple Cat
 
Buzzy's Avatar
 
Joined: Dec 2008
 
Buzzy is offline
Default Re: black hole weapon

I was mucking around with the other function beforehand before i try fakejump (GiveImpulse...) one, it apparantly pushes enemies back really far. So this means that as the projectile hits the enemy, because the enemy follows it for a while, it drags them back probably but that effect was really strange. I'll see if that works when it's fired, otherwise I'll try fakejump. I'm not sure if i need to use fakejump or just the entire jumpfrombouncer code piece..
  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


All times are GMT -4. The time now is 07:36 PM.