Conditions Question
Conditions Question
Currently playing around with the new conditions system -- absolutely loving it and it makes way more sense for your average noob modder ( aka me).
However, I do have one question...is there any to use the conditions system to give one unit 2 versions of the same trait? (i.e, an if/elseif condition?)
For example, lets say I gave tanks GrantConditionOnDeploy: DeployedConditioned: "block." and :UndeployedCondition:"mobile." Is there any way to make the speed = 40 when "block" is true, and the speed 75 when "mobile" is true?
However, I do have one question...is there any to use the conditions system to give one unit 2 versions of the same trait? (i.e, an if/elseif condition?)
For example, lets say I gave tanks GrantConditionOnDeploy: DeployedConditioned: "block." and :UndeployedCondition:"mobile." Is there any way to make the speed = 40 when "block" is true, and the speed 75 when "mobile" is true?
- Graion Dilach
- Posts: 277
- Joined: Fri May 15, 2015 5:57 pm
Speeds directly aren't conditionable like that due to being part of Mobile, but SpeedMultiplier is a way to go.
Assuming you set default speed to 75, you can then add a
block for such an effect. Mind you that during the deploy animation (if you use such) neither condition is applied! Which actually provides a nice example case to answer your main question, since the following block would stop the unit during the deploy animation:
To put it more bluntly: traits which support multiple instances can be used as an if/elseif situation, with each "else statement" would be provided through separate trait instances. However condition support != multiple traits support, there are a few conditionable traits which can't have multiple instances without bugs/crashes (WithSpriteTurret crashes when there are more than 1 Attack* trait on the actor, Mobile is limited to one trait instance, etc).
Assuming you set default speed to 75, you can then add a
Code: Select all
SpeedMultiplier@deployed:
->RequiresCondition: block
->Modifier: 53 # 0.53*75 is 39.75, close enough.
Code: Select all
SpeedMultiplier@deploying:
->RequiresCondition: !block && !mobile
->Modifier: 0
You can enable/disable different armaments to give the unit different weapons. (For example nod-vehicles.yaml#L62-L69)
you can give the unit two different weapons and use conditions to set which weapons is fired (so if you had two weapon, one shoots faster than the other)
so if you had
Armament@Condition1
RequiresCondition: condition1
Armament@Condition2
RequiresCondition: -condition1
(this code isn't 100% accurate, but I think it conveys the idea)
so the first weapon is active whenever condition 1 is being met and the second is active whenever condition 1 isn't being met (put negative sign before condition)
so if you had
Armament@Condition1
RequiresCondition: condition1
Armament@Condition2
RequiresCondition: -condition1
(this code isn't 100% accurate, but I think it conveys the idea)
so the first weapon is active whenever condition 1 is being met and the second is active whenever condition 1 isn't being met (put negative sign before condition)
I was trying to play around with the new conditions by giving sandbags BlocksProjectiles when an infantry unit is next to it. I can get the Blockable trait of the sandbags to turn on and off, but I can't seem to make the weapons switch and/or get the Blockable: false trait to work.
Probably not the smartest way to write it, but it was a product of trial and error...i tried -takecover, -Blockable, switching the order of the armaments, and adjusting the height of BlocksProjectiles, but nothing seems to work. I know I'm missing something here, but I couldn't find any documentation on Weapon traits in the wiki, nor could I figure it out from reading weapons.yaml...
Code: Select all
Rules:
World:
MissionData:
Briefing: \n-Sandbags provide cover for infantry
^Infantry:
ConditionManager:
ExternalCondition:
Condition: takecover
ProximityExternalCondition:
Condition: iscover
Range: 2c0
SBAG:
ConditionManager:
ProximityExternalCondition:
Condition: takecover
Range: 2c0
BlocksProjectiles@SANDBAG:
Height: 0c5
RequiresCondition: iscover
ExternalCondition:
Condition: iscover
E1:
Armament@Primary:
Weapon: M1Carbine
RequiresCondition: !takecover
Armament@TAKECOVER:
Weapon: M1CarbineCover
RequiresCondition: takecover
Armament@GARRISONED:
Weapon: Vulcan
MuzzleSequence: garrison-muzzle
Weapons:
M1CarbineCover:
Projectile: Bullet
Blockable: false
ReloadDelay: 20
Range: 5c0
Report: gun11.aud
Warhead@1Dam: SpreadDamage
Versus:
Wood: 25
- Graion Dilach
- Posts: 277
- Joined: Fri May 15, 2015 5:57 pm
http://resource.openra.net/maps/21685/#
The lint checker on the resource site is going crazy, but the map runs without crashing. I have other maps that have that same error, but I don't know how to fix it.
The lint checker on the resource site is going crazy, but the map runs without crashing. I have other maps that have that same error, but I don't know how to fix it.
- Graion Dilach
- Posts: 277
- Joined: Fri May 15, 2015 5:57 pm
Ahyeah, now I can see the problems.
Armament@Primary != Armament@PRIMARY - you basically allow the default M1Carbine be shot along with that setup.
The lint errors are because you added the ExternalCondition trait (which should have an @ID suffix for clarity IMO) to ^Infantry, but the consumers are only on E1 and the linter is completely valid that no other infantry utilizes it at the moment.
Armament@Primary != Armament@PRIMARY - you basically allow the default M1Carbine be shot along with that setup.
The lint errors are because you added the ExternalCondition trait (which should have an @ID suffix for clarity IMO) to ^Infantry, but the consumers are only on E1 and the linter is completely valid that no other infantry utilizes it at the moment.
I've tried messing around with it, making sure the conditions are right and that the logic is clear, but I can't spot the error because behavior is very strange. With my current setup, all the projectiles pass through the sand bag as long as the rifleman is standing 2c0 or farther. But when the rifle gets closer to the sandbag (conditions are true), the only armament that gets blocked is the M1Carbine and the M1Carbine clone -- all other projectiles (turret shots, flame turret shots, pillbox shots, etc) go past the sand bags.
I need to figure out this selective BlocksProjectiles for some other applications. In particular, when I gave tanks BlocksProjectiles, if the tank is moving forward and shooting forward (in the exact same direction), the tank sprite actually blocks its own turreted shot.
Also a couple more questions...
How is ReturnFire calculated with the RevealsShroud@GAPGEN? When I tested this, if the unit was hidden by the gap generator (enemy does not see this unit) and it fired on an enemy, that enemy would immediately return fire even though this unit is completely hidden by the Gap Generator.
Also, is there any way to create a clone of the GPS power that reveals the surrounding area around an actor, rather than the entire map?
I need to figure out this selective BlocksProjectiles for some other applications. In particular, when I gave tanks BlocksProjectiles, if the tank is moving forward and shooting forward (in the exact same direction), the tank sprite actually blocks its own turreted shot.
Code: Select all
Rules:
World:
MissionData:
Briefing: \n-Sandbags provide cover for infantry
^Infantry:
ConditionManager:
ProximityExternalCondition@ISCOVER:
Condition: iscover
Range: 2c0
SBAG:
ConditionManager:
ProximityExternalCondition@SWITCHGUN:
Condition: switchgun
Range: 2c0
BlocksProjectiles@ISCOVER:
Height: 0c5
RequiresCondition: iscover
ExternalCondition:
Condition: iscover
E1:
ExternalCondition@SWITCHGUN:
Condition: switchgun
Armament@PRIMARY:
Weapon: M1Carbine
RequiresCondition: !switchgun
Armament@SWITCHGUN:
Weapon: M1CarbineCover
RequiresCondition: switchgun
Armament@GARRISONED:
Weapon: Vulcan
MuzzleSequence: garrison-muzzle
Weapons:
M1CarbineCover:
Projectile: Bullet
Blockable: false
ReloadDelay: 20
Range: 5c0
Report: gun11.aud
Warhead@1Dam: SpreadDamage
Versus:
Wood: 25
Also a couple more questions...
How is ReturnFire calculated with the RevealsShroud@GAPGEN? When I tested this, if the unit was hidden by the gap generator (enemy does not see this unit) and it fired on an enemy, that enemy would immediately return fire even though this unit is completely hidden by the Gap Generator.
Also, is there any way to create a clone of the GPS power that reveals the surrounding area around an actor, rather than the entire map?