Jump to content

Scripting an MMO map


ItHadToComeToThis
 Share

You are about to reply to a thread that has been inactive for 1521 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Okay my fine scripters. I have given it a go and i have come to a standstill on the next part. So far, this is working but only works on a square face. What i want to do is have it working on a round face. I know i will have to extend the map edges in some way and modify my calculations but i am a tad stumped on how to go about it.

If you put this on a circular face as it is the marker goes off the circle and assumes its still a square. If anyone can help me figure the next part out i will be eternally grateful.

Note : If you want to use what i have done so far and adapt it to your needs i really do not mind, go ahead.

You need a square prim on your HUD with a smaller square/cylinder in front of it.

string makeURL(string region){
    return "http://api.gridsurvey.com/simquery.php?region="+llEscapeURL(region);
}
string regionTexture;

default {
    attach( key id ) {
        if(id)llResetScript();
    }
    state_entry(){
        llHTTPRequest(makeURL(llGetRegionName()),[ HTTP_METHOD,"POST"],"");
        llSetTimerEvent(0.05);
    }
    http_response(key id, integer status, list data, string body) {
        list parse=llParseStringKeepNulls(body,[" ","\n"],[]);
        integer find=llListFindList(llList2ListStrided(parse,0,-1,2),["terrain_uuid"]);
        if(-1!=find){
            regionTexture=llList2String(parse,(find*2)+1);
            llSetLinkTexture(4,regionTexture,-1);
        }
    }
    timer() {
        vector pos=llGetPos();
        vector scale=llGetScale();
        vector percents;
        
        pos.z=0.1;
        pos-=<128.0,128.0,0.0>;
        pos/=256.0;
        
        percents=pos;
        
        pos.x=scale.x*pos.x;
        pos.y=scale.y*pos.y;
        
        vector texture_size=<0.5,0.5,0.0>;
        vector textureOffset=ZERO_VECTOR;
        
        textureOffset.x+=1.0*percents.x;
        textureOffset.y+=1.0*percents.y;
        
        vector myPrimPos=<0.0,0.0,0.1>;
        
        if(textureOffset.x>0.25){
            float x=textureOffset.x;
            x-=0.25;
            x/=0.25;
            myPrimPos.x=(scale.x*0.5)*x;
            textureOffset.x=0.25;
        }
        else if(textureOffset.x<-0.25){
            float x=-textureOffset.x;
            x-=0.25;
            x/=0.25;
            myPrimPos.x=(scale.x*-0.5)*x;
            textureOffset.x=-0.25;
        }
        if( textureOffset.y>0.25){
            float y=textureOffset.y;
            y-=0.25;
            y/=0.25;
            myPrimPos.y=(scale.y* 0.5)*y;
            textureOffset.y=0.25;
        }
        else if(textureOffset.y<-0.25){
            float y=-textureOffset.y;
            y-=0.25;
            y/=0.25;
            myPrimPos.y=(scale.y*-0.5)*y;
            textureOffset.y =-0.25;
        }
        
        
        llSetLinkPrimitiveParamsFast(4,[
        PRIM_TEXTURE,ALL_SIDES,regionTexture,texture_size,textureOffset,0.0,
        PRIM_LINK_TARGET,2,PRIM_POS_LOCAL,myPrimPos]);
    }
    changed(integer x){
        if(x&CHANGED_REGION){
            llHTTPRequest(makeURL(llGetRegionName()),[ HTTP_METHOD,"POST"],"");
        }
    }
}

 

Edited by ItHadToComeToThis
Link to comment
Share on other sites

what are the initial /relatives sizes of the 2 prims ?  what are their start positions ? and orientations ?

as wrote the linked prim barely moves, so is bit difficult to see what it is supposed to do

 

edit add

normally tho, with a point within a circle then we would check that the 'final' distance from the centre of the root prim is within the radius of the circle

 

Edited by Mollymews
Link to comment
Share on other sites

1 hour ago, Mollymews said:

what are the initial /relatives sizes of the 2 prims ?  what are their start positions ? and orientations ?

as wrote the linked prim barely moves, so is bit difficult to see what it is supposed to do

 

edit add

normally tho, with a point within a circle then we would check that the 'final' distance from the centre of the root prim is within the radius of the circle

 

Urghh I put the wrong script in. I was at work and at the end of my shift and sorting stuff out. Posted in the hopes of some discussion by the time I got home. The one I posted was a much earlier version. The one listed now should display the sim map, zoomed in. The object should stay in the centre of the hud and move the texture instead

Link to comment
Share on other sites

i had a quick play. Is not simple

when the marker is on the circumference, the marker should not move. And the texture map has to move in the opposite direction on the relative X or Y axis,  from the direction it moves when the marker is inside the circle

i will have to think about how to code that

edit add:

i played with it a bit more and the biggest (aesthetic) issue with a circle is that when the marker cannot move outside of the circle (into the corners of the region/arena), and the map texture is moved to the true postion then another texture representing the region boundary (and next region over) needs to be displayed also within the circle for it to look good

for a MMO I would go with the square map, as most players are already used to arena maps being square

also I would not use a timer for this. I would llTakeControls and update the map on keydown

Edited by Mollymews
relative X or Y axis
Link to comment
Share on other sites

i just stick a simple diagram here to show what has to happen with a square arena and a circular viewpoint

1377175058_mmomap.jpg.9113b2395b0282a2639b610cbb26e8b2.jpg

 

green is the arena. Red is the arena border.  Black is the edge of our viewport.  Blue/white is the player marker

 

to do what we want then we create our own texture map of our arena, which is 2 times the size of the arena. Where the green (arena) is centered on the texture with a border (red). Then we can scale/scroll the arena texture. Preventing the marker from moving beyond the circumference of the viewport

 

 

 

Link to comment
Share on other sites

15 hours ago, Mollymews said:

i just stick a simple diagram here to show what has to happen with a square arena and a circular viewpoint

1377175058_mmomap.jpg.9113b2395b0282a2639b610cbb26e8b2.jpg

 

green is the arena. Red is the arena border.  Black is the edge of our viewport.  Blue/white is the player marker

 

to do what we want then we create our own texture map of our arena, which is 2 times the size of the arena. Where the green (arena) is centered on the texture with a border (red). Then we can scale/scroll the arena texture. Preventing the marker from moving beyond the circumference of the viewport

 

 

 

Aha so its double the size. That was one of the issues I was facing. I wasn't sure how much bigger to make it. I have further plans for it once this is figured out fully. Rotating as you turn, markers that appear on map the closer you get and "highlight" around the edge when further away. But first...this issue. Should be simple enough thinking about it if its only double the size. I just have to do the same thing but contained in a smaller square as opposed to the whole texture. Thank you btw much appreciated :)

  • Like 1
Link to comment
Share on other sites

9 hours ago, ItHadToComeToThis said:

double the size

another diagram about the size to confirm double

when the player marker is on the boundary, say at the top of the map on the center line then the marker can't move left or right, so the map scrolls. Same with the other X Y center lines.  And the map looks like this

1062725820_mmoqtrs.jpg.e9c6641085432ed03a3653878a82464e.jpg

 

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1521 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...