Jump to content
ztz2019

How to get upgrade when garrisoned or contain

Recommended Posts

Just like Ra3 IFV, or KW Epic but could exit. And when exit, remove upgrade.

 

No need distinguish every kind of passengers with different upagrade, just 1 upgrade is enough.

 

I tried to add UpgradeContainerOnContain in HordeGarrisonContain, could pass compiling but no use in game.

Edited by ztz2019

Share this post


Link to post

There are several model conditions and object statuses related to garrsion. Model Conditions: "GARRISONED", "INSIDE_GARRISON" or "WEAPONSET_GARRISONED". Object Status: "GARRISONED", "INSIDE_GARRISON".

Try to use one of these to trigger a lua event and for the lua function then use these:

 

ObjectGrantUpgrade(object,upgradename)
ObjectRemoveUpgrade(object,upgradename)
ObjectHasUpgrade(object,upgradename)

 

or these

 

ExecuteAction("NAMED_RECEIVE_UPGRADE",object,upgradename)
ExecuteAction("NAMED_REMOVE_UPGRADE",object,upgradename)

EvaluateCondition("UNIT_HAS_UPGRADE",ObjectStringRef,upgradename)

 

If e.g. the following doesn't work to trigger the removal:

 

<ModelConditionEvent Name="UnGarrisoned">
<Conditions>-GARRISONED</Conditions>
</ModelConditionEvent>

 

..then you can always use a Meta Mod ScriptTimer to test every n seconds ObjectTestModelCondition(object,modelconditionname) or ObjectHasUpgrade(object,upgradename) or try to use 2.9.3 from my guide

 

I didn't look into an xml solution, so there might be another (maybe easier) way making it work on the xml coding side...

Edited by Mjjstral

Share this post


Link to post

There are several model conditions and object statuses related to garrsion. Model Conditions: "GARRISONED", "INSIDE_GARRISON" or "WEAPONSET_GARRISONED". Object Status: "GARRISONED", "INSIDE_GARRISON".

Try to use one of these to trigger a lua event and for the lua function then use these:

 

ObjectGrantUpgrade(object,upgradename)

ObjectRemoveUpgrade(object,upgradename)

ObjectHasUpgrade(object,upgradename)

 

or these

 

ExecuteAction("NAMED_RECEIVE_UPGRADE",object,upgradename)

ExecuteAction("NAMED_REMOVE_UPGRADE",object,upgradename)

EvaluateCondition("UNIT_HAS_UPGRADE",ObjectStringRef,upgradename)

 

If e.g. the following doesn't work to trigger the removal:

 

<ModelConditionEvent Name="UnGarrisoned">

<Conditions>-GARRISONED</Conditions>

</ModelConditionEvent>

 

..then you can always use a Meta Mod ScriptTimer to test every n seconds ObjectTestModelCondition(object,modelconditionname) or ObjectHasUpgrade(object,upgradename) or try to use 2.9.3 from my guide

 

I didn't look into an xml solution, so there might be another (maybe easier) way making it work on the xml coding side...

Thanks, I'll try to add it by setting LUA.

Share this post


Link to post

After modifying LUA it can control upgrade by enter and exit now. However, it still has bug that non-effective when first garrison the structure, it needs to exit and enter again to activate the upgrade.

 

So I've uploaded the source code and model asset, who can fix this?

http://pan.baidu.com/s/1eSj2raa

 

or

Link: http://pan.baidu.com/s/1gf3IVPx access code: pt9a

 

 

 

 

 

 

 

 

 

OK, it seems that I've reached my opinion, but I'll still share the asset for everyone since somebody may have better idea and spreading modding knowledge is my ideal.

Edited by ztz2019

Share this post


Link to post

There are several model conditions and object statuses related to garrsion. Model Conditions: "GARRISONED", "INSIDE_GARRISON" or "WEAPONSET_GARRISONED". Object Status: "GARRISONED", "INSIDE_GARRISON".

Hi, Mjjstral. Thanks for earlier help about LUA Event. However, I'm trapped in new problem now. GARRISONED is effective on buildings when infantry enters in, and INSIDE_GARRISON is for infantry when garrison in structures, so how is the model tag of the vehicle which is entered by infantry? I tried and found GARRISONED is no use for vehicle. Or vehicle entered by passenger isn't related to the status named "garrison" ? Edited by ztz2019

Share this post


Link to post

Hi, Mjjstral. Thanks for earlier help about LUA Event. However, I'm trapped in new problem now. GARRISONED is effective on buildings when infantry enters in, and INSIDE_GARRISON is for infantry when garrison in structures, so how is the model tag of the vehicle which is entered by infantry? I tried and found GARRISONED is no use for vehicle. Or vehicle entered by passenger isn't related to the status named "garrison" ?

 

 

Quick answer: Use modelcondition "LOADED".

 

Long answer:

 

You have two ways also depending on where you need to use it:

 

1. Use modelcondition "LOADED" as LuaEvent or within lua with ObjectTestModelCondition(object,modelconditionname).

 

2. Also within lua possible: EvaluateCondition("UNIT_HAS_PASSENGER",GetObj.String(object)) (GetObj.String is a metamod function)

 

One general thing to help yourself in such cases: Use the lists ModelConditionList.txt, ObjectStatusList.txt and especially ALL_SAGE_LUA_COMMANDS.txt that come with metamod to find these things.

In this case you could find out the modelcondition with metamod easily: 1. select a unit with passenger, 2. Open meta command menu 3. open selected unit info 4. (optional) write the info to a file and you get something like this written to the LIVE_OUTPUT.txt (which is very usefull for modders):

 

Type: SteelTalonsRepairAPC
Health: 100
IsAlive: true
Position: x:261 y:81
KindOf: SELECTABLE CAN_ATTACK CAN_CAST_REFLECTIONS TRANSPORT PRELOAD SCORE ATTACK_NEEDS_LINE_OF_SIGHT CAN_REVERSE_MOVE VEHICLE CAN_BE_FAVORITE_UNIT 
ObjectStatus: CREATE_DRAWABLE_WITH_LOW_DETAIL 
ModelConditions: DOOR_1_CLOSING LOADED SELECTED 
Upgrades: 
ObjectPanelFlags: AI Recruitable Enabled Powered Selectable 
SpecialPowersReady: SpecialPower_TargetedRepairVehicle SpecialPowerGDI_APCMinefield 
Rank: 1
SkillPoints: 0
DistanceToBase: 120
ThreadLevel: 0
HasPassengers: 0
OrientationAngle: 0
NearbyEnemys(radius=300): 0
ObjectCanSufferFear: true
ObjectOwner: Mjjstral
ObjectOwnerFaction: SteelTalons
ObjectOwnerIsAI: 0
ObjectTeamName: teamPlayer_2
ObjectTeamNameInternal: Player_2/teamPlayer_2
NumberOfSameTypeFromTeam: 1
NumberOfSameTypeFromAll: 1
IsSameTypeInsideBase: false
ObjectNumber: 66
StringReference: object_O8zQk
TableReference: table: 3958D1C8
ObjectPlayerSide: {0,0}38EA5BC0
ObjectDescription: Object 66 [steelTalonsRepairAPC, owned by player 3 (Mjjstral)]
ObjectHash: 2093312067
ObjectTemplateName: {0,0}7CC56843
ObjectCapturingObjectPlayerSide: nil

Hope that helps you ;)

 

Share this post


Link to post

Hope that helps you ;)

Thanks very much, I'll try it in metamod. It seems you're expert in modding so do you interested in debugging my demo mod?

The mutant mod sometimes crashes when many units in melee battle but I can't find where's the error, so I need an adept in disassembling to check out the bug.

 

 

Well, LOADED is no effect for the transport vehicle. I'm trying EvaluateCondition

Edited by ztz2019

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×