70 extern Unit *player_unit;
96 missionNode *nr_node = getArgument( node, mode, 0 );
97 int unit_nr = doIntVar( nr_node, mode );
107 viret->
object = (
void*) my_unit;
108 debug( 3, node, mode,
"unit getUnit: " );
109 printVarInst( 3, viret );
112 Unit *my_unit = NULL;
118 viret->
object = (
void*) my_unit;
119 debug( 3, node, mode,
"unit getUnit: " );
120 printVarInst( 3, viret );
123 int which = getIntArg( node, mode, 0 );
124 Unit *my_unit = NULL;
141 viret->
object = (
void*) my_unit;
142 debug( 3, node, mode,
"unit getUnit: " );
143 printVarInst( 3, viret );
147 missionNode *name_node = getArgument( node, mode, 0 );
148 varInst *name_vi = checkObjectExpr( name_node, mode );
149 missionNode *faction_node = getArgument( node, mode, 1 );
150 varInst *faction_vi = checkObjectExpr( faction_node, mode );
151 missionNode *type_node = getArgument( node, mode, 2 );
152 varInst *type_vi = checkObjectExpr( type_node, mode );
153 missionNode *ai_node = getArgument( node, mode, 3 );
154 varInst *ai_vi = checkObjectExpr( ai_node, mode );
155 missionNode *nr_node = getArgument( node, mode, 4 );
156 int nr_of_ships = checkIntExpr( nr_node, mode );
157 missionNode *nrw_node = getArgument( node, mode, 5 );
158 int nr_of_waves = checkIntExpr( nrw_node, mode );
164 destination_vi = checkObjectExpr( faction_node, mode );
166 destinations = *( (
string*) destination_vi->
object );
168 QVector pos( getFloatArg( node, mode, 6 ),
169 getFloatArg( node, mode, 7 ),
170 getFloatArg( node, mode, 8 ) );
172 logo_tex = getStringArgument( node, mode, 9 );
174 logo_alp = getStringArgument( node, mode, 10 );
176 Unit *my_unit = NULL;
183 string name_string = *( (
string*) name_vi->
object );
184 string faction_string = *( (
string*) faction_vi->
object );
185 string type_string = *( (
string*) type_vi->
object );
186 string ai_string = *( (
string*) ai_vi->
object );
199 cf.
waves = nr_of_waves;
202 for (
int i = 0;
i < 3;
i++)
224 viret->
object = (
void*) my_unit;
225 debug( 3, node, mode,
"unit getUnit: " );
228 int quantity = getIntArg( node, mode, 0 );
231 category = getStringArgument( node, mode, 1 );
233 vireturn = call_olist_new( node, mode );
238 if ( !category.empty() ) {
242 unsigned int i = Begin+( rand()%(End-Begin) );
247 for (
unsigned int i = 0;
i < 500;
i++) {
249 if (ret->
GetContent().find(
"mission" ) == string::npos)
286 debug( 3, node, mode,
"unit getRandCargo: " );
287 printVarInst( 3, vireturn );
290 varInst *ovi = getObjectArg( node, mode );
291 Unit *my_unit = getUnitObject( node, mode, ovi );
292 debug( 3, node, mode,
"unit object: " );
293 printVarInst( 3, ovi );
328 varInst *str_vi = call_string_new( node, mode, factionname );
331 varInst *str_vi = call_string_new( node, mode,
"" );
336 varInst *vec3_vi = call_olist_new( node, mode );
337 float vel_mag = my_unit->
GetVelocity().Magnitude();
339 printf(
"VELMAG:%f\n", vel_mag );
340 if (fabs( vel_mag ) > 10e-6) {
350 pos_vi = newVarInst(
VI_TEMP );
353 call_olist_push_back( node, mode, vec3_vi, pos_vi );
355 pos_vi = newVarInst(
VI_TEMP );
358 call_olist_push_back( node, mode, vec3_vi, pos_vi );
360 pos_vi = newVarInst(
VI_TEMP );
363 call_olist_push_back( node, mode, vec3_vi, pos_vi );
371 Unit *res_unit = NULL;
373 res_unit = my_unit->
Target();
381 unit_name = my_unit->
name;
382 viret = call_string_new( node, mode, unit_name );
389 string s = getStringArgument( node, mode, 1 );
395 Unit *res_unit = NULL;
397 res_unit = my_unit->
Threat();
403 Unit *other_unit = getUnitArg( node, mode, 1 );
405 my_unit->
Target( other_unit );
409 Unit *other_unit = getUnitArg( node, mode, 1 );
412 viret->
bool_val = (my_unit == other_unit);
415 Unit *un = getUnitArg( node, mode, 1 );
422 QVector vec3 = getVec3Arg( node, mode, 1 );
430 Unit *other_unit = getUnitArg( node, mode, 1 );
436 angle =
acos( vectothem.Dot( r.Cast() ) );
437 angle = (angle/
PI)*180.0;
443 QVector other_pos = getVec3Arg( node, mode, 1 );
449 angle =
acos( vectothem.Dot( r.Cast() ) );
450 angle = (angle/
PI)*180.0;
500 res = my_unit->
rSize();
552 Unit *other_unit = getUnitArg( node, mode, 1 );
569 missionNode *nr_node = getArgument( node, mode, 1 );
570 float credits = doFloatVar( nr_node, mode );
594 Order *my_order = NULL;
600 viret->
object = (
void*) my_order;
619 if ( fgname.empty() )
621 varInst *str_vi = call_string_new( node, mode, fgname );
629 Unit *ret_unit = NULL;
632 if (ret_unit == NULL)
638 viret->
object = (
void*) ret_unit;
640 Unit *un = getUnitArg( node, mode, 1 );
650 viret = call_string_new( node, mode, fgdir );
652 string inp = getStringArgument( node, mode, 1 );
671 Unit *ret_unit = NULL;
677 viret->
object = (
void*) ret_unit;
679 Unit *ret_unit = NULL;
685 viret->
object = (
void*) ret_unit;
687 Unit *ret_unit = NULL;
693 viret->
object = (
void*) ret_unit;
695 Unit *ret_unit = NULL;
701 viret->
object = (
void*) ret_unit;
703 float ret = 9999999.0;
710 float ret = 9999999.0;
717 float ret = 9999999.0;
724 missionNode *nr_node = getArgument( node, mode, 1 );
725 int unit_nr = doIntVar( nr_node, mode );
726 Unit *turret_unit = NULL;
734 viret->
object = (
void*) turret_unit;
735 debug( 3, node, mode,
"unit getUnit: " );
736 printVarInst( 3, viret );
739 string fgname = my_unit->
getFgID();
740 if ( fgname.empty() )
742 varInst *str_vi = call_string_new( node, mode, fgname );
751 string s = getStringArgument( node, mode, 1 );
753 int quantity = getIntArg( node, mode, 2 );
754 bool erasezero = getBoolArg( node, mode, 3 );
757 if ( my_unit->
GetCargo( s, index ) )
758 quantity = my_unit->
RemoveCargo( index, quantity, erasezero );
767 carg.
content = getStringArgument( node, mode, 1 );
768 carg.
category = getStringArgument( node, mode, 2 );
769 carg.
price = getFloatArg( node, mode, 3 );
770 carg.
quantity = getIntArg( node, mode, 4 );
771 carg.
mass = getFloatArg( node, mode, 5 );
772 carg.
volume = getFloatArg( node, mode, 6 );
788 double x = getFloatArg( node, mode, 1 );
789 double y = getFloatArg( node, mode, 2 );
790 double z = getFloatArg( node, mode, 3 );
796 string file = getStringArgument( node, mode, 1 );
797 double percentage = 0;
799 bool loop_through_mounts =
false;
800 int mountoffset = getIntArg( node, mode, 2 );
801 int subunitoffset = getIntArg( node, mode, 3 );
802 unsigned int siz = node->
subnodes.size();
804 force = getBoolArg( node, mode, 4 );
806 loop_through_mounts = getBoolArg( node, mode, 5 );
809 printf(
"upgrading %s %s %d %d %s\n", my_unit->
name.get().c_str(),
810 file.c_str(), mountoffset, subunitoffset, loop_through_mounts ?
"true" :
"false" );
812 percentage = my_unit->
Upgrade( file, mountoffset, subunitoffset, force, loop_through_mounts );
819 double percentagechange = getFloatArg( node, mode, 1 );
820 int quantity = getIntArg( node, mode, 2 );
826 c.quantity = quantity;
836 float percentagechange;
837 percentagechange = getFloatArg( node, mode, 1 );
849 std::string magic_num;
851 magic_num = getStringArgument( node, mode, 1 );
863 call_unit_toxml( node, mode, ovi );
867 string arg = getStringArgument( node, mode, 1 );
869 string type = my_unit->
name;
870 int nr_waves_left = 0;
872 string order(
"default" );
882 my_unit->
faction ), order, nr_ships, nr_waves_left,
"",
"",
this );
888 Unit *other_unit = getUnitArg( node, mode, 1 );
894 Unit *other_unit = getUnitArg( node, mode, 1 );
895 float mood = getFloatArg( node, mode, 2 );
896 unsigned char sex = 0;
909 string anim = getStringArgument( node, mode, 1 );
917 fatalError( node, mode,
"no such method "+node->
script.
name );
954 for (u = 0; u < fg->
nr_ships; u++) {
958 char *tex = strdup( fg->
fg->
type.c_str() );
959 char *nam = strdup( fg->
fg->
type.c_str() );
960 char *bsrc = strdup( fg->
fg->
type.c_str() );
961 char *bdst = strdup( fg->
fg->
type.c_str() );
962 char *citylights = strdup( fg->
fg->
type.c_str() );
966 citylights[0] =
'\0';
975 my_unit =
UnitFactory::createPlanet(
QVector( 0, 0, 0 ),
QVector( 0, 0, 0 ), 0,
Vector( 0, 0, 0 ),
976 0, 0, radius, tex,
"",
"", s,
997 float fg_radius = units[0]->
rSize();
999 for (u = 0; u < fg->
nr_ships; u++) {
1002 pox.i = fg->
fg->
pos.i+u*fg_radius*3;
1003 pox.j = fg->
fg->
pos.j+u*fg_radius*3;
1004 pox.k = fg->
fg->
pos.k+u*fg_radius*3;
1025 void Mission::findNextEnemyTarget(
Unit *my_unit )
1030 Unit *target_unit = NULL;
1031 for (; (unit = *uiter); ++uiter)
1033 target_unit = *uiter;
1037 my_unit->
Target( target_unit );
1043 for (
int i = 0; (unit = *uiter); ++uiter, ++i)