Seriously!
Go Back   Seriously! Forums > Gaming > 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 07-31-2002, 09:25 AM   #1   Add To Ignore List  
T-Mech
 
zaWasp's Avatar
 
Joined: Mar 2002
Location: Timisoara, Romania
 
zaWasp is offline Send a message via ICQ to zaWasp
Default Problem with events

'ello... ummm, I have some problems sending events, or maybe capturing them right. here's what I've done:

in an entity, I defined this event:

Code:
event ETest {};


..............
class CTest : CMovableModelEntity {
name      "Test";
..............
then, in main

Code:
Main() {


//initialize model here

  wait() {
    on (EBegin) : {
      resume;
      }
    on (ETest) : {
      CPrintF("Test event received\n"); //DEBUG: Event succesfully received
      resume;
      }
    otherwise() : { resume };
    
    }

  return;
}
then I defined a control in Player.es; it's press function is here:
Code:
  {FOREACHINDYNAMICCONTAINER(((CEntity&)*this).GetWorld()->wo_cenEntities, CEntity, iten) {
      CEntity *pen = iten;
      if (IsDerivedFromClass(pen, "Test")) {
      CPrintF("Got Test entity!\n");  //DEBUG: To see if we got the entity right
      CTest &penTest = (CTest&)*pen;
      penTest.SendEvent(ETest());
	  }
    }}
This gets the Test entity right (it prints "Got Test entity"). However the test event is not received (or sent properly).

Any ideas would be appreciated.
__________________
Mircea "zaWasp" Rila
Co-founder / Lead Programmer
Defensive Games
www.defensivegames.com
  Reply With Quote
Old 07-31-2002, 10:03 AM   #2   Add To Ignore List  
untitled.
 
Hollywood's Avatar
 
Joined: Aug 2001
Location: Australia
 
Hollywood is offline Send a message via MSN to Hollywood
Default

your etest entity... never receives an event called etest does it? so how would it print your cool message?
__________________
Tres.
  Reply With Quote
Old 07-31-2002, 03:41 PM   #3   Add To Ignore List  
T-Mech
 
zaWasp's Avatar
 
Joined: Mar 2002
Location: Timisoara, Romania
 
zaWasp is offline Send a message via ICQ to zaWasp
Default

exactly my point. it doesn't print my cool message
although I've sent the event => SendEvent(ETest())

I think there's something wrong with the way I sent it. I tried different ways, like

Code:
ETest eTest;
penTest->SendEvent(eTest);
or in the wait loop of the entity, I tried to change it to:

Code:
on (ETest eTest) : {
}
...but it still doesn't work... and it drives me insane, because I've done it like in other entities

I must be exhausted, because I know I'm missing something...
__________________
Mircea "zaWasp" Rila
Co-founder / Lead Programmer
Defensive Games
www.defensivegames.com

Last edited by zaWasp; 07-31-2002 at 03:43 PM.
  Reply With Quote
Old 07-31-2002, 07:45 PM   #4   Add To Ignore List  
untitled.
 
Hollywood's Avatar
 
Joined: Aug 2001
Location: Australia
 
Hollywood is offline Send a message via MSN to Hollywood
Default

oobies, i was tired when i answered this...

um...

i always get confused with pointers to references and references of pointers, and all the other combinations...

and your situation is puzzling...

you have this:
Code:
CTest &penTest = (CTest&)*pen;

penTest.SendEvent(ETest());
maybe just this?
Code:
((CTest&)*pen).SendEvent(ETest());
__________________
Tres.
  Reply With Quote
Old 05-05-2003, 03:30 PM   #5   Add To Ignore List  
Kleer
 
Aldaris's Avatar
 
Joined: Mar 2003
Location: Québec
 
Aldaris is offline
Default

I have a problem too with events...

I've created an entity, but it don't seems to react to any events.... basicly, I want it to execute some code when the user press the use button, like a switch. My code is almost similar to the switch, but it doesn't work... is there something special to do to receive events??

thanx

- Aldaris
__________________
"If it jams - force it. If it breaks, it needed replacing anyway!!! "

"If at first you don't suceed, destroy all evidences that you tried."
  Reply With Quote
Old 05-07-2003, 04:02 AM   #6   Add To Ignore List  
Witch Bride
 
gone_motard's Avatar
 
Joined: Aug 2002
 
gone_motard is offline
Default

Here... try this aldaris. This is how you set up the event loop. To test this class, i put some code at the end of the TeleportPlayer function in player.es (code at bottom of page). All it does is every time i respawn, it sends a ETutorialEvent to any
CTutorialObject that's in the worldbase. You'll see if you get this to run that it sends the event properly (it gets sent everytime you respawn).

what's crazy with zaWasp's problem was that his code looked fine to me (except there was an extra parentheses in the FOREACHITEMINCONTAINER thingy). i think what his problem was is that Main doesn't get called from in game, it gets called when you drag a new object into your world base from SEd. This is the stuff that basically gets saved in your WLD file, and if you change it, you have to resave your world.

Here's an example:
1.) Make a level and add a CMarker into your world close by.
2.) Edit CMarker code in Main and replace InitAsEditorModel() with
InitAsModel().
3.) Run your level in game (not from SEd).
4.) Notice your Marker still isn't visible!
5.) Now open your level in SEd and resave.
6.) Run your level in game (not from SEd).
7.) Hey, your marker is visible!

So maybe your events aren't being processed because the states aren't in the WLD file becase you added events to your class objects that are in game after you had already built your level!


//
// TutorialEvent.es
//
1000
%{
#include "StdH.h"
%}

event ETutorialEvent {
CEntityPointer entity,
};

%{

%}

class export CTutorialObject : CMovableModelEntity {
name "Tutorial Object";
thumbnail "Thumbnails\\Marker.tbn";
features "HasName";

properties :

1 CTString m_strName "Name" 'N' = "Tutorial Object",
2 CTString m_strDescription = "",

components :

1 model MODEL "Models\\Editor\\Axis.mdl",
2 texture TEXTURE "Models\\Editor\\Vector.tex",

functions :

const CTString &GetDescription(void)const
{
((CTString&)m_strDescription).PrintF("-><none>");
return m_strDescription;
}
SLONG GetUsedMemory(void)
{
SLONG slUsedMemory = sizeof(CMovableModelEntity) - sizeof(CEntity) + CEntity::GetUsedMemory();
slUsedMemory += m_strName.Length();
slUsedMemory += m_strDescription.Length();
return slUsedMemory;
}

procedures :

TutorialEvent(ETutorialEvent emsg)
{
CEntityPointer entity = emsg.entity;
CPrintF("Event received from entity %s\n.", entity->GetName());
return;
}

Main(EVoid)
{
InitAsEditorModel();
SetPhysicsFlags(EPF_MODEL_IMMATERIAL);
SetCollisionFlags(ECF_IMMATERIAL);
SetModel(MODEL);
SetModelMainTexture(TEXTURE);

autowait(0.1f);

wait() {
on(EBegin) : { resume; }
on(ETutorialEvent emsg) : {
call TutorialEvent(emsg);
resume;
}
on(EEnd) : { stop; }
}

// cease to exist
Destroy();
return;
}

};

//
// TeleportPlayer (from Player.es)
//
TeleportPlayer(...)
{
// ...
// ...

// send an event to all entities
{
FOREACHINDYNAMICCONTAINER(this->GetWorld()->wo_cenEntities, CEntity, iten)
{
CEntity* pen = iten;
if(IsOfClass(pen, "Tutorial Object")) {
ETutorialEvent emsg;
emsg.entity = this;
CTutorialObject* ptr = (CTutorialObject*)pen;
ptr->SendEvent(emsg);
}
}

Last edited by gone_motard; 05-07-2003 at 04:15 AM.
  Reply With Quote
Old 05-07-2003, 12:36 PM   #7   Add To Ignore List  
Kleer
 
Aldaris's Avatar
 
Joined: Mar 2003
Location: Québec
 
Aldaris is offline
Default

Thanx!

I found after 1 week of hard working that the problem wasn't in my entity, but in player.es cause my entity is a modified switch and if I want the USE button to recognise the switch, I had to add some code. You have to add some code in playerweapon too if you want to see a message appear when you're near the switch.

Now it works fine, but I got another problem:
I've created a class in game.h for the game properties of my mod, it's created and initialized when a new game is started, but now I need to get these values from my switch entity... I've checked a lot the way CSessionProperties works, but there's one thing I can't do 'cause it's in network.h, and I can't modify that file since I don't have all the sources...

So I need another way to get these values...can someone help me!!!??

- Aldaris
__________________
"If it jams - force it. If it breaks, it needed replacing anyway!!! "

"If at first you don't suceed, destroy all evidences that you tried."

Last edited by Aldaris; 05-07-2003 at 12:42 PM.
  Reply With Quote
Old 05-07-2003, 03:35 PM   #8   Add To Ignore List  
Witch Bride
 
gone_motard's Avatar
 
Joined: Aug 2002
 
gone_motard is offline
Default

*cough cough...
uhm... that's what the keywork "extern" is for
*cough cough...
so that variables can cross the 3 DLLs. you can also use the persistent object table (which is used to store cheat codes and allows you to change values of game properties through the HUD.

// game.h
class CMyGameProperties {};
extern CMyGameProperties* game_props;

// game.cpp
game_props = 0;

// when game loads
game_props = new CMyGameProperties;
//when game finishes
delete game_props;
game_props = 0;

and game_props should be visible in your switch if you include your game props header.
  Reply With Quote
Old 05-09-2003, 09:25 AM   #9   Add To Ignore List  
Kleer
 
Aldaris's Avatar
 
Joined: Mar 2003
Location: Québec
 
Aldaris is offline
Default

Thanx!!!

I'm surely stupid, but it doesn't work..
In game.h I wrote:

class CPropertiesLFDT {
public:
BOOL bLanding_Sas1;
BOOL bLanding_Sas2;
BOOL bLanding_Sas3;
BOOL bLanding_Sas4;
BOOL bLanding_Sas5;

INDEX iPosGrue;
};


extern CPropertiesLFDT* gameProperties;


and I don't see my gameProperties variable in game.cpp....


__________________
"If it jams - force it. If it breaks, it needed replacing anyway!!! "

"If at first you don't suceed, destroy all evidences that you tried."

Last edited by Aldaris; 05-09-2003 at 01:00 PM.
  Reply With Quote
Old 05-09-2003, 03:59 PM   #10   Add To Ignore List  
Witch Bride
 
gone_motard's Avatar
 
Joined: Aug 2002
 
gone_motard is offline
Default

something like #include "directory\Game.h" usually works
but try adding ENGINE_API at the beggining. the variable won't
be exportable (and visible across DLLs) if you don't export it.

ENGINE_API extern CPropertiesLFDT* gameProperties;
  Reply With Quote
Old 05-12-2003, 09:53 AM   #11   Add To Ignore List  
Kleer
 
Aldaris's Avatar
 
Joined: Mar 2003
Location: Québec
 
Aldaris is offline
Default

I get this linking error now when I try to use my variable in game.cpp :

error LNK2001: unresolved external symbol "__declspec(dllimport) class CPropertiesLFDT * gameProperties" (__imp_?gameProperties@@3PAVCPropertiesLFDT@@A)


In game.h I have:
class ENGINE_API CPropertiesLFDT {
public:
BOOL bLanding_Sas1;
BOOL bLanding_Sas2;
BOOL bLanding_Sas3;
BOOL bLanding_Sas4;
BOOL bLanding_Sas5;

INDEX iPosGrue;
};


ENGINE_API extern CPropertiesLFDT *gameProperties;


I'm not used with theses errors, can you tell me exactly what it means..and what sould I do??

[edit]
It may sounds like stupid questions, but I have to learn all that too fast for me...hehe
I have 2 weeks left to finish my things(for my job), and this is the most important part!
__________________
"If it jams - force it. If it breaks, it needed replacing anyway!!! "

"If at first you don't suceed, destroy all evidences that you tried."

Last edited by Aldaris; 05-12-2003 at 12:22 PM.
  Reply With Quote
Old 05-12-2003, 07:24 PM   #12   Add To Ignore List  
Witch Bride
 
gone_motard's Avatar
 
Joined: Aug 2002
 
gone_motard is offline
Default

oh ok, i think i know what the prob is, i'll write up a little example proggie for using variables across dlls today n post it tommorow.
  Reply With Quote
Old 05-14-2003, 11:49 AM   #13   Add To Ignore List  
Kleer
 
Aldaris's Avatar
 
Joined: Mar 2003
Location: Québec
 
Aldaris is offline
Default

can't wait to see that!!
__________________
"If it jams - force it. If it breaks, it needed replacing anyway!!! "

"If at first you don't suceed, destroy all evidences that you tried."
  Reply With Quote
Old 05-19-2003, 03:41 PM   #14   Add To Ignore List  
Witch Bride
 
gone_motard's Avatar
 
Joined: Aug 2002
 
gone_motard is offline
Default

hey aldaris, sorry i was little busy the last few days.
well i tested my code, and my extern class objects work fine across
the DLL boundaries. hmmm... there maybe something else wrong with
your code. if u can, strip your code bare to the point where just the
error remains and send me the ecl files (or the changes made to them).
lates
  Reply With Quote
Old 05-19-2003, 03:59 PM   #15   Add To Ignore List  
Witch Bride
 
gone_motard's Avatar
 
Joined: Aug 2002
 
gone_motard is offline
Default

in Game.h, i have

// added
class CPropertiesLFDT {
public:
BOOL bLanding_Sas1;
BOOL bLanding_Sas2;
BOOL bLanding_Sas3;
BOOL bLanding_Sas4;
BOOL bLanding_Sas5;
INDEX iPosGrue;
};
ENGINE_API extern CPropertiesLFDT* gameProperties;

in game.cpp or elsewhere, you have to initialize your extern variable
in the global namespace:

extern CPropertiesLFDT* gameProperties = 0;

and don't worry about the error:
C:\Projects\SeriousSam\SeriousEngine\GameMP\Game.c pp(22) : warning C4273: 'gameProperties' : inconsistent dll linkage. dllexport assumed,

it's not harmful.

then, in InitInternal, I do a gameProperties = new CPropertiesLFDT;
and initialize it. and in EndInternal i do a

delete gameProperties;
gameProperties = 0;

now, u can use it in EntitiesMP.dll. it should see it, but in order for it to be linked,
properly, make sure you copy your generated GameMP.lib or GameMPD.lib to
the SDK root directory where all the LIB files are.

Last edited by gone_motard; 05-19-2003 at 04:06 PM.
  Reply With Quote
Old 05-19-2003, 04:18 PM   #16   Add To Ignore List  
Kleer
 
Aldaris's Avatar
 
Joined: Mar 2003
Location: Québec
 
Aldaris is offline
Default

thanx, I'll try that tomorrow
__________________
"If it jams - force it. If it breaks, it needed replacing anyway!!! "

"If at first you don't suceed, destroy all evidences that you tried."
  Reply With Quote
Old 05-20-2003, 10:49 AM   #17   Add To Ignore List  
Kleer
 
Aldaris's Avatar
 
Joined: Mar 2003
Location: Québec
 
Aldaris is offline
Default

ohh!!! it works!!!, but the values seems to reset when you change level(maps)...
__________________
"If it jams - force it. If it breaks, it needed replacing anyway!!! "

"If at first you don't suceed, destroy all evidences that you tried."
  Reply With Quote
Old 05-20-2003, 11:13 AM   #18   Add To Ignore List  
Kleer
 
Aldaris's Avatar
 
Joined: Mar 2003
Location: Québec
 
Aldaris is offline
Default

forget that!!! it works!!!
after 3 weeks it finally works!!!
fiou!!

hurray!!!!

thanx a lot motard!!!
__________________
"If it jams - force it. If it breaks, it needed replacing anyway!!! "

"If at first you don't suceed, destroy all evidences that you tried."
  Reply With Quote
Old 05-20-2003, 02:03 PM   #19   Add To Ignore List  
Witch Bride
 
gone_motard's Avatar
 
Joined: Aug 2002
 
gone_motard is offline
Default

no probs dood
  Reply With Quote
Old 06-06-2003, 03:51 PM   #20   Add To Ignore List  
Kleer
 
Aldaris's Avatar
 
Joined: Mar 2003
Location: Québec
 
Aldaris is offline
Default

Hi!

I got another problem here!

I've created an entity, and for a reason I don't know, the events I send don't seems to reach their targets....
SendToTarget(m_penTarget, m_eetEvent, m_penCaused);
SendToTarget(m_BrushTarget, m_eetEventBrush, m_penCaused);

it's freaking me out!!!!

also, I have another entity, that almost work...It catch all the events I send, except EActivate and EDeactivate. beacuse I want the entity to be activable/deactivable....everything works except that....:@

need help!!

- Aldaris
__________________
"If it jams - force it. If it breaks, it needed replacing anyway!!! "

"If at first you don't suceed, destroy all evidences that you tried."
  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
My very own PC problem thread. Yay! Artery Off Topic Forum 3 12-02-2003 06:04 PM
Freaky Sound Problem Walt Off Topic Forum 14 08-07-2003 05:39 AM
Problem playing ANY sound with Goldwave Fiendian Off Topic Forum 7 08-04-2003 05:30 PM
SS:SE LAN Coop Problem: Non-server player becomes "stuck" WindRider Technical Support (SSC) 5 02-25-2002 09:33 PM
problem with EAX... wojtek_pl Technical Support (SSC) 1 02-19-2002 02:07 PM


All times are GMT -4. The time now is 12:50 AM.