Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <foreach>
- #define RELEASED(%0) \
- (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
- forward OnPlayerShot(playerid);
- new PlayerTimer[MAX_PLAYERS];
- new Float:BotHealth[MAX_PLAYERS];
- new BotDead[MAX_PLAYERS];
- new const Float: WeaponDamages[43] =
- {
- 0.0, //ID 1
- 0.0, //ID 2
- 0.0, //ID 3
- 0.0, //ID 4
- 0.0, //ID 5
- 0.0, //ID 6
- 0.0, //ID 7
- 0.0, //ID 8
- 0.0, //ID 9
- 0.0, //ID 10
- 0.0, //ID 11
- 0.0, //ID 12
- 0.0, //ID 13
- 0.0, //ID 14
- 0.0, //ID 15
- 0.0, //ID 16
- 0.0, //ID 17
- 0.0, //ID 18
- 0.0, //ID 19
- 0.0, //ID 20
- 0.0, //ID 21
- 5.5, //ID 23
- 5.5, //ID 24
- 6.5, //ID 25
- 0.0, //ID 26
- 0.0, //ID 27
- 3.5, //ID 28
- 0.0, //ID 29
- 6.5, //ID 30
- 2.5, //ID 31
- 0.0, //ID 32
- 4.5, //ID 33
- 0.0, //ID 34
- 0.0, //ID 35
- 0.0, //ID 36
- 0.0, //ID 37
- 0.0, //ID 38
- 0.0, //ID 39
- 0.0, //ID 40
- 0.0, //ID 41
- 0.0, //ID 42
- 0.0, //ID 43
- };
- // Stocks
- stock IsPlayerFacingPlayer(playerid, playerid2, Float:dOffset) // a_angles.inc -ből, by Tanz0rz
- {
- new
- Float:X,
- Float:Y,
- Float:Z,
- Float:pX,
- Float:pY,
- Float:pZ,
- Float:pA,
- Float:ang;
- if(!IsPlayerConnected(playerid)) return 0;
- GetPlayerPos(playerid2, pX, pY, pZ);
- GetPlayerPos(playerid, X, Y, Z);
- GetPlayerFacingAngle(playerid, pA);
- if( Y > pY ) ang = (-acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
- else if( Y < pY && X < pX ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 450.0);
- else if( Y < pY ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
- if(AngleInRangeOfAngle(-ang, pA, dOffset)) return true;
- return false;
- }
- stock AngleInRangeOfAngle(Float:a1, Float:a2, Float:range)
- {
- a1 -= a2;
- if((a1 < range) && (a1 > -range)) return true;
- return false;
- }
- //
- public OnFilterScriptInit()
- {
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- if(!IsPlayerNPC(playerid)){PlayerTimer[playerid] = SetTimerEx("OnPlayerShot", 150, true, "i", playerid);}
- return 1;
- }
- public OnPlayerDisconnect(playerid)
- {
- if(!IsPlayerNPC(playerid)){KillTimer(PlayerTimer[playerid]);}
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(IsPlayerNPC(playerid)){
- BotHealth[playerid] = 100.0;
- BotDead[playerid] = 0;
- }
- return 1;
- }
- public OnPlayerShot(playerid)
- {
- if(!IsPlayerNPC(playerid))
- {
- new o_keys, up_dw, lt_rt;
- GetPlayerKeys(playerid, o_keys, up_dw, lt_rt);
- foreach(Bot, botid)
- {
- if(o_keys == KEY_FIRE || o_keys == (KEY_FIRE+128))
- {
- if(IsPlayerFacingPlayer(playerid, botid, 5.0) && !IsPlayerInAnyVehicle(botid))
- {
- if(BotHealth[botid] > 0.5)
- {
- BotHealth[botid] -= WeaponDamages[GetPlayerWeapon(playerid) -1];
- }
- else if(BotHealth[botid] < 0.5)
- {
- BotDead[botid] ++;
- ApplyAnimation(botid, "Wuzi","CS_Dead_Guy", 1,0,1,0,0,0);
- if(BotDead[botid] > 10)
- {
- SpawnPlayer(botid);
- BotDead[botid] = 0;
- }
- }
- }
- }
- if(o_keys != KEY_FIRE || o_keys != (KEY_FIRE+128))
- {
- if(BotHealth[botid] < 0.5)
- {
- BotDead[botid] ++;
- ApplyAnimation(botid, "Wuzi","CS_Dead_Guy", 1,0,1,0,0,0);
- if(BotDead[botid] > 10)
- {
- SpawnPlayer(botid);
- BotDead[botid] = 0;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment