C_far icon

Tower | FFG

C_far | PRO | 08/14/18 07:01:33 PM UTC | 0 ⭐ | 7832 👁️ | Never ⏰ | []
Pawn |

15.16 KB

|

None

|

0 👍

/

0 👎

/*
 
    888888888888  ,ad8888ba,   I8,        8        ,8I  88888888888  88888888ba   
         88      d8"'    `"8b  `8b       d8b       d8'  88           88      "8b  
         88     d8'        `8b  "8,     ,8"8,     ,8"   88           88      ,8P  
         88     88          88   Y8     8P Y8     8P    88aaaaa      88aaaaaa8P'  
         88     88          88   `8b   d8' `8b   d8'    88"""""      88""""88'    
         88     Y8,        ,8P    `8a a8'   `8a a8'     88           88    `8b    
         88      Y8a.    .a8P      `8a8'     `8a8'      88           88     `8b   
         88       `"Y8888Y"'        `8'       `8'       88888888888  88      `8b  
 
*/
 
#include "YSI\y_hooks"
 
//-----------------------------
//-------------------------------------------------
//-----------------------------
 
stock static GAMEID;
 
//-----------------------------
 
static
    bool:finish[MAX_LINKS_PER_GAME char],
 
    object_towers[MAX_LINKS_PER_GAME][2],
    
    Text3D:text3d_health_towers[MAX_LINKS_PER_GAME][2],
    int_health_towers[MAX_LINKS_PER_GAME][2],
    
    timer_bomb[MAX_LINKS_PER_GAME],
    object_bomb[MAX_LINKS_PER_GAME],
    Text3D:text3d_bomb[MAX_LINKS_PER_GAME];
    
static const Float:pos_towers[2][3] =
{
    {-972.296020, 1022.695556, 1345.796508},
    {-1133.212890, 1096.327270, 1345.796508}
};
    
//-----------------------------
//-------------------------------------------------
//-----------------------------
 
enum e_PLAYERS_TOWER
{
    pTowKills,
    pTowDeaths,
 
    pTowDamagesTower,
    pTowBombsExp,
    
    bool:pTowHasBomb
}
 
static 
    P_TOW[MAX_PLAYERS][e_PLAYERS_TOWER];
 
//-----------------------------
//-------------------------------------------------
//-----------------------------
 
static GivePlayerPoints(playerid, points, bool:won)
{
    new
        clone[e_PLAYERS_TOWER];
        
    clone = P_TOW[playerid];
 
    static
        query[512];
        
    mysql_format(mysql, query, sizeof(query), "\
    UPDATE TowerGameStats SET \
    Points = Points + %d,\
    Games = Games + 1,\
    GamesWon = GamesWon + %d,\
    GamesLost = GamesLost + %d,\
    GameTime = GameTime + %d,\
    Kills = Kills + %d,\
    Deaths = Deaths + %d,\
    DamagesTower = DamagesTower + %d,\
    BombsExplosed = BombsExplosed + %d \
    WHERE ID = %d",
    
    points,
    
    _:won,
    _:!won,
    
    GetGameTimeByLinkID(PLAYERS[playerid][pLink]),
    
    clone[pTowKills],
    clone[pTowDeaths],
    
    clone[pTowDamagesTower],
    clone[pTowBombsExp],
    
    PLAYERS[playerid][pIDSql]);
    
    //mysql_tquery(mysql, query);
 
    Scm(playerid, Color.GOLD, "Tu remportes "GRAY"%d "GOLD"points !", points);      
    Scm(playerid, Color.AQUA, "Tu remportes "GRAY"%d "AQUA"dollars !", GivePlayerDollars(playerid, points));
    
    return true;
}
 
//-----------------------------
 
static DropBomb(playerid, linkid)
{
    foreach(new i : LinkPlayer[linkid])
    {
        GTFP(i, "~b~La bombe est au sol.", 3000, 4);
    }
    
    P_TOW[playerid][pTowHasBomb] = false;
    
    new 
        cell = GetCellLink(LINKS[linkid][lGame], linkid),
        Float:x,
        Float:y,
        Float:z;
        
    GetPlayerPos(playerid, x, y, z);
    
    object_bomb[cell] = CreateDynamicObject(2891, x, y, z - 1.0, 0.000000, 0.000000, 0.000000, LINKS[linkid][lWorldID], 10, -1, 400.0, 0.0);
    text3d_bomb[cell] = CreateDynamic3DTextLabel("Pour prendre la bombe\nAppuie sur N et clique sur la bombe.", Color.AQUA, x, y, z - 1.0, 250.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, LINKS[linkid][lWorldID], 10, -1, 10.0);
    
    RemovePlayerAttachedObject(playerid, 0);
    
    return true;
}
 
//-----------------------------
//-------------------------------------------------
//-----------------------------
 
static OnTowerTakeDamage(linkid, cell, teamid_tower);
static Timer_Bomb(linkid, cell);
 
//-----------------------------
//-------------------------------------------------
//-----------------------------
 
GameMode::Init()
{
    new
        links[][2] = 
        { 
            {2, 2}, // 4 players
            {2, 4}, // 8 players
            {2, 6}, // 12 players
            {2, 8} // 16 players
        };
 
    GAMEID = CreateGame("Tower", links, 11461);
    
    //-----------------------------
    
    new 
        clone[e_GAMES];
        
    clone = GAMES[GAMEID];
    
    for(new l = 0; l < clone[gaNbrLinks]; l++)
    {
        new
            worldid = LINKS[ clone[gaLinks][l] ][lWorldID];
    
        object_towers[l][0] = CreateDynamicObject(11461, pos_towers[0][0], pos_towers[0][1], pos_towers[0][2] - 14.0, 0.000000, 0.000000, 12.500000, worldid, 10, -1, 200.0, 0.0);
        text3d_health_towers[l][0] = CreateDynamic3DTextLabel("", -1, pos_towers[0][0], pos_towers[0][1], pos_towers[0][2], 250.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, worldid, 10, -1, 100.0);
        
        object_towers[l][1] = CreateDynamicObject(11461, pos_towers[1][0], pos_towers[1][1], pos_towers[1][2] - 14.0, 0.000000, 0.000000, 12.500000, worldid, 10, -1, 200.0, 0.0);
        text3d_health_towers[l][1] = CreateDynamic3DTextLabel("", -1, pos_towers[1][0], pos_towers[1][1], pos_towers[1][2], 250.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, worldid, 10, -1, 100.0);
        
        #include "tower_map.pwn"
    }
}
 
//-----------------------------
//-------------------------------------------------
//-----------------------------
 
GAME::This->Start(gameid, linkid)
{
    new
        cell = GetCellLink(gameid, linkid);
    
    UpdateDynamic3DTextLabelText(text3d_health_towers[cell][0], GetTeamColorString(0), "1000/1000");
    int_health_towers[cell][0] = 1000;
    
    UpdateDynamic3DTextLabelText(text3d_health_towers[cell][1], GetTeamColorString(1), "1000/1000");
    int_health_towers[cell][1] = 1000;
 
    //-----------------------------
    
    timer_bomb[cell] = SetTimerEx("Timer_Bomb", 120000, false, "dd", linkid, cell);
    
    finish{cell} = false;
    
    return true;
}
 
//-----------------------------
 
GAME::This->Finish(gameid, linkid)
{
    new
        cell = GetCellLink(gameid, linkid);
 
    KillTimer(timer_bomb[cell]);
 
    return true;
}
 
//-----------------------------
 
GAME::Player->Join(gameid, linkid, playerid)
{
    RemoveBuildingForPlayer(playerid, 3935, -1097.7422, 1037.8750, 1343.0781, 0.25);
    RemoveBuildingForPlayer(playerid, 3936, -974.5547, 1059.4609, 1344.7734, 0.25);
    RemoveBuildingForPlayer(playerid, 3937, -1130.9219, 1059.4609, 1345.4688, 0.25);
 
    //-----------------------------
    
    static
        query[128];
        
    mysql_format(mysql, query, sizeof(query), "INSERT INTO TowerGameStats (ID) VALUES (%d) ON DUPLICATE KEY UPDATE ID = %d", PLAYERS[playerid][pIDSql], PLAYERS[playerid][pIDSql]);
    //mysql_tquery(mysql, query);
    
    //-----------------------------
    
    SetPlayerColor(playerid, RemoveColorAlpha(TEAMS[ PLAYERS[playerid][pTeamDG] ][tColor]));
    
    return true;
}
 
//-----------------------------
 
GAME::Player->Quit(gameid, linkid, playerid, teamid)
{   
    if(GetNumberPlayersInTeam(linkid, teamid) == 0)
    {
        new
            cell = GetCellLink(gameid, linkid),
            team_enemy = _:!teamid,
            points_bonus = floatround(float(GetGameTimeByLinkID(linkid)) * 0.03125);
            
        ScmToLink(linkid, Color.WHITE, "L'équipe {%x}%s "WHITE"gagne la partie !", TEAMS[team_enemy][tColor] >>> 8, TEAMS[team_enemy][tName]);
 
        foreach(new i : LinkPlayer[linkid])
        {               
            if(team_enemy == PLAYERS[i][pTeamDG])
            {
                new
                    points = 0;
            
                points += P_TOW[i][pTowDamagesTower] / 50;
                points += P_TOW[i][pTowBombsExp] * 5;
                points += floatround(float(P_TOW[i][pTowKills]) * 1.5);
                points += points_bonus;
                
                GivePlayerPoints(i, points, true);
            }
        }
        
        EndGame(linkid);
        finish{cell} = true;
    }
    
    static const
        eBlank[e_PLAYERS_TOWER];
        
    P_TOW[playerid] = eBlank;
    
    return true;
}
 
//-----------------------------
 
GAME::Player->Spawn(gameid, linkid, playerid)
{
    static const
        Float:spawns[][][] =
        {
            {
                {-976.590820, 1092.075683, 1344.968994, 167.189147},
                {-974.331054, 1091.783691, 1344.977539, 182.229415},
                {-972.614746, 1090.735961, 1344.990112, 87.915122},
                {-972.616577, 1088.796875, 1344.991577, 85.408508},
                {-974.064819, 1087.205200, 1344.982788, 353.287658},
                {-976.501831, 1087.189941, 1344.965942, 359.554565}
            },
            
            {
                {-1130.423461, 1026.689697, 1345.723999, 2.107750},
                {-1133.388183, 1026.707275, 1345.739990, 358.011108},
                {-1134.376220, 1028.029052, 1345.745239, 272.493530},
                {-1134.375854, 1030.457885, 1345.745239, 263.406768},
                {-1133.348754, 1031.585083, 1345.734863, 169.719161},
                {-1130.280639, 1031.601318, 1345.718872, 183.819366}
            }
        };
    
    new
        teamid = PLAYERS[playerid][pTeamDG],
        rand = random(sizeof(spawns[]));
        
    SetPlayerInterior(playerid, 10);
    
    SetPlayerPos(playerid, spawns[teamid][rand][0], spawns[teamid][rand][1], spawns[teamid][rand][2]);
    SetPlayerFacingAngle(playerid, spawns[teamid][rand][3]);
 
    //-----------------------------
    
    GivePlayerWeapon(playerid, 24, cellmax);
    GivePlayerWeapon(playerid, 27, cellmax);
    GivePlayerWeapon(playerid, 29, cellmax);
    
    //-----------------------------
    
    SetPlayerSkin(playerid, teamid ? 287 : 285);
    
    SetPlayerHealth(playerid, 100.0);
    
    return true;
}
 
//-----------------------------
 
GAME::Player->KillPlayer(gameid, linkid, playerid, deathid)
{
    P_TOW[playerid][pTowKills]++;
 
    return true;
}
 
//-----------------------------
 
GAME::Player->Death(gameid, linkid, playerid)
{
    P_TOW[playerid][pTowDeaths]++;
    
    if(P_TOW[playerid][pTowHasBomb])
        DropBomb(playerid, linkid);
 
    return true;
}
 
//-----------------------------
 
GAME::Player->ShotObject(gameid, linkid, playerid, weaponid, objectid)
{
    new
        cell = GetCellLink(gameid, linkid),
        teamid_enemy = !PLAYERS[playerid][pTeamDG],
        tower_object = object_towers[cell][teamid_enemy];
 
    if(tower_object == objectid)
    {
        static
            Float:x,
            Float:y,
            Float:z;
            
        GetDynamicObjectPos(tower_object, x, y, z);
        
        if(!IsPlayerInRangeOfPoint(playerid, 20.0, x, y, z))
            return GTFP(playerid, "~r~Tu es trop loin de la tourelle.", 1000, 4);
 
        switch(weaponid)
        {
            case WEAPON_DEAGLE: int_health_towers[cell][teamid_enemy] -= 10, P_TOW[playerid][pTowDamagesTower] += 10;
            case WEAPON_SHOTGSPA: int_health_towers[cell][teamid_enemy] -= 4, P_TOW[playerid][pTowDamagesTower] += 4;
            default: int_health_towers[cell][teamid_enemy]--, P_TOW[playerid][pTowDamagesTower]++;
        }
        
        OnTowerTakeDamage(linkid, cell, teamid_enemy);
    }
    
    return true;
}
 
//-----------------------------
 
GAME::Player->KeyChange(gameid, linkid, playerid, newkeys, oldkeys)
{
    if(HOLDING(KEY_NO))
    {
        if(P_TOW[playerid][pTowHasBomb])
        {
            DropBomb(playerid, linkid);
        }
        
        else
        {
            new
                cell = GetCellLink(gameid, linkid),
                Float:x,
                Float:y,
                Float:z;
        
            GetDynamicObjectPos(object_bomb[cell], x, y, z);
        
            if(GetPlayerDistanceFromPoint(playerid, x, y, z) > 5.0) 
                return GameTextForPlayer(playerid, "~r~Tu es trop loin de la bombe.", 1000, 4);
            
            P_TOW[playerid][pTowHasBomb] = true;
            SetPlayerAttachedObject(playerid, 0, 2891, 1, 0.127000, -0.053999, -0.011000, 92.000007, 0.000000, 90.199974);
            
            DestroyDynamicObject(object_bomb[cell]);
            DestroyDynamic3DTextLabel(text3d_bomb[cell]);
            
            GTFP(playerid, "~g~Tu viens de ramasser la bombe~n~~b~Fais-toi sauter avec la tourelle adverse.", 1000, 4);
            Scm(playerid, Color.GRAY, "Pour te faire sauter avec la bombe, appuyez sur la touche H.");
        }
        
        return true;
    }
    
    if(HOLDING(KEY_CTRL_BACK))
    {
        if(P_TOW[playerid][pTowHasBomb])
        {
            new
                cell = GetCellLink(gameid, linkid),
                teamid_enemy = !PLAYERS[playerid][pTeamDG];
        
            if(!IsPlayerInRangeOfPoint(playerid, 5.0, pos_towers[teamid_enemy][0], pos_towers[teamid_enemy][1], pos_towers[teamid_enemy][2])) 
                return GameTextForPlayer(playerid, "~r~Tu es trop loin de la tourelle.", 1000, 4);
        
            P_TOW[playerid][pTowBombsExp]++;
            P_TOW[playerid][pTowHasBomb] = false;
            
            RemovePlayerAttachedObject(playerid, 0);
            
            new 
                Float:x,
                Float:y,
                Float:z;
                
            GetPlayerPos(playerid, x, y, z);
            SetPlayerHealth(playerid, 0.0);
            CreateExplosion(x, y, z, 6, 15.0);
            
            int_health_towers[cell][teamid_enemy] -= 200;
            
            foreach(new i : LinkPlayer[linkid])
            {
                GTFP(i, "~g~La bombe apparaitra~n~~y~dans 2 minutes.", 5000, 4);
                
                if(teamid_enemy == PLAYERS[playerid][pTeamDG])
                    Scm(i, Color.RED, "La bombe vient d'endommager votre tourelle.");
                    
                else
                    Scm(i, Color.GREEN, "La bombe vient d'endommager la tourelle adverse.");
            }
 
            timer_bomb[cell] = SetTimerEx("Timer_Bomb", 120000, false, "dd", linkid, cell);
            
            OnTowerTakeDamage(linkid, cell, teamid_enemy);
        }
    
        return true;
    }
 
    return true;
}
 
//-----------------------------
//-------------------------------------------------
//-----------------------------
 
public OnTowerTakeDamage(linkid, cell, teamid_tower)
{
    if(int_health_towers[cell][teamid_tower] < 0) 
        int_health_towers[cell][teamid_tower] = 0;
 
    static
        string[10];
 
    format(string, sizeof(string), "%d/1000", int_health_towers[cell][teamid_tower]);
    UpdateDynamic3DTextLabelText(text3d_health_towers[cell][teamid_tower], COLOR_RED, string);
 
    //-----------------------------
    
    if(int_health_towers[cell][teamid_tower] <= 0)
    {
        new
            teamid = _:!teamid_tower,
            points_bonus = floatround(float(GetGameTimeByLinkID(linkid)) * 0.03125);
            
        ScmToLink(linkid, Color.WHITE, "L'équipe {%x}%s "WHITE"gagne la partie !", GetTeamColorString(teamid), TEAMS[teamid][tName]);
 
        foreach(new i : LinkPlayer[linkid])
        {               
            if(teamid == PLAYERS[i][pTeamDG])
            {
                new
                    points = 0;
            
                points += P_TOW[i][pTowDamagesTower] / 50;
                points += P_TOW[i][pTowBombsExp] * 5;
                points += floatround(float(P_TOW[i][pTowKills]) * 1.5);
                points += points_bonus;
                
                GivePlayerPoints(i, points, true);
            }
            
            else
            {
                new
                    points = 0;
            
                points += P_TOW[i][pTowDamagesTower] / 100;
                points += P_TOW[i][pTowBombsExp] * 5;
                points += P_TOW[i][pTowKills];
                points += points_bonus;
                
                GivePlayerPoints(i, points, false);
            }
        }
        
        EndGame(linkid);
        finish{cell} = true;
    }
}
 
//-----------------------------
 
public Timer_Bomb(linkid, cell)
{
    if(finish{cell})
        return true;
 
    foreach(new i : LinkPlayer[linkid])
    {   
        GTFP(i, "~g~La bombe est apparue au~n~~g~milieu de la map.", 5000, 4);
    }
    
    object_bomb[cell] = CreateDynamicObject(2891, -1054.687622, 1063.608764, 1343.958740, 0.000000, 0.000000, 0.000000, LINKS[linkid][lWorldID], 10, -1, 400.0, 0.0);   
    text3d_bomb[cell] = CreateDynamic3DTextLabel("Pour prendre la bombe :\nAppuie sur N !", Color.AQUA, -1054.687622, 1063.608764, 1343.958740, 250.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, LINKS[linkid][lWorldID], 10, -1, 10.0);
 
    return true;
}
 
/*
 
    888888888888  ,ad8888ba,   I8,        8        ,8I  88888888888  88888888ba   
         88      d8"'    `"8b  `8b       d8b       d8'  88           88      "8b  
         88     d8'        `8b  "8,     ,8"8,     ,8"   88           88      ,8P  
         88     88          88   Y8     8P Y8     8P    88aaaaa      88aaaaaa8P'  
         88     88          88   `8b   d8' `8b   d8'    88"""""      88""""88'    
         88     Y8,        ,8P    `8a a8'   `8a a8'     88           88    `8b    
         88      Y8a.    .a8P      `8a8'     `8a8'      88           88     `8b   
         88       `"Y8888Y"'        `8'       `8'       88888888888  88      `8b  
 
*/

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎