Jump to content
Sign in to follow this  
Ravendark

a brainstorm about power/supply depots

Recommended Posts

Awhile ago i was experimenting with giving units a powerconsumption cost...the idea was to mimic a supplychain effect....build to many units overload your supplychain/powergrid and receive a penalty to your units performace alongside the usual lowerpower effect of buildings....so basicly mimicing a working or breakdown in military logistics.

i didnt really got further then giving a unit a power consumption and fiddled arround with the low_power status and the onpoweroutage and onpowerrestored events.....didnt really work like i intended and had someweird effects on my powerturbineupgrades weirdly enough.

 

So last night the idea came back to me (yay for being an insomniac) but under a slightly diffferent idea:

 

When lower power:

A:through an auramodifier:

 

Have a persistent building or better yet a persisten gameobject (something that spawns every game(maybe together with the playerspellbook if that works?)) ,have that gameobject be effected by power. On low power have it either use the aura system to effect mapwide everyplayer unit and give it a atribute modifier that reduces speed,rate of fire,vision range etc.

So the rough idea atm is to:

 

<AttributeModifierAuraUpdate
                id="ModuleTag_AttributeModifierAuraUpdate_LowPower"
                AttributeModifierName="Logistics_Failure_attributeMod"
                RefreshDelay="1.0s"
                Range="99999"
                InitiallyActive="true"
                RequiredConditions="MOUNTED">
        <ObjectFilter
                    Rule="ALL"
                    Relationship="PLAYER"
                    />
</AttributeModifierAuraUpdate>
 
<AttributeModifier
        id="Logistics_Failure_attributeMod"
        Category="NONE" 
        Duration="2s" 
        ModelConditionsSet="User_20" > /** maybe set some visual overlay on the effected unit to indicate a supply breakdown
        <Modifier Type="VISION" Value="50%"/>
        <Modifier Type="SHROUD_CLEARING" Value="50%" />
        <Modifier Type="SPEED" Value="50%"/>
        <Modifier Type="RATE_OF_FIRE" Value="50%"/>
</AttributeModifier>
 
<EventList Name="Logistics_Event" Inherit="BaseScriptFunctions">
        <EventHandler EventName="OnPowerOutage" ScriptFunctionName="OnLogisticsFailure" DebugSingleStep="false"/>
        <EventHandler EventName="OnPowerRestore" ScriptFunctionName="OnLogisticsRestore" DebugSingleStep="false"/>
</EventList>
 
function OnLogisticsFailure(self)
    -- Set MOUNTED state to enable Aura
    ObjectGrantUpgrade( self, "Upgrade_TriggerMountedAuraState" )
end
function OnLogisticsRestore(self)
    -- Set MOUNTED state to disable Aura
    ObjectGrantUpgrade( self, "Upgrade_RemoveMountedAuraState" )
end
 
<RemoveUpgradeUpgrade
                id="ModuleTag_CommandSet_RemoveFor_01">
                <TriggeredBy>Upgrade_TriggerMountedAuraState</TriggeredBy>
                <UpgradeToRemove>Upgrade_RemoveMountedAuraState</UpgradeToRemove>
</RemoveUpgradeUpgrade>
<RemoveUpgradeUpgrade
                id="ModuleTag_CommandSet_RemoveFor_02">
                <TriggeredBy>Upgrade_RemoveMountedAuraState</TriggeredBy>
                <UpgradeToRemove>Upgrade_TriggerMountedAuraState</UpgradeToRemove>
</RemoveUpgradeUpgrade>
<ModelConditionUpgrade
                id="ModuleTag_ModelConditionUpgrade_TriggerMountedAuraState"
                AddConditionFlags="MOUNTED">
                <TriggeredBy>Upgrade_TriggerMountedAuraState</TriggeredBy>
</ModelConditionUpgrade>
<ModelConditionUpgrade
                id="ModuleTag_ModelConditionUpgrade_RemoveMountedAuraState"
                RemoveConditionFlags="MOUNTED">
                <TriggeredBy>Upgrade_RemoveMountedAuraState</TriggeredBy>
</ModelConditionUpgrade>
 

 

This as early concept, another method could be using the ObjectBroadcastEventToAllies through lua maybe, but im not sure if you can broadcast to a whole faction, or just to a single object and if it can differentiate between player objects only and similar allies object aswell?

Share this post


Link to post

To just tell a specific unit something use:

 

scripts.lua

function TellOtherSuperSpecificAlly(self)
  ObjectBroadcastEventToAllies(self, "SuperEncodedMessage", 99999)
end
scriptevents.xml
<ScriptedEvent Name="SuperEncodedMessage" />
...
<EventList Name="SuperSpecificUnitFunctions">
  <EventHandler EventName="SuperEncodedMessage" ScriptFunctionName="MyHandler" />
</EventList
So as you can see you can name your event whatever you like, a radius of 99999 should usually be enough to affect a whole map, and only handle it by your specific unit.

 

I'm not even sure if the passing of self is a must, could be that you can also do something like this:

 

scripts.lua

function TellOtherSuperSpecificAlly(self)
  ObjectBroadcastEventToAllies("123456", "SuperEncodedMessage", 99999)
end
scriptevents.xml
<ScriptedEvent Name="SuperEncodedMessage" />
...
<EventList Name="SuperSpecificUnitFunctions">
  <EventHandler EventName="SuperEncodedMessage" ScriptFunctionName="MyHandler" />
</EventList
scripts.lua
function MyHandler(self, data)
  if data == "123456" then
...
  end
end
Edited by Lauren

Share this post


Link to post

What i actually meant (i probably phrased it wrong) would be following scenario:

 

Player 1: gdi -> has predator tank

player 2: gdi -> has predator tank

 

the above are allies. and the opponent is any other or even equal faction.

 

if player 1 his predator has the SuperSpecificUnitFunctions on its predator tank....player 2 plays the same faction who's pred tank will have those functions aswell.

If player 1 broadcasts the message that will be recieved by its pred tanks....will player 2 his predator tanks recieve that aswell because he basicly owns the same architype of unit just the unit is owned by another player?

hence would player 1 unwillingly disable player 2 aswell on a low power scenario as i se in example of the code used? or can the broadcasteventoallies distinguish between player 1 and player 2? maybe im reading tomuch to the allies part in the string name?

Share this post


Link to post

Well you can do

function MyHandler(self, other)

local selfstr = tostring(ObjectTeamName(self))

local otherstr = tostring(ObjectTeamName(other))

if selfstr == otherstr then

...do stuff..

end

end

The function ObjectTeamName returns teamPlayer_x where x is the starting position on the map. And if the unit belongs to a team via WB it would say teamPlayer_x/teamname. Edited by Lauren

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.

×