Closed robinhoersch closed 10 years ago
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 { ... }; };
I agree.
Very nice! But, commy, does it work? I though CfgVehicles was outright ignored in description.ext
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?
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.
Oh sorry, you are right. I think it should work, but I'm not sure, either.
I am going to test it later.
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.
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.
Obviously normal config entries won't work since the mission config != addon config, but these are accessed via missionConfigFile, which is completely different.
I hope you are right! I'll test it in a couple of hours and report back.
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.
Aren't you confusing this with 'isKindOf' ? 'typeOf' returns a String and config entries are strings in sqf.
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.
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,,,
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?
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.
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.
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.
Oh this looks totally interesting for my mission :)
This could maybe even more interesting to you: https://github.com/KoffeinFlummi/AGM/issues/360-
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.