Jump to content
timmiej93

What could be causing 'PushAction' calls to not be executed?

Recommended Posts

I'm trying to make some changes to the Bieberfelde 2020 mod (for personal use only, just trying to make the mod more to my personal liking), but I'm having issues with getting all 'PushActionXXX' calls to execute properly.

This is the code I've got:

void PushActions(GameObject *Caller, Actor *Target, int childID) {
    Vehicle myVehicle(VehicleList(Caller->GetName()).GetVehicle(0));
    	int myVehicleID = myVehicle.GetID();
    	PersonList myCrew(myVehicle.GetName());
		System::Log("Start loop");
		for (int i=myCrew.GetNumPersons()-1; i > -1; i--)
		{
			Person *person = myCrew.GetPerson(i);
			person.PushActionWait(ACTION_NEWLIST, 0.1f);
			person.PushActionLeaveCar(ACTION_APPEND, &myVehicle);
			Mission::PlayHint("1");
			person.PushActionExecuteCommand(ACTION_APPEND, "GetFirehose", &myVehicle, 0, false);
			Mission::PlayHint("2");
			person.PushActionWait(ACTION_APPEND, 1.0f);
			person.PushActionExecuteCommand(ACTION_APPEND, "AttachFireHose", Target, 0, false);
			Mission::PlayHint("3");
			person.PushActionWait(ACTION_APPEND, 1.0f);
			person->PushActionExecuteCommand(ACTION_APPEND, "attachfirehose_wv", &myVehicle, 0, false);
			Mission::PlayHint("4");

For clarity: I'm trying to have the GruppenFuhrer (squad leader?) give a command for creating a water supply. This is done by clicking on the hydrant (Target) with the GF. It then finds a person from his vehicle that's "available", tells him to grab a hose, connect to the hydrant, and then connect to the vehicle. 

The person getting out works fine, and so does getting the firehose. However, with the first "AttachFireHose", things get a bit weird. Despite the fact that I'm calling the exact same function that you would if you connect a firehose to the hydrant manually1, whenever I call the function here, the firefighter attaches a hose to the first attachpoint, even if there's already a hose attached to it. When connecting a firehose to the hydrant manually1, the firefighter does select a free attachpoint. Could this have something to do with pointers? As far as I know2, the Target variable in the snippet above is a reference (so not a copy) to the hydrant, so that should be fine?

Now, like I said before, "AttachFireHose" is weird, but it works. "attachfirehose_wv" however, doesn't execute at all. I've put some log entries and PlayHints3 in the code, so I can debug it. I've done this in the snippet above, and in all 3 functions that are called in the snippet above.
So as expected, when I click a hydrant with the GF, 1, 2, 3 and 4 pop up pretty much instantly, and the FF gets out and grabs a hose. As soon as the FF starts walking towards the hydrant, the number 5 is displayed. However, the number 6 is never displayed, appearing as if the attachfirehose_wv function is never called. I've displayed how numbers 5 and 6 are located inside their respective functions below.

// AttachFireHose
void PushActions(GameObject *Caller, Actor *Target, int childID) {
	System::Log("5");
	Mission::PlayHint("5");

	// Rest of the code for this function
}

// attachfirehose_wv
void PushActions(GameObject *Caller, Actor *Target, int childID) {
	System::Log("6");
	Mission::PlayHint("6");

	// Rest of the code for this function
}

 

So basically, I'm at a complete loss. If these functions were simple, I'd just copy their code over into the new function (I know, you shouldn't do that, but if it works and the proper way doesn't 🤷‍♂️), but these functions are pretty large, and call upon other functions as well.

Does anyone have any tips or tricks I can try? Any tips regarding speeding up the testing of code would be nice as well, Bieberfelde is a great mod, but having to sit through that loading time just because you mistyped something, or are trying out a different pointer thingy is not that great.

 

Footnotes:
1: Selecting firefighter with hose, clicking hydrant
2: My C++ skills aren't that great, especially with things like pointers etc., that aren't common in other languages
3: System::Log(""); and Mission::PlayHint("");, displaying numbers, so I can trace in which order (if at all) the code executes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...