Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 8 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Previous Page
subscribe
Author Topic: Timed explosion
codmp
General Member
Since: Feb 7, 2006
Posts: 905
Last: Aug 1, 2011
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Monday, Mar. 19, 2007 08:54 pm
To repeat the explosions you could just use a while loop.

bomb
{
//Define stuf here....maybe

while(1)
{
........
..
........
}
}
Share |
WHC_Grassy
General Member
Since: Apr 20, 2005
Posts: 1426
Last: Aug 25, 2007
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Tuesday, Mar. 20, 2007 06:26 am
Expanding on what codmp posted.

This will loop constantly but you can set a delay in the main loop.
You can also set the number of arty hits you want.
You can also set the random time delay of the hits.

Code:

main
{
  level._effect["explosion"] = loadfx("fx/explosions/artilleryExp_dirt_brown.efx");

  thread do_arty();
}

do_arty()
{
	//set how many arty hits you want
	number_of_strikes = 3;
	
	//set a delay period between loops
	loop_delay = 60;	// 1 minute
	
	//script origins, all with targetnames of arty_drop_point
	arty = getentarray("arty_drop_point", "targetname");

	while(1)
	{
		for( i = 0 ; i < number_of_strikes ; i++ )
		{
			delay = randomfloat(3);	//set desired delay maximum
			hit_point = randomint(arty.size);
			playfx(level._effect["explosion"], arty[hit_point].origin);
			wait(delay);
		}
		wait(loop_delay);
	}
}


Regards Grassy

edited on Mar. 20, 2007 02:28 am by WHC_Grassy
Share |
PfcOutlaw
General Member
Since: May 20, 2004
Posts: 29
Last: Sep 13, 2008
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Tuesday, Mar. 20, 2007 04:10 pm
that looks alot simpler than the way I was doing it, and alot less code. I will give that a try tonight after work
thanks guys for your help
Share |
PfcOutlaw
General Member
Since: May 20, 2004
Posts: 29
Last: Sep 13, 2008
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Thursday, Mar. 22, 2007 01:33 pm
I have the arty working and it picks random points to explode, nice by the way. The only problem I have now is that I can't get the sound working at all. I was getting a script error with some of things I tried but no script errors now when I run the map, just explosions but no sound.
Thanks in advance

Here is the explosions.gsc

Code:
main()

{
  level._effect["explosion"] = loadfx("fx/explosions/artilleryExp_dirt_brown.efx");

  thread do_arty();
}

do_arty()
{
	//set how many arty hits you want
	number_of_strikes = 3;
	
	//set a delay period between loops
	loop_delay = 60;	// 1 minute
	
	//script origins, all with targetnames of arty_drop_point
	arty = getentarray("arty_drop_point", "targetname");

	while(1)
	{
		for( i = 0 ; i < number_of_strikes ; i++ )
		{
			delay = randomfloat(3);	//set desired delay maximum
			hit_point = randomint(arty.size);
			playfx(level._effect["explosion"], arty[hit_point].origin);
			// Play the explosion sound
    			arty playsound("arty_explosion");
			radiusDamage(arty[hit_point].origin+(0,0,12), 500, 2000, 50);
			earthquake(0.3, 3, arty[hit_point].origin, 2096);  //(scale, duration, source, radius)	
			wait(delay);
		}
		wait(loop_delay);
	}
}


here is the mp_artytestmap.csv

Code:
name,sequence,file,vol_min,vol_max,vol_mod,pitch_min,pitch_max,dist_min,dist_max,channel,type,probability,loop,masterslave,loadspec,subtitle,compression,secondaryaliasname,volumefalloffcurve,startdelay,speakermap,reverb,lfe percentage

#Ambiance

ambient_mp_artytestmap,,ambient/amb_france01b.mp3,0.63,,,,,,,local,streamed,,looping,,mp_artytestmap

arty_explosion,1,explosions/mortar_dirt01.wav,0.85,0.9,explosion,1,1.3,50,15000,voice,streamed,,,0.5,mp_artytestmap
Share |
The_Caretaker
General Member
Since: Jun 8, 2004
Posts: 11625
Last: Jul 7, 2009
[view latest posts]
Level 10
Category: CoD2 Scripting
Posted: Thursday, Mar. 22, 2007 02:09 pm
because arty is an array, you'll have to define which entity out of the array has to play the sound.

arty[hit_point] playsound("arty_explosion");

should work.
Share |
PfcOutlaw
General Member
Since: May 20, 2004
Posts: 29
Last: Sep 13, 2008
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Thursday, Mar. 22, 2007 03:07 pm
yup that worked, thanks alot
I knew that and was sure I tried that, but it was late, I was tired, and I must have typed it in wrong

thanks again
Share |
Screwtape566
General Member
Since: Jun 28, 2006
Posts: 33
Last: Sep 8, 2007
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Friday, Mar. 23, 2007 01:21 pm
The way I would do this would be to call a thread with an always true loop construct, for example:
Code:

main
{
  level thread repeat_this();
}
repeat_this ()
{
  while (1)
  {
      wait *some interval*;
      do_something();
  }
}
do_something() 
{
  iprintln("ouch, stop it");
}

Just define your interval, and put your effect in your equivalent to do_something() and your set.

As for selecting a target at random, just use randomInt function, such as:
Code:
target = randomInt(6);

which will give you a randomly generated value of 0 to 5, which you can use to select a target for your intended effect. For a 2 out of 6 targets, you'll need to get two random values, and make sure you track which targets you've already selected at random so you don't get the same target twice. Of course if you don't care, you don't need to track that.

PfcOutlaw writes...
Quote:
I have been playing around with this and have gotten it to work as an arty strike basically, no planes or such, just a couple of nice explosions at a timed period. I just have a couple of questions that have eluded me.

how would you get a script like this to repeat itself after its run thru the first time?

And would it be possible to have a random selection of just 2 or 3 "targets" out of a possible 6 or more "targets"?

thanks in advance

Share |
PfcOutlaw
General Member
Since: May 20, 2004
Posts: 29
Last: Sep 13, 2008
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Friday, Mar. 23, 2007 11:36 pm
I have noticed sometimes they do happen in the same place, not very often but once in awhile. I will have to play around with that and see what will happen.
thanks for the advice and info
Share |
Restricted Access Topic is Locked
Page
Previous Page
subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»