Lua based map objects, help! (BW related)
Author |
Message |
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
Re: Lua based map objects, help! (BW related)
You guys.......youre just amazing. Wish i was that good with Lua
|
Thu Apr 23, 2009 2:07 am |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
Re: Lua based map objects, help! (BW related)
The Mind wrote: You guys.......youre just amazing. Wish i was that good with Lua Just had to do this: Code: function GrantWish(target, wish) if target.wishes < 1 then return "Sorry, out of wishes" end ... if wish == "cake" then table.insert(target,cake) return "Wish Granted" end if wish == "lua skill" then target.luaskill = 100 wishes = wishes - 1 return "Wish Granted" end if wish == "more wishes" target.wishes = 32767 -- Inaccurate, but I'm not willing to but the actual number lua overflows there. target.wishes = target.wishes + 1 return "Wish Overflow" end ... end
But seriously, take some tutorials. And go fiddle with other people's code. Fix for the killzone, I just had the items go so fast that they should gib/disappear.: Code: function Create(self) x = self; end
function Destroy(self)
end
function Update(self) --First checks whether an actor or an item is within the box and then gibs them. for actor in MovableMan.Actors do if (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) then actor:GibThis() ; end end for item in MovableMan.Items do if (item.Pos.X >= self.Pos.X - 24) and (item.Pos.X <= self.Pos.X + 24) and (item.Pos.Y >= self.Pos.Y - 25) and (item.Pos.Y <= self.Pos.Y + 25) then item.Velocity = Vector(1000,1000) end end end
And for the regen pod, just explain that it reclones the actor or something. Code: function Create(self) x = self; regenchargetimer = Timer() regencharge = 15000 --10 sec recharge per healing end
function Destroy(self)
end
function Update(self) --First checks whether an actor or an item is within the box and then replaces them. Will remove inventory. Also decriments kill count to offset loss. for actor in MovableMan.Actors do if (regenchargetimer:IsPastSimMS(regencharge)) and (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) and (actor.Health < 100) then local spawnpos = actor.Pos; local spawnteam = actor.Team; local spawnAI = actor.AIMode local spawnname = actor.PresetName; local spawntype = actor.ClassName; actor:GibThis(); if spawntype == "AHuman" then guy = CreateAHuman(spawnname); end if spawntype == "ACrab" then guy = CreateACrab(spawnname); end if spawntype == "Actor" then guy = CreateActor(spawnname); end if spawntype == "ACDropShip" then guy = CreateACDropShip(spawnname); end if spawntype == "ACRocket" then guy = CreateACRocket(spawnname); end guy.Pos = spawnpos guy.Team = spawnteam guy.AIMode = spawnAI ActivityMan:GetActivity():ReportDeath(spawnteam,-1); regenchargetimer:Reset() end end end
|
Thu Apr 23, 2009 5:19 am |
|
|
numgun
Joined: Sat Jan 13, 2007 11:04 pm Posts: 2932
|
Re: Lua based map objects, help! (BW related)
mail2345 wrote: Fix for the killzone, I just had the items go so fast that they should gib/disappear. No worriers for the killzone, I asked TLB about while I was chatting with him and he suggested the following: Worked. Quote: And for the regen pod, just explain that it reclones the actor or something.
Hmm sounds great. But instead of changing the code, I'll make this a whole new module and warn the user so he'd drop his items before entering this thing. (I'll make it blow up the items so players reconsider using it while their being chased.) I'll name it respawn module or reconstructor module. It would serve as a much more powerful version of the regen with its own little traits. As for the teleporter, especially after some testing, the random teleportation is just too messy. And not only that, it still keeps hugging the same teleport you entered. (Do note, mail2345, I have NOT yet tested the code on the previous page you posted. and I cant right now, will test later when I get home.) So what we need now is to make the teleporter teleport the actor to the next teleporter in the list in a continous order. With this, telefragging will be good again so I'll keep that. Btw, how would a zero gravity module work? It simply would make stuff inside the area of the object behave like its in 0 gravity. I've heard that actor.GlobalAccScalar = 0 doesnt work so whats the other method?
|
Thu Apr 23, 2009 11:08 am |
|
|
piipu
Joined: Mon Jun 30, 2008 9:13 pm Posts: 499 Location: Finland
|
Re: Lua based map objects, help! (BW related)
I'd imagine teleporter pairs would be the best solution. The classical each teleporter teleports you to its pair sort. You could do maybe four different coloured teleporters each having their own luascript. Code: function Create(self) if (_teleporters == nil) then _teleporters = {self} else table.insert(_teleporters,self) end self.teledelaytimer = Timer(); self.teleactivate = nil; self.thistele = #_teleporters; end
function Destroy(self) table.remove(_teleporters,self) end
function Update(self) if(#_teleporters > 1) then for actor in MovableMan.Actors do if (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) and (actor.PinStrength <= 0) then if not self.teleactivated then local teleactivate = CreateAEmitter("Teleport Activation"); teleactivate.Lifetime = 2000; teleactivate.Pos = self.Pos; teleactivate:EnableEmission(true); MovableMan:AddParticle(teleactivate); self.teledelaytimer:Reset(); self.teleactivated = 1 else if self.teledelaytimer:IsPastSimMS(2000) then --TELEPORTATION HAPPENS HERE if self.thistele == 1 then i = 2 else i = 1 end for oactor in MovableMan.Actors if (oactor.Pos.X >= _teleporters[i].Pos.X - 24) and (oactor.Pos.X <= _teleporters[i].Pos.X + 24) and (oactor.Pos.Y >= _teleporters[i].Pos.Y - 25) and (oactor.Pos.Y <= _teleporters[i].Pos.Y + 25) then oactor:GibThis(); end end actor.Pos = _teleporters[i].Pos self.teledelaytimer:Reset(); self.teleactivated = 0 end end end end end end
Then just change _teleport to _teleport1 and so on for each different type of teleporter. Edit: when the actor is in the antigrav module, you could do Code: actor.Vel.Y = actor.Vel.Y - SceneMan.Scene.GlobalAcceleration.Y That should counter the scenes gravity. Edit2: Attempt at fixing the disappearing emitter.
|
Thu Apr 23, 2009 1:43 pm |
|
|
numgun
Joined: Sat Jan 13, 2007 11:04 pm Posts: 2932
|
Re: Lua based map objects, help! (BW related)
piipu wrote: I'd imagine teleporter pairs would be the best solution. The classical each teleporter teleports you to its pair sort. You could do maybe four different coloured teleporters each having their own luascript. Are you sure? You mean the code cant be done so it would simply move the actor to the next teleport on the table? If this is the case, does this mean I'll have to put 2 teleporters if I want to travel to different locations? And if all above is true, then stop coding the teleporter for now. TLB made a teleport of his own yesterday and it does just that. teleports an actor from teleporter A to teleporter B and viceversa. But this also means I'll have to revise the map layout. Crap. : /
|
Thu Apr 23, 2009 2:09 pm |
|
|
piipu
Joined: Mon Jun 30, 2008 9:13 pm Posts: 499 Location: Finland
|
Re: Lua based map objects, help! (BW related)
No, it can be done pretty easily. And here it is: Code: function Create(self) if (_teleporters == nil) then _teleporters = {self} else table.insert(_teleporters,self) end self.teledelaytimer = Timer(); self.teleactivate = nil; self.thistele = #_teleporters; end
function Destroy(self) table.remove(_teleporters,self) end
function Update(self) if(#_teleporters > 1) then for actor in MovableMan.Actors do if (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) and (actor.PinStrength <= 0) then if not self.teleactivated then local teleactivate = CreateAEmitter("Teleport Activation"); teleactivate.Lifetime = 2000; teleactivate.Pos = self.Pos; teleactivate:EnableEmission(true); MovableMan:AddParticle(teleactivate); self.teledelaytimer:Reset(); self.teleactivated = 1 else if self.teledelaytimer:IsPastSimMS(2000) then --TELEPORTATION HAPPENS HERE i = self.thistele + 1 if not (_teleporters[i]) then i = 1 end for oactor in MovableMan.Actors if (oactor.Pos.X >= _teleporters[i].Pos.X - 24) and (oactor.Pos.X <= _teleporters[i].Pos.X + 24) and (oactor.Pos.Y >= _teleporters[i].Pos.Y - 25) and (oactor.Pos.Y <= _teleporters[i].Pos.Y + 25) then oactor:GibThis(); end end actor.Pos = _teleporters[i].Pos self.teledelaytimer:Reset(); self.teleactivated = 0 end end end end end end
|
Thu Apr 23, 2009 2:43 pm |
|
|
zalo
Joined: Sat Feb 03, 2007 7:11 pm Posts: 1496
|
Re: Lua based map objects, help! (BW related)
What do you mean you can't make a teleporter that teleports to the next tele?
I saw some code in the Zombie Mission's Lua that randomly selects which actor/ weapon the Ronin guys should have when they spawn. It seems like a fairly simple task to chnage that from that to an orderly thing that teleports the guy to the next thing in the table.
And if the actual teleporters are static areas, then it's even better. Just put the code out seperately in the .lua file for each teleporter, and just make it so when you enter an area, it teleports you to the "Inward Bay" of the Tele (which has no tele code), using just positions and then when you enter the "Outward bay" it teleports you to whatever position that teleporter has in mind (Usually the next tele's Inward Bay).
Sure it isn't Dynamic and Scaleable (Unless the teleport position is defined by some sort of marker object), But it should work.
EDIT: Nevermind.
|
Thu Apr 23, 2009 2:50 pm |
|
|
piipu
Joined: Mon Jun 30, 2008 9:13 pm Posts: 499 Location: Finland
|
Re: Lua based map objects, help! (BW related)
^:D What I meant with the teleport pairing stuff was that it would be easier to learn where you would end up in when teleporting. But I guess it's not too hard to learn it this way either.
|
Thu Apr 23, 2009 2:59 pm |
|
|
zalo
Joined: Sat Feb 03, 2007 7:11 pm Posts: 1496
|
Re: Lua based map objects, help! (BW related)
If you wanted to learn where you are going, maybe Numgun could have a cute little icon/picture next to each teleporter describing the basic base structure and style and objects etc.
|
Thu Apr 23, 2009 3:30 pm |
|
|
numgun
Joined: Sat Jan 13, 2007 11:04 pm Posts: 2932
|
Re: Lua based map objects, help! (BW related)
piipu wrote: ^:D What I meant with the teleport pairing stuff was that it would be easier to learn where you would end up in when teleporting. But I guess it's not too hard to learn it this way either. Oh I see. Well, a bit of randomness should be cool. The main point is that theres a teleporter that can move you away from harm and where it takes you doesnt matter as long as you get the hell away from that other guy with the large gun. Gonna go test these scripts and add some new things now... Say, I was thinking how aqcuire weapons if those get broken or stolen from you. How should one be able to get new weapons during a match? And what about starting? Should you get a ready full loadout of random guns, or just a random sidearm or absolutely nothing but your knife?
|
Thu Apr 23, 2009 4:03 pm |
|
|
piipu
Joined: Mon Jun 30, 2008 9:13 pm Posts: 499 Location: Finland
|
Re: Lua based map objects, help! (BW related)
Maybe a module that gives you a random ranged weapon? And a puny sidearm as a starter weapon would be nice I think.
|
Thu Apr 23, 2009 5:17 pm |
|
|
zalo
Joined: Sat Feb 03, 2007 7:11 pm Posts: 1496
|
Re: Lua based map objects, help! (BW related)
it could be a terminal or something that calls a crate from the sky (When you shoot the picture of the weapon that you want), and the crate will have that weapon.
Or a "Held Device" like the control chip, could be like credits, or money, and you toss one of those into a pod looking thing, which immediately gets launched into the sky, and a moment later, a crate comes down. (And the pod respawns) Like real money. Maybe the Held Device Credits could spawn based on the amount of money that you have, but it'd subtract the real gold from you, so you could only use the credit system, and not the normal Buy menu. Each weapon would be worth different amounts of credits, like "A Pistol is one Credit", and "An SMG is 2 Credits" etc.
Or you could just do a system like Klone Soccer where the different areas are unlocked and more weapons get available, but that's lame.
|
Thu Apr 23, 2009 6:57 pm |
|
|
numgun
Joined: Sat Jan 13, 2007 11:04 pm Posts: 2932
|
Re: Lua based map objects, help! (BW related)
I like the idea about new stuff falling from the sky, but some of the maps are fully underground... so yeah. The credits thing... nah. I think one of those UT style weapon dispenser modules might be the way to go. Every 10 or even 20 seconds a new random weapon can be picked up if an actor enters it and it gets loaded straigth into his inventory. So it would first check if a player is within an area and see if the Timer for the next weapon is available (20 secs). Then it would load randomly one weapon from a list into the actors inventory and set the recharge timer to reset. ...how would one do a function to a module with a timer that would make it constantly spawn a particle effect(A simple glow MOPixel will do) to show that the module is ready to use again? EDIT: I cooked up some code, I'm pretty sure it will work and all it needs now is the effect that shows when the timer has ended for the new gun. EDITEDIT: I added some selfmade code, not tested yet. I have a doubt it will lag my CC to hell. Code: function Create(self) x = self; rechargetimer = Timer() newgundelay = 25000 --25 sec recharge per gun self.WepList = { "ViPeR", "SAR-12", "M75", "R78", "SRS900", "M50", "M925", "M353", "XMV-850", "XK2", "Fifty9", "R9", "Deermaster 6k", "Wilson", "AM76", "D49", "GRS9", "M802", "Knife", "Chainsaw", "HF Katana", "M763", "MRS38", "M280", "Lightning Gun", "HAMR", "G5", "JL21", "RX22A", }; self.BomList = { "NRP57 Grenade", "FP7 Grenade", "T10 Grenade" }; self.TolList = { "PT2", "PT46" }; self.readytogive = nil; end
function Destroy(self)
end
function Update(self) --Checks if actor within module and gives them a gun if 25 seconds have passed. Timer is then restarted. for actor in MovableMan.Actors do if (rechargetimer:IsPastSimMS(newgundelay)) and (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) then actor:FlashWhite(500); actor:AddInventoryItem(CreateHDFirearm(self.WepList[math.random(#self.WepList)],"BW.rte")); rechargetimer:Reset() end if (rechargetimer:IsPastSimMS(newgundelay)) local readytogive = CreateMOPixel("Module Ready Pixel"); MovableMan:AddParticle(readytogive); end end end
|
Thu Apr 23, 2009 7:34 pm |
|
|
numgun
Joined: Sat Jan 13, 2007 11:04 pm Posts: 2932
|
Re: Lua based map objects, help! (BW related)
Hmm after further testing I found out this: The teleporters only work ONCE. After teleporting the actor to the next teleport and playing the animation, the teleports simply stops showing the teleportation effect, and it only teleports to itself with a brief blink to another teleporter. On top of that, the teleporter will teleport the actor instantly after the first time and will wait the 3 second delay between the teleportation and when it does teleport after the first time, it only teleports back to itself. Code: function Create(self) if (_teleporters == nil) then _teleporters = {self} else table.insert(_teleporters,self) end self.teledelaytimer = Timer(); self.teleactivate = nil; self.thistele = #_teleporters; end
function Destroy(self) table.remove(_teleporters,self) end
function Update(self) if(#_teleporters > 1) then for actor in MovableMan.Actors do if (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) and (actor.PinStrength <= 0) then if not self.teleactivated then local teleactivate = CreateAEmitter("Teleport Activation"); teleactivate.Lifetime = 2000; teleactivate.Pos = self.Pos; teleactivate:EnableEmission(true); MovableMan:AddParticle(teleactivate); self.teledelaytimer:Reset(); self.teleactivated = 1 else if self.teledelaytimer:IsPastSimMS(2000) then --TELEPORTATION HAPPENS HERE i = self.thistele + 1 if not (_teleporters[i]) then i = 1 end for oactor in MovableMan.Actors do if (oactor.Pos.X >= _teleporters[i].Pos.X - 24) and (oactor.Pos.X <= _teleporters[i].Pos.X + 24) and (oactor.Pos.Y >= _teleporters[i].Pos.Y - 25) and (oactor.Pos.Y <= _teleporters[i].Pos.Y + 25) then oactor:GibThis(); end end actor:FlashWhite(1500); actor.Pos = _teleporters[i].Pos self.teledelaytimer:Reset(); self.teleactivated = 0 end end end end end end Then the zero gravity module doesnt work at all. Whats wrong here? Code: function Create(self) x = self; end
function Destroy(self)
end
function Update(self) --Any actor inside this will get his vertical velocity reduced from the scenes gravity or something. Zero gravity is what it does anyways. for actor in MovableMan.Actors do if (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) then actor.Vel.Y = actor.Vel.Y - SceneMan.Scene.GlobalAcceleration.Y end end --Same for items for item in MovableMan.Items do if (item.Pos.X >= self.Pos.X - 24) and (item.Pos.X <= self.Pos.X + 24) and (item.Pos.Y >= self.Pos.Y - 25) and (item.Pos.Y <= self.Pos.Y + 25) then item.Vel.Y = item.Vel.Y - SceneMan.Scene.GlobalAcceleration.Y end end end However, I got the weapon dispenser to work perfectly. Except the glow effect to show its done reloading. The code is on my previous post.
|
Thu Apr 23, 2009 10:33 pm |
|
|
TheLastBanana
DRL Developer
Joined: Wed Dec 13, 2006 5:27 am Posts: 3138 Location: A little south and a lot west of Moscow
|
Re: Lua based map objects, help! (BW related)
We can't access a scene's GlobalAcceleration via Lua... Yet.
|
Thu Apr 23, 2009 11:56 pm |
|
|
|
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
|
|