Previous Thread
Next Thread
Print Thread
Rate This Thread
Hop To
Page 1 of 3 1 2 3
#3387619 - 09/11/11 02:49 PM Ambulance Station: notes from the Cavern  
Joined: Sep 2004
Posts: 10,618
Ming_EAF19 Offline
Babelfish Immune
Ming_EAF19  Offline
Babelfish Immune
Veteran

Joined: Sep 2004
Posts: 10,618
London
In the standard provided Stukas mission script I see how to pass an object's ID to running scripts so that objects can be damaged perhaps or to move them around intelligently (vehicles break out of convoy mode on spotting the enemy to get off the road, scat)

In this case b1 is looking at the mission (dot mis) file to pick up the IDentification that the FMB mission file is using to refer to the ship. Ships are GroundActors and vehicles are also in that group with any luck

Vehicle b1 (1_Chief in the dot-mis mission file) for example would then be driven by a script from point to point using the FindPath or .set functions perhaps

Not sure why there's a Gameplay (GamePlay.gpGetTrigger) and an IGamePlay- example maddox.game.IGamePlay.gpGetTrigger(string)

GP might be GPS. Which would be nice Smile2

Place vehicle in FMB, pick up its ID in the script, blow the bloody doors off when it finishes its move to the final waypoint.

Ming

Two fairly comprehensive functions (classes I think the C# programmers use) GameWorld and IGamePlay (found so far) and there's a GamePlay.gpxxx class too

maddox.game.GameWorld

maddox.game.GameWorld.ActorByName(string)

b1 = GamePlay.gpActorByName("1_Chief");

AiActor b1
AiGroundActor ship1
ship1.Health()

maddox.game.GameWorld.ActorIsValid(maddox.game.world.AiActor)
maddox.game.GameWorld.AiAirGroup(int, int)
maddox.game.GameWorld.AirGroups(int)
maddox.game.GameWorld.Airports()
maddox.game.GameWorld.Armies()
maddox.game.GameWorld.BirthPlaces()
maddox.game.GameWorld.FindPath(maddox.GP.Point2d, double, maddox.GP.Point2d, double, maddox.game.PathType, int)
maddox.game.GameWorld.FrontArmy(double, double)
maddox.game.GameWorld.FrontDistance(int, double, double)
maddox.game.GameWorld.FrontExist()
maddox.game.GameWorld.GetAction(string)
maddox.game.GameWorld.GetTrigger(string)
maddox.game.GameWorld.GroundGroups(int)
maddox.game.GameWorld.LandType(double, double)
maddox.game.GameWorld.MakeAirGroup(maddox.game.world.AiAircraft[ ], maddox.game.world.AiAirWayPoint[ ])
maddox.game.GameWorld.SectorName(double, double)

Places where classes are used (from online-posted missions) - 3D map positions etc mentioned

GamePlay.gpGetTrigger (shortName). Enable = false;
GamePlay.gpGetTrigger ("t_4"). Enable = false;
Player pl = GamePlay.gpPlayer();
GamePlay.gpLogServer(players, msg, args);
foreach (int army in GamePlay.gpArmies())
{
foreach (AiAirGroup group in GamePlay.gpAirGroups(army))

int ar = GamePlay.gpFrontArmy(actor.Pos().x, actor.Pos().y);
double ds = GamePlay.gpFrontDistance(2, actor.Pos().x, actor.Pos().y);

if ((GamePlay.gpFrontDistance (2, aircraft.Pos (). x, aircraft.Pos (). y)) <100)

GamePlay.gpHUDLogCenter("Your wingman is killed!");

if (GamePlay.gpPlayer().Place() != null)

aa = GamePlay.gpActorByName("0:BoB_LW_JG27_I.300");

action = GamePlay.gpGetAction ("a3");
GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName)).Do();

GamePlay.gpPostMissionLoad(UKMissionPath + "ships.mis");

GamePlay.gpPostMissionLoad(DEMissionPath + DEMissions[rand.Next(0, DEMissions.Count)]);

GamePlay.gpLogServer(null, "{0} was destroyed by {1}", new object[] { (actor as AiCart).InternalTypeName().Substring(4), (damages[0].initiator.Player.Name()) });

if (GamePlay.gpGroundGroups(1).Length == 0 || GamePlay.gpGroundGroups(1) == null)

foreach (AiGroundGroup group in GamePlay.gpGroundGroups(1))

if (GamePlay.gpRemotePlayers() == null || GamePlay.gpRemotePlayers().Length <= 0)
return;

foreach (Player p in GamePlay.gpRemotePlayers())

if (GamePlay.gpTime().current() > checkTime) {

if (checkShip1 && ship1.Health() < 1.0) {

if (GamePlay.gpPlayer().Place() != null) {

maddox.GP.Loc.set(ref maddox.GP.Point3d)

public void set(ref maddox.GP.Point3d T2)
Member of maddox.GP.Loc

maddox.GP.Loc.transformInvP(ref maddox.GP.Point3d, out maddox.GP.Point3d)


'You are either a hater or you are not' Roman Halter
Inline advert (2nd and 3rd post)

#3387723 - 09/11/11 06:19 PM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Sep 2004
Posts: 10,618
Ming_EAF19 Offline
Babelfish Immune
Ming_EAF19  Offline
Babelfish Immune
Veteran

Joined: Sep 2004
Posts: 10,618
London
Drawn out the vehicle-ish functions and found

maddox.game.world.AiAIChief

maddox.game.world.AiAIChief.FieldR()

It's a derived type from AiGroundGroup (whatever that is, a derived type I mean) - but anyway it has the magic AIChief word

maddox.game.world.AiGroundActor is an object with three parameters/Properties-
int Fuel()
double Health()
maddox.game.world.AiGroundActorType Type()

-so that's likely describing a vehicle and there looks to be a way to engineer a vehicle to run out of fuel to check that one is getting closer to taking command of the vehicle from the script

Selected-for-ground-operations listing below with interesting items

AiWayPoint hmm Smile2

Ming

maddox.game.world.AiGroundGroup

GetPos(out maddox.GP.Point3d)
maddox.game.world.AiGroundGroup.GetPos(out maddox.GP.Point3d)

GroupType()
maddox.game.world.AiGroundGroup.GroupType()

ID()
maddox.game.world.AiGroundGroup.ID()

maddox.game.world.AiGroundActor
int Fuel()
double Health()
maddox.game.world.AiGroundActorType Type()

public interface AiGroundActor
Member of maddox.game.world

Base Type
public interface AiActor
Member of maddox.game.world

AiGroundActor has the same set of base types as AiActor
but with another base type - AiCart


AiCart members (members?)
maddox.game.world.AiCart.Carter()
maddox.game.world.AiCart.CrewFunctionPlace(int)
maddox.game.world.AiCart.Destroy()
maddox.game.world.AiCart.ExistCabin(int)
maddox.game.world.AiCart.InternalTypeName()
maddox.game.world.AiCart.Person(int)
maddox.game.world.AiCart.Places()
maddox.game.world.AiCart.Player(int)

maddox.game.world.AiGroundActorType
Examples:-
public const maddox.game.world.AiGroundActorType Truck = 11
public const maddox.game.world.AiGroundActorType Tank = 8
public const maddox.game.world.AiGroundActorType Motorcycle = 2

Base Type AiActor
maddox.game.world.AiActor.Army()
maddox.game.world.AiActor.Group()
maddox.game.world.AiActor.IsAlive()
maddox.game.world.AiActor.IsTaskComplete()
maddox.game.world.AiActor.IsValid()
maddox.game.world.AiActor.Name()
maddox.game.world.AiActor.Pos()
maddox.game.world.AiActor.Tag

Base Type AIGroup
maddox.game.world.AiGroup.GetItems()
maddox.game.world.AiGroup.GetWay()
maddox.game.world.AiGroup.SetWay(maddox.game.world.AiWayPoint[ ])
maddox.game.world.AiGroup.Idle

Derived Types
maddox.game.world.AiAIChief

maddox.game.world.AiAIChief.FieldR()

maddox.game.world.AiGroundGroupType
maddox.game.world.AiGroundGroupType.Artillery
maddox.game.world.AiGroundGroupType.Ship
maddox.game.world.AiGroundGroupType.Town
maddox.game.world.AiGroundGroupType.Train
maddox.game.world.AiGroundGroupType.Vehicle
(public const maddox.game.world.AiGroundGroupType Vehicle = 1)

maddox.game.world.AiGroundWayPoint
public AiGroundWayPoint(ref maddox.GP.Point3d p, double speed, double wait_time, double road_width)
maddox.game.world.AiGroundWayPoint.BridgeIdx
maddox.game.world.AiGroundWayPoint.roadWidth
maddox.game.world.AiGroundWayPoint.waitTime


'You are either a hater or you are not' Roman Halter
#3387729 - 09/11/11 06:28 PM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Jan 2009
Posts: 4,737
FearlessFrog Offline
Senior Member
FearlessFrog  Offline
Senior Member

Joined: Jan 2009
Posts: 4,737
On the way out the door, being shouted at by Mrs Frog, but wanted to leave some clues I've found Ming in my extensive and exhaustive minutes of research into the FMB and moving vehicles.

- I thought I saw a training mission with an ambulance in it. One of the training ones?

- Took a copy of the 'Training mission 4', to play with i.e. copied these

C:\Program Files (x86)\Steam\steamapps\common\il-2 sturmovik cliffs of dover\parts\bob\mission\training\training04.mis, .misroads and .briefing (i.e. three files) into my:

C:\Users\OlegMaddox\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Single

..directory (that way I can edit them).

- Opened up the FMB and fiddled with training04 in respect to vehicles, i.e:

- Clicking on a tilly car, the 'actor' part shows 'NPC' (non player character) ticked and a script of 'car.cpp' assigned, with the waypoint target being the spline1 road.

In the underlying mission file it translates to this line:

1_Chief Vehicle.Austin_10_Tilly gb /posx 29702.30/posy 248009.84 /script car.cpp/target 1_SplineRoad /num_units 2/marker0 circle_yellow/skin1 materialsSummer_RAF

So what I've learnt from this quick glance is:

- There are inbuilt scripts you can assign objects

- Spline roads can be pre-defined and assigned as targets to the scripts

- Additional scripting can reference these vehicles and also their targets.

So the next step would be something to change either the scripted associated with the vehicle, i.e. away from car.cpp to something that moved it itself, or perhaps change the end-point of the target spline, so as to move the car 'off-road' to where you want it to go (i.e. the location of the crashed aircraft).





#3387742 - 09/11/11 06:58 PM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Apr 2005
Posts: 2,818
BKHZ_Furbs Offline
Senior Member
BKHZ_Furbs  Offline
Senior Member

Joined: Apr 2005
Posts: 2,818
You know i have no idea what your talking about, but it sounds more promising than my TIR on the ceiling stuff. wave

#3387861 - 09/11/11 09:46 PM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Jan 2009
Posts: 4,737
FearlessFrog Offline
Senior Member
FearlessFrog  Offline
Senior Member

Joined: Jan 2009
Posts: 4,737
Ok, we have a working ambulance smile

The basic premise is that you just make up some new waypoint routes for a ground vehicle and then find something to trigger them, i.e. a OnCrashLanded event or a Mission menu call. Here's the summary, where I've added an extra menu item to the previous add-in I did here http://simhq.com/forum/ubbthreads.php/topics/3385237/New_API_in_the_Beta.html#Post3385237

To add the new menu item 'Call Ambulance' find this line in the previous post

Click to reveal..


GamePlay.gpSetOrderMissionMenu( player, true, 1, new string[] { "Destroy Wings", "Destroy Engine",
"Destroy Guns", "Report Damage On", "Report Damage Off"}, new bool[] { false, false, false, false, false } );


..and replace it with

Click to reveal..


GamePlay.gpSetOrderMissionMenu(player, true, 1, new string[] { "Destroy Wings", "Destroy Engine",
"Destroy Guns", "Report Damage On", "Report Damage Off", "Call Ambulance" }, new bool[] { false, false,
false, false, false, false });



New code is then after the last } of the menu:

Click to reveal..



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);
}











Now it would be the opportunity to add some 3d positional sound (wooooo, woooooo) plus see if any of the parts on that vehicle can be modified with an animation (flashing light).

Sorry it's a bit rough. If needed, I can upload the mission file somewhere too.

Edit. Test mission uploaded here: http://www.megaupload.com/?d=ZL5XO3UV

Last edited by FearlessFrog; 09/20/11 10:28 PM. Reason: added preview to stop wideness
#3388138 - 09/12/11 08:30 AM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Jun 2001
Posts: 2,264
No457_Squog Offline
Squadron Leader
No457_Squog  Offline
Squadron Leader
Member

Joined: Jun 2001
Posts: 2,264
Melbourne, Australia
(without me having tested the mission) Did the ambo tip you over because the waypoint co-ords are the same as yours?

Ideally you would want to call a mission with the ambo in it and teleport it to some pre-set co-ords at the player's field and then plan the waypoints to the player's plane.

This has real expand abilities - trucks dragging crashed wrecks off runways in use, fuel trucks etc...

PS: FF can we have a dedicated 'cliffs' scripting sub-forum?


No457_Squog
Squadron Leader

No. 457 Squadron vRAAF
#3388170 - 09/12/11 11:00 AM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Sep 2004
Posts: 10,618
Ming_EAF19 Offline
Babelfish Immune
Ming_EAF19  Offline
Babelfish Immune
Veteran

Joined: Sep 2004
Posts: 10,618
London
Aaagh now it's my turn to be on the way out Smile2 (will test later, thanks!)

Quote:
AiActor amb = GamePlay.gpActorByName("0_Chief");

Gorgeous.

Very exciting developments thanks Frog and other contributors!

Ming


'You are either a hater or you are not' Roman Halter
#3388417 - 09/12/11 04:58 PM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Jan 2009
Posts: 4,737
FearlessFrog Offline
Senior Member
FearlessFrog  Offline
Senior Member

Joined: Jan 2009
Posts: 4,737
On sharing back the code (as seems proper, as I've used it as a source so many times) on the banana forum it looks like it prompted someone to add a lot more examples in this theme (is he (naryv) a Russian dev, not sure?)

http://forum.1cpublishing.eu/showthread.php?p=335269#post335269

That script dynamic creates vehicles that on an aircraft landing do the following:

- If you are damaged it sends a Fire Tender and Ambulance

- Sends a Fuel and Ammo supplies trucks

- If you are a bomber type that the Ammo truck also brings bombs (which you can see)

- If you land at an enemy base it sends a Tank out to capture you as a prisoner smile

Also, unlike the wee ambulance example, it will plot a FindPath course and not hurtle in to you, hastening your demise.


I'm unsure about a scripting sub-forum at the moment Ming, as I think we'd need more interest here to justify it other than just for me and you.

#3388465 - 09/12/11 06:11 PM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Sep 2004
Posts: 10,618
Ming_EAF19 Offline
Babelfish Immune
Ming_EAF19  Offline
Babelfish Immune
Veteran

Joined: Sep 2004
Posts: 10,618
London
Very kind of you thanks Frog, btw I didn't ask for a sub-forum that was Squog (who I know longtime to be a content creator and all-round good egg/virtual pilot), you'd need content before considering that so let's build some content if possible. You've given us a ton of stuff to play with thanks again Smile2

Ambulance races stand by, someone build a lawyer model Smile2

Ming


'You are either a hater or you are not' Roman Halter
#3388505 - 09/12/11 07:07 PM Re: Ambulance Station: notes from the Cavern [Re: No457_Squog]  
Joined: Jan 2009
Posts: 4,737
FearlessFrog Offline
Senior Member
FearlessFrog  Offline
Senior Member

Joined: Jan 2009
Posts: 4,737
Originally Posted By: No457_Squog
(without me having tested the mission) Did the ambo tip you over because the waypoint co-ords are the same as yours?

Ideally you would want to call a mission with the ambo in it and teleport it to some pre-set co-ords at the player's field and then plan the waypoints to the player's plane.

This has real expand abilities - trucks dragging crashed wrecks off runways in use, fuel trucks etc...

PS: FF can we have a dedicated 'cliffs' scripting sub-forum?


The ambulance would occasionally go on a Mad Max style tour-de-force and get to the injured as fast as possible then only to massacre all who it found there, but the waypoint system seems to take not crashing into account sometimes. I think it's related to the wideness of the 'road' (as in the waypoint) and some object avoidance code.

The script I linked to on the banana forums does seem to do what you suggested, i.e. teleport in the vehicles if needed and then plot - I haven't tried it yet but the code looks great. We're collectively building up a good library of how-to's which is looking very promising so far.

Apologies on the Ming doppelganger clanger, I think once we have a bit more content then we could set one up.

#3388512 - 09/12/11 07:16 PM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Sep 2004
Posts: 10,618
Ming_EAF19 Offline
Babelfish Immune
Ming_EAF19  Offline
Babelfish Immune
Veteran

Joined: Sep 2004
Posts: 10,618
London
My goodness Smile2

I took that

Quote:
Various emergency & service cars script by naryv posted an sukhoi.ru today

http://forum.1cpublishing.eu/showthread.php?p=335269#post335269

-from your heads-up thanks Frog and added the script (with BabelFished comments) to my initial ambulance-deploying test mission

I took my Spit up and pulled it around to try to break something - sturdy girl Smile2 and finally did a touch-and-go to break one gear wheel

I managed to land on one wheel with a broken prop and I was ASTONISHED/made up to see two service vehicles approaching my damaged plane (shots below and track saved)

'ASTONISHED' because trust me dear FMB-interested reader nothing ever works first time and this worked first time. Robust.

For mission builders then - you can grab the script and add it to a single/whatever mission and test it out. Break something and find airfield equipment ready to assist you as you climb out of your damaged plane. There are probably lots of variants in the script - Ataros at the 1C forum pointed to here by FearlessFrog says it's 'Various emergency & service cars script by naryv posted an sukhoi.ru today' (Russian forum, excellent)

I just added the script from naryv to my standard test-flying mission...

From your standard test-flying (or single/whatever) mission, copy and paste in the script it's magic well done CoD developers!

Ming

I did not create these vehicles in this standard testing-mission


They must have been spawned from the script by naryv. Cool stuff.


'You are either a hater or you are not' Roman Halter
#3388520 - 09/12/11 07:22 PM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Jan 2009
Posts: 4,737
FearlessFrog Offline
Senior Member
FearlessFrog  Offline
Senior Member

Joined: Jan 2009
Posts: 4,737

Now go land a 109 at Hawkinge and see what happens. smile

#3388522 - 09/12/11 07:25 PM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: May 2006
Posts: 3,644
HeinKill Offline
Senior Member
HeinKill  Offline
Senior Member

Joined: May 2006
Posts: 3,644
Cloud based
Way cool. The script stuff is cyrillic (or is that cyryllic) to me, but I did notice that in the latest RAF campaign mission I flew, two Hurris ploughed into each other on takeoff, and then suddenly trucks and ambulances were rushing from everywhere to the crash. That was cool.


What was not so cool, was that two of the fire trucks obviously had the same final waypoint and just kept butting into each other, reversing, butting into each other, reversing etc endlessly...that kind of ruined the moment.

But as for all things CoD, the potential is great!

H


[Linked Image]
#3388546 - 09/12/11 08:03 PM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Sep 2001
Posts: 2,890
Warbirds Offline
Senior Member
Warbirds  Offline
Senior Member

Joined: Sep 2001
Posts: 2,890
I am really excited by your work and the possible outcome of it all. This is a first in this type of game/sim and breaking new ground is always fun and rewarding.
Thanks

Last edited by Warbirds; 09/12/11 08:04 PM.

"A time when America was great,,when the chrome was thick and the women were straight" - Micheal Savage

"If you really want to experience flight in this life then you have to strap a DC-3 to your ass." - Buffalo Joe McBryan President & Captain Buffalo Airways
#3388582 - 09/12/11 08:50 PM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Jan 2009
Posts: 4,737
FearlessFrog Offline
Senior Member
FearlessFrog  Offline
Senior Member

Joined: Jan 2009
Posts: 4,737
One thing I think worth adding is that you don't have to be able to decipher the programming mumbo-jumbo to play with this stuff.

Here's some steps with less mumbo jumbo:

- Take a look at something like Ajay's wonderful airbase additions here:

http://jimeez.weebly.com/airfields-and-enviroment.html

The download instructions set up a new nice mission and environment called 'Hawkinge1'.

- To add 'behavior' to this mission then create a file in Notepad called 'Hawkinge1.cs' (i.e. the ending has to be '.cs' and not '.txt'. Save it to where you put Ajay's mission, i.e. for me here:

C:\Users\OlegMaddox\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Single

Paste into the file the complete contents from the post

http://forum.1cpublishing.eu/showpost.php?p=335114&postcount=8

(with the first line being 'using System;' and the last being '}')

- Go to Single Player / Single Mission and then pick Hawkinge

You'll be able to see emergency vehicles if you crash, refuelers if you don't and various prisoner details if you land somewhere where you shouldn't (basically a red in a blue etc)

The following picture is where in the FMB I changed to aircraft to a 109 and then forgot Ajay had added lots of AA. Got shot down taking off, but at least I had a welcoming party when I got back on the ground



Last edited by FearlessFrog; 09/12/11 08:52 PM.
#3388596 - 09/12/11 09:12 PM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Mar 2001
Posts: 12,726
bisher Offline
I'll be your Huckleberry
bisher  Offline
I'll be your Huckleberry
Veteran

Joined: Mar 2001
Posts: 12,726
Manitoba, Canada
Ya it looks like you got a bit of an armed response Fearless...



#3388617 - 09/12/11 09:44 PM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Jun 2001
Posts: 2,264
No457_Squog Offline
Squadron Leader
No457_Squog  Offline
Squadron Leader
Member

Joined: Jun 2001
Posts: 2,264
Melbourne, Australia
Sweet! Let's keep up the pace and see if we can mod the code to add a tow-truck that drags the crashed plane off the runway smile

I tidied up your code a bit, FF and started working out how to get the ambo to stop before it turns into destruction derby. Not that it matters now that you norther-hemisphere types have found that other script!

Click to reveal..
Code:
using System;
using System.Collections;
using maddox.game;
using maddox.game.world;
using maddox.GP;

public class Mission : AMission {
	bool dmgOn = false;
	private void setMainMenu(Player player) {
		GamePlay.gpSetOrderMissionMenu(player, false, 0, new string[] { "Damage & Diagnostics" }, new bool[] { true });
    }
	private void setSubMenu(Player player) {
		GamePlay.gpSetOrderMissionMenu(player, true, 1, new string[] { "Destroy Wings", "Destroy Engine", "Destroy Guns", "Report Damage On", "Report Damage Off", "Call Ambulance" }, new bool[] { false, false, false, false, false, false });
    }
	public override void OnOrderMissionMenuSelected(Player player, int ID, int menuItemIndex) {
		if( ID == 0 ) { // main menu
			if( menuItemIndex == 1 ) {
				setSubMenu( player );
			}
		} else if( ID == 1 ) { // sub menu
			if (menuItemIndex == 1) {
				Player[] all = { player };
				AiActor where = player.Place();
				AiAircraft aircraft = (GamePlay.gpPlayer().Place() as AiAircraft);
				GamePlay.gpLogServer(all, "POW!!", null);
				aircraft.cutLimb(part.LimbNames.WingR2);
				setMainMenu( player );
			} else if (menuItemIndex == 2) {
				Player[] all = { player };
				AiActor where = player.Place();
				AiAircraft aircraft = (GamePlay.gpPlayer().Place() as AiAircraft);
				GamePlay.gpLogServer(all, "POW!!", null);
				aircraft.hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
				setMainMenu( player );
			} else if (menuItemIndex == 3) {
				Player[] all = { player };
				AiActor where = player.Place();
				AiAircraft aircraft = (GamePlay.gpPlayer().Place() as AiAircraft);
				GamePlay.gpLogServer(all, "POW!!", null);
				aircraft.hitNamed(part.NamedDamageTypes.Machinegun00Failure);
				aircraft.hitNamed(part.NamedDamageTypes.Machinegun01Failure);
				aircraft.hitNamed(part.NamedDamageTypes.Machinegun02Failure);
				setMainMenu( player );
			} else if (menuItemIndex == 4) {
				dmgOn = true;
				GamePlay.gpHUDLogCenter("Will show damage on all aircraft");
				setMainMenu( player );
			} else if (menuItemIndex == 5) {
				dmgOn = false;
				GamePlay.gpHUDLogCenter("Will not show damage on all aircraft");
				setMainMenu( player );
			} else if (menuItemIndex == 6) {
				dmgOn = false;
				Player[] all = { player };
				AiActor amb = GamePlay.gpActorByName("0_Chief");
				if (amb != null) {
					AiGroup g = (AiGroup)amb; // Always in groups
					AiWayPoint[] waypoints = g.GetWay(); // Get the waypoints
					Point3d wp = new Point3d();
					foreach (AiWayPoint waypoint in waypoints) {
						//GamePlay.gpLogServer(all, "waypoint: x=" + waypoint.P.x.ToString() + " y=" + waypoint.P.y.ToString(), null);
						wp.x = waypoint.P.x;
						wp.y = waypoint.P.y;
						wp.z = waypoint.P.z;
					}
					Point3d pos = GamePlay.gpPlayer().Place().Pos();
					
					//GamePlay.gpLogServer(all, "me: x=" + pos.x.ToString() + " y=" + pos.y.ToString() + " z=" + pos.z.ToString(), null);
					// Set the z height to be the last waypoint height, Pos seems a PoS
					
					Point3d last_known = new Point3d(amb.Pos().x, amb.Pos().y, wp.z);
					Point3d target = new Point3d(pos.x, pos.y, wp.z);
					double hyp = Math.Sqrt((Math.Abs(amb.Pos().x - target.x)*Math.Abs(amb.Pos().x - target.x)) + Math.Abs((amb.Pos().y - target.y)*Math.Abs(amb.Pos().y - target.y)));
					GamePlay.gpHUDLogCenter("Ambulance " + hyp.ToString() + "m away");
					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();
					foreach (AiWayPoint waypoint in resetWaypoints) {
						//GamePlay.gpLogServer(all, "New waypoint: x=" + waypoint.P.x.ToString() + " y=" + waypoint.P.y.ToString(), null);
					}
				}
				setMainMenu(player);
			}
		}
	}
	public override void OnPlayerConnected(Player player) {
		if (MissionNumber == 0) {
			setMainMenu(player);
		}
	}
	public override void Inited() {
		if (MissionNumber == 0) {
			setMainMenu(GamePlay.gpPlayer());
		}
	}
	public override void OnAircraftDamaged(int missionNumber, string shortName, AiAircraft Aircraft, AiDamageInitiator DamageFrom, part.NamedDamageTypes WhatDamaged) {
		base.OnAircraftDamaged(missionNumber, shortName, Aircraft, DamageFrom, WhatDamaged);
		if (DamageFrom.Player != null) {
			if (dmgOn == true) {
				GamePlay.gpLogServer(null, "{0} hits {1} : {2} \n", new object[] { DamageFrom.Player, shortName, WhatDamaged });
			}
		}
	}
}


Originally Posted By: "FearlessFrog"
I'm unsure about a scripting sub-forum at the moment Ming, as I think we'd need more interest here to justify it other than just for me and you.
Originally Posted By: "Ming_EAF19"
btw I didn't ask for a sub-forum that was Squog (who I know longtime to be a content creator and all-round good egg/virtual pilot), you'd need content before considering that so let's build some content if possible. You've given us a ton of stuff to play with thanks again smile


Ok I'm going to focus on modifying those scripts a little bit to see what I can come up with smile If we had a scripting sub-forum it would get need to file a restraining order on me - just sayin'.


No457_Squog
Squadron Leader

No. 457 Squadron vRAAF
#3388647 - 09/12/11 10:33 PM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Dec 2002
Posts: 18,389
Ajay Offline
newbie
Ajay  Offline
newbie
Veteran

Joined: Dec 2002
Posts: 18,389
Brisbane OZ



Awesome work so far guys smile I am still struggling crash wise in the FMB so i am having no joy playing with anything at all in there, quite annoying.Game is ok playing the stock single missions but the FMB is basically a no go atm.

Looks like campaigns and single missions will be a blast though once the game fully settles *crosses fingers*


My il2 page
Seelowe Campaign
Cliffs of Dover page
CloD
My Models
Tanks/Planes/Ships


#3388649 - 09/12/11 10:37 PM Re: Ambulance Station: notes from the Cavern [Re: Ming_EAF19]  
Joined: Dec 2002
Posts: 18,389
Ajay Offline
newbie
Ajay  Offline
newbie
Veteran

Joined: Dec 2002
Posts: 18,389
Brisbane OZ
An FMB/scripting subforum would be good , always wanted one for the IL2 series as well so we didn't lose all of the the little tidbits in the faster moving main forum.


My il2 page
Seelowe Campaign
Cliffs of Dover page
CloD
My Models
Tanks/Planes/Ships


#3388661 - 09/12/11 10:55 PM Re: Ambulance Station: notes from the Cavern [Re: Ajay]  
Joined: Jan 2009
Posts: 4,737
FearlessFrog Offline
Senior Member
FearlessFrog  Offline
Senior Member

Joined: Jan 2009
Posts: 4,737
Originally Posted By: Ajay
An FMB/scripting subforum would be good , always wanted one for the IL2 series as well so we didn't lose all of the the little tidbits in the faster moving main forum.


I've added some links to the 'Mods etc' Sticky up-top (although I do have a blindness for stickies I need to work on). Once that has some more bits on it then I shall go cap in hand to guod to see if we can get an extension built. It would certainly be significantly easier if someone in the MG team could write something in an SDK soon though, although half the fun is the discovery bit..

Page 1 of 3 1 2 3

Moderated by  RacerGT 

Quick Search
Recent Articles
Support SimHQ

If you shop on Amazon use this Amazon link to support SimHQ
.
Social


Recent Topics
How to pi$$ off Londoners...
by Chucky. 10/17/19 12:16 PM
Video game map size comparison
by DM. 10/17/19 09:45 AM
Happy Thanksgiving
by No105_Archie. 10/13/19 05:15 PM
Happy Birthday US Navy
by oldgrognard. 10/13/19 04:31 PM
American Civil War photos
by KraziKanuK. 10/12/19 04:18 AM
“Masters of Air”
by PanzerMeyer. 10/11/19 10:51 PM
WW2 still finding bodies
by Alicatt. 10/10/19 04:10 PM
That moment in time....
by Bill_Grant. 10/09/19 01:35 PM
Copyright 1997-2016, SimHQ Inc. All Rights Reserved.

Powered by UBB.threads™ PHP Forum Software 7.6.0