Data Realms Fan Forums
http://45.55.195.193/

Order dropship @ 750 oz, get 250 back when returned.
http://45.55.195.193/viewtopic.php?f=73&t=18358
Page 1 of 2

Author:  Gotcha! [ Sun Apr 04, 2010 5:56 pm ]
Post subject:  Order dropship @ 750 oz, get 250 back when returned.

Hello people,

Would it be possible for someone to create a script that does the following:
I'd like, upon ordering a specific dropship (UniTec Mammoth) for 750 oz, to only get 250 oz back when it returns to orbit.

Is this possible, and if so, is anyone up for it? :)

Author:  Abdul Alhazred [ Sun Apr 04, 2010 6:21 pm ]
Post subject:  Re: Order dropship @ 750 oz, get 250 back when returned.

Code:
function Update(self)
   if self.Pos.Y < -75 and self.Vel.Y < 0 then
      self.Health = -33.333
      self.Vel.Y = -100
   end
end
A craft with health -100 return zero gold, so -100/3 will return ~250 gold for a 750 gold craft. This script will return the same amount no matter how damaged the craft is.

Author:  Gotcha! [ Sun Apr 04, 2010 6:32 pm ]
Post subject:  Re: Order dropship @ 750 oz, get 250 back when returned.

Thanks. :) The problem is though, it should give 250 on return at full health.

I'll try to explain;
I have a dropship (250 oz) which delivers a mech from its inventory (500 oz), but right now it delivers the mech for free.
So I made the dropship 750 oz but am looking for a way to substract the 500 oz for the mech when the dropship disappears into orbit.

Author:  Grif [ Sun Apr 04, 2010 6:40 pm ]
Post subject:  Re: Order dropship @ 750 oz, get 250 back when returned.

Code:
function Update(self)
   if self.Pos.Y < -75 and self.Vel.Y < 0 then
      self.Health = self.Health -133.333
      self.Vel.Y = -100
   end
end

Author:  CrazyMLC [ Sun Apr 04, 2010 7:50 pm ]
Post subject:  Re: Order dropship @ 750 oz, get 250 back when returned.

Couldn't you just do something like this...
Code:
function Create(self)
   self.Creation = Timer()
end

function Update(self)
   if self.Pos.Y < 1 and self.Creation:IsPastSimMS(5000) then
      self.Health = self.Health/3
      self.Vel.Y = 100
   end
end

?

Author:  Gotcha! [ Sun Apr 04, 2010 7:52 pm ]
Post subject:  Re: Order dropship @ 750 oz, get 250 back when returned.

Thanks Grif. Works like a charm. :grin: Thank you both.

Edit: And thank you as well, CrazyMLC.

Author:  Gotcha! [ Sun Apr 04, 2010 8:03 pm ]
Post subject:  Re: Order dropship @ 750 oz, get 250 back when returned.

Oh crap, I forgot something. The money can't be deducted when the dropship disappears, because people would crash the dropship instead after getting the 'free' mech.

If anyone has a brilliant idea, I'd love to hear it. :oops:

Edit: Never mind for now. I think I got a solution. :)

Author:  Duh102 [ Sun Apr 04, 2010 9:09 pm ]
Post subject:  Re: Order dropship @ 750 oz, get 250 back when returned.

Why not just make it cost 250 but subtract 500 (if possible, and if not, return the dropship) when it appears on the map?

Author:  Lizardheim [ Sun Apr 04, 2010 9:17 pm ]
Post subject:  Re: Order dropship @ 750 oz, get 250 back when returned.

If not the subtracting is possible, have it spawn an invisible craft that flies upwards with the cost being -500.

Author:  CaveCricket48 [ Sun Apr 04, 2010 9:18 pm ]
Post subject:  Re: Order dropship @ 750 oz, get 250 back when returned.

I got it. Have 2 dropships exactly the same except in cost. When you order the DS, you order the more expensive one, which will be instanly deleted and replaced by the cheaper copy.

Author:  PhantomAGN [ Sun Apr 04, 2010 9:25 pm ]
Post subject:  Re: Order dropship @ 750 oz, get 250 back when returned.

Can you order the mech by itself?
The mech's Create function could subtract this money.
The one you order separate would be a version without this code.

Buy craft > fly around > open doors > get mech, lose money > fly craft away, and it returns at "full" price of 250.

CC48's method looks good too.

Author:  Lizardheim [ Sun Apr 04, 2010 9:36 pm ]
Post subject:  Re: Order dropship @ 750 oz, get 250 back when returned.

CC's way is the best, cause you can't get your money below 0 with it.

Author:  Gotcha! [ Sun Apr 04, 2010 9:43 pm ]
Post subject:  Re: Order dropship @ 750 oz, get 250 back when returned.

I almost got it, but this doesn't go right;

Code:
function Update(self)
   if self.Pos.Y < -75 and self.Vel.Y < 0 then
      self.CurrentF = ActivityMan:GetActivity():GetTeamFunds(self.Team);
      ActivityMan:GetActivity():SetTeamFunds(self.CurrentF - 500), self.Team);
      self.Vel.Y = -100
   end
end


It doesn't substract 500 oz for some reason, but sets the amount to 500?
If this script would work then I can add a sequence that if the dropship dies before leaving the screen that it will cost 750 oz.
Can anyone see what I am doing wrong?

Author:  TheLastBanana [ Sun Apr 04, 2010 9:45 pm ]
Post subject:  Re: Order dropship @ 750 oz, get 250 back when returned.

Code:
function Update(self)
   if self.Pos.Y < -75 and self.Vel.Y < 0 then
      self.CurrentF = ActivityMan:GetActivity():GetTeamFunds(self.Team);
      ActivityMan:GetActivity():SetTeamFunds(self.CurrentF - 500, self.Team);
      self.Vel.Y = -100
   end
end

You had an extra bracket.

Author:  Gotcha! [ Sun Apr 04, 2010 10:09 pm ]
Post subject:  Re: Order dropship @ 750 oz, get 250 back when returned.

Sorry, it was a mistake in that post. Copied it from my notepad.
My script doesn't have that bracket. (Yeah, I am very chaotic. :oops: )
This script sets the amount of money to 500, no matter what. :???:

So the final script would look like something like this:

Code:
function Update(self)
   if self.Pos.Y < -75 and self.Vel.Y < 0 then
      self.CurrentF = ActivityMan:GetActivity():GetTeamFunds(self.Team);
      ActivityMan:GetActivity():SetTeamFunds(self.CurrentF - 500, self.Team);
      self.Vel.Y = -100
   end
   if actor:IsDead() == true then
      self.CurrentF = ActivityMan:GetActivity():GetTeamFunds(self.Team);
      ActivityMan:GetActivity():SetTeamFunds(self.CurrentF - 750, self.Team);
   end
end


Making sure 500 oz is removed when the dropship escapes and 750 oz is removed when it dies. (If it worked.)

Edit: Further testing:
I have 5000
I buy the dropship with included mech for 750
I have 4250 left
Dropship drops mech and returns and I end up with 4000
It should have returned 750 and substracted 500 through this script, adding 250 to the 4250 that I had, instead of substracting an extra 250. :???:

Page 1 of 2 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/