Jump to content
Sign in to follow this  
Madin

LUA issue

Recommended Posts

I have a situation were I am not sure whether it is my poor coding, or some other issue that is causing my code not to work.

 

I am using a 'ObjectStatusEvent':

            <ObjectStatusEvent Name="HexaPodFull">
			<Conditions>+RIDER1 +RIDER2 +RIDER3</Conditions>
		</ObjectStatusEvent>
<EventList Name="AlienEradicatorHexapodFunctions" Inherit="BaseScriptFunctions">
		<EventHandler EventName="HexaPodFull"	ScriptFunctionName="OnAlienHexaPodFull" DebugSingleStep="false"/>
	</EventList>

 

I have not seen this type of event used anywhere, including BFME, so I am going of information that i got of a internet search. Does anyone know if this type of event works, and if the code looks OK?

 

Here is the LUA:

function OnAlienHexaPodFull(self)
	if ObjectHasUpgrade( self, "Upgrade_EradicatorTeleportFront" ) == 1 and
         ObjectHasUpgrade( self, "Upgrade_EradicatorTeleportMiddle" ) == 1 and
         ObjectHasUpgrade( self, "Upgrade_EradicatorTeleportRear" ) == 1 then
	   ObjectGrantUpgrade( self, "Upgrade_EradicatorTeleport" )	
	end
end

The purpose of this code is supposed to be, if the Hexapod is full and all the slots are filled by the Prodigy, then grant a special upgrade which unpauses a power that is only available in this special case.

Why am I not using the 'RequiresAllTriggers' attribute in code located within the actual 'GameObject'? because I already tried and it is not working for some reason (the Hexapod code is not mine, it is Denato's, so I do not fully understand it).

 

Any coders that can help me out?

Share this post


Link to post

Where is the section that gives the front/middle/rear upgrades? (+RIDER1 give upgrade_front etc)

I havent used the RIDER conditions yet myself, but i assume they refer to each transport slot then? Did you leave it out for sake of screen space or doesnt it exist?

Im curious how you trigger those 3 upgrades from a objectstatus, is there a lua script that checks for object status? i know you can with a modelcondition, but that is basicly out of habit/(limited)knowledgbase on my part i guess.

Share this post


Link to post

It would be interesting to know if AILuaEventsList is even set in the AIUpdate.

Additionally if it's even setting the ObjectStatus and not a ModelCondition (RIDERX exists in both).

Share this post


Link to post

I have not seen this type of event used anywhere, including BFME, so I am going of information that i got of a internet search. Does anyone know if this type of event works, and if the code looks OK?

that i am wondering aswell. It seems do be a logical thing to include...objectstatusevent, but i can't find anything like it anywhere either. But as Lauren says, you could probably replace it with modelconditionevent and rider1-8(iirc).

 

What i am wondering aswell is...

 

if the Hexapod is full and all the slots are filled by the Prodigy

you seem to have 3 rider slots, does the prodigy count as 3 transportslots or just 1? i am not sure if it will grab rider1-3 for just 1 unit, i think it just locks out the other 2 transport slots for the sake of space and only enables rider1

 

 

if i would go about making such a unit+system i would try to just give the prodigy a aura that enables a status/model condition for the hexapod and by so unlock the teleport ability. you prob could give the aura

 

RequiredObjectStatusFlags="RIDER1 RIDER2 RIDER3" if you want a full load prerequisition

Edited by Ravendark

Share this post


Link to post

When I was working on the TWA epic units, I NEVER got ObjectHasUpgrade to work corrently. No idea why, but it never seemed to work the way I wanted. As a workaround, I used the upgrades to trigger modelconditions and checked these instead.

Share this post


Link to post

I wanted to try and reduce the size of the post, because the epic code is obviously massive.

First of all the Denato epic code is done entirely using XML code, it does not use LUA at all (obviously there is the standard 'HideSubObjects' when built LUA code).

 

The individual units have variations of this code (Prodigy used in example):

<!-- ############# Hexapod Upgrade Special Abillity ############# -->
      <SpecialPowerDispatchSpecialPower id="ModuleTag_GiveMARVUpgradeSP" SpecialPowerTemplate="SpecialPower_BlinkUpgrade_Dispatch" RequireAllPowersToFunction="false">
        <SpecialPower SpecialPowerTemplate="SpecialPower_UseTraveler59BlinkPack" />
        <SpecialPower SpecialPowerTemplate="SpecialPower_GiveMARVUpgrade_Tech_1" />
        <SpecialPower SpecialPowerTemplate="SpecialPower_GiveMARVUpgrade_Tech_2" />
        <SpecialPower SpecialPowerTemplate="SpecialPower_GiveMARVUpgrade_Tech_3" />
      </SpecialPowerDispatchSpecialPower>
      <SpecialPower id="ModuleTag_GiveMARVUpgradeUnitDieSP" SpecialPowerTemplate="SpecialPowerDummyTriggered7" UpdateModuleStartsAttack="true" />
      <GiveOrRestoreUpgradeSpecialPower id="ModuleTag_GiveMARVUpgradeUnitDie" SpecialPowerTemplate="SpecialPowerDummyTriggered7" UpgradeToGive="Upgrade_UnPack" />
      <ReplaceSelfUpgrade id="ModuleTag_ReplaceSelf" NewObjectUnpackTime="0.0s" DisabledDuringUnpack="false" CheckBuildAssistant="false">
        <TriggeredBy>Upgrade_UnPack</TriggeredBy>
        <ReplacementTemplate>MARVUpgradeDieObject</ReplacementTemplate>
      </ReplaceSelfUpgrade>
      <SpecialPower id="ModuleTag_GiveMARVUpgradeSP_Level3" SpecialPowerTemplate="SpecialPower_GiveMARVUpgrade_Tech_3" UpdateModuleStartsAttack="true" />
      <ActivateModuleSpecialPower id="ModuleTag_GiveMARVUpgradeUpdate_Level3" SpecialPowerTemplate="SpecialPower_GiveMARVUpgrade_Tech_3" StartAbilityRange="=$GDI_MARVUPGRADE_ABILITYSTARTRANGE" UnpackTime="0.0s" ChainedButton="Command_GiveMARVUpgrade_UnitDie" Options="CHECK_CHAINED_COMMAND CHECK_SPECIALPOWER_REQUIREMENTS_DURING_UPDATE">
        <SpecialPowerModules ModuleId="ModuleTag_GiveMARVUpgrade_Level3" TriggerType="TARGET_OBJECT" />
      </ActivateModuleSpecialPower>
      <GrantUpgradeAreaOfEffectSpecialPower id="ModuleTag_GiveMARVUpgrade_Level3" UpdateModuleStartsAttack="true" SpecialPowerTemplate="SpecialPower_GiveMARVUpgrade_Tech_3" TriggerFX="=$GDI_MARVUPGRADE_FX" Radius="=$GDI_MARVUPGRADE_RADIUS">
        <AcceptObjectFilter Rule="NONE">
          <IncludeThing>AlienEradicatorHexapod</IncludeThing>
        </AcceptObjectFilter>
        <UpgradeTemplate>Upgrade_EradicatorTeleportRear</UpgradeTemplate>
      </GrantUpgradeAreaOfEffectSpecialPower>
      <SpecialPower id="ModuleTag_GiveMARVUpgradeSP_Level2" SpecialPowerTemplate="SpecialPower_GiveMARVUpgrade_Tech_2" UpdateModuleStartsAttack="true" />
      <ActivateModuleSpecialPower id="ModuleTag_GiveMARVUpgradeUpdate_Level2" SpecialPowerTemplate="SpecialPower_GiveMARVUpgrade_Tech_2" StartAbilityRange="=$GDI_MARVUPGRADE_ABILITYSTARTRANGE" UnpackTime="0.0s" ChainedButton="Command_GiveMARVUpgrade_UnitDie" Options="CHECK_CHAINED_COMMAND CHECK_SPECIALPOWER_REQUIREMENTS_DURING_UPDATE">
        <SpecialPowerModules ModuleId="ModuleTag_GiveMARVUpgrade_Level2" TriggerType="TARGET_OBJECT" />
      </ActivateModuleSpecialPower>
      <GrantUpgradeAreaOfEffectSpecialPower id="ModuleTag_GiveMARVUpgrade_Level2" UpdateModuleStartsAttack="true" SpecialPowerTemplate="SpecialPower_GiveMARVUpgrade_Tech_2" TriggerFX="=$GDI_MARVUPGRADE_FX" Radius="=$GDI_MARVUPGRADE_RADIUS">
        <AcceptObjectFilter Rule="NONE">
          <IncludeThing>AlienEradicatorHexapod</IncludeThing>
        </AcceptObjectFilter>
        <UpgradeTemplate>Upgrade_EradicatorTeleportMiddle</UpgradeTemplate>
      </GrantUpgradeAreaOfEffectSpecialPower>
      <SpecialPower id="ModuleTag_GiveMARVUpgradeSP_Level1" SpecialPowerTemplate="SpecialPower_GiveMARVUpgrade_Tech_1" UpdateModuleStartsAttack="true" />
      <ActivateModuleSpecialPower id="ModuleTag_GiveMARVUpgradeUpdate_Level1" SpecialPowerTemplate="SpecialPower_GiveMARVUpgrade_Tech_1" StartAbilityRange="=$GDI_MARVUPGRADE_ABILITYSTARTRANGE" UnpackTime="0.0s" ChainedButton="Command_GiveMARVUpgrade_UnitDie" Options="CHECK_CHAINED_COMMAND CHECK_SPECIALPOWER_REQUIREMENTS_DURING_UPDATE">
        <SpecialPowerModules ModuleId="ModuleTag_GiveMARVUpgrade_Level1" TriggerType="TARGET_OBJECT" />
      </ActivateModuleSpecialPower>
      <GrantUpgradeAreaOfEffectSpecialPower id="ModuleTag_GiveMARVUpgrade_Level1" UpdateModuleStartsAttack="true" SpecialPowerTemplate="SpecialPower_GiveMARVUpgrade_Tech_1" TriggerFX="=$GDI_MARVUPGRADE_FX" Radius="=$GDI_MARVUPGRADE_RADIUS">
        <AcceptObjectFilter Rule="NONE">
          <IncludeThing>AlienEradicatorHexapod</IncludeThing>
        </AcceptObjectFilter>
        <UpgradeTemplate>Upgrade_EradicatorTeleportFront</UpgradeTemplate>
      </GrantUpgradeAreaOfEffectSpecialPower>

This is the generic special powers that all infantry use that can enter the Hexapod:

<AssetDeclaration>
<Includes>
 <Include type="all" source="DATA:GlobalData/GlobalDefines.xml"/>
 </Includes>
<SpecialPowerTemplate id="SpecialPower_GiveMARVUpgrade" Flags="NEEDS_OBJECT_FILTER" ReloadTime="0s" TargetType="OBJECT" NameOfVoiceNameToUseAsInitiateIntendToDoVoice="InitiateChargeDefensesTrigger">
<ObjectFilter Relationship="ALLIES" Rule="NONE">
 <IncludeThing>AlienEradicatorHexapod</IncludeThing>
 </ObjectFilter>
 </SpecialPowerTemplate>
<SpecialPowerTemplate id="SpecialPower_GiveMARVUpgrade_Tech_1" Flags="NEEDS_OBJECT_FILTER TARGET_NEEDS_OBJECT_STATUS" ReloadTime="0s" TargetType="OBJECT" DisallowedTargetObjectStatus="RIDER1" NameOfVoiceNameToUseAsInitiateIntendToDoVoice="InitiateChargeDefensesTrigger">
<ObjectFilter Relationship="ALLIES" Rule="NONE">
 <IncludeThing>AlienEradicatorHexapod</IncludeThing>
 </ObjectFilter>
 </SpecialPowerTemplate>
<SpecialPowerTemplate id="SpecialPower_GiveMARVUpgrade_Tech_2" Flags="NEEDS_OBJECT_FILTER TARGET_NEEDS_OBJECT_STATUS" ReloadTime="0s" TargetType="OBJECT" RequiredConditions="RIDER1" DisallowedTargetObjectStatus="RIDER2" NameOfVoiceNameToUseAsInitiateIntendToDoVoice="InitiateChargeDefensesTrigger">
<ObjectFilter Relationship="ALLIES" Rule="NONE">
 <IncludeThing>AlienEradicatorHexapod</IncludeThing>
 </ObjectFilter>
 </SpecialPowerTemplate>
<SpecialPowerTemplate id="SpecialPower_GiveMARVUpgrade_Tech_3" Flags="NEEDS_OBJECT_FILTER TARGET_NEEDS_OBJECT_STATUS" ReloadTime="0s" TargetType="OBJECT" RequiredConditions="RIDER1 RIDER2" DisallowedTargetObjectStatus="RIDER3" NameOfVoiceNameToUseAsInitiateIntendToDoVoice="InitiateChargeDefensesTrigger">
<ObjectFilter Relationship="ALLIES" Rule="NONE">
 <IncludeThing>AlienEradicatorHexapod</IncludeThing>
 </ObjectFilter>
 </SpecialPowerTemplate>
 <SpecialPowerTemplate id="SpecialPowerDummyTriggered7" TargetType="NONE"/>
 </AssetDeclaration>

Finally here is the relevant section on the Hexapod code where the ObjectStatus is set:

<StatusBitsUpgrade id="ModuleTag_UpgradeWeapon_HexapodFront" StatusToSet="RIDER1">
 <TriggeredBy>Upgrade_EradicatorLaserFront</TriggeredBy>
 <TriggeredBy>Upgrade_EradicatorDiscsFront</TriggeredBy>
 <TriggeredBy>Upgrade_EradicatorShardsFront</TriggeredBy>
 <TriggeredBy>Upgrade_EradicatorHealingFront</TriggeredBy>
 <TriggeredBy>Upgrade_EradicatorTeleportFront</TriggeredBy>
 </StatusBitsUpgrade>
<StatusBitsUpgrade id="ModuleTag_UpgradeWeapon_HexapodMiddle" StatusToSet="RIDER2">
 <TriggeredBy>Upgrade_EradicatorLaserMiddle</TriggeredBy>
 <TriggeredBy>Upgrade_EradicatorDiscsMiddle</TriggeredBy>
 <TriggeredBy>Upgrade_EradicatorShardsMiddle</TriggeredBy>
 <TriggeredBy>Upgrade_EradicatorHealingMiddle</TriggeredBy>
 <TriggeredBy>Upgrade_EradicatorTeleportMiddle</TriggeredBy>
 </StatusBitsUpgrade>
<StatusBitsUpgrade id="ModuleTag_UpgradeWeapon_HexapodRear" StatusToSet="RIDER3">
 <TriggeredBy>Upgrade_EradicatorLaserRear</TriggeredBy>
 <TriggeredBy>Upgrade_EradicatorDiscsRear</TriggeredBy>
 <TriggeredBy>Upgrade_EradicatorShardsRear</TriggeredBy>
 <TriggeredBy>Upgrade_EradicatorHealingRear</TriggeredBy>
 <TriggeredBy>Upgrade_EradicatorTeleportRear</TriggeredBy>
 </StatusBitsUpgrade>

Here is the standard blink teleport code, which works:

<UnpauseSpecialPowerUpgrade id="ModuleTag_UnpauseManipulatorSpecialPowerLF" SpecialPowerTemplate="SpecialPower_HexapodManipulateObjectLF">
 <TriggeredBy>Upgrade_EradicatorTeleportFront</TriggeredBy>
 </UnpauseSpecialPowerUpgrade>
 <SpecialPower id="ModuleTag_ManipulatorDeviceLF" SpecialPowerTemplate="SpecialPower_HexapodManipulateObjectLF" UpdateModuleStartsAttack="true" StartsPaused="true"/>
<ActivateModuleSpecialPower id="ModuleTag_ManipulatorDeviceUpdateLF" SpecialPowerTemplate="SpecialPower_HexapodManipulateObjectLF" StartAbilityRange="300" Options="CHECK_SPECIALPOWER_REQUIREMENTS_DURING_UPDATE INSTANT IGNORE_FACING_CHECK">
 <SpecialPowerModules ModuleId="ModuleTag_ManipulatorDeviceWorkerLF" TriggerType="TARGET_OBJECT"/>
 </ActivateModuleSpecialPower>
 <TemporaryOwnerSpecialPower id="ModuleTag_ManipulatorDeviceWorkerLF" SpecialPowerTemplate="SpecialPowerDummyTriggered3" UpdateModuleStartsAttack="false"/>
<UnpauseSpecialPowerUpgrade id="ModuleTag_UnpauseManipulatorSpecialPowerLM" SpecialPowerTemplate="SpecialPower_HexapodManipulateObjectLM">
 <TriggeredBy>Upgrade_EradicatorTeleportMiddle</TriggeredBy>
 </UnpauseSpecialPowerUpgrade>
 <SpecialPower id="ModuleTag_ManipulatorDeviceLM" SpecialPowerTemplate="SpecialPower_HexapodManipulateObjectLM" UpdateModuleStartsAttack="true" StartsPaused="true"/>
<ActivateModuleSpecialPower id="ModuleTag_ManipulatorDeviceUpdateLM" SpecialPowerTemplate="SpecialPower_HexapodManipulateObjectLM" StartAbilityRange="300" Options="CHECK_SPECIALPOWER_REQUIREMENTS_DURING_UPDATE INSTANT IGNORE_FACING_CHECK">
 <SpecialPowerModules ModuleId="ModuleTag_ManipulatorDeviceWorkerLM" TriggerType="TARGET_OBJECT"/>
 </ActivateModuleSpecialPower>
 <TemporaryOwnerSpecialPower id="ModuleTag_ManipulatorDeviceWorkerLM" SpecialPowerTemplate="SpecialPowerDummyTriggered3" UpdateModuleStartsAttack="false"/>
<UnpauseSpecialPowerUpgrade id="ModuleTag_UnpauseManipulatorSpecialPowerLR" SpecialPowerTemplate="SpecialPower_HexapodManipulateObjectLR">
 <TriggeredBy>Upgrade_EradicatorTeleportRear</TriggeredBy>
 </UnpauseSpecialPowerUpgrade>

The above is the standard Kane's wrath style Hexapod, only one Prodigy (or Mastermind) is required in any position, to trigger the Hexapod's teleport ability.

 

I tried first adjusting the code like this hoping to require all three upgrades in order to trigger the power:

<UnpauseSpecialPowerUpgrade id="ModuleTag_UnpauseTeleportSpecialPower" SpecialPowerTemplate="SpecialPower_TeleportEradicator" RequiresAllTriggers="true">
 <TriggeredBy>Upgrade_EradicatorTeleportFront</TriggeredBy>
 <TriggeredBy>Upgrade_EradicatorTeleportMiddle</TriggeredBy>
 <TriggeredBy>Upgrade_EradicatorTeleportRear</TriggeredBy>
 </UnpauseSpecialPowerUpgrade>
 <SpecialPower id="ModuleTag_TeleportSpecialPower" SpecialPowerTemplate="SpecialPower_TeleportEradicator" UpdateModuleStartsAttack="true" StartsPaused="true" AttributeModifierFX="FX_AlienInfantryHitFX"/>
 <TeleportSpecialAbilityUpdate id="ModuleTag_TeleportSpecialAbility" SpecialPowerTemplate="SpecialPower_TeleportEradicator" DestinationWeapon="AlienEradicatorBlinkWeapon2" SourceWeapon="AlienEradicatorBlinkWeapon" FadeInTime="2s" UnpackTime="1s" PackTime="1s" BusyDuration="1.5s" MaxDistance="750" StartAbilityRange="750"/>

That did not work, so I changed the code to:

<UnpauseSpecialPowerUpgrade id="ModuleTag_UnpauseTeleportSpecialPower" SpecialPowerTemplate="SpecialPower_TeleportEradicator">
 <TriggeredBy>Upgrade_EradicatorTeleport</TriggeredBy>
 </UnpauseSpecialPowerUpgrade>
 <SpecialPower id="ModuleTag_TeleportSpecialPower" SpecialPowerTemplate="SpecialPower_TeleportEradicator" UpdateModuleStartsAttack="true" StartsPaused="true" AttributeModifierFX="FX_AlienInfantryHitFX"/>
 <TeleportSpecialAbilityUpdate id="ModuleTag_TeleportSpecialAbility" SpecialPowerTemplate="SpecialPower_TeleportEradicator" DestinationWeapon="AlienEradicatorBlinkWeapon2" SourceWeapon="AlienEradicatorBlinkWeapon" FadeInTime="2s" UnpackTime="1s" PackTime="1s" BusyDuration="1.5s" MaxDistance="750" StartAbilityRange="750"/>

Which was supposed to be triggered by the code in my first post on this subject, but it also does not work.

 

Please note that the basic functions of the Hexapod are fine, the standard weapons upgrade fine, and the correct subobjects show when certain infantry units are entered into the Hexapod.

To answer one query, I have a mind control ability (basic Cultist style, inspired by TWA!) and has such, the Prodigy can fill all the slots if a player so desires (each Prodigy added, will give you the ability to control two enemy units, for a maximum of six units!).

The reason why I wanted to restrict the teleport to requiring 3 Prodigies, is the fact that I have improved the teleport weapon to guarentee it crushing any enemy unit that is vunerable to the Hexapods crusher level (this was inspired by the BFME monster style teleports). Obviously this massively increases the power of the teleport, so I wanted to limit it.

 

So to clarify, the only thing which is not working, is me being able to trigger the teleport from 3 specific upgrades, everything else is fine.

 

PS: full disclosure, the actual upgrades will not always start from the front slots, to the rear like the code suggest (eg many times it will fill the rear or middle slots first) so the Denato code is not perfect.

Edited by Madin

Share this post


Link to post

you could try to replace the hasupgrade bit in your lua with a testmodelcondition: like

 

 

Function  OnAlienHexaPodFull (self)
               If ObjectTestModelCondition(Self, "RIDER1") ==1 And ObjectTestModelCondition(Self, "RIDER2") ==1 and ObjectTestModelCondition(Self, "RIDER3") ==1
               then ObjectGrantUpgrade(Self, "Upgrade_EradicatorTeleport")
               End
End
 
Edited by Ravendark

Share this post


Link to post

you could try to replace the hasupgrade bit in your lua with a testmodelcondition: like

 

Since testmodelcondition has bool, you can remove ==1

 

function  OnAlienHexaPodFull (self)
               if (ObjectTestModelCondition(Self, "RIDER1") and ObjectTestModelCondition(Self, "RIDER2") and ObjectTestModelCondition(Self, "RIDER3")) then
                   ObjectGrantUpgrade(Self, "Upgrade_EradicatorTeleport")
               end
end
Edited by jvm

Share this post


Link to post

 

you could try to replace the hasupgrade bit in your lua with a testmodelcondition: like

 

 

Function  OnAlienHexaPodFull (self)
               If ObjectTestModelCondition(Self, "RIDER1") ==1 And ObjectTestModelCondition(Self, "RIDER2") ==1 and ObjectTestModelCondition(Self, "RIDER3") ==1
               then ObjectGrantUpgrade(Self, "Upgrade_EradicatorTeleport")
               End
End
 

This would depend if setting the 'ObjectStatus' "RIDER1" also sets the model condition to "RIDER1".

And if not, does the 'ObjectTestModelCondition' also look for ObjectStatus?

From what I read, there are issues when with 'ScriptEvents' when model condition and object status are the same.

 

It is worth trying though.

Share this post


Link to post

Next time just use pastebin.

The code itself seems convoluted and there's a much easier solution, but looking at what you have here are my comments:

 

Your special powers are broken. SpecialPower_GiveMARVUpgrade_Tech_2 and SpecialPower_GiveMARVUpgrade_Tech_3 shouldn't even work as they require the caster (the unit that's "entering") to have the RIDERX status.

 

SpecialPower_GiveMARVUpgrade_Tech_1 should have DisallowedTargetObjectStatus="RIDER1"

SpecialPower_GiveMARVUpgrade_Tech_2 should have RequiredTargetObjectStatus="RIDER1" and DisallowedTargetObjectStatus="RIDER2"

SpecialPower_GiveMARVUpgrade_Tech_3 should have RequiredTargetObjectStatus="RIDER2" and DisallowedTargetObjectStatus="RIDER3"

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×