View topic - Tech Requirements



All times are UTC + 1 hour


Post new topic Reply to topic  [ 73 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject: Re: Tech Requirements
PostPosted: 09 Mar 2010, 10:50 
Evolution RTS Developer
User avatar

Joined: 17 Nov 2005, 02:43
Location: Raegquitting Spring on 04/24/12
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.


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 06 Apr 2010, 22:26 
Kernel Panic Co-Developer
User avatar

Joined: 16 Nov 2004, 13:08
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:
Code:
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:
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


And then having the BOS/COB calls it regularly:
Code:
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;
}
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.


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 09 Dec 2010, 07:31 

Joined: 19 Nov 2010, 09:44
How would I apply the advanced tech tree in a lua unitdef?


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 09 Dec 2010, 10:34 
Kernel Panic Co-Developer
User avatar

Joined: 16 Nov 2004, 13:08
Try something like:
Code:
CustomParams = {
      RequireTech = "2 SomeTech, AnotherTech",
      ProvideTech = "NewTech, 10 OtherNewTech",
   },


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 09 Dec 2010, 19:20 

Joined: 19 Nov 2010, 09:44
Thanks.


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 14 Mar 2011, 20:45 

Joined: 19 Nov 2010, 09:44
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?


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 14 Mar 2011, 20:52 
Blood & Steel Developer
User avatar

Joined: 25 Aug 2004, 12:31
Location: Has not played *a in years.
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.


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 17 May 2012, 07:12 
Evolution RTS Developer
User avatar

Joined: 17 Nov 2005, 02:43
Location: Raegquitting Spring on 04/24/12
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?


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 18 May 2012, 05:56 
Evolution RTS Developer
User avatar

Joined: 17 Nov 2005, 02:43
Location: Raegquitting Spring on 04/24/12
Yes Alex, I'd like to buy a vowel.


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 18 May 2012, 15:41 
Moderator

Joined: 12 Oct 2007, 08:24
Try turning the factory script into lua. At least you should receive a useful crash report.


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 18 May 2012, 19:21 
Kernel Panic Co-Developer
User avatar

Joined: 16 Nov 2004, 13:08
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?


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 18 May 2012, 22:01 
User avatar

Joined: 02 May 2005, 02:56
Location: Canada
zwzsg wrote:
Who is Alex?

Alex Trebek


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 18 May 2012, 22:05 
Content Developer
User avatar

Joined: 13 Jan 2005, 00:46
Location: ModalitÃ
who was only the host of wheel of fortune as a gag.


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 19 May 2012, 02:04 
Evolution RTS Developer
User avatar

Joined: 17 Nov 2005, 02:43
Location: Raegquitting Spring on 04/24/12
Attachment:
Evolution_RTS-TechCrashDemo.sdz [2.42 KiB]
Downloaded 15 times


Make 2 fusions (hotkey b, n)
Make a hover factory (hotkey b, z)

Tell the factory to make engineers or somethign on repeat, then self d the powerplants.


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 19 May 2012, 02:59 
Kernel Panic Co-Developer
User avatar

Joined: 16 Nov 2004, 13:08
Thanks. I replicated it.

The problem is not in the tech gadget, it is in the factory animation script.
Specifically, ebasefactory.bos line 53:
Code:
      while(!Maya)
      {
         // Activated animation when needing tech
      }
Add at least a sleep there!


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 19 May 2012, 03:25 
Evolution RTS Developer
User avatar

Joined: 17 Nov 2005, 02:43
Location: Raegquitting Spring on 04/24/12
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.


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 19 May 2012, 03:55 
Kernel Panic Co-Developer
User avatar

Joined: 16 Nov 2004, 13:08
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.


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 19 May 2012, 05:58 
Evolution RTS Developer
User avatar

Joined: 17 Nov 2005, 02:43
Location: Raegquitting Spring on 04/24/12
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).

Code:
for ($i = 1; $i <= 10; $i++) {
    echo $i;
}


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 19 May 2012, 15:48 
Kernel Panic Co-Developer
User avatar

Joined: 16 Nov 2004, 13:08
Quote:
Other languages tell you in various ways
Most other language/environment hang your computer as well. You were lucky Spring has hang detection.

Forboding Angel wrote:
Moreover, other languages don't require sleeps in the loop (least, not the ones I work with).
Code:
for ($i = 1; $i <= 10; $i++) {
    echo $i;
}
This is a finite loop!

Just try with for ($i = 1; $i <= 10; $i += 0) I dare you!


Top
 Offline Profile  
 
 Post subject: Re: Tech Requirements
PostPosted: 19 May 2012, 17:58 
Evolution RTS Developer
User avatar

Joined: 17 Nov 2005, 02:43
Location: Raegquitting Spring on 04/24/12
Code:
for ($i = 1; $i <= 10; $i++) {
    echo $i;
}


Loops until it reaches the end, z (In this case, the number 10). Doesn't repeat. However, usage is obviously completely different from a while loop in bos.

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.


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 73 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.