Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official Fulqrum Publishing forum > Fulqrum Publishing > IL-2 Sturmovik: Cliffs of Dover > FMB, Mission & Campaign builder Discussions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-12-2011, 12:15 AM
fearlessfrog fearlessfrog is offline
Approved Member
 
Join Date: Jul 2010
Posts: 64
Default Mission Menu and Ambulance

I spent a short bit of time looking at the new Beta API for a 'Mission Menu' and figuring out how to direct traffic. When you crash you can call for an ambulance.

Details and test mission download here:
http://simhq.com/forum/ubbthreads.ph...ml#Post3387861

The interesting part of the script is here:

Code:
else if (menuItemIndex == 6)
      {
          GamePlay.gpHUDLogCenter("Ambulance Dispatched!");

          Player[] all = { player };

          AiActor amb = GamePlay.gpActorByName("0_Chief"); // Our ambulance, defined as 
first vehicle in mission
          if (amb != null)
          {
              AiGroup g = (AiGroup)amb; // Everything with waypoints is always in groups
              AiWayPoint[] waypoints = g.GetWay(); // Get the waypoints it had

              foreach (AiWayPoint waypoint in waypoints)
              {
                  //GamePlay.gpLogServer(all, "waypoint: x=" + waypoint.P.x.ToString() + " y=" + 
waypoint.P.y.ToString(), null);
                  x = waypoint.P.x;
                  y = waypoint.P.y;
                  z = waypoint.P.z; // Remember this for late, as we need a good height from somewhere
              }

              Player me = GamePlay.gpPlayer();
              AiActor where = me.Place();
              Point3d pos = where.Pos(); // Get our position, i.e. where to send the ambulance
              Point3d target = new Point3d(pos.x, pos.y, z); // Set our target to be us

              //GamePlay.gpLogServer(all, "me: x=" + pos.x.ToString() + " y=" + pos.y.ToString()
 + " z=" + pos.z.ToString(), null);

              // Note: Set the z height to be the last waypoint height rather than it's real height, 
Pos seems a PoS
              Point3d last_known = new Point3d(amb.Pos().x, amb.Pos().y, z);

              AiGroundWayPoint[] newWaypoints = { new AiGroundWayPoint(ref last_known, 50.0, 0.0, 10.0),                                                    
                                                    new AiGroundWayPoint(ref target, 50.0, 0.0, 10.0) };

              g.SetWay(newWaypoints); // Off we go, on new route!

              AiWayPoint[] resetWaypoints = g.GetWay(); // Just diagnostics, i.e. can be removed
 but basically to check they took
              foreach (AiWayPoint waypoint in resetWaypoints)
              {
                  //GamePlay.gpLogServer(all, "New waypoint: x=" + waypoint.P.x.ToString() + " y="
 + waypoint.P.y.ToString(), null);
              }

          }
          setMainMenu(player);
      }
Hope that helps put someone on the right spline.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:39 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.