Barrel reproduction?

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Barrel reproduction?

Post by Master-Of-Fungus-Foo-D »

umh i dug up this old thing:
burshmodel land
and i used it in my script and i cant seem to get it to work.. heres my script:

Code: Select all

local.barrel1 = spawn BarrelObject "targetname" "barrel1" "model" "$Gas_Mother.brushmodel"
local.barrel2 = spawn BarrelObject "targetname" "barrel2" "model" "$Gas_Mother.brushmodel"
local.barrel3 = spawn BarrelObject "targetname" "barrel3" "model" "$Gas_Mother.brushmodel"
local.barrel4 = spawn BarrelObject "targetname" "barrel4" "model" "$Gas_Mother.brushmodel"
local.barrel5 = spawn BarrelObject "targetname" "barrel5" "model" "$Gas_Mother.brushmodel"
local.barrel6 = spawn BarrelObject "targetname" "barrel6" "model" "$Gas_Mother.brushmodel"
local.fxtruck = spawn fx/tankboom 
local.fx  = spawn models/fx/barrel_gas_destroyed 
local.fx2 = spawn models/fx/barrel_gas_destroyed 
local.fx3 = spawn models/fx/barrel_gas_destroyed 
local.fx4 = spawn models/fx/barrel_gas_destroyed 
local.fx5 = spawn models/fx/barrel_gas_destroyed 
local.fx6 = spawn models/fx/barrel_gas_destroyed 
local.fxtruck glue $trucky
local.fx glue $barrel1
local.fx glue $barrel2
local.fx glue $barrel3
local.fx glue $barrel4
local.fx glue $barrel5
local.fx glue $barrel6


local.truck = spawn vehicles/opeltruckgreen.tik "trucky"
local.truck.origin = $truckspawn.origin
local.truck.angles = (0.00 90.00 0.00)
local.truck attachpassengerslot 1 $barrel1
local.truck attachpassengerslot 2 $barrel2
local.truck attachpassengerslot 3 $barrel3
local.truck attachpassengerslot 4 $barrel4
local.truck attachpassengerslot 5 $barrel5
local.truck attachpassengerslot 6 $barrel6

local.trig = spawn trigger_multiple "health" "1000" "spawnflags" "128" "setthread" "maps/minigames/DYC2/tanx.scr::killmrtruck"
local.trig setsize  ( -128 -128 -128 ) ( 128 128 128 )
local.trig glue local.truck

local.guy = spawn human/german_winter_type1.tik "targetname" "trucker" "testanim" "opel_driver"
local.guy ai_off
local.truck attachdriverslot local.guy
and heres my qconsole log:

Code: Select all

^~^~^ Can't find models/$gas_mother.brushmodel
Tiki:LoadFile Couldn't load models/$gas_mother.brushmodel
^~^~^ Bad model name '$Gas_Mother.brushmodel'
local.barrel1 = spawn BarrelObject "targetname" "barrel1" "model" "$Gas_Mother.brushmodel" (maps/minigames/dyc2/tanx.scr, 92)
local.barrel1 = ^

	thread spawntrux (maps/minigames/dyc2/tanx.scr, 13)
	^

exec maps/minigames/DYC2/tanx.scr (maps/test_winterbash.scr, 59)
^

********************
ERROR: func_barrel::setSolidType : SOLID_BSP entity at x0.00 y0.00 z0.00 with no BSP model


********************
i made a barrel out of patches, turned it into a script_object and targetnamed it "Gas_mother".... what am i doing wrong?
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

Try this:

Code: Select all

local.barrel1 = spawn BarrelObject "targetname" "barrel1" "model" "*Gas_Mother"
local.barrel2 = spawn BarrelObject "targetname" "barrel2" "model" "*Gas_Mother"
local.barrel3 = spawn BarrelObject "targetname" "barrel3" "model" "*Gas_Mother"
local.barrel4 = spawn BarrelObject "targetname" "barrel4" "model" "*Gas_Mother"
local.barrel5 = spawn BarrelObject "targetname" "barrel5" "model" "*Gas_Mother"
local.barrel6 = spawn BarrelObject "targetname" "barrel6" "model" "*Gas_Mother"
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Post by Master-Of-Fungus-Foo-D »

with the star? ive never sen that before :S
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

If you look in the bsp for worldspawn that is the start of the text part of the bsp brushmodels are stored by * and a number like this

{
"model" "*40"
"origin" "788 3232 -36"
"classname" "func_barrel"
"barreltype" "gas"
}
{
"model" "*41"
"origin" "796 3280 -36"
"barreltype" "oil"
"classname" "func_barrel"
}


you can use that for the model and set the barreltype key as well I guess when you spawn it .
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Re: Barrel reproduction?

Post by tltrude »

Master-Of-Fungus-Foo-D wrote:...targetnamed it "Gas_mother".... what am i doing wrong?
Perhaps it is a syntax error with the targetname.

Gas_Mother
Gas_mother

I have never had any luck spawning func_barrels, but you could always spawn a trigger and an explosion--like I did for the crates in "altelevator".

Here is something else you can try, but I have only had limited success with it. Copy it to note pad and name it "explodeobject.cpp". Then put it in a main/code folder. Most of the tik files it mentions do not exist in mohaa. But, you will see func_explodeobject in the editor.

Code: Select all

/*****************************************************************************/
/*QUAKED func_explodeobject (0 0.25 0.5) ? MULTI_USE RANDOM_TIME VISIBLE RANDOM_SCALE NO_EXPLOSIONS METAL_DEBRIS ROCK_DEBRIS NOTSOLID

tltrude comments/information:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Description:
------------

  Spawns different kinds of debris when triggered.  Triggers any targets.
  size of brush determines where explosions and debris will be spawned.

Spawnflags:
===========

  MULTI_USE allows the func_explodeobject to be used more than once
  RANDOM_TIME adjusts the wait between each explosion by the random factor
  VISIBLE allows you to make the trigger visible
  RANDOM_SCALE scale explosions and debris randomly. size will be between 0.25 and 1 times scale
  NO_EXPLOSIONS, if checked no explosions will be created
  METAL_DEBRIS automatically spawn metal debris, no need for debrismodel to be set
  ROCK_DEBRIS automatically spawn rock debris, no need for debrismodel to be set
  NOTSOLID debris is not solid

  other valid tiki files include:

  obj_debris_glass1-4.tik
  obj_debris_wood1-4.tik


Values:
=======

  "dmg" specifies how much damage to cause from each explosion. (Default 120)
  "delay" delay before exploding (Default 0 seconds)
  "duration" how long to explode for (Default 1 second)
  "wait" time between each explosion (default 0.25 seconds)
  "random" random factor (default 0.25)
  "health" if specified, object must be damaged to trigger
  "key" The item needed to activate this. (default nothing)
  "severity" how violent the debris should be ejected from the object( default 1.0 )
  "debrismodel" What kind of debris to spawn (default nothing)
  "amount" how much debris to spawn for each explosion (default 4)
  "thread" name of thread to trigger.  This can be in a different script file as well\
by using the '::' notation.
  "health" makes the object damageable
  "scale" set the maximum size for spawned debris and explosions
  "doexplosion" specifies to use an explosion (can also specify explosion model and explosion radius)

Functions:
==========

None !

Internal Engine Use:
====================

None !

Not sure ?:
===========


******************************************************************************/

Event EV_ExplodeObject_SetSeverity
(
	"severity",
	EV_DEFAULT,
	"f",
	"newSeverity",
	"How violently the debris should be ejected."
);
Event EV_ExplodeObject_SetDebrisModel
(
	"debrismodel",
	EV_DEFAULT,
	"s",
	"debrisModel",
	"What kind of debris to spawn when triggered."
);
Event EV_ExplodeObject_SetDebrisAmount
(
	"amount",
	EV_DEFAULT,
	"i",
	"amountOfDebris",
	"How much debris to spawn each time."
);
Event EV_ExplodeObject_SetSound
(
	"setsound",
	EV_DEFAULT,
	"s",
	"soundname",
	"Sound played when the debris explosion occurs"
);
Event EV_ExplodeObject_SetupExplodeTiki
(
	"explodetiki",
	EV_TIKIONLY,
	NULL,
	NULL,
	"Specifies that this is an exploding tiki file (visible and solid).  Use only in tiki files"
);
Event EV_ExplodeObject_SetExplosion
(
	"doexplosion",
	EV_DEFAULT,
	"SF",
	"explosionModel explosionRadius",
	"Causes the object to explode (use dmg to set the damage)"
);
Event EV_ExplodeObject_UseEarthquake
(
	"explodeObject_UseEarthquake",
	EV_DEFAULT,
	NULL,
	NULL,
	"Causes the object to spawn an earthquake when it explodes"
);
Event EV_ExplodeObject_SetEarthquakeDuration
(
	"explodeObject_EarthquakeDuration",
	EV_DEFAULT,
	"f",
	"earthquakeDuration",
	"Sets the earthquake duration"
);
Event EV_ExplodeObject_SetEarthquakeMagnitude
(
	"explodeObject_EarthquakeMagnitude",
	EV_DEFAULT,
	"f",
	"earthquakeMagnitude",
	"Sets the earthquake magnitude"
);
Event EV_ExplodeObject_SetEarthquakeDistance
(
	"explodeObject_EarthquakeDistance",
	EV_DEFAULT,
	"f",
	"earthquakeDistance",
	"Sets the earthquake distance"
);

CLASS_DECLARATION( MultiExploder, ExplodeObject, "func_explodeobject" )
{
	{ &EV_Touch,										NULL },
	{ &EV_Trigger_Effect,								MakeExplosion },
	{ &EV_ExplodeObject_SetSeverity,					SetSeverity },
	{ &EV_ExplodeObject_SetDebrisModel,					SetDebrisModel },
	{ &EV_ExplodeObject_SetDebrisAmount,				SetDebrisAmount },
	{ &EV_ExplodeObject_SetupExplodeTiki,				ExplodeTiki },
	{ &EV_Damage,										Damage },
	{ &EV_ExplodeObject_SetSound,						SetSound },
	{ &EV_ExplodeObject_SetExplosion,  					SetExplosion },
	{ &EV_ExplodeObject_UseEarthquake, 					setSpawnEarthquake },
	{ &EV_ExplodeObject_SetEarthquakeDuration,			setEarthquakeDuration },
	{ &EV_ExplodeObject_SetEarthquakeMagnitude,			setEarthquakeMagnitude },
	{ &EV_ExplodeObject_SetEarthquakeDistance,			setEarthquakeDistance },

	{ NULL, NULL }
};

void ExplodeObject::SetSound( Event *ev )
{
	if ( ev->NumArgs() > 0 )
		debrissound = ev->GetString(1);
}

void ExplodeObject::SetExplosion( Event *ev )
{
	if ( ev->NumArgs() > 0 )
		explosionmodel = ev->GetString( 1 );
	if ( ev->NumArgs() > 1 )
		explosionradius = ev->GetFloat( 2 );
	
	spawnflags &= ~NO_EXPLOSIONS;
}

void ExplodeObject::Damage( Event *ev )
{
	Entity::DamageEvent( ev );
}

void ExplodeObject::SetDebrisModel( Event *ev )
{
	char   string[ 1024 ];
	const char *ptr;
	
	// there could be multiple space delimited models, so we need to search for the spaces.
	strcpy( string,  ev->GetString( 1 ) );
	ptr = strtok( string, " " );
	while ( ptr )
	{
		debrismodels.AddUniqueObject( str( ptr ) );
		CacheResource( ptr, this );
		ptr = strtok( NULL, " " );
	}
}

void ExplodeObject::SetSeverity( Event *ev )
{
	severity = ev->GetFloat( 1 );
}

void ExplodeObject::ExplodeTiki( Event *ev )
{
	spawnflags |= VISIBLE;
	spawnflags |= NO_EXPLOSIONS;
	spawnflags |= NOTSOLID;
	PostEvent( EV_Show, EV_POSTSPAWN );
	setSolidType( SOLID_BBOX );
}

void ExplodeObject::SetDebrisAmount( Event *ev )
{
	debrisamount = ev->GetInteger( 1 );
}

void ExplodeObject::MakeExplosion( Event *ev )
{
	Vector pos;
	float t, scale;
	Entity *other;
	Event *event;
	
	other = ev->GetEntity( 1 );
	
	// make sure other is valid
	if ( !other )
	{
		other = world;
	}
	
	// prevent the trigger from triggering again
	trigger_time = -1;
	
	if ( !explode_time )
	{
		setSolidType( SOLID_NOT );
		hideModel();
		explode_time = level.time + duration;
	}

	if ( _spawnEarthquake && !_haveSpawnedEarthquake )
	{
		Event *earthquakeEvent = new Event( EV_CreateEarthquake );
		
		earthquakeEvent->AddFloat( _earthquakeMagnitude );
		earthquakeEvent->AddFloat( _earthquakeDuration );
		earthquakeEvent->AddFloat( _earthquakeDistance );

		ProcessEvent( earthquakeEvent );

		_haveSpawnedEarthquake = true;
	}
	
	if ( spawnflags & RANDOM_TIME )
	{
		t = explodewait * ( 1.0f + G_CRandom( randomness ) );
	}
	else
	{
		t = explodewait;
	}
	
	event = new Event( EV_Trigger_Effect );
	event->AddEntity( other );
	PostEvent( event, t );
	
	if ( level.time > explode_time )
	{
		if ( spawnflags & MULTI_USE )
		{
			//
			// reset the trigger in a half second
			//
			trigger_time = level.time + 0.5f;
			explode_time = 0;
			CancelEventsOfType( EV_Trigger_Effect );
			//
			// reset health if necessary
			//
			health = max_health;
			if ( health )
            {
				setSolidType( SOLID_BBOX );
            }
			if ( spawnflags & VISIBLE )
            {
				PostEvent( EV_Show, 0.5f );
            }

			_haveSpawnedEarthquake = false;
			return;
		}
		else
		{
			PostEvent( EV_Remove, 0.0f );
			return;
		}
	}
	
	pos[ 0 ] = absmin[ 0 ] + G_Random( absmax[ 0 ] - absmin[ 0 ] );
	pos[ 1 ] = absmin[ 1 ] + G_Random( absmax[ 1 ] - absmin[ 1 ] );
	pos[ 2 ] = absmin[ 2 ] + G_Random( absmax[ 2 ] - absmin[ 2 ] );
	
	if ( spawnflags & RANDOM_SCALE )
	{
		scale = edict->s.scale * 0.25f;
		scale += G_Random( 3.0f * scale );
	}
	else
	{
		scale = 1.0f;
	}
	
	if ( !( spawnflags & NO_EXPLOSIONS ) )
	{
		CreateExplosion
			(
			pos,
			damage,
			this,
			other,
			this,
			explosionmodel.c_str(),
			scale,
			explosionradius
			);
	}
	if ( debrismodels.NumObjects() )
	{
		TossObject *to;
		int i;

		if ( debrissound.length() )
		{
			Sound( debrissound );
		}

		for ( i = 0; i < debrisamount; i++ )
		{
			int num;
			
			if ( spawnflags & RANDOM_SCALE )
            {
				scale = edict->s.scale * 0.25f;
				scale += G_Random( 3.0f * scale );
            }
			else
            {
				scale = 1.0f;
            }
			
			num = (int)G_Random( (float)debrismodels.NumObjects() ) + 1;
			to = new TossObject( debrismodels.ObjectAt( num ) );
			to->setScale( scale );
			to->setOrigin( pos );
			to->SetVelocity( severity );
			if ( spawnflags & NOTSOLID )
            {
				to->setSolidType( SOLID_NOT );
            }
			pos[ 0 ] = absmin[ 0 ] + G_Random( absmax[ 0 ] - absmin[ 0 ] );
			pos[ 1 ] = absmin[ 1 ] + G_Random( absmax[ 1 ] - absmin[ 1 ] );
			pos[ 2 ] = absmin[ 2 ] + G_Random( absmax[ 2 ] - absmin[ 2 ] );
		}
	}	
}

ExplodeObject::ExplodeObject()
{
	if ( !LoadingSavegame )
	{
		duration			= 1;
		explodewait		= 0.25f;
		severity       = 1.0f;
		explosionradius = 0.0f;
		debrismodels.ClearObjectList();
		explosionmodel = "fx_explosion.tik";
		debrisamount   = 2;
		if ( spawnflags & METAL_DEBRIS )
		{
			debrismodels.AddUniqueObject( str( "fx/fx_debris_metal1.tik" ) );
			debrismodels.AddUniqueObject( str( "fx/fx_debris_metal2.tik" ) );
			debrismodels.AddUniqueObject( str( "fx/fx_debris_metal3.tik" ) );
			CacheResource( "fx/fx_debris_metal1.tik", this );
			CacheResource( "fx/fx_debris_metal2.tik", this );
			CacheResource( "fx/fx_debris_metal3.tik", this );
		}
		else if ( spawnflags & ROCK_DEBRIS )
		{
			debrismodels.AddUniqueObject( str( "fx/fx_debris_rock1.tik" ) );
			debrismodels.AddUniqueObject( str( "fx/fx_debris_rock2.tik" ) );
			debrismodels.AddUniqueObject( str( "fx/fx_debris_rock3.tik" ) );
			debrismodels.AddUniqueObject( str( "fx/fx_debris_rock4.tik" ) );
			CacheResource( "fx/fx_debris_rock1.tik", this );
			CacheResource( "fx/fx_debris_rock2.tik", this );
			CacheResource( "fx/fx_debris_rock3.tik", this );
			CacheResource( "fx/fx_debris_rock4.tik", this );
		}
	}

	_spawnEarthquake = false;
	_haveSpawnedEarthquake = false;
	_earthquakeMagnitude = 1.0f;
	_earthquakeDuration = 1.0f;
	_earthquakeDistance = 500.0f;
}

void ExplodeObject::setSpawnEarthquake( Event *ev )
{ 
	_spawnEarthquake = true;
}

void ExplodeObject::setEarthquakeDuration( Event *ev ) 
{ 
	_spawnEarthquake = true;
	_earthquakeDuration = ev->GetFloat( 1 ); 
}

void ExplodeObject::setEarthquakeMagnitude( Event *ev )
{ 
	_spawnEarthquake = true;
	_earthquakeMagnitude = ev->GetFloat( 1 ); 
}

void ExplodeObject::setEarthquakeDistance( Event *ev )
{ 
	_spawnEarthquake = true;
	_earthquakeDistance = ev->GetFloat( 1 );
}
Tom Trude,

Image
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

The star means a pointer. Try it. I've seen this method working with script-spawned ladders.

Another thing, I haven't tried it, but FAKK's source code suggests, that you can refer to entities by their numbers via a star and an integer number (e.g. *48 for the entity #48), as it's the way entities are stored.

You could also try this:

Code: Select all

local.barrel1 = spawn BarrelObject "targetname" "barrel1"
$barrel1.model = $Gas_Mother.brushmodel
local.barrel2 = spawn BarrelObject "targetname" "barrel2"
$barrel2.model = $Gas_Mother.brushmodel
local.barrel3 = spawn BarrelObject "targetname" "barrel3"
$barrel3.model = $Gas_Mother.brushmodel
local.barrel4 = spawn BarrelObject "targetname" "barrel4"
$barrel4.model = $Gas_Mother.brushmodel
local.barrel5 = spawn BarrelObject "targetname" "barrel5"
$barrel5.model = $Gas_Mother.brushmodel
local.barrel6 = spawn BarrelObject "targetname" "barrel6"
$barrel6.model = $Gas_Mother.brushmodel
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Post Reply