Hi! I have a problem in this game I am making with Fenner. I want a Railgun weapon in ths game and I can't get it to work. I tried using Fastloop. Can anyone help?
@Kramy: That's wrong. Loops work wherever you put them. My whole current project is filled with loops (using both, the fast loop object and MMF's internal loops) and I've never had any problems with placing them even at the very bottom of all my events.
[A quick note on fastloop: um I cant exactly remember for sure, but I'm pretty sure the action "Start loop 'x'" actually jumps out of the action list to the loop event, executes that event the number of times u specify, then jumps back to the action that called the loop in the action list. Just like any sub-routine/function/sub-program call in programming languages. Tigerworks wrote a very good article all about this i dont remember where it is tho]
Ok, here's a kind of system you could use:
Objects needed:
Active Objects:
• Player - no doubt you already have this
• Painter - not visible at start, do NOT destroy if too far from frame, do NOT deactivate if too far from frame, do NOT follow the frame
• RailParticle - small, 2x2px or whatever. this will make up the beam, in terms of Quake II, this is grey
• SwirlParticle - similar to the above, this will be the little swirly kind of stuff that filters off from the beam, in terms of Quake II, this is blue
Other Objects:
• Fast Loop Object - Only if you aren't using MMF
• Advanced Direction Object (ADO) - Only if you want to do directional aiming, like, with the mouse
Events:
1.
Always
+ Flag 0 of [Painter] is OFF:
• Set direction of [Painter] to ADO→Get Direction(X of [Player], Y of [Player], XMouse, YMouse) /*If you dont want to use mouse aiming, just substitute "Direction of [Player]" here instead*/
2.
Player 1 pressed fire button 1:
• Set position of [Painter] to (0,0) from [Player]
• Set flag 0 of [Painter] ON
• Start loop "MakeBeam" for 400 loops /*Number of loops determines range of the weapon*/
3.
On loop "MakeBeam"
+ NOT [Painter] is overlapping backdrop
+ X of [Painter] < X Right Frame
+ X of [Painter] > X Left Frame
+ Y of [Painter] < Y Bottom Frame
+ Y of [Painter] > Y Top Frame:
• Set X position of [Painter] to [X position of Painter]+ADO→GetXMovement(Direction of [Painter], 3)
• Set Y position of [Painter] to [Y position of Painter]+ADO→GetYMovement(Direction of [Painter], 3) /*the value of "3" determines the space between the beam particles, the smaller, the better the beam will look, but the more objects it will need and the more loops you will need to make a long beam, thus its pretty chunky*/
• Create [RailParticle] at (0,0) from [Painter]
4.
On loop "MakeBeam"
+ [Painter] is overlapping backdrop:
• Stop loop "MakeBeam"
• Set flag 0 of [Painter] OFF
5.
On loop "MakeBeam"
+ X of [Painter] < X Left Frame
• Stop loop "MakeBeam"
• Set flag 0 of [Painter] OFF
6.
On loop "MakeBeam"
+ Y of [Painter] > Y Bottom Frame
• Stop loop "MakeBeam"
• Set flag 0 of [Painter] OFF
7.
On loop "MakeBeam"
+ Y of [Painter] < Y Top Frame
• Stop loop "MakeBeam"
• Set flag 0 of [Painter] OFF
8.
Every 0.04 seconds
+ Number of [RailParticle] > 0:
• Shoot [SwirlParticle] from [RailParticle] in random direction out of 32 at speed 15
9.
Number of [RailParticle] > 0:
• Add 1 to value A of [SwirlParticle]
• Add 1 to value A of [RailParticle]
• Set semi transparency of [SwirlParticle] to (Value A of [SwirlParticle] * 10)
• Set semi transparency of [RailParticle] to (Value A of [RailParticle] * 5)
10.
Semi Transparency of [SwirlParticle] > 100:
• Destroy [SwirlParticle]
11.
Semi Transparency of [RailParticle] > 100:
• Destroy [RailParticle]
12.
<enemy> is overlapping [RailParticle]
+ Value A of [RailParticle] <= 7:
• <kill/damage enemy>
end of document
That should just about cover it, it's pretty late here I might of missed something. Of course the effects are pretty basic, a LOT more could be done to make it look way cooler, I might write an article sometime with more effects and such. Hope that helps, if there's any problems contact me on MSN at: biax666@hotmail.com
"You could just have a really long, skinny active object since Railguns score instant hits."
I don't think that would work. If you did that then you could hit multiple enemies, even behind walls
Jannis: Read a post thoroughly before you say it's wrong. Here's what I wrote, expanded.
Make sure your fastloops are at the top of the conditions, or they won't work.
Example:
-----Fastloop is at top of condition-----
On loop "LoopName"
+ Some other condition
+ Some other condition
-- Do something
Fastloops are ran in order from top to bottom in the event list
Example:
-----Fastloop is called in an event-----
Event list is checked from top to bottom for loop events, and they are ran. Loopstep goes down one, and starts again if it isn't 0.
but the event list only continues going down after the loop is complete
Example:
-----Fastloop is over and reached 0-----
The event list continues processing from where the loop was originally called.