Tech Requirements
Moderator: Moderators
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Tech Requirements
Would it be possible to add an ability to make units who are no longer in range of the tech giver to completely stop working? By that I mean, fusions stop producing, mexes stop producing, factories stop working, defenses stop firing, etc.
Re: Tech Requirements
Yes.
You already have them now in EvoRTS, but, I'm posting to say I updated the Better_Ranged_Counted_Multi_Tech.lua on page 1 to fix some bugs, and to make it call the cob functions TechLost and TechGranted, so you can just implement whatever deactivation code you need through those BOS/COB custom call-ins.
Here's an exemple turret script making use of them to deactivate turret if they lose the tech that was necessary to build them:
Here's an exemple of a factory getting deactivated when the teach necessary to build it is lost. I didn't clean it from the EvoRTS unit I took from, but the basic idea is to set HasTech to 0 in TechLost and to 1 in TechGranted, and then in the Activate, to not set INBUILDSTANCE to 1 if HasTech is not true. Plus some smoke effect to show the factory state of disability.
http://pastebin.org/139379
Note that disabling unit that lose tech was already possible with the previous version, by having an intermediary gadget implementing a registered function that check for a specific tech:
And then having the BOS/COB calls it regularly:
That method has the advantage of not requiring the tech to build the turret, but only to fire. But it's less flexible since you have to explicitly write and register a short Lua function for each tech you want COB/LUA scripts to be able to check.
You already have them now in EvoRTS, but, I'm posting to say I updated the Better_Ranged_Counted_Multi_Tech.lua on page 1 to fix some bugs, and to make it call the cob functions TechLost and TechGranted, so you can just implement whatever deactivation code you need through those BOS/COB custom call-ins.
Here's an exemple turret script making use of them to deactivate turret if they lose the tech that was necessary to build them:
Code: Select all
piece base, turret, barrel, flare;
static-var CanFire;
#define SIG_AIM 2
Create()
{
CanFire=FALSE;
}
AimWeapon1(heading, pitch)
{
signal SIG_AIM;
set-signal-mask SIG_AIM;
while(!CanFire)
sleep 200;
turn turret to y-axis heading speed <225>;
turn barrel to x-axis <0> - pitch speed <150>;
wait-for-turn turret around y-axis;
wait-for-turn barrel around x-axis;
return (1);
}
AimFromWeapon1(piecenum)
{
piecenum = barrel;
}
QueryWeapon1(piecenum)
{
piecenum = flare;
}
TechLost()
{
CanFire=FALSE;
signal SIG_AIM;
stop-spin turret around y-axis decelerate <10>;
stop-spin barrel around x-axis decelerate <10>;
}
TechGranted()
{
CanFire=TRUE;
}
Here's an exemple of a factory getting deactivated when the teach necessary to build it is lost. I didn't clean it from the EvoRTS unit I took from, but the basic idea is to set HasTech to 0 in TechLost and to 1 in TechGranted, and then in the Activate, to not set INBUILDSTANCE to 1 if HasTech is not true. Plus some smoke effect to show the factory state of disability.
http://pastebin.org/139379
Note that disabling unit that lose tech was already possible with the previous version, by having an intermediary gadget implementing a registered function that check for a specific tech:
Code: Select all
if (gadgetHandler:IsSyncedCode()) then
local function CheckUnitPower(u, ud, team, level)
return GG.TechCheck("power",team,level,u) -- change "power" by the name of your tech
end
function gadget:Initialize()
gadgetHandler:RegisterGlobal("CheckUnitPower", CheckUnitPower)
end
end
Code: Select all
piece base, turret, barrel, flare;
static-var power;
#define SIG_AIM 2
#ifndef LUA1
#define LUA1 111
#endif
lua_CheckUnitPower()
{
return 0;
}
KeepAnEyeOnPower()
{
while(TRUE)
{
call-script lua_CheckUnitPower();
if(get LUA1)
power=TRUE;
else
power=FALSE;
sleep 500;
}
}
Create()
{
power=FALSE;
start-script KeepAnEyeOnPower();
}
AimWeapon1(heading, pitch)
{
signal SIG_AIM;
set-signal-mask SIG_AIM;
while(!power)
sleep 200;
turn turret to y-axis heading speed <225>;
turn barrel to x-axis <0> - pitch speed <150>;
wait-for-turn turret around y-axis;
wait-for-turn barrel around x-axis;
return (1);
}
AimFromWeapon1(piecenum)
{
piecenum = barrel;
}
QueryWeapon1(piecenum)
{
piecenum = flare;
}
Re: Tech Requirements
How would I apply the advanced tech tree in a lua unitdef?
Re: Tech Requirements
Try something like:
Code: Select all
CustomParams = {
RequireTech = "2 SomeTech, AnotherTech",
ProvideTech = "NewTech, 10 OtherNewTech",
},
Re: Tech Requirements
Would there be a way to modify the advanced tech tree so it works like normal until you get a choice to build two units, after building one you unlock the following tech, but you lock out building the other one and all the following tech?
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2700
- Joined: 25 Aug 2004, 13:31
Re: Tech Requirements
Yeah. It is all in the read me isn't it? Look at the one with the heros. Make the new tech use up the old tech, just be sure to set it really high.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Tech Requirements
Calling techlost and techgranted via cob in a factory script results in a access violation spring crash (without stacktrace) when the unit providing the tech is destroyed.
Any ideas on what might be wrong?
Any ideas on what might be wrong?
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Tech Requirements
Yes Alex, I'd like to buy a vowel.
-
- Moderator
- Posts: 2464
- Joined: 12 Oct 2007, 09:24
Re: Tech Requirements
Try turning the factory script into lua. At least you should receive a useful crash report.
Re: Tech Requirements
Who is Alex?
Can you make me an Evo mutator and spell me the unitnames to spawn and to self D so that I have an easier time reproducing?
Can you make me an Evo mutator and spell me the unitnames to spawn and to self D so that I have an easier time reproducing?
Re: Tech Requirements
Alex Trebekzwzsg wrote:Who is Alex?
Re: Tech Requirements
who was only the host of wheel of fortune as a gag.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Tech Requirements
Make a hover factory (hotkey b, z)
Tell the factory to make engineers or somethign on repeat, then self d the powerplants.
Re: Tech Requirements
Thanks. I replicated it.
The problem is not in the tech gadget, it is in the factory animation script.
Specifically, ebasefactory.bos line 53: Add at least a sleep there!
The problem is not in the tech gadget, it is in the factory animation script.
Specifically, ebasefactory.bos line 53:
Code: Select all
while(!Maya)
{
// Activated animation when needing tech
}
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Tech Requirements
Thanks
All that was originally stuff added by you to provide me with an example on how to add requirements to factories, but I have never actually used it, so news to me.
I might have accidentally nuked the sleep at one point (I doubt it but it is certainly possible). I dunno O_o You did that a really long time ago and I haven't really messed with it (the factory script) much since.
All that was originally stuff added by you to provide me with an example on how to add requirements to factories, but I have never actually used it, so news to me.
I might have accidentally nuked the sleep at one point (I doubt it but it is certainly possible). I dunno O_o You did that a really long time ago and I haven't really messed with it (the factory script) much since.
Re: Tech Requirements
Yep, it was you: r220 by forbodingangel on Feb 8, 2012 Diff
Let's hope it will server you as a reminder that:
while(1){} // HANG your computer!
while(1){sleep 666;} // okay
This applies to other languages, outside of Spring, as well.
Let's hope it will server you as a reminder that:
while(1){} // HANG your computer!
while(1){sleep 666;} // okay
This applies to other languages, outside of Spring, as well.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Tech Requirements
I probably wouldn't have caught that without any decent error reporting from spring.
Other languages tell you in various ways (though I've never actually caused an infinite loop in any other language). Moreover, other languages don't require sleeps in the loop (least, not the ones I work with).
Other languages tell you in various ways (though I've never actually caused an infinite loop in any other language). Moreover, other languages don't require sleeps in the loop (least, not the ones I work with).
Code: Select all
for ($i = 1; $i <= 10; $i++) {
echo $i;
}
Re: Tech Requirements
Most other language/environment hang your computer as well. You were lucky Spring has hang detection.Other languages tell you in various ways
This is a finite loop!Forboding Angel wrote:Moreover, other languages don't require sleeps in the loop (least, not the ones I work with).Code: Select all
for ($i = 1; $i <= 10; $i++) { echo $i; }
Just try with for ($i = 1; $i <= 10; $i += 0) I dare you!
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Tech Requirements
Code: Select all
for ($i = 1; $i <= 10; $i++) {
echo $i;
}
http://us.php.net/manual/en/control-structures.for.php
But even so:
http://us.php.net/manual/en/control-str ... .while.php
Different language, different structure.