Lua based map objects, help! (BW related)
Author |
Message |
Geti
Joined: Sun Jul 13, 2008 9:57 am Posts: 4886 Location: some compy
|
Re: Lua based map objects, help! (BW related)
it sounds unlikely, but could it be that you need to specify the .rte for the sound? or, you could just use the filepath for it with the usual arguments; eg. Code: AudioMan:PlaySound("<SOUNDPATH HERE>", 0, 0); blah, i have to go, sorry.. good work on the huge set of modules, im annoyed i hadnt seen this topic before.. oh, quickly, on the alt-fire, i'd probably prefer a key to swap ammo types, can't you just bind a key and swap a value to change the round in the gun and the muzzleoffset for grenade launchers?
|
Sun Apr 26, 2009 2:31 am |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
Re: Lua based map objects, help! (BW related)
You can't change either of those in lua, as far as I know.
You can emulate it though, like I said, spawn rounds that spawn the ammo type. Have the gun check the key, have a variable for communication, and done.
|
Sun Apr 26, 2009 3:17 am |
|
|
Lord Tim
Joined: Fri Apr 27, 2007 4:55 pm Posts: 1178 Location: America!
|
Re: Lua based map objects, help! (BW related)
I see how it works now. See, there is a difference between "sound" and "music". Sounds are stored in memory and can be played at any time. Usually sounds are shorter to save memory space. The upside of storing it in memory is that you can play it with practically no delay. Music differs in that it is streamed from the file. So there might be a very small delay when playing it. You would want to use music over sound for larger files. The problem here is that since sounds can only be played from memory, you need to have access to the actual sound object. PlayMusic uses the filename, because it streams the music from that file, and not from a music object. What Data should probably be doing is storing the sounds in a data structure so that you can access them by filename. Right now, you have to give it the object. And since there isn't a "CreateSound", pretty much the only option that I know of is to use GetPreset. Try this: (assuming the arguments are sound object, times to play, volume, and something else) .ini file: Code: AddSound = Sound PresetName = Regen Module Sound AddSample = ContentFile FilePath = Whatever.rte/Sounds/regensound.wav lua file: Code: local sound = PresetMan:GetPreset("Regen Module Sound", "myrte"); AudioMan:PlaySound(sound, 1, 1, 0);
|
Sun Apr 26, 2009 3:48 am |
|
|
piipu
Joined: Mon Jun 30, 2008 9:13 pm Posts: 499 Location: Finland
|
Re: Lua based map objects, help! (BW related)
For the zerogravitymodule you can use Code: actor.Vel.Y = actor.Vel.Y - 19.82 instead of that Code: actor.Vel.Y = acor.Vel.Y - SceneMan.Scene.Globalacceleration.Y or whatever it was. This will work in any map with standard gravity.
|
Sun Apr 26, 2009 3:28 pm |
|
|
numgun
Joined: Sat Jan 13, 2007 11:04 pm Posts: 2932
|
Re: Lua based map objects, help! (BW related)
Ok so I tried to make a vortex grenade using Piipu's gravity guns code, but it doesnt seem to pull actors and is helluva laggy. And on top of that it dissappears ahead of its time. What the vortex grenade must do is this:1. Pull actors to the center of the vortex within the range of 300 pixels around the vortex. 2. Pull particles(MOPixel) that are named "Vortex Particle" ONLY. No other particle should be affected, only the one I specified. Also it would do it within the range of 200 pixels around the vortex. The vortex is a pinned AEmitter. The vortex itself must last 10 seconds. Heres the code:Code: function Create(self) vortex = self; end
function Destroy(self) end
function Update(self) local actorclose = 0 for actor in MovableMan.Actors do local diff = math.sqrt(math.pow((actor.Pos.X-vortex.Pos.X),2) + math.pow((actor.Pos.Y - vortex.Pos.Y),2)) if diff < 30 then diff = 30 end if diff < 700 then if actor.Team == self.CPUTeam then local diffx = actor.Pos.X - vortex.Pos.X local diffy = actor.Pos.Y - vortex.Pos.Y local ang = math.atan2(diffy,diffx) actor.Vel.Y = actor.Vel.Y - (50 / diff * math.sin(ang)) actor.Vel.X = actor.Vel.X - (100 / diff * math.cos(ang)) -- if diff < 35 then -- actor:GibThis() -- end end end for actor in MovableMan.Particles do local diff = math.sqrt(math.pow((actor.Pos.X-vortex.Pos.X),2) + math.pow((actor.Pos.Y - vortex.Pos.Y),2)) if diff < 50 then diff = 50 end if diff < 600 then local diffx = actor.Pos.X - vortex.Pos.X local diffy = actor.Pos.Y - vortex.Pos.Y local ang = math.atan2(diffy,diffx) actor.Vel.Y = actor.Vel.Y - ((100 / math.pow(diff,1)) * math.sin(ang)) actor.Vel.X = actor.Vel.X - ((100 / math.pow(diff,1)) * math.cos(ang)) end end end end Also the sound problem has been fixed, TLB made the module spawn another emitter that would then play the sound using BurstSound. It works.
Last edited by numgun on Sun Apr 26, 2009 6:14 pm, edited 1 time in total.
|
Sun Apr 26, 2009 5:42 pm |
|
|
piipu
Joined: Mon Jun 30, 2008 9:13 pm Posts: 499 Location: Finland
|
Re: Lua based map objects, help! (BW related)
Code: function Create(self) end
function Destroy(self) end
function Update(self) for actor in MovableMan.Actors do local diff = math.sqrt(math.pow((actor.Pos.X-self.Pos.X),2) + math.pow((actor.Pos.Y - self.Pos.Y),2)) if diff < 30 then diff = 30 end if diff < 300 then local diffx = actor.Pos.X - self.Pos.X local diffy = actor.Pos.Y - self.Pos.Y local ang = math.atan2(diffy,diffx) actor.Vel.Y = actor.Vel.Y - (50 / diff * math.sin(ang)) actor.Vel.X = actor.Vel.X - (100 / diff * math.cos(ang)) -- if diff < 35 then -- actor:GibThis() -- end end for actor in MovableMan.Particles do if (actor.PresetName == "Vortex Particle") local diff = math.sqrt(math.pow((actor.Pos.X-self.Pos.X),2) + math.pow((actor.Pos.Y - self.Pos.Y),2)) if diff < 50 then diff = 50 end if diff < 600 then local diffx = actor.Pos.X - self.Pos.X local diffy = actor.Pos.Y - self.Pos.Y local ang = math.atan2(diffy,diffx) actor.Vel.Y = actor.Vel.Y - ((100 / math.pow(diff,1)) * math.sin(ang)) actor.Vel.X = actor.Vel.X - ((100 / math.pow(diff,1)) * math.cos(ang)) end end end end end The not working thing was propably caused by self.CPUTeam. The short lifetime was somehow caused by the vortex sucking itself in. This should work fine.
|
Sun Apr 26, 2009 5:57 pm |
|
|
numgun
Joined: Sat Jan 13, 2007 11:04 pm Posts: 2932
|
Re: Lua based map objects, help! (BW related)
AWESOME! This grenade is like a dream come true. :' ) I've always wanted it exactly like this since build 11. I also made it so that it can suck in items. It just seemed wierd that guns were lying around while actors were flying and getting torn apart. And btw. Code: actor.Vel.Y = actor.Vel.Y - 19.82 Instead of making the module be zerogravity, it smacked my actors at the roof. And hard. (It sends actor upwards at that speed.)
|
Sun Apr 26, 2009 7:34 pm |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Lua based map objects, help! (BW related)
if actor.VelY >= 1 then actor.VelY = actor.VelY - 1 end
Try that. To make zero gravity in a really bad way, just make any positive velocity cancel itself.
|
Sun Apr 26, 2009 7:47 pm |
|
|
piipu
Joined: Mon Jun 30, 2008 9:13 pm Posts: 499 Location: Finland
|
Re: Lua based map objects, help! (BW related)
Oops. Replace 19.82 with (19.82 * 0.016667)
|
Sun Apr 26, 2009 8:02 pm |
|
|
numgun
Joined: Sat Jan 13, 2007 11:04 pm Posts: 2932
|
Re: Lua based map objects, help! (BW related)
Um, in B23, I'll be setting the default gravity for every map be 20 instead of that 19,82. What is that second value and will it change if the gravity is 20?
|
Sun Apr 26, 2009 9:23 pm |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Lua based map objects, help! (BW related)
0.016667 is the delta time, I believe.
And I think it would be 19.82/0.166667; the change in gravity you get per increment of change ingame.
However, I'm not sure if Lua's deltatime is the same as the game's.
|
Sun Apr 26, 2009 9:35 pm |
|
|
piipu
Joined: Mon Jun 30, 2008 9:13 pm Posts: 499 Location: Finland
|
Re: Lua based map objects, help! (BW related)
I tried that in a scene and it worked. To use 20 gravity change it to (20 * 0.016667)
|
Mon Apr 27, 2009 5:44 am |
|
|
Foa
Data Realms Elite
Joined: Wed Sep 05, 2007 4:14 am Posts: 3966 Location: Canadida
|
Re: Lua based map objects, help! (BW related)
Here is a suggestion, how about a non-lethal weapon that forces the enemies away.
|
Mon Apr 27, 2009 7:08 am |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
Re: Lua based map objects, help! (BW related)
The bullets calculate what direction they are going in, and make the actor move in that direction. Easy. So, without needed code(iteration and the like) Code: if (self.Vel.X>0) then actor.Vel.X = (how fast you want it) end if(self.Vel<0) then actor.Vel.X = -(how fast you want it) end
|
Mon Apr 27, 2009 7:57 am |
|
|
411570N3
Joined: Wed Jan 07, 2009 10:26 am Posts: 4074 Location: That quaint little British colony down south
|
Re: Lua based map objects, help! (BW related)
How about a module that does what you guys have suggested as zero gravity, except in reverse; a super gravity module, only the lightest of actors may pass. Oh and I think the hard-code for gravity would be essentially what you guys are talking about: constant acceleration downwards, which, in a physics context, it is; so constant acceleration upwards should be fine... except if your actor was heavy enough it could end up being really buggy...
|
Mon Apr 27, 2009 8:47 am |
|
|
|
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
|
|