Jump to content
Sign in to follow this  
Anzu

Set Start Location on Carrier for Warfare

Recommended Posts

Hey guys, I've been having some trouble trying to make my own version of Warfare. Here's what my idea is: Warfare BE type game, except have each side start on their own aircraft carrier at opposite ends of the map. I want to have each MHQ along with all player slots start out on their respective aircraft carrier. So the the teams will have to lift their MHQs to land, then start capturing towns like normal Warfare. I don't know a whole lot of scripting, although I've been learning and can do basic things. So I figured I would just use one of the WarfareBE missions as a template and just edit that. Well I've been successful in getting most things the way I want them with the exception of the starting locations.

In the mission editor, there are 20 or so game logics named StartingLocation#, starting at StartingLocation0. In the parameters for the warfare mission, theres also a setting that lets me specify West North | East South for starting locations, which, from what I can tell, just causes StartingLocation0 to be used for West, and StartingLocation1 to be used for East. Now, I tried just moving StartingLocation0 to one carrier, and StartingLocation1 to the other carrier, and put the following in the Init box oh the game logic starting locations:

this setPosASL [getPosASL this select 0, getPosASL this select 1, 18]

Since this is what I use to set vehicles and things on the carrier, i thought it would work. However, when I save the mission, export to MP as PBO, and host local game to test the mission (selecting the West North | East South option in parameters), it gets stuck at the black screen with "Loading..." and doesn't let me into the game. When I chose blufor, after a few seconds at the Loading screen I see "HQ Destroyed" in the corner of the screen. I don't see "HQ Destroyed' when I try it as opfor, so I'm assuming the blufor HQ is getting destroyed due to being placed in the water. However, i can't seem to figure out why its hanging at the Loading screen like this.

I also tried placing that same Init line inside the Init fields of each MHQ and player slot unit, but this doesn't seem to do the trick.

I've tried a few other things, such as messing with the script files Init_Server.sqf and Init_Client.sqf. I tried manually specifying the starting locations in those files but had no luck, same issue: it would hang at the black Loading... screen when I tested it in MP. To be honest, I feel like I'm in way over my head here with editing the Warfare BE mission script like this, cuz I really don't understand half of the scripts here. But they say the best way to learn to swim is to dive right in, right?

So if anyone can lend me any assistance here I would appreciate it. I'm not looking for someone to do the work for me, just point me in the right direction. I'd be perfectly happy if I could just remove all StartingLocations and just have the players and MHQs always start where I place them on the map in the editor, that way I could definitely place them on the carrier. But alas, I tried removing all the game logic starting locations and placing the units where I wanted them, but it didn't seem to work (same problem as before, hangs at Loading...). My guess is that it's hanging because it's trying to find a safe start location and can't find one. :shrug:

So in a sentence, I'm asking: How do I set starting locations so the players and MHQ will start on top of the carrier, and not so far apart that they fall into the water?

Thanks in advance for any advice!

(incase anyone wants to know, I'm using the USS Nimitz addon for my carriers, and i used WarfareV2_068LiteCO.isladuala as my template for this mission)

Edited by Anzu
Better title

Share this post


Link to post
Share on other sites
I'm not sure, but isn't the base thing a location? I think you're supposed to use setPosition for locations:

http://community.bistudio.com/wiki/setPosition

I'm not at all acquainted with this type of scripting yet.

Thanks for the reply. I didn't know this! So I tried moving the StartingLocation 0 and 1 to the carriers, and put this in their init box:

this setPosition [locationPosition this select 0, locationPosition this select 1, 18];

However, when I start the mission, I still get stuck at the black "Loading..." screen and it doesn't load me into the game (although I can hear game sounds in the background). So, this didn't seem to work.

Now, when I move the StartingLocations 0 and 1 to somewhere on land, then start the game, it loads fine and it starts me at the place where I put the StartingLocation. So I'm guessing there is some problem with putting the starting locations over water?

Hmm, does anyone have any other suggestions as to how I can make the starting locations be ontop of the carriers? I will keep experimenting and post what I find here.

Update:

--------

I tried a few things and still have the same issues :-( Here's what I did...

Moved StartingLocation0 and 1 to the carriers and put this line in their init boxes:

this setPosition [locationPosition this select 0, locationPosition this select 1, 18];

Then I modified a section in Client\Init\Init_Client.sqf from

/* Positionate the client at the previously defined location */
player setPos ([getPos _base,20,30] Call GetRandomPosition);

to this:

/* Positionate the client at the previously defined location */
player setPosASL ([[getPosASL _base select 0, getPosASL _base select 1, 18],10,10] Call GetRandomPosition);

I figured this would work because it seemed llike the numbers 20 and 30 there were being passed to GetRandomPosition as some kind of area limit, so I thought I'd reduce it to 10.

Then I also changed a section in Server\Init\Init_Server.sqf from

//--- Moving each non-owner objects to the location.
EastMHQ setPos getPos _eastLocation;
WestMHQ setPos getPos _westLocation;

to this:

//--- Moving each non-owner objects to the location.
EastMHQ setPosASL [getPosASL _eastLocation select 0, getPosASL _eastLocation select 1, 18];
WestMHQ setPosASL [getPosASL _westLocation select 0, getPosASL _westLocation select 1, 18];

I did this in an attempt to set the MHQs at the right height on the starting locations. Now, I figured that all this combined would HAVE to work....but alas, I still get the same issue when starting the game: it gets stuck at the black "Loading..." screen. Although, when I was blufor and started the mission, I no longer see the "HQ Destroyed" message after a few seconds at the loading screen. So maybe there is some progress being made? I can't tell...

Any body know what I'm doing wrong here?

Edited by Anzu
Tried new things

Share this post


Link to post
Share on other sites

Argh, Okay I've tried a bunch more things and none of them have worked :-( I won't cover everything here, but basically I tried creating a script that would move the player to the carrier position after a sleep of 10 seconds. I ran the script from the init line of the WestSlot1 player.. But unfortunately the script didn't seem to move me anywhere.

I also tried simply changing one line in the Init_Client.sqf that is setting the player position. This is what I had:

/* Positionate the client at the previously defined location */
player setPosASL [getPos carrier_north select 0, getPos carrier_north select 1, 18];

Since carrier_north is what I named the carrier, and I know the deck height is 18, I thought this would HAVE to work. But no, I still get stuck at the black "Loading..." screen forever once I start the game. The commander vote box doesn't even pop up. I also tried this same line of code like this:

/* Positionate the client at the previously defined location */
player setPos [getPos carrier_north select 0, getPos carrier_north select 1, 18];

...same problem. If i change this line back to normal, the game starts fine but it's not the starting location that I wanted.

Can someone please explain to me why changing this one, simple line of script in Client\Init\Init_Client.sqf causes the game to get stuck at the "Loading..." screen when I start the game? I am really pulling my hair out over this guys, everything I'm trying is giving me the same problem :-(((

Edited by Anzu

Share this post


Link to post
Share on other sites

Thanks Weirdo10o4. I'll download squint and see if I can solve my scripting issues using that. I've used it a while back and loved the tool.

Update:

Progress!!! I was actually able to get the MHQ to spawn at a predefined marker by using this code in the Server\Init\Init_Server.sqf

//--- Moving each non-owner objects to the location.
EastMHQ setPos getMarkerPos "southMark";
WestMHQ setPos getMarkerPos "northMark";

then I have two markers on map with names southMark and northMark, set to positions on LAND.

And finally, this is what I did to get the player start location working correctly for MP play. Maybe there's an easier way, but I'm just going with what works for now :-)

In my Client\Init\Init_Client.sqf I have these changes:

_northPos = [getMarkerPos "northCarrier" select 0, getMarkerPos "northCarrier" select 1, 18];
_southPos = [getMarkerPos "southCarrier" select 0, getMarkerPos "southCarrier" select 1, 18];

if (side player == west) then {
player setPosASL ([_northPos,10,10] Call GetRandomPosWater);
} else {
player setPosASL ([_southPos,10,10] Call GetRandomPosWater);
};

/* Positionate the client at the previously defined location */
/* player setPos ([getPos _base,20,30] Call GetRandomPosition); */

I also have _southPos and _northPos declared as Private in an array at the beginning of the file. There are also two markers on the map, one at each carrier location, called northCarrier and southCarrier. Notice I'm calling GetRandomPosWater instead of GetRandomPosition. This is because I noticed in the original function Common\Functions\Common_GetRandomPosition.sqf there was a while loop that was making sure I did NOT spawn on the water. So I created a new function file called Common\Functions\Common_GetRandomPosWater.sqf and put this code in it:

Private["_position","_radius","_direction","_maxRadius","_minRadius"];

_position = _this select 0;
_minRadius = _this select 1;
_maxRadius = _this select 2;
_direction = random 360;

_radius = (random (_maxRadius - _minRadius)) + _minRadius;
_position = [(_position select 0)+((sin _direction)*_radius),(_position select 1)+((cos _direction)*_radius),(_position select 2)];

_position

basically the same as the other function but with the while loop cut out. I also had to declare this function in the file Common\Init\Init_Common.sqf with the following line:

GetRandomPosWater = Compile preprocessFile "Common\Functions\Common_GetRandomPosWater.sqf";

And it works! =D I'm leaving the MHQs to spawn on land for now. Although I'm thinking of doing a script to teleport the MHQ from the carrier to a nearby shore. Anyways, I hope this helps somebody with a similar problem.

Edited by Anzu
Got it working!!! :-D

Share this post


Link to post
Share on other sites

Carriers consist of multiple objects and are built up by their own scripts.

Chances are if you are firing your own scripts on or around the carriers too early the carriers won't be fully formed and you could end up with problems.

Placing something in their INIT could ..... in fact .... will result in weirdness.

Share this post


Link to post
Share on other sites
Gnat;1952452']Carriers consist of multiple objects and are built up by their own scripts.

Chances are if you are firing your own scripts on or around the carriers too early the carriers won't be fully formed and you could end up with problems.

Placing something in their INIT could ..... in fact .... will result in weirdness.

Hey thanks for the reply. :-) Hmm, I do have a bunch of vehicles on the carriers that each run a respawn script and setPosASL from their init boxes. So that might be causing issues for me. Although I have nothing in the init box of the carriers themselves. Anyways it seems to be working ok now, but there's probly a better way of doing it >_<

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×