| Author |
Topic: Working artillery system |
| XICXAC |
 |
General Member Since: Jun 3, 2007 Posts: 91 Last: Mar 28, 2008 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Saturday, Aug. 4, 2007 11:04 am |
 |
Hey guys. I'm trying to set up a working artillery system, that randomly plays an explosion effect on one of the script_origins with the targetname "artilleryspot" (random one in the array). I want this to work to fire like 30 - 40 shells every artillery barrage but when I try my script nothing happens.
Code:
level._effect["flak_artillery"] = loadfx("fx/explosions/artilleryExp_dirt_libya.efx");
artillery_spots = getentarray("artilleryspot","targetname");
for(i=0;i>30;i++) { // play fx 30 times
wait(1);
rand = randomint(artillery_spots.size);
fx_origin = artillery_spots[rand] getorigin();
playfx(level._effect["flak_artillery"], fx_origin);
}
This is for sp. Can anyone tell me what's wrong?
edited on Aug. 4, 2007 07:04 am by XICXAC |
 |
|
|
| The_Caretaker |
General Member Since: Jun 8, 2004 Posts: 11625 Last: Jul 7, 2009 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Saturday, Aug. 4, 2007 11:18 am |
 |
try
Code: for(i=0;i<30;i++)
instead. |
 |
|
|
| XICXAC |
 |
General Member Since: Jun 3, 2007 Posts: 91 Last: Mar 28, 2008 [view latest posts] |
|
|
|
|
| kalieck |
General Member Since: Aug 9, 2006 Posts: 161 Last: Feb 14, 2009 [view latest posts] |
|
|
|
|
| ahoji |
 |
General Member Since: May 16, 2006 Posts: 74 Last: Jun 27, 2008 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Saturday, Sep. 1, 2007 06:05 pm |
 |
I tryied do a script on artillery - randomly plays efx and do radius damage in origin ( still without making holes - but it won't be difficult)
mainly used script on making mortal holes
Code:
main()
{
level._effect["mortexplosion"] = loadfx("fx/explosions/artilleryExp_dirt_brown.efx");
thread bradio();
level.bombing = false;
}
bradio()
{
bradio=getent("bradio","targetname");
trig=getent("bradiotrig","targetname");
while(1)
{
trig waittill ("trigger",other);
if((isplayer (other)) && (other.pers["team"] == "allies") && !level.bombing)
{
level.bombing = true;
bradio playsound("sound1sg");
wait 5;
bradio playsound("sound3sg");
wait 5;
thread bombing();
}
}
}
bombing()
{
orig_boom = getentarray ("orig_boom","targetname");
for(i=0;i<10;i=i+1)
{
k=randomint(31); //nums of origins on map + 1
origin = orig_boom[k] getorigin();
orig_boom[k] playsound("incoming_mortar");
wait (1);
orig_boom[k] playsound("explosion_ground");
playfx(level._effect["mortexplosion"], origin);
radiusDamage(origin, 200, 200, 100);
wait (1);
}
level.bombing = false;
}
|
 |
|
|
| kalieck |
General Member Since: Aug 9, 2006 Posts: 161 Last: Feb 14, 2009 [view latest posts] |
|
|
|
|
| ahoji |
 |
General Member Since: May 16, 2006 Posts: 74 Last: Jun 27, 2008 [view latest posts] |
|
|
|
|
| XICXAC |
 |
General Member Since: Jun 3, 2007 Posts: 91 Last: Mar 28, 2008 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Sunday, Sep. 2, 2007 05:42 pm |
 |
Well here's my code. Before you add it to your source code, make a bunch of script_origins, all with the key/value of targetname/artilleryspot .
Now I made this an own function so you have to call it to get it working. In your code, write Code:
thread artillery(10) or Code: artillery(10)
The "10" means it will "fire" 10 shells.
you also need to add the main artillery function
Code:
artillery(shells) {
artillery_spots = getentarray("artilleryspot","targetname");
for(i=0;i<shells;i++) {
wait(0.5 + randomfloat(1));
rand = randomint(artillery_spots.size);
origin = artillery_spots[rand] getorigin();
playfx(level._effect["flak_artillery"], origin);
if(distance(artillery_spots[rand].origin,level.player.origin) > 100) {
level.player playsound("explosion_ground");
earthquake(0.5, 2, level.player.origin, distance(artillery_spots[rand].origin,level.player.origin));
}
}
}
The earthquake is just something i played with, and as I can't get the sounds working, there are no sounds played in this script. You gonna have to add that yourself.
|
 |
|
|
| Snake-nl |
 |
General Member Since: May 30, 2004 Posts: 394 Last: Jan 23, 2011 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Saturday, Nov. 3, 2007 02:42 pm |
 |
srry for using this topic but i have a question about the same subject.
i also want a artillery system. But this time i want to trigger it. so when the player hits the trigger the artillery must start.
i have made the origins and used the script of XICXAC and that works perfect (no sound yet but working on that) . only the artillery starts when the map starts.
now i made a trigger named:
Key: targetname
value: startartillery
And i use this code but i doens't work.
Code:
artillery()
{
startartillery = getent ("startartillery", "targetname");
trig = getent ("startartillery_trigger", "targetname");
{
trig waittill ("trigger");
level._effect["flak_artillery"] = loadfx("fx/explosions/artilleryExp_dirt_libya.efx");
artillery_spots = getentarray("artilleryspot","targetname");
for(i=0;i<30;i++) { // play fx 30 times
wait(1);
rand = randomint(artillery_spots.size);
fx_origin = artillery_spots[rand] getorigin();
playfx(level._effect["flak_artillery"], fx_origin);
}
}
}
|
 |
|
|
| XICXAC |
 |
General Member Since: Jun 3, 2007 Posts: 91 Last: Mar 28, 2008 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Tuesday, Nov. 13, 2007 06:02 pm |
 |
Try
Code: artillery()
{
startartillery = getent ("startartillery", "targetname");
{
startartillery waittill ("trigger");
level._effect["flak_artillery"] = loadfx("fx/explosions/artilleryExp_dirt_libya.efx");
artillery_spots = getentarray("artilleryspot","targetname");
for(i=0;i<30;i++) { // play fx 30 times
wait(1);
rand = randomint(artillery_spots.size);
fx_origin = artillery_spots[rand] getorigin();
playfx(level._effect["flak_artillery"], fx_origin);
}
}
}
|
 |
|
|
|
|
mp_TempleCall of Duty: Mods: Multiplayer (624.12Kb)
|