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

Members Online

»
1 Active | 43 Guests
Online:

LATEST FORUM THREADS

»
New BF2 Mod
BF2 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 4
Category: CoD4 SP Mapping
CoD 4 mapping and level design for single player.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Undefined is not a field object
darkness_225
General Member
Since: Sep 2, 2009
Posts: 65
Last: Apr 30, 2013
[view latest posts]
Level 3
Category: CoD4 SP Mapping
Posted: Friday, Jul. 9, 2010 11:33 am
Hey, I'm stuck again. This time it's something to do with my objective. It's one of those Undefined is not a field object, and it's something to do with my BMP.

Code:
objective_add(1, "active", &"DEFEND_OBJ1",obj1.origin);


the BMP's targetname is obj1

Here is the entire script

Code:
#include common_scripts\utility;
#include maps\_utility;
#include maps\_anim;
#include maps\_hud_util;
#using_animtree( "generic_human" );

main()
{
	// if script causes reflection compile to fail
	if ( getdvar( "r_reflectionProbeGenerate" ) == "1" )
		return;

	level thread maps\_bmp::main( "vehicle_bmp_desert" );
	level thread maps\_hind::main( "vehicle_mi24p_hind_woodland_opened_door" );
	
	maps\_load::main();

	flag_init("bmp_dead");
	flag_init("bc2_style_hind_dead");

	// player loadout
	level.player takeallweapons();
	level.player giveWeapon ("m16_basic"); //use whatever gun you want
	level.player giveWeapon ("m1014"); //same
	level.player switchToWeapon ("m16_basic"); //pick the gun you want to hold
	level.player giveWeapon ("fraggrenade");
	level.player giveWeapon ("flash_grenade");

	// friendly setups
	thread ally_nodamage();

	// objectives
	thread obj1();
	thread obj2();

	// global threads
	getEnt( "bmp_start", "targetname" ) thread manage_bmp();

	seekers = getentarray("seekers","targetname");
	array_thread(seekers,::enemy_think);
	
	thread BackGroundMusic();
}

obj1()
{

	obj1 = getent("obj1", "targetname");

	objective_add(1, "active", &"DEFEND_OBJ1",obj1.origin);

	objective_current(1);

	iprintlnbold (&"DEFEND_OBJ1");

	obj1 waittill("death");

	flag_wait("bmp_dead");

	objective_state(1, "done");

	wait(2);

	thread obj2();

}

obj2()
{
	obj2 = getent("obj2", "targetname");

	objective_add(2, "active", &"DEFEND_OBJ2",obj2.origin);

	objective_current(2);

	iprintlnbold (&"DEFEND_OBJ2");

	thread manage_hind();

	obj2 waittill("death");
	
	flag_set("bmp_dead");
	flag_wait("bc2_style_hind_dead");

	objective_state(2, "done");

	wait(5);
	
	missionSuccess ("fun",false);

}

manage_hind()
{
	thread maps\_vehicle::create_vehicle_from_spawngroup_and_gopath( 1 );
	waittillframeend;
	wait ( 1.2 );
	hind = getEnt( "obj2", "targetname" );
	hind thread hind_ai_mode_aim_turret();
	hind thread hind_ai_mode_shoot_turret();

	flag_set("bc2_style_hind_dead");
	
	wait( 200 );
	if( isAlive( hind ) )
		RadiusDamage( hind.origin, 50, 1000, 100 );
} // manage_hind()

hind_ai_mode_aim_turret()
{
	/*--------------------
	 HIND AIMS AT ENEMIES
	----------------------*/
	level.cosine[ "45" ] = cos( 45 );
	self endon( "death" );	
	for(;;)
	{
		eTarget = get_closest_ai( level.player getOrigin(), "allies" );
		if ( RandomInt( 4 ) == 2 ) 
			eTarget = level.player;
		
		if( isdefined( eTarget ) )
		{
			eTargetOffset = ( 8, 13, 10 );
			self setTurretTargetEnt( eTarget, eTargetOffset );
			self setLookAtEnt(level.player);
		}
		wait randomfloatrange( 1.5, 2.9 );
	}
} // hind_ai_mode_aim_turret()

hind_ai_mode_shoot_turret()
{
	/*--------------------
	 HIND FIRES AT ENEMIES
	----------------------*/
	self endon( "death" );
	self setVehWeapon( "hind_turret" );
	for(;;)
	{
		randomShots = randomintrange( 100, 150 );
		for( i = 0 ; i < randomShots ; i++ )
		{
			self fireWeapon( "tag_flash" );
			wait 0.05;
		}
		wait randomfloatrange( 1.0, 1.75 );
	}
} // hind_ai_mode_shoot_turret()

ally_nodamage()
{
	allyteam =getent ("attic_dude_1", "targetname");
	allyteam =getent ("attic_dude_2", "targetname");

	allyteam =getent ("dudes_1", "targetname");
	allyteam =getent ("dudes_2", "targetname");
	allyteam =getent ("dudes_3", "targetname");

	for(i=0;i
Share |
darkness_225
General Member
Since: Sep 2, 2009
Posts: 65
Last: Apr 30, 2013
[view latest posts]
Level 3
Category: CoD4 SP Mapping
Posted: Friday, Jul. 9, 2010 11:36 am
sorry the script cut off

Code:
#include common_scripts\utility;

#include maps\_utility;

#include maps\_anim;

#include maps\_hud_util;

#using_animtree( "generic_human" );

main()
{
	// if script causes reflection compile to fail
	if ( getdvar( "r_reflectionProbeGenerate" ) == "1" )
		return;

	level thread maps\_bmp::main( "vehicle_bmp_desert" );
	level thread maps\_hind::main( "vehicle_mi24p_hind_woodland_opened_door" );
	
	maps\_load::main();

	flag_init("bmp_dead");
	flag_init("bc2_style_hind_dead");

	// player loadout
	level.player takeallweapons();
	level.player giveWeapon ("m16_basic"); //use whatever gun you want
	level.player giveWeapon ("m1014"); //same
	level.player switchToWeapon ("m16_basic"); //pick the gun you want to hold
	level.player giveWeapon ("fraggrenade");
	level.player giveWeapon ("flash_grenade");

	// friendly setups
	thread ally_nodamage();

	// objectives
	thread obj1();
	thread obj2();

	// global threads
	getEnt( "bmp_start", "targetname" ) thread manage_bmp();

	seekers = getentarray("seekers","targetname");
	array_thread(seekers,::enemy_think);
	
	thread BackGroundMusic();
}

obj1()
{

	obj1 = getent("obj1", "targetname");

	objective_add(1, "active", &"DEFEND_OBJ1",obj1.origin);

	objective_current(1);

	iprintlnbold (&"DEFEND_OBJ1");

	obj1 waittill("death");

	flag_wait("bmp_dead");

	objective_state(1, "done");

	wait(2);

	thread obj2();

}

obj2()
{
	obj2 = getent("obj2", "targetname");

	objective_add(2, "active", &"DEFEND_OBJ2",obj2.origin);

	objective_current(2);

	iprintlnbold (&"DEFEND_OBJ2");

	thread manage_hind();

	obj2 waittill("death");
	
	flag_set("bmp_dead");
	flag_wait("bc2_style_hind_dead");

	objective_state(2, "done");

	wait(5);
	
	missionSuccess ("fun",false);

}

manage_hind()
{
	thread maps\_vehicle::create_vehicle_from_spawngroup_and_gopath( 1 );
	waittillframeend;
	wait ( 1.2 );
	hind = getEnt( "obj2", "targetname" );
	hind thread hind_ai_mode_aim_turret();
	hind thread hind_ai_mode_shoot_turret();

	flag_set("bc2_style_hind_dead");
	
	wait( 200 );
	if( isAlive( hind ) )
		RadiusDamage( hind.origin, 50, 1000, 100 );
} // manage_hind()

hind_ai_mode_aim_turret()
{
	/*--------------------
	 HIND AIMS AT ENEMIES
	----------------------*/
	level.cosine[ "45" ] = cos( 45 );
	self endon( "death" );	
	for(;;)
	{
		eTarget = get_closest_ai( level.player getOrigin(), "allies" );
		if ( RandomInt( 4 ) == 2 ) 
			eTarget = level.player;
		
		if( isdefined( eTarget ) )
		{
			eTargetOffset = ( 8, 13, 10 );
			self setTurretTargetEnt( eTarget, eTargetOffset );
			self setLookAtEnt(level.player);
		}
		wait randomfloatrange( 1.5, 2.9 );
	}
} // hind_ai_mode_aim_turret()

hind_ai_mode_shoot_turret()
{
	/*--------------------
	 HIND FIRES AT ENEMIES
	----------------------*/
	self endon( "death" );
	self setVehWeapon( "hind_turret" );
	for(;;)
	{
		randomShots = randomintrange( 100, 150 );
		for( i = 0 ; i < randomShots ; i++ )
		{
			self fireWeapon( "tag_flash" );
			wait 0.05;
		}
		wait randomfloatrange( 1.0, 1.75 );
	}
} // hind_ai_mode_shoot_turret()

ally_nodamage()
{
	allyteam =getent ("attic_dude_1", "targetname");
	allyteam =getent ("attic_dude_2", "targetname");

	allyteam =getent ("dudes_1", "targetname");
	allyteam =getent ("dudes_2", "targetname");
	allyteam =getent ("dudes_3", "targetname");

	for(i=0;i<allyteam.size;i++)
	allyteam thread maps\_utility::magic_bullet_shield();
}

manage_bmp()
{
	// thread maps\_vehicle::create_vehicle_from_spawngroup_and_gopath( 0 );
	self waittill ( "trigger" );
	wait ( 1.2 );
	bmp = getEnt( "obj1", "targetname" );
	bmp thread bmp_ai_mode_aim_turret();
	bmp thread bmp_ai_mode_shoot_turret();
}

bmp_ai_mode_aim_turret()
{
	/*--------------------
	 BMP AIMS AT ENEMIES
	----------------------*/
	level.cosine[ "45" ] = cos( 45 );
	self endon( "death" );	
	for(;;)
	{
		eTarget = get_closest_ai( level.player getOrigin(), "allies" );
		if ( RandomInt( 4 ) == 2 ) 
			eTarget = level.player;
		
		if( isdefined( eTarget ) )
		{
			eTargetOffset = ( 8, 13, 10 );
			self setTurretTargetEnt( eTarget, eTargetOffset );
			// self setLookAtEnt(level.player);
		}
		wait randomfloatrange( 1.5, 2.9 );
	}
}

bmp_ai_mode_shoot_turret()
{
	/*--------------------
	 BMP FIRES AT ENEMIES
	----------------------*/
	self endon( "death" );
	self setVehWeapon( "bmp_turret" );
	for(;;)
	{
		randomShots = randomintrange( 7,10 );
		for( i = 0 ; i < randomShots ; i++ )
		{
			self fireWeapon( "tag_flash" );
			wait 8.05;
		}
		wait randomfloatrange(  1.0, 1.75 );
	}
}

BackGroundMusic()
{
    defend = getent( "defend", "targetname" );
    
    MusicPlay( "defend" );
    
    defend waittill( "trigger" );
}

enemy_think()
{
	player = getent( "level.player" );
	self endon("death");
	player endon("death");
	player endon("disconnect");

	wait(1);

	self disable_ai_color();
	self.goalradius = 256;

	while( 1 )
	{
		for(i = 0;i < player.size;i++)
		{
			self setGoalPos( player[i].origin );
		}

		wait(0.05);
	}
}
Share |
voidsource
General Member
Since: May 5, 2007
Posts: 1513
Last: Aug 31, 2013
[view latest posts]
Level 8
Category: CoD4 SP Mapping
Posted: Sunday, Jul. 11, 2010 01:53 am
it would help us more if u provided us with the actual error. as we might be able to solve this faster now that u have script up.
Share |
*Delta*Obi-Wan
General Member
Since: Jul 16, 2007
Posts: 233
Last: Dec 24, 2010
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD4 SP Mapping
Posted: Sunday, Jul. 11, 2010 03:50 am
I believe your code should work like this:

objective_add(1, "active", &"DEFEND_OBJ1",getent("obj1", "targetname").origin);

You seee when you put just OBJ1 the game doesnt know what that is, hence the UNDEFINED error, you have to tell it what it is. [machine_gun]
Share |
voidsource
General Member
Since: May 5, 2007
Posts: 1513
Last: Aug 31, 2013
[view latest posts]
Level 8
Category: CoD4 SP Mapping
Posted: Sunday, Jul. 11, 2010 09:29 pm
it seems ok and right. probably u need to compile the bsp as u might have added that and forgot to update the bsp in the process.
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 SP Mapping

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

»