PDA

View Full Version : Standalone Airstrike CoD2



BlancO
13th September 2013, 22:05
For all wanted real airstrike. Full customizable airstreak standalone script.

_airstrike.gsc


/////////////////////////
// scripted by: BlancO //
/////////////////////////

Setup()
{
// Text variables
level.airstrikeUseText = "Press F in Binoculars to use airstrike!";
level.airstrikeIncommingText = "Airstrike incomming!";

// Models
level.airstrikePlane = "xmodel/vehicle_p51_mustang";
precacheModel(level.airstrikePlane);

level.airstrikeBomb = "xmodel/prop_stuka_bomb";
precacheModel(level.airstrikeBomb);

// Efx of bomb explosion
level.airstrikBombEFX = loadFx("fx/explosions/mortarExp_dirt.efx");

// Count of bombs plane will drop
level.airstrikeBombsCount = 10;
// Distance of damage
level.airstrikeBombRange = 200;
// Damage of single bomb
level.airstrikeBombsDamage = 300;
// Set to 1 on zombie maps with ceils
level.airstrikeIgnoreCeils = 0;
// Team will get damage "allies", "axis", "enemy", "all"
level.airstrikeDamageTo = "axis";
}

DoAirstrike()
{
self endon("disconnect");

if(isDefined(level.airstrikeUse) && level.airstrikeUse != "")
self iPrintlnBold(level.airstrikeUse);

self waittill("binocular_fire");
targetPos = GetTargetedPos();

if(isDefined(level.airstrikeIncommingText) && level.airstrikeIncommingText != "")
iPrintln(level.airstrikeIncommingText);

if(isDefined(targetPos))
{
randomize = (0, randomInt(360), 0);
droppos = (targetPos[0], targetPos[1], targetPos[2] + 400);

forward = anglesToForward(randomize);
forward = maps\mp\_utility::vectorScale(forward, 10000);
endOrigin = droppos + forward;
startOrigin = droppos - forward;

plane = spawn("script_model", startOrigin);
plane setmodel(level.airstrikePlane);
plane.angles = plane.angles + randomize;

plane moveto(endOrigin, 10);

bombs = level.airstrikeBombs;
if(bombs > 30) bombs = 30;

delay = (5 - bombs * 0.05);

wait delay;
for(i = 1; i <= bombs; i += 1)
{
plane thread DropBomb(self);
wait 0.1;
}
wait delay;

plane delete();
}
}

DropBomb(eAttacker)
{
tergetPos = self.origin + (0, 0, -400)
if(!level.airstrikeIgnoreCeils)
{
trace = bulletTrace(self.origin, self.origin + (0, 0, -1000), false, self);
targetPos = trace["position"];
}

bomb = spawn("script_model", self.origin);
bomb setModel(level.airstrikeBomb);
bomb.angles = (90, 0, 0);

time = int(distance(self.origin, targetPos) / 400);
if(time < 0.1)
time = 0.1;

bomb moveTo(targetPos, time);
wait time;

playfx(level.airstrikBombEFX, targetPos);

players = getentarray("player", "classname");
for(i = 0; i < players.size; i++)
if(distance(targetPos, players[i].origin) < level.airstrikeBombRange && players[i].pers["team"] != "spectator" && isAlive(players[i]) && (level.airstrikeDamageTo == "all" || (level.airstrikeDamageTo == "enemy" && eAttacker.pers["team"] != players[i].pers["team"]) || (eAttacker.pers["team"] == level.airstrikeDamageTo)))
players[i] thread [[level.callbackPlayerDamage]](eAttacker, eAttacker, level.airstrikeBombsDamage, 1, "MOD_PISTOL_BULLET", "airstrike_mp", targetPos, targetPos, "none", 0);

bomb delete();
}

GetTargetedPos()
{
startOrigin = self getEye();
forward = anglesToForward(self getPlayerAngles());
forward = maps\mp\_utility::vectorScale(forward, 100000);
endOrigin = startOrigin + forward;

trace = bulletTrace(startOrigin, endOrigin, false, self);
if(trace["fraction"] == 1.0 || trace["surfacetype"] == "default")
endOrigin = trace["position"];
else if(trace["fraction"] < 1)
endOrigin = trace["position"];

return endOrigin;
}


call on start
thread scripts\_airstrike::Setup();

call on player
thread scripts\_airstrike::DoAirstrike();

Have fun!
BlancO ;)

default
22nd October 2013, 20:39
how to use :D

IzNoGoD
22nd October 2013, 21:18
There is a friggin setup() function and a doairstrike() function. What more do you want?

Reading scripts is a good practice to start scripting yourself, and i'd suggest no more explanation should be given

goddzila
5th January 2014, 17:23
No work Script eror u line 82: if(!level.airstrikeIgnoreCeils)

kung foo man
5th January 2014, 17:29
No work Script eror u line 82: if(!level.airstrikeIgnoreCeils)

Looks like a missing ; in the line before.



tergetPos = self.origin + (0, 0, -400)
if(!level.airstrikeIgnoreCeils)


To



tergetPos = self.origin + (0, 0, -400);
if(!level.airstrikeIgnoreCeils)

goddzila
6th January 2014, 12:08
yes and fail line:
tergetPos = self.origin + (0, 0, -400)

update to:

targetPos = self.origin + (0, 0, -400)

and work script...


if someone knows somewhere a script and a model helicopter for cod2

and if someone can make a script to nuke
Video: http://www.youtube.com/watch?list=UU4tE5A94-Lspy_faMU3O-jg&v=OUkuCiM5yLI

Rocky
6th January 2014, 13:03
wtf xd ask inak :]

guiismiti
7th January 2014, 22:18
The chopper script should be complicated, and would require new models.

Guys I'm gonna try to include this to my mod. It will be called on player death and be unlocked on kill streaks (like in the case of COD4, it's a 5 kill streak).

Edit: the chopper movement would be complicated... it accelerates and stops all the time, its longitudinal and side velocities vary a lot -different from the airplane, that has a constant longitudinal velocity. It also turns to different directions. The coordinates it must follow should also be complicated, since the size of the maps is different (idk how its done for COD4, never played a custom map on it).

goddzila
11th January 2014, 17:28
If any of you know how to change the button :

self waittill("binocular_fire")

in this button 6,7,8,9 or f6, f7, f8

Tally
11th January 2014, 18:07
If any of you know how to change the button :

self waittill("binocular_fire")

in this button 6,7,8,9 or f6, f7, f8

You can do that in Options/Shoot/binoculars - [bind key of your choice]

Or, find your "players" folder, and manually edit config_mp.cfg file:


bind F6 "+binoculars"

goddzila
11th January 2014, 19:05
ok for bind

need for airstrike

goddzila
11th January 2014, 19:13
DoAirstrike()
{
self endon("disconnect");

if(isDefined(level.airstrikeUse) && level.airstrikeUse != "")
self iPrintlnBold(level.airstrikeUse);

self waittill("binocular_fire"); <==================================== for:this:I need
targetPos = GetTargetedPos();

if(isDefined(level.airstrikeIncommingText) && level.airstrikeIncommingText != "")
iPrintln(level.airstrikeIncommingText);

if(isDefined(targetPos))

Tally
11th January 2014, 21:04
DoAirstrike()
{
self endon("disconnect");

if(isDefined(level.airstrikeUse) && level.airstrikeUse != "")
self iPrintlnBold(level.airstrikeUse);

self waittill("binocular_fire"); <==================================== for:this:I need
targetPos = GetTargetedPos();

if(isDefined(level.airstrikeIncommingText) && level.airstrikeIncommingText != "")
iPrintln(level.airstrikeIncommingText);

if(isDefined(targetPos))

That is an engine notification - when you raise your binoculars, the game notifies you "binocular_enter"; when you lower them, it notifies you "binocular_exit". You don't have to do anything. The game does it for you.

They are left over notifications from COD:United Offensive - in that game, you fired artillery with the binoculars you acquired when you were a certain rank. The game notified itself that the binoculars had been raised, and then there was a function to monitor for the attackbutton pressed. Then, it targeted what the player was looking at, and fired the artillery on their position. It ended on lowering the binoculars with the notification "binocular_exit".

goddzila
12th January 2014, 12:19
I need more buttons because I need to sentrygun. airstrike and nuke but thanks anyway.

Now I nuke currently put on a headshot kill
http://fr.xfire.com/video/61be00/

guiismiti
1st September 2014, 21:31
Can anybody give me a hand?

What I'm trying to do is - enable air strike for the player when he kills 5 enemies without dying.

- Setup() from _airstrike.gsc is being called in Callback_StartGameType() from tdm.gsc as it is instructed in the first post
- both corrections were made (from kung foo man and goddzila)
- in Callback_PlayerKilled from tdm.gsc I'm calling this:


thread maps\mp\gametypes\_addairstrike::addAirstrike(atta cker);


And this is _addairstrike.gsc:


addAirstrike(attacker)
{
if(attacker.pers["kill_spree"] > 999)
attacker.pers["kill_spree"] = 0;

killcount = undefined;
self.pers["kill_spree"] = 0;
attacker.pers["kill_spree"]++;
killcount = attacker.pers["kill_spree"];

if(killcount == 5)
{
attacker iprintlnBold("^3Use your binoculars to call air support.");
attacker thread maps\mp\gametypes\_airstrike::DoAirstrike();
}
}


The result - I can see the "Use your binoculars" message, but when I do it nothing happens.

By the way, the console is not reporting any errors.

Lol, instead of pressing "F" I've been pressing the regular fire button (mouse 1) all the time.

Anyway, the code I posted is working and should allow the player to use air strike after 5 frags in a row. :)

guiismiti
2nd September 2014, 18:15
Made a mod from the script:
https://www.youtube.com/watch?v=iNEwG3D8EIQ

Modifications:
- Implemented the modifications reported by kung foo man and goddzila;
- You need a 5 killstreak to be able to use the air strike - you can change it in _addAirstrike.gsc;
- When you die, you loose your air strike (to avoid stacks... e. g. someone who died without using it would be able to use twice after another 5 killstreak);
- Changed the models of the planes - it's a spitfire if you're in an allied team, and a stuka if you're axis;
- Added sound to the bomb explosions;
- Added sound to the planes - it's the spitfire flyby sound if you're in an allied team, and a stuka if you're axis;
- Increased the height of the plane route from 400 to 600;
- All changes to ctf/dm/hq/sd/tdm.gsc can be found by searching for the word airstrike. Total of two changes in each file;
- Changed the "Press F (...)" message to "Press [[{+activate}]] (...)", so players who have changed the key of the activate fuction will see the proper key in the message.

http://www.speedyshare.com/yNeGZ/download/zzz-airstrike.iwd


Bug - I had to add self endon spawn to avoid players stacking multiple airstrikes - if a player uses the airstrike, dies and spawns before the plane is gone, the plane won't get deleted (you can even see it in the video).

Another detail - you might need to adjust the number of bombs dropped depending on the size of your map.

guiismiti
3rd September 2014, 19:48
One doubt remaining... the type of weapon used is not defined on airstrike. How can I do it? You can see in the video that, when a player dies, the hud weapon image is a skull - I wanna change it to the one used in COD4 airstrike.

Like these:
745

746

747

serthy
3rd September 2014, 20:04
I wanna change it to the one used in COD4 airstrike.

- create a new custom weapon (or modify a standard one)
- in the weaponfile change the name of the hud indicator to your new material (guess its prefixed with 'hud_')
- precache the weapon in script
- call obituary( arg0 , arg1 , your_weapon_name , arg3 , ... ); (if the weaponfile is corrupted or not precached/does not exist the default deathicon/skull is shown)

remember: you can only precache a specific amount of weapons (32 or 64)

guiismiti
10th September 2014, 02:33
another correction:


bombs = level.airstrikeBombs;


should be changed to:



bombs = level.airstrikeBombsCount;

guiismiti
20th September 2014, 21:48
still in development:

http://social.xfire.com/video/62cc29

:p


by the way, the first matrix I made was 30x15 (so, 450 elements...), and then I found out that it appears I cannot have more than 256 (or so) elements in a single menu. Now it's a 20x10 matrix (200 elements, still good enough).
The background image depends on the map - I added one element with a full screen image for each map of the server, and there's a dvartest to display the image or not.

What is not working so far:
4:3 isn't working. The background image is fullscreen (which is relative to the ratio of your screen). So, if you use 4:3, the menu elements will be in the wrong positions, since they have an absolute origin value, and not a relative (fullscreen is relative). The solution to this would be to use relative origin values for the elements, but right now I don't know how to do that.

BoB-666
31st July 2019, 15:12
Hello how can I install this??
or better where can I download the IWD??

maxdamage99
31st July 2019, 16:59
Maybe this:
https://killtube.org/showthread.php?1526-Airstrike-CoD2&highlight=Mortar

BoB-666
31st July 2019, 20:52
I've got it now have now only the problem that he shows me after 5 kills me no picture...

BoB-666
3rd August 2019, 12:30
Hallo ich habe das Problem wenn ich sterbe das er mir die Grafik by (BomberReady) nicht löscht kann mir da Bitte einer weiterhelfen???
Hello I have the problem if I die that he does not delete the graphic by (BomberReady) can me there Please help one ???



///////////////////////////////////
// Scripted by: BlancO //
// Modifikation by: BoB-666 //
/////////////////////////////////

Setup()
{
// Text variables
level.airstrikeIncommingText = "Airstrike incomming!";

// Models
level.airstrikePlane = "xmodel/vehicle_condor";
precacheModel(level.airstrikePlane);

level.airstrikeBomb = "xmodel/prop_stuka_bomb";

precacheModel(level.airstrikeBomb);

//STHM Efx of bomb explosion
level._effect["airstrikBombEFX"] = loadfx("fx/custom/airstrike.efx");

level.airstrikeBombsCount = 10; // OR, 10 // Anzahl der Bomben Flugzeug wird fallen
level.airstrikeBombRange = 200; // OR, 200 // Entfernung des Schadens
level.airstrikeBombsDamage = 250; // Beschädigung einer einzelnen Bombe
level.airstrikeIgnoreCeils = 0; // Auf Zombiekarten mit Decken auf 1 setzen
level.airstrikeDamageTo = "enemy"; // Team will get damage "allies", "axis", "enemy", "all"

// STHM Modifikation
game["bomber_icon"] = "sthm_@_bombe";
precacheShader(game["bomber_icon"]);
precacheString(&"[ B ]");
}

CleanupKilled()
{
self endon("killed_player");
self endon("disconnect");

// Remove hud elements
if (isdefined(self.bomber_icon)) self.bomber_icon destroy();
if (isdefined(self.bomber_text)) self.bomber_text destroy();
}

DoAirstrike()
{
self endon("killed_player"); // STHM Modifikation
self endon("disconnect");

if(isDefined(level.airstrikeUse) && level.airstrikeUse != "")
self iPrintlnBold(level.airstrikeUse);

//===== STHM Show Bomber HUD ================================================== ===
BomberReady(); // STHM Bomber Ready HuD
//================================================== =========================

self waittill("binocular_fire");
targetPos = GetTargetedPos();

if(isDefined(level.airstrikeIncommingText) && level.airstrikeIncommingText != "")
iPrintln(level.airstrikeIncommingText);

if(isDefined(targetPos))
{
randomize = (0, randomInt(360), 0);
droppos = (targetPos[0], targetPos[1], targetPos[2] + 1000);
forward = anglesToForward(randomize);
forward = maps\mp\_utility::vectorScale(forward, 10000);
endOrigin = droppos + forward;
startOrigin = droppos - forward;

//===== STHM CleanUp Bomber HUD =================================================
CleanupKilled(); // STHM Remove hud elements
//================================================== =======================

plane = spawn("script_model", startOrigin);
plane setmodel(level.airstrikePlane);
plane.angles = plane.angles + randomize;

plane moveto(endOrigin, 10);
plane playSound( "stuka_comming"); // STHM Sound Play Bomber is Comming

bombs = level.airstrikeBombsCount;
if(bombs > 30) bombs = 30;

delay = (5 - bombs * 0.05);

wait delay;
for(i = 1; i <= bombs; i += 1)
{
plane thread DropBomb(self);
wait 0.1;
}
wait delay;

plane delete();
}
}

BomberReady()
{
self endon("killed_player"); // STHM Modifikation
self endon("disconnect");

//===== STHM Bomber HuD Anzeige Setup ================================================== ===
horzAlign = "center_safearea";
vertAlign = "bottom";
alignX = "center";
alignY = "middle";
X = 0;
Y = -30;
alpha = 0.6;
fontscale = 0.65;
//================================================== ================================

//===== STHM Bomber HUD Bild ================================================== ============
if (!isdefined(self.bomber_icon))
{
self.bomber_icon = newClientHudElem(self);
self.bomber_icon.horzAlign = horzAlign;
self.bomber_icon.vertAlign = vertAlign;
self.bomber_icon.alignX = alignx;
self.bomber_icon.alignY = alignY;
self.bomber_icon.x = X;
self.bomber_icon.y = Y;
self.bomber_icon.alpha = 0.7;
self.bomber_icon setShader(game["bomber_icon"], 30, 30);
}
//================================================== =======================================
// END Bomber HUD Bild

//===== STHM Bomber HUD Text ================================================== ============
if (!isdefined(self.bomber_text))
{
self.bomber_text = newClientHudElem(self);
self.bomber_text.horzAlign = horzAlign;
self.bomber_text.vertAlign = vertAlign;
self.bomber_text.alignx = alignX;
self.bomber_text.alignY = alignY;
self.bomber_text.x = X;
self.bomber_text.y = Y + 20;
self.bomber_text.fontscale = fontscale;
self.bomber_text.label = &"[ B ]";
}
//================================================== =======================================
// END Bomber HUD Text
}

DropBomb(eAttacker)
{
//===== Auf Zombiekarten mit Decken ================================================== =====
if(!level.airstrikeIgnoreCeils)
{
trace = bulletTrace(self.origin, self.origin + (0, 0, -1000), false, self);
targetPos = trace["position"];
}
//================================================== =======================================

targetPos = self.origin + (0, 0, -1000);
trace = bulletTrace(self.origin, self.origin + (0, 0, -1600), false, self);
targetPos = trace["position"];

bomb = spawn("script_model", self.origin);
bomb setModel(level.airstrikeBomb);
bomb.angles = (90, 0, 0);

time = 0.85;

bomb moveTo(targetPos, time);

wait time;

number = randomInt(5) + 1;
bomb playsound("mortar_explosion" + number);

bomb hide();

playfx(level._effect["airstrikBombEFX"], targetPos);

players = getentarray("player", "classname");
for(i = 0; i < players.size; i++)
{
if(distance(targetPos, players[i].origin) < level.airstrikeBombRange && players[i].pers["team"] != "spectator" && isAlive(players[i]) && (level.airstrikeDamageTo == "all" || (level.airstrikeDamageTo == "enemy" && eAttacker.pers["team"] != players[i].pers["team"]) || (eAttacker.pers["team"] == level.airstrikeDamageTo)))
players[i] thread [[level.callbackPlayerDamage]](eAttacker, eAttacker, level.airstrikeBombsDamage, 1, "MOD_EXPLOSIVE", "airstrike_mp", targetPos, targetPos, "none", 0);
}

wait 0.5;

bomb delete();
}

GetTargetedPos()
{
startOrigin = self getEye();
forward = anglesToForward(self getPlayerAngles());
forward = maps\mp\_utility::vectorScale(forward, 100000);
endOrigin = startOrigin + forward;
trace = bulletTrace(startOrigin, endOrigin, false, self);

if(trace["fraction"] == 1.0 || trace["surfacetype"] == "default")
endOrigin = trace["position"];
else
if(trace["fraction"] < 1)
endOrigin = trace["position"];

return endOrigin;
}


MFG
BoB

vanfreddy
3rd August 2019, 18:21
muss das killed player wegmachen zb bei cleanup und vlt noch bei anderen

vanfreddy
3rd August 2019, 18:23
DoAirstrike()
{
self endon("killed_player"); // STHM Modifikation

hier muss das killed player auf jedenfall weg

und beim spawn zur sicherheit in der spawnplayer funktion nochma
if (isdefined(self.bomber_icon)) self.bomber_icon destroy();
if (isdefined(self.bomber_text)) self.bomber_text destroy();