Correct district names

Started by Mötley, Nov 23, 2016, 04:00 PM

Previous topic - Next topic

Mötley

Okay I have a project I plan to attack for either LU or Vcmp, or both, Not really sure which one.

I want to retrieve all of the district names from the main.scm as I want to create a kill system similar to GTA 5 where as when killed you kind of have a random spawn within that district.

Is there anything I need to know when retrieving the names from the original mission file? Are they an exact match "String names from function GetDistrictName".

This is going to be a lot of wasted freaking time and I would prefer to hear an output from someone else before even attempting something as massive as this, Sounds simple but really freaking time consuming. So I cant waste time by doing something wrong, Or hear about better ways. I'm sure someone understands..

:P I already tried creating a loop for increasing float values for GetDistrictName(pos.x, pos.y) didn't ;D work out

EK.IceFlake

Well, I recommend you to instead of hardcoding it, add a command
/adddistrictspawnlocation
which saves it to the database and check it from the database.

Use Distance for district as it'd be much easier.

Mötley

I thought about something similar to this due to a script that was released in LU, Something about creating your own district names.
/* coded by Pipec */
COLOUR_WHITE <- Colour(255, 255, 255);
COLOUR_BLACK <- Colour(0, 0, 0);
g_GUI_ZONE <- null;
g_GUI_ZONEName <- null;

g_ZoneID <- -1;

g_T_Owner  <- ["Bandito","Triad", "Bandito",
"Diablos","Ballas", "Ballas",
"Yakuza","Yakuza", "Yakuza",
"Triada","Triada", "Triada",
"Leone","Leone", "Leone",
"Banditos","Diablos", "Bandito",
"Bandito","Bandito", "Bandito",
"Diablos","Ballas", "Ballas"];


function SetZoneOwner(i, myData){  g_T_Owner[i] = myData;  }



function onScriptLoad()
{

pPlayer <- FindLocalPlayer();
NewTimer("ZoneCheck", 1000,0);


g_GUI_ZONE = GUIWindow(VectorScreen(ScreenWidth/2-265, ScreenHeight/2-160),ScreenSize(301,50),"Current Zone of:");
g_GUI_ZONE.Visible = false;
g_GUI_ZONE.Colour = COLOUR_BLACK;
AddGUILayer( g_GUI_ZONE );


g_GUI_ZONEName = GUILabel( VectorScreen(5,1), ScreenSize(300,20 ), "......" );
g_GUI_ZONEName.TextColour = COLOUR_WHITE
g_GUI_ZONEName.FontSize = 12
g_GUI_ZONEName.FontName = "Arial";
g_GUI_ZONE.AddChild( g_GUI_ZONEName );

print("Zone script has been loaded");

}

function ZoneCheck()
{

local i=-1;
if(CheckDistance4D(1136.4, 1388.1, -332.2, -194.03)){ i=0; }
if(CheckDistance4D(1206.6, 1388.1, -517.1, -335.6)){ i=1; }
if(CheckDistance4D(1116.1, 1205.5, -193.63, -38.84)){ i=2; }
if(CheckDistance4D(1035.9, 1115.9, -233.71, -114.05)){ i=3; }
if(CheckDistance4D(901.1, 1034.6, -328.4, -109.31)){ i=4; }
if(CheckDistance4D(901, 1007.9, -108.84, 27.49)){ i=5; }
if(CheckDistance4D(763.0, 900.4, -284.0, -59.45)){ i=6; }
if(CheckDistance4D(764.8, 900.4, -444.3, -283.87)){ i=7; }
if(CheckDistance4D(901.3, 1011.2, -471.7, -329.3)){ i=8; }
if(CheckDistance4D(764.7, 901.2, -477.8, -444.2)){ i=9; }
if(CheckDistance4D(1011.5, 1068.4, -467.7, -234.46)){ i=10; }
if(CheckDistance4D(1113.4, 1205.8, -483.6, -334.3)){ i=11; }
if(CheckDistance4D(996, 1205.3, -517.4, -483.8)){ i=12; }
if(CheckDistance4D(765.3, 995.1, -640, -475.3)){ i=13; }
if(CheckDistance4D(995.2, 1086.9, -639.8, -606.3)){ i=14; }
if(CheckDistance4D(765.6, 1073.8, -778.8, -639.5)){ i=15; }
if(CheckDistance4D(765.2, 1071.3, -865.1, -779.1)){ i=16; }
if(CheckDistance4D(1079, 1141.1, -1049.8, -940)){ i=17; }
if(CheckDistance4D(1085.2, 1222.7, -1171.4, -1039.9)){ i=18; }
if(CheckDistance4D(939.5, 1084.9, -1157.7, -1050.1)){ i=19; }
if(CheckDistance4D(1223.7, 1355.2, -1185.8, -1001.7)){ i=20; }
if(CheckDistance4D(1357.7, 1540.4, -871.3, -766)){ i=21; }
if(CheckDistance4D(1357, 1549.8, -1040.7, -872.9)){ i=22; }
if(CheckDistance4D(1290.5, 1340, -804.5, -716.1)){ i=23; }

if(g_ZoneID != i){
onPlayerZoneChanged(g_ZoneID, i);  }
g_ZoneID = i;
//Message("Zona:" + g_ZoneID);

return 1;
}


function onPlayerZoneChanged(OldID, NewID) //Its a Call back
{

if(NewID == -1){
g_GUI_ZONEName.Text = " ";
g_GUI_ZONE.Visible = false;  } else  {
g_GUI_ZONEName.Text = g_T_Owner[NewID] + " gang";
g_GUI_ZONE.Visible = true;  }

//DO something else here...

}

function CheckDistance4D(Xlow, Xhigh, Ylow,  Yhigh )
{
local mP = pPlayer.Pos;
if ( ( mP.x >= Xlow ) && ( mP.x <= Xhigh )  && ( mP.y >= Ylow ) && ( mP.y <= Yhigh ))
{ return true;  }

return false;
}


But then I began thinking It would be nice to have full control over every district. I have not seen a inpolly style for districts in the main.scm, That would be cool but.. I am still considering a similar method

vito

use a tree, split map on sectors, sectors on subsectors and so on.

Mötley

I started with LU as there is less districts.

Still in a debug state.

What do you think? Could of done better?

District_ID <- array(120, 0);
District_Name <- array(120, "");

function SetPlayersDistrict(Name, player)
{
    switch(Name)
    {
        /* Portland */
        case "Harwood":                                return District_ID[player.ID] = 1;
        case "Portland Beach":                         return District_ID[player.ID] = 2;
        case "Hepburn Heights":                        return District_ID[player.ID] = 3;
        case "Saint Marks":                            return District_ID[player.ID] = 4;
        case "Red Light District":                     return District_ID[player.ID] = 5;
        case "Chinatown":                              return District_ID[player.ID] = 6;
        case "Portland View":                          return District_ID[player.ID] = 7;
        case "Trenton":                                return District_ID[player.ID] = 8;
        case "Portland Harbor":                        return District_ID[player.ID] = 9;
        case "Atlantic Quays":                         return District_ID[player.ID] = 10;
        case "Callahan Point":                         return District_ID[player.ID] = 11;

        /* To Staunton Island */
        case "Callahan Bridge":                        return District_ID[player.ID] = 12;


        case "Torrington":                             return District_ID[player.ID] = 13;
        case "Bedford Point":                          return District_ID[player.ID] = 14;
        case "Belleville Park":                        return District_ID[player.ID] = 15;
        case "Liberty Campus":                         return District_ID[player.ID] = 16;
        case "Fort Staunton":                          return District_ID[player.ID] = 17;
        case "Rockford":                               return District_ID[player.ID] = 18;
        case "Aspatria":                               return District_ID[player.ID] = 19;

        /* To Shoreside Island */
        case "Francis International Airport":          return District_ID[player.ID] = 20;
        case "Pike Creek":                             return District_ID[player.ID] = 21;
        case "Wichita Gardens":                        return District_ID[player.ID] = 22;
        case "Cedar Grove":                            return District_ID[player.ID] = 23;
        case "Cochrane Dam":                           return District_ID[player.ID] = 24;

        /* Typically in the ocean */
        case "Liberty City":                           return District_ID[player.ID] = 25;
        case "Portland":                               return District_ID[player.ID] = 26;
        case "Staunton Island":                        return District_ID[player.ID] = 27;
        default:                                       return District_ID[player.ID] = 0;
}
}

function onPlayerDeath(player, reason)
{
    District_Name[player.ID] = GetDistrictName(player.Pos.x, player.Pos.y);
   
    SetPlayersDistrict(District_Name[player.ID], player); //Do not remove player, LOL..
}

function onPlayerSpawn(player, spawn)
{
    if ( ( District_ID[player.ID] >= 1 ) && ( District_ID[player.ID] <= 12 ) && (player.Island == 1) )
    {
        Message("Portland Island")
    }

    if ( ( District_ID[player.ID] >= 12 ) && ( District_ID[player.ID] <= 19 ) && (player.Island == 2) )
    {
        Message("Staunton Island")
    }

    if ( ( District_ID[player.ID] >= 20 ) && ( District_ID[player.ID] <= 24 ) && (player.Island == 3) )
    {
        Message("Shoreside Island")
    }

    if ( ( District_ID[player.ID] >= 25 ) && ( District_ID[player.ID] <= 27 ))
    {
         if (player.Island == 1 ) Message("Portland Island/ Lost island")
         if (player.Island == 2 ) Message("Staunton Island/ Lost island")
         if (player.Island == 3 ) Message("Shoreside Island/ Lost island")

    }
}

function onPlayerPart(player, reason)
{
    District_ID[player.ID] = 0;
    District_Name[player.ID] = "";
}