ModEnc is currently in Maintenance Mode: Changes could occur at any given moment, without advance warning.

Ore spawning

From ModEnc
Revision as of 17:21, 26 January 2008 by 78.86.141.70 (talk)
Jump to navigation Jump to search

Spawning ore with debris

This tutorial will explain how to create patches (or tiles) of ore from flying debris. This can be used for many other purposes such as when hooked to a weapon it becomes an ore spawning weapon, Shoot a tile, and ore appears, and such.
This works on Red Alert 2 Yuri's Revenge 1.001 without rockpatch or npatch

Intro

There are 3 main elements to controlling ore:

  • Generation of debris
  • Debris piece that becomes ore
  • Global ore properties

Generation of debris

Very easy to achieve with a DebrisTypes= tag, in practice harder to get working reliably, so start by picking a "guinea pig" unit which we will do all experiments on. I chose the Rhino Tank since you start with 4 of them in multiplayer.
In its properties add these tags as a test: ( Note: beware that there is a mistake in the original code, "Maxdebris=" should be "MaxDebris=" )
MaxDebris=6 MinDebris=4 DebrisTypes=TIRE DebrisMaximums=6 ;Later on this one, i promise
The tags are self explanatory. Test the changes by blowing up a Rhino Tank in game, you should see 4 to 6 tires flying off the tank after it explodes, if it doesnt, you messed up.

Debris piece that becomes an ore tile

Now that we know the debris generation works, we shall play with TIRE voxel debris code now. Using TIRE again as our guniea pig.
at the bottom of the code add these tags:
IsTiberium=true TiberiumRadius=1 ;how many tiles of ore we want around our impact TiberiumSpawnType=TIB07 ;type of ore to spawn 1-12 works. gems are GEM01 - 12 i think.
Now if you test this in game you will see something very strange. If you check carefully you will realise that ore in fact is spawned by the TIRE debris, yet in such small amounts that its very hard to see. If this is the case next section should sort it.

Global Ore Properties

Be aware that we are changing the global ore properties, this means that it will affect not only the ore that we spawn, but also the ore that is grown naturally by ore drills. The effect is small but significant enough to look out for.
The problem with out new spawned ore patches is that they dont grow (by grow i mean the ore in the tile stays the same density, this has nothing to do with amount of ore produced by the ore drills).

In the ore properties we have 4 entries, all are different forms of ore (Tiberium, remnants from Tiberium Sun game) [Cruentus] are gems [Riparius] is ore

In [Riparious] section change this tag:

Growth=500 ;original value is 2200

Results

Start the game and blow up your tank. If you done everything correctly the tank should blow into several tires, those, when stop bouncing should create single full patches of ore worth 275 credits.

Cleaning Up

Now suppose you would like to hook this to every unit that is destroyed in game? its a bit rubbish leaving it as a tire. So... lets change it ! This means we need to do these things:

  • Create a special ORE debris type
  • Hook the ORE debris to units
  • Create a voxel for the ORE
    • Tweek parameters and looks
  • Control the amount of ore expelled

Creating a new ORE debris type

Copy the code as it is from TIRE entry (same code that currently generates ore). Call it [ORE] leave everything as it is for now, we would like to test this first Remove 3 lines from [TIRE] that we added previously

Hooking the ORE debris to units

In our Rhino Tank change this line to:

DebrisTypes=ORE ; Was set to TIRE

And now test to see if it works exactly as it was before. If it doesn't, recheck everything.

Creating a Voxel for ORE

Create a ore looking piece (mine was 10x10x10 in size, looked alright) and name it ORE.vxl Put this file in the game folder and change the ORE entry like this:

Image=ORE ; was set to TIRE

Test the game once more.

Tweek parameters and looks of ORE debris

Now you know that everything works you can change how far the ore is flying out and where it lands, I made it land just short of where tires could go, i also changed Elasticity= tag to stop the ore from bouncing.

Warhead= tag isn't necessary

Control amount of ORE expelled

Tanks explode in ore, OK, but is that fair? now you can build tanks => kill them => mine the ore for profit? thats not fair at all now is it. So lets limit the amount of debris that is spawned by units.

Now you need to one rule about the DebrisMaximums= tag:

DebrisMaximums= must not be larger than MaxDebris= tag. Sounds stupid, its actually quite clever, for example: Our Rhino tank is worth 900 credits, so about 3 ore pieces should cover it. i also want some tires to be expelled, but they shouldn't contain any ore

MaxDebris=5 ;total number of debris MinDerbis=3 ;minumum number of debris DebrisTypes=ORE,TIRE ;types of debris DebrisMaximums=3,2 ;maximum nummber for each type

This way, when the tank blows up, you should get at combination of ore and tires, no more than 3 ore pieces, no less than 1 ore piece. sounds fair that.

You will have to go through every unit and change these tags to suit the unit cost, you might not want to add 2 debris types at all.