Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom entries to interaction menu #244

Closed
robinhoersch opened this issue Jun 15, 2014 · 20 comments
Closed

Add custom entries to interaction menu #244

robinhoersch opened this issue Jun 15, 2014 · 20 comments
Assignees
Milestone

Comments

@robinhoersch
Copy link

It would be a nice feature to be able to add entries to the AGM interaction menu as a missionmaker.
Unfortunately we cannot edit the CfgVehicles class in the description.ext file.

@robinhoersch
Copy link
Author

I think the best way is to let the missionmaker define their actions inside
https://community.bistudio.com/wiki/missionConfigFile
the same way its in CfgVehicles.
Maybe a structure like:
class AGM_CustomActions {
class Man {
class Action1 {
...
};
class Action2 {
...
};
};
class Car {
...
};
};

@commy2
Copy link
Collaborator

commy2 commented Jun 23, 2014

I agree.

@commy2 commy2 self-assigned this Jun 23, 2014
@commy2 commy2 closed this as completed in a4f0f3b Jun 23, 2014
@nicolasbadano
Copy link
Collaborator

Very nice! But, commy, does it work? I though CfgVehicles was outright ignored in description.ext

@robinhoersch
Copy link
Author

Your custom actions are not inside CfgVehicles. They are in an own class inside descriptions.ext.
Well done commy! What about putting duplicate code into a function/variable?

@nicolasbadano
Copy link
Collaborator

The code is looking for custom actions as:

_config = missionConfigFile >> "CfgVehicles" >> typeOf _object >> "AGM_Actions";

So inside CfgVehicles! I haven't test it yet, but as I think it shouldn't work.

@robinhoersch
Copy link
Author

Oh sorry, you are right.
I think it should work, but I'm not sure, either.

I am going to test it later.

@commy2
Copy link
Collaborator

commy2 commented Jun 24, 2014

Please test it. The path can be changed if it doesn't work, but I don't know why it would fail.

It's not that I'm actually updating the "CfgVehicles" config file but rather the mission config file, which is why adding this was necessary in the first place.

@commy2 commy2 reopened this Jun 24, 2014
@nicolasbadano
Copy link
Collaborator

Ok, I'll try to test it latter today. I've tried to introduce new config entries under cfgvehicles in description.ext before without sucess, but I've never tried reading them the way you did it, so maybe it behaves differently.

@commy2
Copy link
Collaborator

commy2 commented Jun 24, 2014

Obviously normal config entries won't work since the mission config != addon config, but these are accessed via missionConfigFile, which is completely different.

@nicolasbadano
Copy link
Collaborator

I hope you are right! I'll test it in a couple of hours and report back.

@KoffeinFlummi
Copy link
Owner

Just using typeOf might not work. Since there's no inheritance of all the different vehicles in the missionConfigFile you wouldn't be able to simply define something for, say, "Car" and have it apply to all cars.

If you would want to make that possible, you'd have to go through all parents of a vehicle class, checking them all individually.

@commy2
Copy link
Collaborator

commy2 commented Jun 24, 2014

Aren't you confusing this with 'isKindOf' ? 'typeOf' returns a String and config entries are strings in sqf.

@KoffeinFlummi
Copy link
Owner

Yes, but look at robin's example:

class AGM_CustomActions {
class Man {
class Action1 {
...
};
class Action2 {
...
};
};
class Car {
...
};
};

Nothing you add to "Car" would ever get used. A Hunter for example would return "B_MRAP_01_F" for typeOf, and not find anything under that classname, since none of those vehicles were ever defined in missionConfigFile.

@commy2
Copy link
Collaborator

commy2 commented Jun 24, 2014

So you would have to recreate the whole inheritance tree for every unit. Thats stupid. I might have to rewrite this, so it checks in the missionConfig file for all the base classes,,,

@nicolasbadano
Copy link
Collaborator

Commy, if you have to refactor the code one more time (and I think you will!), I'll add another related use case for you to consider.

Would it be difficult to allow the mission maker to specify certain interaction with a particular object instead of a class of objects? E.g. interact with a certain computer to "Extract Criptography" or something.

But...

Thinking about it now I realize that maybe it could be done without changing anything in AGM by applying the interaction to the class but restricting the activation condition to a particular object; could a better way be coded in AGM?

@commy2
Copy link
Collaborator

commy2 commented Jun 24, 2014

Restricting the condition to a specific vehicle should be sufficient.
I will have to rewrite this though using https://community.bistudio.com/wiki/inheritsFrom. Working on this now.

@commy2
Copy link
Collaborator

commy2 commented Jun 24, 2014

Done. Still needs testing.
I also added the option to overwrite existing actions with the mission config.

class CfgVehicles {

// Another option to toggle earbuds
class CAManBase {
class AGM_SelfActions {
class AGM_Earplugs_New {
displayName = "Plug Earbuds in Two";
condition = "AGM_EarPlugsIn || {player canAdd 'AGM_EarBuds'}";
statement = "[] call AGM_Hearing_fnc_Earplugs";
showDisabled = 1;
priority = -0.9;
};
};
};

//Opfor can't use earbuds for some reason
class O_Soldier_AR_F {
class AGM_SelfActions {
class AGM_Earplugs {
displayName = "Earbuds on";
condition = "false";
statement = "[] call AGM_Hearing_fnc_Earplugs";
showDisabled = 1;
priority = -0.9;
};
};
};
};

*Note: The mission config file doesn't need class inheritance for this.

commy2 pushed a commit that referenced this issue Jun 24, 2014
@robinhoersch
Copy link
Author

Another way instead of looping through all parents is to loop through all entries in AGM_Actions and check configName with isKindOf.
@esteldunedain if you add actions to a single object with this there would be no use for addAction anymore.

@nomisum
Copy link

nomisum commented Jul 15, 2014

Oh this looks totally interesting for my mission :)

@commy2
Copy link
Collaborator

commy2 commented Jul 15, 2014

This could maybe even more interesting to you: #360

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants