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