Jump to content


Random coding questions


51 replies to this topic

#1 Golan

    <Charcoal tiles available>

  • Member Test
  • 3300 posts

Posted 18 September 2007 - 08:23

I´m currently working on implementing a tank that has both a cannon and coaxial machine gun. However, the unit doesn´t choose the correct weapon for attacks - it uses the cannon against infantry and the machine gun against buildings and vehicles.
The cannon is a modified version of the Predator´s cannon, the MG was based on the APC´s gun.

I already tried adding "DamageObjectFilter"-tags to both weapons, but that only resulted in the tank still using the wrong weapon and doing no damage at all.
I also tried using a "DamageScalarDetails" setting the damage against the unwanted targets to 0% and giving the tank a WeaponChoiceCriteria="PREFER_MOST_DAMAGE" entry on the WeaponSlotTurret - same as above.
Also tried the WeaponChoiceCriteria="USE_WEAPONSET_DEFAULT_CRITERIA" - however, there seems to be no way to actually define those criteria.

Any help would be appreciated.

WeaponSet and weapon code:
<WeaponSetUpdate
				id=&#34;ModuleTag_WeaponSetUpdate&#34;>
				<WeaponSlotTurret
					ID=&#34;1&#34;
					<Weapon
						Ordering=&#34;PRIMARY_WEAPON&#34;
						Template=&#34;GDIMilShepherdCannon&#34;/>
					<Weapon
						Ordering=&#34;SECONDARY_WEAPON&#34;
						Template=&#34;GDIMilShepherdGun&#34;>
					<TurretSettings
						TurretTurnRate=&#34;60&#34;
						TurretPitchRate=&#34;20&#34;
						AllowsPitch=&#34;true&#34;
						MinimumPitch=&#34;-15d&#34;
						MinIdleScanTime=&#34;1.0s&#34;
						MaxIdleScanTime=&#34;5.0s&#34;
						MinIdleScanAngle=&#34;0.0&#34;
						MaxIdleScanAngle=&#34;90.0&#34;>
						<TurretAITargetChooserData
							CanAcquireDynamicIfAssignedOutOfRange=&#34;true&#34; />
					</TurretSettings>
				</WeaponSlotTurret>
			</WeaponSetUpdate>
&#91;s&#93;-------------------------------------------------------------------------------------------------&#91;/s&#93;
	<WeaponTemplate
		  id=&#34;GDIMilShepherdCannon&#34;
		  Name=&#34;GDIMilShepherdCannon&#34;
		  AttackRange=&#34;300.0&#34;
		  MinTargetPitch=&#34;-15d&#34;
		  MaxTargetPitch=&#34;15d&#34;
		  WeaponSpeed=&#34;600&#34;
		  AcceptableAimDelta=&#34;2d&#34;
		  WeaponRecoil=&#34;5d&#34;
		  RadiusDamageAffects=&#34;ALLIES ENEMIES NEUTRALS&#34;
		  ShotsPerBarrel=&#34;1&#34;
		  ClipSize=&#34;1&#34;
		  ReAcquireDetailType=&#34;POST_FIRE&#34;
		  ProjectileCollidesWith=&#34;ALLIES ENEMIES NEUTRAL STRUCTURES WALLS&#34;
		  FireFX=&#34;FX_PredTankGun&#34;
		  FireVeteranFX=&#34;FX_PredTankGunHeroic&#34;
		  CanFireWhileMoving=&#34;true&#34; >
		<FiringDuration
				MinSeconds=&#34;0.3s&#34;
				MaxSeconds=&#34;0.3s&#34; />
		<ClipReloadTime
				MinSeconds=&#34;3.0s&#34;
				MaxSeconds=&#34;3.0s&#34; />
		<Nuggets>
			<ProjectileNugget 
				WarheadTemplate=&#34;GDIMilShepherdCannonWarhead&#34; 
				ProjectileTemplate=&#34;FXTankShell02&#34;>
				<VeterancyProjectiles
					VeterancyLevel=&#34;HEROIC&#34;
					ProjectileTemplate=&#34;FXTankShell02_Veteran&#34;/>
			</ProjectileNugget>
		</Nuggets>
		<ScatterRadiusVsType
			Radius=&#34;10.0&#34;>
			<Filter
				Rule=&#34;NONE&#34;
				Include=&#34;INFANTRY&#34; />
		</ScatterRadiusVsType>
	</WeaponTemplate>

	<WeaponTemplate
		  id=&#34;GDIMilShepherdCannonWarhead&#34;
		  Name=&#34;GDIMilShepherdCannonWarhead&#34; 
		  ProjectileCollidesWith  = &#34;ALLIES ENEMIES NEUTRAL STRUCTURES WALLS&#34; 
		  RadiusDamageAffects=&#34;ALLIES ENEMIES NEUTRALS&#34; >
		<Nuggets>
			<DamageNugget
				Damage=&#34;2100.0&#34; 
				DelayTimeSeconds=&#34;0.0s&#34; 
				DamageType=&#34;CANNON&#34; 
				DamageFXType=&#34;GDI_CANNON&#34;		
				DeathType=&#34;NORMAL&#34; >
					<DamageObjectFilter
						Rule=&#34;ALL&#34;
						Exclude=&#34;INFANTRY&#34;/>
			</DamageNugget>
			<SuppressionNugget
					  Radius=&#34;25.0&#34;
					  Suppression=&#34;25&#34;
					  DurationSeconds=&#34;5s&#34; />
		</Nuggets>
	</WeaponTemplate>
	
	<WeaponTemplate
		id=&#34;GDIMilShepherdGun&#34;
		Name=&#34;GDIMilShepherdGun&#34;
		FireSoundPerClip=&#34;GDI_GuardianAPC_MachineGunFire&#34;
		FireFX=&#34;FX_GDIRifleManFire&#34;
		FireVeteranFX=&#34;FX_GDIRifleManFireHeroic&#34;
		AttackRange=&#34;200.0&#34; 
		WeaponSpeed=&#34;999999.0&#34; 
		RadiusDamageAffects=&#34;ALLIES ENEMIES NEUTRALS&#34;
		AntiMask=&#34;ANTI_GROUND&#34;
		CanFireWhileMoving=&#34;true&#34;	
		ClipSize=&#34;3&#34;
		ReAcquireDetailType=&#34;PER_CLIP&#34;>		
		<FiringDuration
			MinSeconds=&#34;0.1s&#34;
			MaxSeconds=&#34;0.1s&#34; />
		<ClipReloadTime
			MinSeconds=&#34;1.0s&#34;
			MaxSeconds=&#34;1.0s&#34;/>
			<Nuggets>
				<DamageNugget 
					Damage=&#34;300.0&#34; 
					Radius=&#34;0.0&#34; 
					DelayTimeSeconds=&#34;0.0s&#34; 
					DamageType=&#34;GUN&#34; 
					DamageFXType=&#34;GDI_MACHINEGUN&#34;		
					DeathType=&#34;NORMAL&#34;>
						<DamageObjectFilter
							Rule=&#34;NONE&#34;
							Include=&#34;INFANTRY&#34;/>
				</DamageNugget >
				<SuppressionNugget
					Radius=&#34;15.0&#34;
					Suppression=&#34;25&#34;
					DurationSeconds=&#34;2s&#34; />
			</Nuggets>
	</WeaponTemplate>
</AssetDeclaration>

Edited by Golan, 26 September 2007 - 16:29.

Now go out and procreate. IN THE NAME OF DOOM!

#2 Sgt. Rho

    Kerbal Rocket Scientist

  • Project Leader
  • 6870 posts
  • Projects: Scaring Jebediah.

Posted 18 September 2007 - 09:35

try "inverting" it, so as if you did want it to attack infantry with the cannon and vehicles and buildings with the MG :P

#3 Golan

    <Charcoal tiles available>

  • Member Test
  • 3300 posts

Posted 18 September 2007 - 09:47

What do you mean with "inverting"? Swapping primary/secondary classification?
Now go out and procreate. IN THE NAME OF DOOM!

#4 Sgt. Rho

    Kerbal Rocket Scientist

  • Project Leader
  • 6870 posts
  • Projects: Scaring Jebediah.

Posted 18 September 2007 - 09:55

Then in german:

Mach es so als ob du panzer und gebäude mit dem MG angreifen willst, und infanterie mit dem MG, dass sollte dann den umgekehrten effekt haben und so greift das MG inf and und die kanone das andere

#5 Guest_Centric Founder and Owner_*

  • Guest

Posted 18 September 2007 - 10:38

View PostMaster_Chief, on 18 Sep 2007, 19:55, said:

Then in german:

Mach it so as if you tanks and buildings with the mg to attack want, and infantry with the mg the fact that should have then the reverse effect and so seizes the mg inf and and the cannon the other one


#6 Rayburn

    People-Hater

  • Gold Member
  • 4802 posts

Posted 18 September 2007 - 10:49

That translation is erroneous and the fact that Golan knows German drives it obsolete :P

#7 Slye_Fox

    FOXTec Leader

  • Project Leader
  • 2351 posts
  • Projects: CnC: Condition Red, Sigma Invasion, Armoured Sky: Ethereal Dawn

Posted 18 September 2007 - 11:07

		AntiMask=&#34;ANTI_GROUND&#34;


Isn't there an ANTI_INFANTRY tag, or something like it?
Posted Image

#8 Golan

    <Charcoal tiles available>

  • Member Test
  • 3300 posts

Posted 18 September 2007 - 11:14

Nope, there´s only anti_ground, anti_airborne_vehicle and anti_airborne_infantry. Standard Kind_Of classifications are not supported.

View PostMaster_Chief, on 18 Sep 2007, 9:55, said:

Then in german:

Mach es so als ob du panzer und gebäude mit dem MG angreifen willst, und infanterie mit dem MG, dass sollte dann den umgekehrten effekt haben und so greift das MG inf and und die kanone das andere
But the only thing that specifies the target (even though it doesn´t work :P) is ATM negating the damage against unwanted targets - if I change this to the opposite, it wouldn´t have ANY use, as the tank would then either still use the wrong weapon, or use the right one but do no damage at all.

Edited by Golan, 18 September 2007 - 11:15.

Now go out and procreate. IN THE NAME OF DOOM!

#9 Slye_Fox

    FOXTec Leader

  • Project Leader
  • 2351 posts
  • Projects: CnC: Condition Red, Sigma Invasion, Armoured Sky: Ethereal Dawn

Posted 18 September 2007 - 11:27

acttuly, that's not he only ones.

I just cheacked the schema, but there's no infantry or vehicle ones.
ANTI_AIRBORNE_VEHICLE
ANTI_GROUND
ANTI_PROJECTILE
ANTI_SMALL_MISSILE
ANTI_MINE
ANTI_AIRBORNE_INFANTRY
ANTI_BALLISTIC_MISSILE
ANTI_PARACHUTE
ANTI_STRUCTURE
ANTI_AIRBORNE_MONSTER
Posted Image

#10 Judgement

    Demon of the Fall

  • Member
  • 2330 posts
  • Projects: Same old shit different pile.

Posted 18 September 2007 - 19:51

Just try swapping the spots around.
Posted Image
Posted Image

#11 Golan

    <Charcoal tiles available>

  • Member Test
  • 3300 posts

Posted 22 September 2007 - 13:18

Small update on the progress so far: Another approach by setting the weapon´s effectiveness to 0, this time by modifying the targets armor, ended with the same results as before - no damage but the tank still firing like a berserk.
Adding AllowInterleavedFiring="true" made the tank now use both weapons. However, as the secondary weapon has less range, it had the tank go way too near to the target - this means certain death in any tank vs. tank scenario.
Swapping primary/secondary classification didn´t change anything.

So far, I´ve almost run out of options. The last attempt will be to make a special power to control the secondary weapon - I´ll report back after some tests, but if anyone should still have some ideas, please post them.
Now go out and procreate. IN THE NAME OF DOOM!

#12 Golan

    <Charcoal tiles available>

  • Member Test
  • 3300 posts

Posted 23 September 2007 - 15:15

Now that´s what I´d call depressing... it seems like TW doesn´t only check damage effectiveness, but also side effects. As both weapons also had a suppression update without the SpecialObjectFilter, the weapons still counted as effective and were thus used.
Adding a SpecialObjectFilter to the suppression updates as well fixed the problem.

Which brings me right to the next problem: HordeTransportContains - anyone got these working for loading in several squads?
Now go out and procreate. IN THE NAME OF DOOM!

#13 CodeCat

    It's a trap!

  • Gold Member
  • 6111 posts

Posted 23 September 2007 - 17:41

I got them working for several single units, but I'm not sure about squads.
CodeCat

Posted Image
Posted Image

Go dtiomsaítear do chód gan earráidí, is go gcríochnaítear do chláir go réidh. -Old Irish proverb

#14 Daz

    Visitor

  • Member
  • 21 posts
  • Projects: It Came From Red Alert!

Posted 23 September 2007 - 18:18

The Ox transport (as it is in GDIV35Ox.xml) can take 6 squads.
You won't get them back out again though :P

For some reason evacuate stops working after you've unloaded 2 units.

#15 Golan

    <Charcoal tiles available>

  • Member Test
  • 3300 posts

Posted 23 September 2007 - 18:57

From what i gathered, transports will only unload the last squads that entered at the same time - say you have a three slot APC and already loaded in a grenadier Squad and then have two Riflemensquads enter at the same time, you will be able to only unload the Riflemen. If it´s initial situation but the Riflemen are loaded in one after another, then only the last Riflemen squad may be evacuated.
Now go out and procreate. IN THE NAME OF DOOM!

#16 CodeCat

    It's a trap!

  • Gold Member
  • 6111 posts

Posted 23 September 2007 - 21:15

I've yet to discover how to make the cargo come out damaged rather than dead when the transport is destroyed...
CodeCat

Posted Image
Posted Image

Go dtiomsaítear do chód gan earráidí, is go gcríochnaítear do chláir go réidh. -Old Irish proverb

#17 Vengence

    Professional

  • Project Team
  • 341 posts
  • Projects: Silent Dawn VI: The Dark Return, Sigma Invasion

Posted 24 September 2007 - 14:31

View PostGolan, on 22 Sep 2007, 9:18, said:

Adding AllowInterleavedFiring="true" made the tank now use both weapons.


Just as an off question... does that mean a unit can fire multiple weapons at the same time?
Posted Image
Posted Image
Posted Image
Friends look out for one another

#18 Golan

    <Charcoal tiles available>

  • Member Test
  • 3300 posts

Posted 26 September 2007 - 16:32

Yes it does. I´m not exactly sure though if the unit then uses both weapons at the same time or starts with one and uses the other while reloading.

Anpther question that didn´t seem to be worth another thread: can the generals promotion system still be used? Not necessarily the generals points, but advancing to higher ranks that can be referred to as prerequisites...
Now go out and procreate. IN THE NAME OF DOOM!

#19 Golan

    <Charcoal tiles available>

  • Member Test
  • 3300 posts

Posted 01 October 2007 - 22:13

Another issue that doesn´t always seem clear to me: object filters.

From what I understand, the "Rule=" tag defines the basic pool of what objects are affected. "All" means that by default the filter includes all objects, while "NONE" means that the object pool is empty. "Any" appears to mean "every object that has one of the following attributes" (see the gamedependecy for power plants) - however, this interpretation often conflicts with "Rule=NONE" serving the same function, e.g. when damage scalars are applied.
"Include=" and "Exclude=" seem to simply add or take away objects with a specific KindOf from the objects pool defined by "Rule=". So "Rule=All" in combination with "Exlude=" means "All objects but those of this type", while "Rule=None" in combination with "Include=" means "Only objects of these specific types". "Rule=None" with both "Include=" and "Exclude=" then means "Only objects of these specific types that are not of these other types as well".
Then finally, there´s "<ExludeThing>" and "<IncludeThing>" - from my understanding, they should have the same function as "Include=" and "Exclude=", only defining specific Objects instead of general KindOfs though.

Which leads me to this code snippet:
<ScatterRadiusVsType
			Radius=&#34;500.0&#34;>
			<Filter
				Rule=&#34;NONE&#34;
				Include=&#34;INFANTRY&#34;>
				<IncludeThing>GDIMilHumvee</IncludeThing>
			</Filter>
		</ScatterRadiusVsType>
As I see it, this ought to make a weapon scatter against all infantry units and the object GDIMilHumvee. Point is however that the Humvee gets roasted just like before. :lol:

Any help concerning filters in general and this very specific problem would be appreciated.
Now go out and procreate. IN THE NAME OF DOOM!

#20 CodeCat

    It's a trap!

  • Gold Member
  • 6111 posts

Posted 02 October 2007 - 22:01

The difference between ALL, ANY and NONE as I see it is with the KindOfs.

ALL: Only objects having all the KindOfs listed in Include= are eligible.
ANY: Objects having at least one of the KindOfs listed in Include= are eligible.
NONE: No objects are eligible by default, except those added explicitly with IncludeThing.

- An object that has at least one of the KindOfs in Exlude= is not eligible.
- An object added with IncludeThing is always eligible, ignoring all the above.
- An object added with ExcludeThing is never eligible, ignoring all the above.
CodeCat

Posted Image
Posted Image

Go dtiomsaítear do chód gan earráidí, is go gcríochnaítear do chláir go réidh. -Old Irish proverb

#21 Golan

    <Charcoal tiles available>

  • Member Test
  • 3300 posts

Posted 27 October 2007 - 14:46

Still stuck with the APC, any help would be appreciated.

I´ve tried HordeTransportContain with and without ExtendedExitContainerChecks as well as with various ContainMax and Slot ratios (to make sure that the Troopers of the squad don´t need any of these themselfs). I´ve also used HordeGarrisonContain with and without MobileGarrison but the effect was the same. I thought about spawning a dummy to function as a quasi-garrisonable structure but abandoned the idea as that´d have different selection spots for the vehicle and the transporter (correct me if I´m wrong).
Modifying the evacuate button to at least have the units leave on command wasn´t successful either. The MoveToPositionAndEvacuateSpecialPower doesn´t have any variables to adjust and I was unable to find another command or weapon (Bunker Busters...) to evacuate the transported units.

So please, if anyone has got any idea, no matter how absurd it is, tell me...
Now go out and procreate. IN THE NAME OF DOOM!

#22 Sgt. Rho

    Kerbal Rocket Scientist

  • Project Leader
  • 6870 posts
  • Projects: Scaring Jebediah.

Posted 27 October 2007 - 15:30

what about 2 weapon slots, where only one can be fired on the humvee and that one scatters?

#23 Golan

    <Charcoal tiles available>

  • Member Test
  • 3300 posts

Posted 27 October 2007 - 15:37

The Humvee issue is fixed already, i simply added a second ScatterRadiusVsType filter specifically for the Humvee. :P Sorry for not having cleared this up.

APC still doesn´t work properly.

Edited by Golan, 27 October 2007 - 20:07.

Now go out and procreate. IN THE NAME OF DOOM!

#24 Golan

    <Charcoal tiles available>

  • Member Test
  • 3300 posts

Posted 03 November 2007 - 10:50

Update on the APC issue:
I was able to attach a dig-in building to my APCs. However, the bunker can´t be selected and infantry can´t enter it. Not sure though if there´s simply a kindof missing or something similar.
Posted Image
If someone wants to experiment with this, this is the relevant Code:
APC&#58;
KindOf=&#34;PRELOAD SELECTABLE SLAVE_OWNER COVER CAN_CAST_REFLECTIONS SCORE VEHICLE CAN_REVERSE_MOVE CAN_BE_FAVORITE_UNIT&#34;

<CombinedInfoModule
				DockingBone=&#34;BoneGarrison01&#34; />
			<SpawnBehavior
				id=&#34;ModuleTag_SpawnFighter&#34;
				SpawnNumberData=&#34;1&#34;
				InitialBurst=&#34;1&#34;
				SpawnReplaceDelayData=&#34;30s&#34;
				SpawnInsideBuilding=&#34;true&#34;
				FadeInTime=&#34;1s&#34;
				CombineOnCreate=&#34;true&#34;
				PassExperienceToSpawned=&#34;true&#34;>
				<SpawnTemplate>AlienInvaderFighter2</SpawnTemplate>
			</SpawnBehavior>

&#34;AlienInvaderFighter2&#34;&#58;

KindOf=&#34;PRELOAD CAN_CAST_REFLECTIONS CAN_ATTACK ATTACK_NEEDS_LINE_OF_SIGHT SCORE IMMOBILE PASS_EXPERIENCE_TO_SLAVER NO_COLLIDE GARRISONABLE_UNTIL_DESTROYED GARRISON&#34;

<SlavedUpdate
				id=&#34;ModuleTag_SlavedUpdate&#34;
				LeashRange=&#34;600&#34;
				GuardMaxRange=&#34;0&#34;
				GuardWanderRange=&#34;0&#34;
				AttackRange=&#34;0&#34;
				DieOnMastersDeath=&#34;true&#34; />


What it definitely proves is that an immobile garrison object can be attached to a unit - IMO this is the only approach that allows bypassing the problem of mobile containers. However, perhaps the approach with slaved objects is the wrong one. I want to try using a transportmodule with the actual infantry container being an InitialPayload and the evacuate button being a weapon that triggers a weapon attack of the contained object which again would have the garrisoned infantry attack - AFAIK there´s some weapon code for this.
Now go out and procreate. IN THE NAME OF DOOM!

#25 Ort

    Newbie

  • Member
  • 10 posts

Posted 06 December 2007 - 20:44

I got a question on weapons that i dont seem to understand: what exactly is FiringDuration in WeaponTemplate asset? I thought it is the time of firing the entire clip so that the delay between shots time (that was explicitly given by the DelayBetweenShots attribute in Generals) could be calculated like this: DelayBetweenShots = ClipSize/FiringDuration. But sadly it isn't. So, what is it?



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users