iTrafficCreation and iScriptedOrders
19 years 8 months ago #18407
by Joco
iTrafficCreation and iScriptedOrders was created by Joco
After some comments by GrandpaTrout I decided to start this thread to record my and others learnings in this area. I've only started on the simple functions at this point but hope to get proof code for preety much all the call patterns in these two packages.
I'll post more as I learn more. Particularly the single ship commands.
Cheers,
Joco.
Code:
iTrafficCreation.Start( iMapEntity.FindByName ( "Hoffers Wake Police Headquarters" ) ); // basic traffic in place
//
// made a group of 5 corvettes and sent them on a system patrol.
hgroup traffic_group;
traffic_group = iTrafficCreation.CustomLocalSecurityPatrol( iMapEntity.FindByName ( "Hoffers Wake Police Headquarters" ), ST_CombatHeavy, 5, A_Police, true );
Task.Detach ( start iScriptedOrders.SystemPatrol( traffic_group ) );
//
I'll post more as I learn more. Particularly the single ship commands.
Cheers,
Joco.
Please Log in or Create an account to join the conversation.
19 years 8 months ago #12698
by Joco
Replied by Joco on topic iTrafficCreation and iScriptedOrders
I did some more tests tonight and was able to get it so my ship could follow the patrol. I tried both the local and system patrol options from iScriptedOrders with success. Success == following said patrols about.
Cheers,
Joco.
Cheers,
Joco.
Please Log in or Create an account to join the conversation.
- GrandpaTrout
- Offline
- King of Space
19 years 8 months ago #12700
by GrandpaTrout
Replied by GrandpaTrout on topic iTrafficCreation and iScriptedOrders
Cool! Any progress is good.
The issue we have, is that if we want to replace the standard ships and factions then we need to understand how iTrafficCreation is structuring the group of ships. For instance, a Buda5 total conversion, or an Iwar 1 conversion would need another option for selecting ships.
There might be a few ways to discover what is happening (if your game for it) and the information would be useful to everyone. These are the types of things I would attempt this summer, but the Traffic release will go faster if someone else can do the needed research.
Use the group commands to examine the group returned by iTrafficCreation. How is it structured? Is it a group within a group? When I hand iScriptedOrders a group of ships, it complains there is no valid leader. Is the leader in a special group?
Does iTraffic call the formation commands, or does iScripted? You can see what call a POG package is making by looking at the package with a hex editor and reading the strings.
You can also look at the strings to learn what any object properties it is using are named. Look for strings that might indicate what calls are being made.
Then try to setup a package that returns a group that iScriptedOrders will accept and move around. Then you get to be famous!
The issue we have, is that if we want to replace the standard ships and factions then we need to understand how iTrafficCreation is structuring the group of ships. For instance, a Buda5 total conversion, or an Iwar 1 conversion would need another option for selecting ships.
There might be a few ways to discover what is happening (if your game for it) and the information would be useful to everyone. These are the types of things I would attempt this summer, but the Traffic release will go faster if someone else can do the needed research.
Use the group commands to examine the group returned by iTrafficCreation. How is it structured? Is it a group within a group? When I hand iScriptedOrders a group of ships, it complains there is no valid leader. Is the leader in a special group?
Does iTraffic call the formation commands, or does iScripted? You can see what call a POG package is making by looking at the package with a hex editor and reading the strings.
You can also look at the strings to learn what any object properties it is using are named. Look for strings that might indicate what calls are being made.
Then try to setup a package that returns a group that iScriptedOrders will accept and move around. Then you get to be famous!
Please Log in or Create an account to join the conversation.
19 years 8 months ago #12701
by Joco
Replied by Joco on topic iTrafficCreation and iScriptedOrders
Ok - can do that. It will be tonights mission.
Happy to help out you guys anyway I can.
--- Updates/Info ---
I have done some initial tests on the nature of the hgroup returned. I think I will have sample code on this once I get home from work tonight (about 4-6hrs time)
Have some code working but the scripted orders seems to only be effecting the first member of my ship group. So partial success but still working on it.
Happy to help out you guys anyway I can.
--- Updates/Info ---
I have done some initial tests on the nature of the hgroup returned. I think I will have sample code on this once I get home from work tonight (about 4-6hrs time)
Have some code working but the scripted orders seems to only be effecting the first member of my ship group. So partial success but still working on it.
Please Log in or Create an account to join the conversation.
- GrandpaTrout
- Offline
- King of Space
19 years 8 months ago #12703
by GrandpaTrout
Replied by GrandpaTrout on topic iTrafficCreation and iScriptedOrders
Please Log in or Create an account to join the conversation.
19 years 8 months ago #12704
by Joco
Replied by Joco on topic iTrafficCreation and iScriptedOrders
Yeah - that was the conclusion I got to before calling it a night. Should all be good after work today. I'll post code then.
Ok - here is my working function:
Ok - here is my working function:
Code:
task delayed_event ( float secs )
{
hgroup traffic_group;
hship ship1;
hship ship2;
hship ship3;
Task.Sleep( Task.Current(), secs );
// create some new ships and add to a group
traffic_group = Group.Create();
ship1 = iShip.Create( "ini:/sims/ships/utility/puffin", "Caroline");
iPilotSetup.Generic( ship1 );
Group.AddSim( traffic_group, ship1 );
Sim.PlaceNear( ship1, iMapEntity.FindByName ( "Hoffers Wake Police Headquarters" ), 1km );
ship2 = iShip.Create( "ini:/sims/ships/utility/puffin", "James");
iPilotSetup.Generic( ship2 );
Group.AddSim( traffic_group, ship2 );
Sim.PlaceNear( ship2, iMapEntity.FindByName ( "Hoffers Wake Police Headquarters" ), 1km );
ship3 = iShip.Create( "ini:/sims/ships/utility/puffin", "Alex");
iPilotSetup.Generic( ship3 );
Group.AddSim( traffic_group, ship3 );
Sim.PlaceNear( ship3, iMapEntity.FindByName ( "Hoffers Wake Police Headquarters" ), 1km );
// explicitly set the group leader, even though it should default as index 0 in the group.
Group.PromoteSim( traffic_group, 0);
// lock in a formation for the group
iFormation.LineAbreast( traffic_group, 200.0, true );
debug Debug.PrintString("scenario_skeleton: Num sims in hgrp = ");
debug Debug.PrintInt( Group.SimCount(traffic_group) );
debug Debug.PrintString("\n");
Task.Detach( start iScriptedOrders.SystemPatrol( traffic_group ) );
}
Please Log in or Create an account to join the conversation.