Minimap mod

Post Reply
DoctorGester
Posts: 44
Joined: Fri Apr 29, 2011 4:22 am

Minimap mod

Post by DoctorGester » Sat Oct 22, 2011 9:55 am

Hi there. There's my mod, adding minimap to game interface. It's poorly done, because i have some problems with coding.

Problem 1:
Mini map shows only units, not obstacles. I think at the moment there's no way to get shapes of obstacles on the level.

Problem 2:
I couldn't find the function, which returns current facing of unit. Insted of it i'm using velocity of unit, that sometimes looks weird on the minimap.

Problem 3:
I couldn't find the way to move minimap to the corner of screen, or the function, returning screen size. So minimap is placed near the center of screen.

Mod installation:
1. Place minimap.html to Overgrowth\Data\UI\dialogs
2. Replace Overgrowth\Data\Scripts\level.as with my level.as or use instruction below to modify it.
3. ??????
4. PROFIT

If you want to modify level.as by yourself follow these steps:
1. Place

Code: Select all

uint32 minimap = 0;
bool mapPreload = true;
at the first line.
2. Place

Code: Select all

    if ((has_gui && minimap != 0) || GetPlayerCharacterID() == -1){
		gui.RemoveGUI(minimap);
		minimap = 0;
	} else if (!has_gui && minimap == 0 && GetPlayerCharacterID() != -1){
		minimap = gui.AddGUI("minimap","dialogs\\minimap.html",600,400);
		if (mapPreload){
			gui.RemoveGUI(minimap);
			minimap = gui.AddGUI("minimap","dialogs\\minimap.html",600,400);
			mapPreload = false;
		}
	}
    UpdateMap();
after

Code: Select all

void Update() {
    gui.Update();
3. Place

Code: Select all

void UpdateMap(){
	int player_id = GetPlayerCharacterID();
    if(minimap == 0 || player_id == -1){
        return;
    }
	MovementObject@ player_char = ReadCharacter(player_id);
	float x = player_char.position.x,
		  y = player_char.position.z;
    int num = GetNumCharacters();
	for(int i=0; i<num; i++){
        MovementObject@ char = ReadCharacter(i);
		float cx = char.position.x,
			  cy = char.position.z;
		float vx = cx - x,
			  vy = cy - y;
		float dist = sqrt(vx * vx + vy * vy);
		int state = 0;
		if (char.controlled)
			state = 1;
		if (char.IsKnockedOut() != _awake)
			state = 2;
		vx += 50.0f;
		vy += 50.0f;
		vx *= 2.0f;
		vy *= 2.0f;
		vec3 vel = char.velocity;
		float an = atan2(vel.z, vel.x);
		gui.CallFunction(minimap, "addObject(" + vx + "," + vy + "," + an + "," + state + ")");
    }
	gui.CallFunction(minimap, "draw();");
}
before

Code: Select all

const float _reset_delay = 4.0f;
float reset_timer = _reset_delay;
4. ?????
5. PROFIT AGAIN
Attachments
Minimap mod by DoctorGester.zip
(3.01 KiB) Downloaded 53 times

User avatar
Markuss
Posts: 193
Joined: Sun Apr 04, 2010 1:52 pm

Re: Minimap mod

Post by Markuss » Sat Oct 22, 2011 12:07 pm

this is so far beyond my understanding of scripting i can't even comprehend it, cool mod.

User avatar
Korban3
Posts: 4146
Joined: Tue May 31, 2011 9:14 pm
Location: 42nd St E, Hell

Re: Minimap mod

Post by Korban3 » Sat Oct 22, 2011 2:45 pm

Hmm, that's pretty cool. Can you take a screenshot via the AS? You could take a screenshot from up above and save it as a texture, or maybe make the minimap a small game screen itself that looks down upon the player from the sky. Might solve issues with shapes and things, although I'm not sure if that's what you're wanting.

DoctorGester
Posts: 44
Joined: Fri Apr 29, 2011 4:22 am

Re: Minimap mod

Post by DoctorGester » Sat Oct 22, 2011 3:09 pm

> Can you take a screenshot via the AS
i think no =(

User avatar
Aaron
Posts: 595
Joined: Tue Feb 16, 2010 12:13 pm
Location: About 2 hours away from Anton
Contact:

Re: Minimap mod

Post by Aaron » Sat Oct 22, 2011 8:52 pm

Wow, this is an awesome use of scripting! Maybe as a next step we can have someone generate overhead images for each map.

I tried to solve problem #2 with the following code:

Code: Select all

vec3 facing = char.GetFacing();
float an = atan2(facing.z, facing.x);
though strangely enough the game responds with the message "No matching signatures to 'MovementOject::GetFacing()'", which is odd, as the function is used in aschar.as (on line 781, for example). If anyone has any idea why, I'd love to know!

Also, I decided to take a screenshot so that people could get an idea of what it looks like (click to enlarge):
Image

DoctorGester
Posts: 44
Joined: Fri Apr 29, 2011 4:22 am

Re: Minimap mod

Post by DoctorGester » Sun Oct 23, 2011 3:48 am

Samusaaron3, thanks. i tried to use GetFacing too, but i was getting same error as you.

User avatar
AAorris
Posts: 178
Joined: Sun Jun 12, 2011 1:01 pm
Contact:

Re: Minimap mod

Post by AAorris » Tue Nov 29, 2011 6:42 pm

The problem you guys are having with GetFacing is because level.as does not have access to that function in movement_object defined in player_dump.as... the only scripts that can access it are mentioned by learn_more:

* Files that can access these (and included) functions/objects/properties:
*/

// Data/Scripts/enemycontrol.as
// Data/Scripts/aschar.as
// Data/Scripts/interpdirection.as
// Data/Scripts/aircontrols.as
// Data/Scripts/fliproll.as
// Data/Scripts/ledgegrab.as
// Data/Scripts/playercontrol.as

I'll investigate further about accessing them now :3

Post Reply