View unanswered posts | View active topics It is currently Wed Dec 25, 2024 8:49 pm



Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3
 SWAT Kats, the Radical Squadron. Lua help needed. 
Author Message
User avatar

Joined: Fri Jun 19, 2009 5:57 pm
Posts: 84
Reply with quote
Post Re: SWAT Kats, the Radical Squadron. Lua help needed.
Thankfully, the Glovatrix are plot-powered. I mean, seriously, just how many useful devices are stashed into them? Cement guns, grappling hooks, normal missiles, octopus missiles, net missiles, turboblades, boomerangs, blowtorch, buzzsaw (launchable buzzsaw), and that's only as much as I can remember off the top of my head. So, it won't be too bad if the weaponry is infinite, with cooldown times for every specific weapon.

Another thing occured to me - another version of the 'Kats could be made, specifically the 'Kats flying in Ejektor seats. It'd have to be an AHuman, most likely, but something akin to the Lua armed drones could also work.


Tue Jun 30, 2009 6:00 am
Profile
User avatar

Joined: Fri Jun 19, 2009 5:57 pm
Posts: 84
Reply with quote
Post Re: SWAT Kats, the Radical Squadron. Lua help needed.
Ok, numgun, I took your harpoon code and bastardized it so that it has actor:AttachEmitter(self,DifX,DifY) and self.Pinstrength=100 but it doesn't work right. It does work somewhat, because the projectile is HitsMOs=0 but interacts with actors, seemingly bouncing away. What am I missing? The projectile is now low-mass, and comparably low-power, so it shouldn't be able to break away. Help?

Edit: so, it wasn't working after all. Some weird stuff with GetsHitByMOs caused it to bounce off. Maybe it's impossible for an emitter to just attach itsef? I tried to just call an " actor:AttachEmitter(CreateAEmitter("Mini Octopus Open","SWAT Kats.rte"),DifX, DifY) ", but it still won't register. DifX and DifY are locals holding the X and Y difference in position. What am I doing wrong?
Code:
function Create(self)
    self.LTimer = Timer();
   --local isAttached = false
end

function Update(self)
    if self.LTimer:IsPastSimMS(5) then
      for actor in MovableMan.Actors do
         if (math.abs(actor.Pos.X - self.Pos.X) < 18) and (math.abs(actor.Pos.Y - self.Pos.Y) < 18) and (actor.PinStrength <= 50) then
         --Pin the ship and place it nicely in the docking unit.
            --if isAttached = false then
            local DifX = self.Pos.X - actor.Pos.X;
            local DifY = self.Pos.Y - actor.Pos.Y;
            --local DifA = self.RotAngle - actor.RotAngle;
            self.PinStrength = 0;
            actor:AttachEmitter(CreateAEmitter("Mini Octopus Open","SWAT Kats.rte"),DifX,DifY);
            self.PinStrength = 10;
            --isAttached = true;
            --else
            --self.RotAngle = actor.RotAngle + DifA;
            --end
         end   
      end
   end
   if self.LTimer:IsPastSimMS(5000) then
      self:GibThis() ;
   end
end

The isAttached var is my attempt at streamlining the code execution (since I don't want the missile to grab several actors at once), and it's commented out until I can get the main thing working.


Tue Jun 30, 2009 6:48 pm
Profile

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Re: SWAT Kats, the Radical Squadron. Lua help needed.
PinStrength variable does not attach an object to another. What it does is it pins an object (itself or someone else like: self.PinStrgh and actor.PinStrgh respectively).

What my harpoon gun did is scan for an actor within the area of 18 pixels around the harpoon and then if an actor was in that little area, he would be dragged by the harpoon by moving to the harpoon's position and inheriting its velocity.

Code:
            actor.PinStrength = 0;
            actor.Pos = self.Pos;
            actor.Vel = self.Vel;
            actor.PinStrength = 5;


This code unpins the actor first so it can inherit velocity.
The second part moves the actor to the harpoon's own position. Do note, the Update() function repeats EVERY FRAME while its active.
The 3rd line sets the caught actor's velocity to be the same as harpoon's own.

Finally the last line gives pinstrength of 5 to the actor. I used this for my harpoon gun so after the harpoon came to an end, it would sort of "pin" the actor where it was, making him not able to move unless a small force of 5 impulses were hit by it and then it would become free.

Mass, velocity and anything else the harpoon has is no matter. The code will always do the same.

I suggest you take the Lua stuff to Lua section of the forum since I am a total newbie at Lua myself.
At the section, more experienced people will be able to help you out.


Or heck, ask an admin to move your topic to mod making since more traffic of people come by there.
Mainly because this is a mod in making and you've done considerable work already.


Wed Jul 01, 2009 12:20 am
Profile
User avatar

Joined: Fri Jun 19, 2009 5:57 pm
Posts: 84
Reply with quote
Post Re: SWAT Kats, the Radical Squadron. Lua help needed.
I don't like having threads moved. I'll rather start another thread in Mod Making, because then it will only contain things relevant to the mod in progress.

Figuring out Lua would be easier if it cared to dump errors somewhere. As far as I can see, if there is an error in the script, it won't run, and this seems to be what's happening with mine.


Wed Jul 01, 2009 9:17 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: SWAT Kats, the Radical Squadron. Lua help needed.
AttachEmitter is broken. Data really needs to clean up his bindings.


Wed Jul 01, 2009 9:20 am
Profile
User avatar

Joined: Fri Jun 19, 2009 5:57 pm
Posts: 84
Reply with quote
Post Re: SWAT Kats, the Radical Squadron. Lua help needed.
Well, broken or no, I actually found the error. I couldv'e sworn I checked the console after using the things, but it seems I need an AEmitter* instead of an AEmitter, and a vector instead of two coords. Who would've thunk it? What's the difference between an AEmitter and an AEmitter*, anyway?

edit: ok, object and object pointer. Well, it works now, in the sense that it doesn't generate any errors by itself. But it crashes CC as soon as I try to attach the thing, so yeah, it must be broken. Any other way I can attach anything with a force applied, without resorting to manually calculating thrust-to-weight ratios?


Wed Jul 01, 2009 9:34 am
Profile
User avatar

Joined: Fri Jun 19, 2009 5:57 pm
Posts: 84
Reply with quote
Post Re: SWAT Kats, the Radical Squadron. Lua help needed.
Zuxxezz! :D

Hmm, forgot to take a pic. Anyway, it really works now. The mini-octopus works by casting a short MORay in front of it, and attaching itself to the first thing it identifies as a viable target. Currently, that means any items or attachables - strangely, does not work on dropships or unarmed dummies, but these can be fixed. After attaching, it applies a small amount of force (using AddForce) to the item in question, propelling it somewhere.

I also have an idea for the Glovetrix, but it needs some experimenting first.

If the weapon constantly emits a short-lived (really short-lived, a few milliseconds) MOSParticle that happens to be very close to the center of the actor holding it, the actor could detect the presence of the particle and identify that the weapon is currently in its hands, without shuffling through the entire MO list. Better yet, by simply using the fixed offset as a guide, you could use GetMOAtPixel (or what was that function?) to get a bead on the weapon itself, and work with its frame of reference. After that, spawning projectiles is relatively easy.


Wed Jul 01, 2009 10:19 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 37 posts ]  Go to page Previous  1, 2, 3

Who is online

Users browsing this forum: No registered users


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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.075s | 13 Queries | GZIP : Off ]