Jump to content


Delayed Auto Upgrade


17 replies to this topic

#1 Slye_Fox

    FOXTec Leader

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

Posted 06 August 2008 - 22:07

Is it possable to have an upgrade, automaticly given a spasific amount of time after the structure has bee placed?
Posted Image

#2 JJ

    Half dead member

  • Project Leader
  • 3294 posts
  • Projects: Real life things, personal RA3 mod

Posted 07 August 2008 - 07:36

What kind of upgrade? OBJECT or PLAYER?

#3 Slye_Fox

    FOXTec Leader

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

Posted 07 August 2008 - 07:47

Object
Posted Image

#4 JJ

    Half dead member

  • Project Leader
  • 3294 posts
  • Projects: Real life things, personal RA3 mod

Posted 07 August 2008 - 07:55

Somehow give the object an object status which is an exempt status for the grant upgrade module that is gone after a set amount of time? It's hard with object upgrades... D:

#5 Slye_Fox

    FOXTec Leader

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

Posted 07 August 2008 - 17:28

Can an FX grant an upgrade?
Posted Image

#6 JJ

    Half dead member

  • Project Leader
  • 3294 posts
  • Projects: Real life things, personal RA3 mod

Posted 08 August 2008 - 03:37

Don't think so.

#7 Slye_Fox

    FOXTec Leader

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

Posted 09 August 2008 - 19:12

View PostJJ_, on 7 Aug 2008, 8:55, said:

Somehow give the object an object status which is an exempt status for the grant upgrade module that is gone after a set amount of time

How can i do this?
Posted Image

#8 JJ

    Half dead member

  • Project Leader
  • 3294 posts
  • Projects: Real life things, personal RA3 mod

Posted 10 August 2008 - 02:51

Well, I don't know. I was just throwing around some ideas.

#9 Chronosheep

    Amateur

  • Member
  • 106 posts
  • Projects: C&C: Renovatio

Posted 10 August 2008 - 11:02

Chronosheep to the rescue! :)

How about just using DelayedUpgrade (haven't used it, so can't guarantee that the code is active), and make it TriggeredBy an upgrade the structure automaticly gives itself when built?
You can then make the real upgrades (whatever is supposed to happen after the given time) to the building be triggered by the DelayedUpgrade.

See the schema file named DelayedUpgrade.xsd and the file it refers to: Upgrade.xsd

Hope this helps ;)
Posted Image

#10 Slye_Fox

    FOXTec Leader

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

Posted 10 August 2008 - 14:26

the upgrade modual dosn't have a grantupgrade codeing.
Posted Image

#11 JJ

    Half dead member

  • Project Leader
  • 3294 posts
  • Projects: Real life things, personal RA3 mod

Posted 11 August 2008 - 01:16

Erm, use a GrantUpgradeCreate to give an upgrade, which triggers the DelayedUpgrade?

#12 Chronosheep

    Amateur

  • Member
  • 106 posts
  • Projects: C&C: Renovatio

Posted 11 August 2008 - 01:22

Quote

Erm, use a GrantUpgradeCreate to give an upgrade, which triggers the DelayedUpgrade?

He means that DelayedUpgrade can't be used to trigger an upgrade....

And ouch... this severely complicates things...

I have an idea, but it's VERY complicated, and the coding is a bit advanced...
I usually don't do this, but since you're a friend of Oleg (aka FreedoM_FighteR) and I already said "Chronosheep to the rescue", I will help :) .

First of all the timer: Let's say 20 seconds. Give your building an autofire code:
<FireWeaponUpdate
	id=&#34;ModuleTag_FireWeaponUpdate01&#34;>
	<FireWeaponNugget
		WeaponName=&#34;UpgradeGrantWeapon&#34;
		FireDelay=&#34;20s&#34;
		OneShot=&#34;true&#34; />
</FireWeaponUpdate>


Make a weapon template (I think this one should work):
<WeaponTemplate
	id=&#34;UpgradeGrantWeapon&#34;
	Name=&#34;UpgradeGrantWeapon&#34;
	AttackRange=&#34;1&#34; 
	RadiusDamageAffects=&#34;ALLIES&#34;>
	<Nuggets>
		<AttributeModifierNugget
			  PartitionFilterTestType=&#34;SPHERE&#34;
			  AttributeModifierOwnerName=&#34;Modifier_AutoUpgrade&#34; />
	</Nuggets>
</WeaponTemplate>


Make an attribute modifier:
<AttributeModifier
	id=&#34;Modifier_AutoUpgrade&#34;
	Category=&#34;NONE&#34;
	ModelConditionsSet=&#34;UNUSED_06&#34;>
</AttributeModifier>


Now for the more complicated stuff... you will need to use lua scripts (unless you find better way):
You need to extract scriptevents.xml from the .big files, and you will need to add the modified version of this, as well as the modified Scripts.lua to your own mod .big file(s).
I added them manually to a separate .big file (that is also refrenced to by my .skudef file) using FinalBig, but you can also program the compiler to automaticly add them to your .big files.
The code:

For scriptevents.xml, add this code:
<ModelConditionEvent Name=&#34;AutoUpgrading&#34;>
	<Conditions>+UNUSED_06</Conditions>
</ModelConditionEvent>

<EventList Name=&#34;YourBuildingFunctions&#34; Inherit=&#34;BaseScriptFunctions&#34;>
	<EventHandler EventName=&#34;AutoUpgrading&#34;	ScriptFunctionName=&#34;AddMyUpgradeNOW&#34; DebugSingleStep=&#34;false&#34;/>
</EventList>


To Scripts.lua, add this (where InsertUpgradeNameHere is the name of your upgrade):
function AddMyUpgradeNOW&#40;self&#41;
	ObjectGrantUpgrade&#40; self, &#34;InsertUpgradeNameHere&#34; &#41;
end


Last step:
Add this under <AIUpdate> under <AI> in your building code:
AILuaEventsList=&#34;YourBuildingFunctions&#34;>



Now let's hope this all works... 8| . There is a risk of errors in the code I wrote (very tired when writing this), so keep your eyes open.

Edited by Chronosheep, 11 August 2008 - 01:24.

Posted Image

#13 Slye_Fox

    FOXTec Leader

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

Posted 11 August 2008 - 14:48

the eventlist isn't beign triggered

i set the structre to use the GDI powerplant for the unused_06 model, and it is changeing to that when the weapon fires.
Posted Image

#14 Chronosheep

    Amateur

  • Member
  • 106 posts
  • Projects: C&C: Renovatio

Posted 11 August 2008 - 18:42

ok, time to start troubleshooting :)
It's good that you tested the normal .xml code; now we know that the problem is in the scripts.

As before, I don't usually do this because of the time needed to write it, but let this be a script troubleshooting tutorial:

Something I remembered after writing most of the text below :stickattack2: : This code in scriptevents.xml must go under <Events>:
<ModelConditionEvent Name=&#34;AutoUpgrading&#34;>
	<Conditions>+UNUSED_06</Conditions>
</ModelConditionEvent>


If this doesen't work, here is my tutorial XD:
First of all, to do this, I recomend using the Predator tank. If you have removed it from the game, put it back in (name and id is not important).

1.) Build a Predator tank. If the railgun shows (when not having railgun upgrade), there is without a doubt bad code (probably a typo) in scriptevents.xml or Scripts.lua .
If it works the way it's supposed to (railgun doesen't show), move on to next point.

2.) Now to test if scriptevents.xml and Scripts.lua is being loaded.
How did you add them to your .big files?
I don't think it works if you add them in mod.xml, they will eighter have to be added to a sepatate .big file using FinalBig, or by programming the compiler to add them automaticly (but I'm not sure how this is done). [You don't have to use a separate .big file, but if you don't, you'll have to add them again every time you compile your mod.] If you use a separate .big file, make sure it's referenced to by your .skudef file.
Repeat point 1 if it still doesen't work if you try another way to add the files.
Now, if the above criteria are met, and it still doesen't work, open scriptevents.xml and replace this code
	<EventList Name=&#34;GDIPredatorFunctions&#34; Inherit=&#34;BaseScriptFunctions&#34;>
		<EventHandler EventName=&#34;OnCreated&#34;	ScriptFunctionName=&#34;OnGDIPredatorCreated&#34; DebugSingleStep=&#34;false&#34;/>
	</EventList>

with this
	<EventList Name=&#34;GDIPredatorFunctions&#34; Inherit=&#34;BaseScriptFunctions&#34;>
		<EventHandler EventName=&#34;OnCreated&#34;	ScriptFunctionName=&#34;kill&#34; DebugSingleStep=&#34;false&#34;/>
	</EventList>

Put the file in your .big file(s), go ingame, and build a Predator tank. If scriptevents.xml and Scripts.lua is being loaded, the Predator should self-destruct when created (given that the code for that works.. if not, the railgun should at least show). If this doesen't happen, the files are not being loaded, but I can't think of any other (than the above) reasons to why.

3.) If the Predator self-destructed or had visible railgun in the above test, the files are being loaded, but there is something wrong with the code. You may now restore the Predator code to normal.
Try giving your eventlist an OnCreated dummy event (perhaps it's needed?):
<EventList Name=&#34;YourBuildingFunctions&#34; Inherit=&#34;BaseScriptFunctions&#34;>
	<EventHandler EventName=&#34;OnCreated&#34;	ScriptFunctionName=&#34;OnNODShredderCreated&#34; DebugSingleStep=&#34;false&#34;/>
	<EventHandler EventName=&#34;AutoUpgrading&#34;	ScriptFunctionName=&#34;AddMyUpgradeNOW&#34; DebugSingleStep=&#34;false&#34;/>
</EventList>


4.) If that doesen't work: use the Predator tank model for your building, and use this code:
<EventList Name=&#34;YourBuildingFunctions&#34; Inherit=&#34;BaseScriptFunctions&#34;>
		<EventHandler EventName=&#34;OnCreated&#34;	ScriptFunctionName=&#34;OnGDIPredatorCreated&#34; DebugSingleStep=&#34;false&#34;/>
</EventList>

If the railgun is visible, there is most likely a typo eighter here, or in the AILuaEventsList in the building code. You may also try using the self-destruct code, but I'm not sure if it works.

If the railgun does not show/tank does self-destruct, try this code (if you used the Predator model for your building):
<EventList Name=&#34;YourBuildingFunctions&#34; Inherit=&#34;BaseScriptFunctions&#34;>
	<EventHandler EventName=&#34;OnCreated&#34;	ScriptFunctionName=&#34;OnNODShredderCreated&#34; DebugSingleStep=&#34;false&#34;/>
	<EventHandler EventName=&#34;AutoUpgrading&#34;	ScriptFunctionName=&#34;OnGDIPredatorCreated&#34; DebugSingleStep=&#34;false&#34;/>
</EventList>

Or this code if you used self-destruct, and you know that it works:
<EventList Name=&#34;YourBuildingFunctions&#34; Inherit=&#34;BaseScriptFunctions&#34;>
	<EventHandler EventName=&#34;OnCreated&#34;	ScriptFunctionName=&#34;OnNODShredderCreated&#34; DebugSingleStep=&#34;false&#34;/>
	<EventHandler EventName=&#34;AutoUpgrading&#34;	ScriptFunctionName=&#34;kill&#34; DebugSingleStep=&#34;false&#34;/>
</EventList>

If the railgun shows or the tank doesen't self-destruct, there must be a typo in this code or the refrence to it:
<ModelConditionEvent Name=&#34;AutoUpgrading&#34;>
	<Conditions>+UNUSED_06</Conditions>
</ModelConditionEvent>


5.) If the railgun is hidden / the tank self-destructs in the previous test, but the upgrade won't work with the old code, the error lies in Scripts.lua, and you may restore the old code in scriptevents.xml.
Make absolutely sure there is no typo in the refrence between you code in scriptevents.xml and that in Scripts.lua. The error in Scripts.lua must be a typo, so you'll have to find it yourself.
Posted Image

#15 Slye_Fox

    FOXTec Leader

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

Posted 11 August 2008 - 19:21

Id like to point out that the scrip file is being loaded, it's used to hide upgrade turrets on models, and they are hidden.
Posted Image

#16 Chronosheep

    Amateur

  • Member
  • 106 posts
  • Projects: C&C: Renovatio

Posted 12 August 2008 - 00:24

Quote

Id like to point out that the scrip file is being loaded, it's used to hide upgrade turrets on models, and they are hidden.

Then have you done the other points on my list? Most importantly this:

Quote

This code in scriptevents.xml must go under <Events>:
<ModelConditionEvent Name=&#34;AutoUpgrading&#34;>
	<Conditions>+UNUSED_06</Conditions>
</ModelConditionEvent>

Edited by Chronosheep, 12 August 2008 - 00:24.

Posted Image

#17 Slye_Fox

    FOXTec Leader

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

Posted 12 August 2008 - 01:01

yes

you got msn?
Posted Image

#18 Slye_Fox

    FOXTec Leader

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

Posted 12 August 2008 - 14:23

[SOLVED]
Posted Image



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users