Jump to content

Help with Elite force 1 single player code

  • You cannot reply to this topic

6 replies to this topic

#1 com-man



  • Members
  • PipPipPip
  • 33 posts

Posted 20 July 2009 - 05:51 PM

Hi guys,

Some might know me as being more active in mapping in the EF community (altough i never released anything haha, i did annoy you with mapping questions). Recently I've started to have a look at the c++ code side of stuffs (we got that in school and I quite like working with it and I'm fairly good at it).

Now, my question is, (and yes, i've had a long look at the sp source code) is it possible, while being ingame (so no UI is activated) to lock the view angle of the player (aka mouse movements dont affect where the player looks anymore) and draw a mouse cursor (i know how drawing goes, but i mean aquire the x and y coordiantes of the mouse)?

I've had a look but there is no callback or anything that handles mouse movements, and since I cant go into the stvoy.exe I can't create one either. There is one for when you are in UI mode, but none for when you are in Game mode. I've also tried hacking my way around, aquiring the x and y coordinates from the uis struct and putting them into cvars in the ui part then reading them back in the game part, but when the ui is not active, the ui mouse callback doesnt register anything so that didn't work.

Does anyone have any suggestion on how this could be achieved, if its even possible?
Posted Image

#2 TiM



  • UberGames Admin
  • 3,425 posts

Posted 21 July 2009 - 05:35 PM

Ahaha welcome back. :)

Even tho we chatted about this on MSN, I think I'll add some more here as well.

Essentially what you're trying to do is set up a 'pseudo-UI' within the GAME/CGAME modules... which seems pretty crazy haha.

Either way... rendering 2D elements on the screen isn't a problem, so the main issue is just the mouse. But that ___should___ be doable with a multitude of epic hacks. XD

That being said tho... can you capture the mouse click events in cgame too? I remember that was something I was having trouble with...

#3 Ryan



  • Members
  • 368 posts

Posted 21 July 2009 - 06:43 PM

I don't know anything about coding in C++ or the specifics of EF in particular BUT...surely, the ESC key menu is overlayed above the game(ness...lol). Presumably a hack that would create that - without the semi-opaque background and removing lots of the menu items could provide a base for an on-screen in-game UI. If yes, then perhaps even the code could be replicated to create multiple UIs and allow the existing esc menu to stay in place. Yes? No? Maybe?

- Ryan -

#4 com-man



  • Members
  • PipPipPip
  • 33 posts

Posted 21 July 2009 - 06:48 PM

Already did that, the problem is, as soon as you switch to "menu mode" AKA, make the mouse not point your character but controlling the on screen mouse cursor, all other keys are locked out from controlling your character aswel.

The best thing thats possible which i have already implemented:
When the menu pops up, the game is still running and you can also still see it in the background, not darkened. It's not possible to control your character and have a mouse cursor at the same time. At least not with alot of really really dirty hacks.

Thanks for your replies though.
Posted Image

#5 com-man



  • Members
  • PipPipPip
  • 33 posts

Posted 22 July 2009 - 09:08 AM

Ok, I got another problem, this is more a C++ related thing though.

1. I've got 2 classes item_space_c, item_c
2. I've got 2 arrays: item_space_c itemgrid[24][10], item_c itemlist[3]
3. I've got a member function: item_c::init( ....., item_space_c ** grid, ....)
4. I've got a private variable in item_c: item_space_c ** _grid;

My problem:
When i initialize the itemlist array, i call (inside a loop):
itemlist[i].init(..., itemgrid, ...);

inside the init function i got:

_grid = grid;

When I compile: error C2440: '='cannot convert from 'item_space_c **'to 'item_space_c[24][10]'
My knowledge of c++ tells me that what I am doing is correct (aka the itemgrid IS a pointer to a pointer to an item_space_c already).
When i try typecasting: itemlist[i].init(..., (item_space_c **) itemgrid, ...);
The code compiles, but then when i use the _grid variable inside one of the itemlist classes inside a member functions, the code crashes. When i print the _grid variable as a number, it is the same number as when i print just the itemgrid variable as a number, but as soon as i index _grid (aka _grid[0][0]) the program crashes. What am I doing wrong?
Posted Image

#6 GSIO01


    UberGames Developer

  • UberGames Developer
  • 1,021 posts

Posted 22 July 2009 - 11:58 AM

I don't know exactly what your init function does but wouldn't it work if you use a pointer to item_space_c instead?
item_c::item_space_c *_grid;
item_c::init(..., item_space_c *grid, ...);
item_space_c itemgrid[24][10];

item_c::init(..., &itemgrid, ...);

#7 com-man



  • Members
  • PipPipPip
  • 33 posts

Posted 22 July 2009 - 12:14 PM

Well, im not sure...
Since the value of the pointer is correct something goes ok, but when i index the pointer it crashes.

void item_c::function()
ui.Printf("Test: %d\n", _grid);

works but

void item_c::function()
ui.Printf("Test: %d\n", _grid[0]);

crashes, since _grid is a item_space_c **, _grid[0] is a item_space_c * and should also just print a number. Like I said, item_c is a class, just as item_space_c. When I init the array that holds all item_c instantiations i want, i pass the array pointer to the 2-dimensional array of item_space_c's i got since the function in the item_c class needs to have and set some data... I hope this makes sence lol

BTW, my init functions looks like this:

void item_c::init(int id, int x, int y, int w, int h, qhandle_t * t, int iw, int ih, qboolean hasit, item_space_c ** grid, int gx, int gy)

_x = x;
_y = y;
_width = w;
_height = h;
_texture = t;
_beingdragged = qfalse;
_dragx = 0;
_dragy = 0;
_selected = qfalse;
_item = id;
_itemwidth = iw;
_itemheight = ih;
_available = hasit;
_grid = grid;
_gridx = gx;
_gridy = gy;

with grid being a private variarlbe of the class:


int _x, _y;
int _width, _height;
qhandle_t * _texture;
qboolean _beingdragged;
int _dragx, _dragy;
qboolean _selected;
int _item, _itemwidth, _itemheight;
qboolean _available;
item_space_c ** _grid;
int _gridx, _gridy;
Posted Image

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users