0
Delayed Auto Upgrade
Started By Slye_Fox, Aug 06 2008 22:07
17 replies to this topic
#2
Posted 07 August 2008 - 07:36
What kind of upgrade? OBJECT or PLAYER?
#4
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:
#6
Posted 08 August 2008 - 03:37
Don't think so.
#8
Posted 10 August 2008 - 02:51
Well, I don't know. I was just throwing around some ideas.
#9
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
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
#11
Posted 11 August 2008 - 01:16
Erm, use a GrantUpgradeCreate to give an upgrade, which triggers the DelayedUpgrade?
#12
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="ModuleTag_FireWeaponUpdate01"> <FireWeaponNugget WeaponName="UpgradeGrantWeapon" FireDelay="20s" OneShot="true" /> </FireWeaponUpdate>
Make a weapon template (I think this one should work):
<WeaponTemplate id="UpgradeGrantWeapon" Name="UpgradeGrantWeapon" AttackRange="1" RadiusDamageAffects="ALLIES"> <Nuggets> <AttributeModifierNugget PartitionFilterTestType="SPHERE" AttributeModifierOwnerName="Modifier_AutoUpgrade" /> </Nuggets> </WeaponTemplate>
Make an attribute modifier:
<AttributeModifier id="Modifier_AutoUpgrade" Category="NONE" ModelConditionsSet="UNUSED_06"> </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="AutoUpgrading"> <Conditions>+UNUSED_06</Conditions> </ModelConditionEvent> <EventList Name="YourBuildingFunctions" Inherit="BaseScriptFunctions"> <EventHandler EventName="AutoUpgrading" ScriptFunctionName="AddMyUpgradeNOW" DebugSingleStep="false"/> </EventList>
To Scripts.lua, add this (where InsertUpgradeNameHere is the name of your upgrade):
function AddMyUpgradeNOW(self) ObjectGrantUpgrade( self, "InsertUpgradeNameHere" ) end
Last step:
Add this under <AIUpdate> under <AI> in your building code:
AILuaEventsList="YourBuildingFunctions">
Now let's hope this all works... . 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.
#14
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>:
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
with this
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?):
4.) If that doesen't work: use the Predator tank model for your building, and use this code:
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):
Or this code if you used self-destruct, and you know that it works:
If the railgun shows or the tank doesen't self-destruct, there must be a typo in this code or the refrence to it:
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.
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="AutoUpgrading"> <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="GDIPredatorFunctions" Inherit="BaseScriptFunctions"> <EventHandler EventName="OnCreated" ScriptFunctionName="OnGDIPredatorCreated" DebugSingleStep="false"/> </EventList>
with this
<EventList Name="GDIPredatorFunctions" Inherit="BaseScriptFunctions"> <EventHandler EventName="OnCreated" ScriptFunctionName="kill" DebugSingleStep="false"/> </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="YourBuildingFunctions" Inherit="BaseScriptFunctions"> <EventHandler EventName="OnCreated" ScriptFunctionName="OnNODShredderCreated" DebugSingleStep="false"/> <EventHandler EventName="AutoUpgrading" ScriptFunctionName="AddMyUpgradeNOW" DebugSingleStep="false"/> </EventList>
4.) If that doesen't work: use the Predator tank model for your building, and use this code:
<EventList Name="YourBuildingFunctions" Inherit="BaseScriptFunctions"> <EventHandler EventName="OnCreated" ScriptFunctionName="OnGDIPredatorCreated" DebugSingleStep="false"/> </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="YourBuildingFunctions" Inherit="BaseScriptFunctions"> <EventHandler EventName="OnCreated" ScriptFunctionName="OnNODShredderCreated" DebugSingleStep="false"/> <EventHandler EventName="AutoUpgrading" ScriptFunctionName="OnGDIPredatorCreated" DebugSingleStep="false"/> </EventList>
Or this code if you used self-destruct, and you know that it works:
<EventList Name="YourBuildingFunctions" Inherit="BaseScriptFunctions"> <EventHandler EventName="OnCreated" ScriptFunctionName="OnNODShredderCreated" DebugSingleStep="false"/> <EventHandler EventName="AutoUpgrading" ScriptFunctionName="kill" DebugSingleStep="false"/> </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="AutoUpgrading"> <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.
#16
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="AutoUpgrading"> <Conditions>+UNUSED_06</Conditions> </ModelConditionEvent>
Edited by Chronosheep, 12 August 2008 - 00:24.
3 user(s) are reading this topic
0 members, 3 guests, 0 anonymous users