-
Notifications
You must be signed in to change notification settings - Fork 8
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
Implements TransformsInto
for UnitType's.
#933
base: develop
Are you sure you want to change the base?
Implements TransformsInto
for UnitType's.
#933
Conversation
This comment is automaticly generated by Nightly.link and allows non-registered users to get download the artifacts for this pull request. These links are also updated when the pull request is pushed to. |
6452ce7
to
a5491de
Compare
Check if unit type is initialized, if not throw a warning, i suppose could just check if MaxStrength isn't 0, or some other constant that should definitely be set |
48cd2ea
to
b789478
Compare
TransformsInto
for UnitType's.
25c023e
to
1b29304
Compare
1b29304
to
0b029a3
Compare
* Stolen bytes/code. | ||
*/ | ||
if (unittype->IsToHarvest || unittype->IsToVeinHarvest) { | ||
harvester_process: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this label to the end of the function.
unittypeext = Extension::Fetch<UnitTypeClassExtension>(unittype); | ||
|
||
if (unittype->DeploysInto != nullptr || unittypeext->TransformsInto != nullptr) { | ||
deployable_process: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this label to the end of the function.
* @author: Rampastring | ||
*/ | ||
DECLARE_PATCH(_UnitClass_Mission_Unload_Transform_To_Vehicle_Patch) { | ||
GET_REGISTER_STATIC(UnitTypeClass*, unittype, eax); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a space between UnitTypeClass
and *
.
This is most likely your MSVC auto-formatting taking over here, you can change those easily in Tools -> Options -> Text Editor -> C/C++.
/** | ||
* We can transform and either don't need charge or we have enough of it, return ACTION_SELF | ||
*/ | ||
return_self: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little bit of code duplication here. We could clean this up by using making a single return label, with the return value being a variable that can be set in the jumping case.
_asm { pop esi } | ||
_asm { pop ebp } | ||
_asm { pop ebx } | ||
_asm { add esp, 10h } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be changed to use 0x10
instead of 10h
for hexadecimal values.
if (unittype->DeploysInto != nullptr) { | ||
objectcount += house->BQuantity.Count_Of((BuildingType)unittype->DeploysInto->Get_Heap_ID()); | ||
} | ||
else if (unittypeext->TransformsInto != nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reformat to;
if (unittype->DeploysInto != nullptr) {
objectcount += house->BQuantity.Count_Of((BuildingType)unittype->DeploysInto->Get_Heap_ID());
} else if (unittypeext->TransformsInto != nullptr) {
* This unit can transform into another unit, increment the object count | ||
* by the number of transformed units. | ||
*/ | ||
objectcount += house->UQuantity.Count_Of((UnitType)(unittypeext->TransformsInto->Get_Heap_ID())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful of such a large operation here. Check the assembly, hopefully, this only uses EAX for each operation.
*/ | ||
DECLARE_PATCH(_HouseClass_Can_Build_BuildLimit_Handle_Vehicle_Transform) | ||
{ | ||
GET_REGISTER_STATIC(UnitTypeClass*, unittype, edi); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A space between the HouseClass
/UnitTypeClass
and *
please.
*/ | ||
DECLARE_PATCH(_HouseClass_ShouldDisableCameo_BuildLimit_Fix) | ||
{ | ||
GET_REGISTER_STATIC(FactoryClass*, factory, ecx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A space between the FactoryClass
/TechnoTypeClass
and *
please.
* | ||
* Author: Rampastring | ||
*/ | ||
int _HouseClass_ShouldDisableCameo_Get_Queued_Count(FactoryClass* factory, TechnoTypeClass* technotype) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be best to move this to HouseClassExtension
.
d649039
to
5a6cb19
Compare
Closes #611 , Closes #715
This patch makes it possible for vehicles to transform into other vehicles on deploy.
This behaviour is controlled by a new
TransformsInto=<unit type>
key forUnitType
s. If it points to a validUnitType
, the unit is transformed into the specified unit type when deployed.Also, in DTA we have a use-case where we want the transform to have a cooldown. This can be optionally enabled by giving the unit
TransformRequiresFullCharge=yes
. This re-uses the Mobile EMP's Charge logic: when this key is set, the unit is required to have full charge or it isn't able to transform.Finally, for implementing this without having the transform break the build limits of units, I had to re-implement a part of the build limit checking for this patch. While at it, I also fixed #611 .
Remarks
If the unit also has
DeploysInto=
pointing to a building type, theDeploysInto
logic is prioritized over unit transformation.The unit transformation logic, however, is prioritized over the Mobile EMP blast logic.