The Daily Click ::. Forums ::. Klik Coding Help ::. Use replace ammo
 

Post Reply  Post Oekaki 
 

Posted By Message

jason w.



Registered
  02/05/2012 12:25:08
Points
  10
2nd May, 2012 at 02/05/2012 13:41:04 -

Im trying to figure out how to create a use replace event.
I have shot glasses that I am throwing at the bottles behind a bar. There are 3 shots lined up on the bar. The player grabs one throw it. Now he has 2 left.
There is a bartender moving back & forth. When he passes the line of shots he should replace any missing ones.

Can someone help me out with this?
Thanks

 
n/a

Chris Burrows



Registered
  14/09/2002
Points
  2396

GOTW WINNER OCT. 2011
2nd May, 2012 at 02/05/2012 14:23:58 -

Hey Jason,

It is done just as you said, when the bartender passes the shot glasses, if there is less than 3, add 1 to your shot glass value. If you want them all replenished instantly, either add 3 to your shot glass value, and then if it is higher than 3, set it to 3. Or, run a loop adding 1 glass at a time until there are 3.


If you want me to explain any of that in further detail let me know.

 
n/a

jason w.



Registered
  02/05/2012 12:25:08
Points
  10
2nd May, 2012 at 02/05/2012 19:21:04 -

Thanks for responding. I hate to be a pain but Im really new to this & would love a more detailed explanation on how to do this.
I think I'm not even close with how I have it set up.
Im not sure what you mean by adding 1 to the value of a shot glass. I do not have it set up to use variables to display the shot glass. I dont know how to do that.
I have three shot glasses label shot1, shot2 & shot3. When my player launches one then shot3 becomes invisible.
Please don't blast me...I know that is wrong but I do not know another way to do & im sure that shows my skill level.

Thank you...thank you


 
n/a

Chris Burrows



Registered
  14/09/2002
Points
  2396

GOTW WINNER OCT. 2011
2nd May, 2012 at 02/05/2012 19:54:58 -


Relax homie, there are infinite ways to tackle any problem.

What I would do is have a value for storing how much ammo you have left. This could be a counter or an alterable value in one of your active objects, it really doesn't matter what or where it is, so long as it is somewhere.

Now you need to add a few simple events and actions.


+ AmmoValue = 0
-> Make Glass1 invisible
-> Make Glass2 invisible
-> Make Glass3 invisible

+ AmmoValue = 1
-> Make Glass1 visible
-> Make Glass2 invisible
-> Make Glass3 invisible

+ AmmoValue = 2
-> Make Glass1 visible
-> Make Glass2 visible
-> Make Glass3 invisible

+ AmmoValue = 3
-> Make Glass1 visible
-> Make Glass2 visible
-> Make Glass3 visible

+ Upon Pressing Fire Button
+ AmmoValue > 0
-> Subtract 1 from AmmoValue
-> Launce shot glass

Now, for this part, the easiest way is to have an invisible detector for your bartender to collide with.

+ Bartender collides with Invisible Detector
+ AmmoValue < 3
-> Add 1 to AmmoValue

That should be enough to get you started. If you are having serious issues, upload your mfa and I'll take a look.

 
n/a

jason w.



Registered
  02/05/2012 12:25:08
Points
  10
2nd May, 2012 at 02/05/2012 20:43:28 -

Awesome. It sounds so simple after you spell it out.
I only had a minute to try it out & I have everything working except the actual shots showing up.
I dont have too much time to play with it today or tomorrow, but I think I can figure the rest out.
One question. Is Make Reappear the same command you would use for make visible.
thanks for the help. you rock !

 
n/a

Chris Burrows



Registered
  14/09/2002
Points
  2396

GOTW WINNER OCT. 2011
3rd May, 2012 at 03/05/2012 04:38:45 -

Correct. Make reappear = make visible.

What do you mean the actual shots don't show up? The on screen glasses?

 
n/a

jason w.



Registered
  02/05/2012 12:25:08
Points
  10
4th May, 2012 at 04/05/2012 15:01:38 -

Yes, the counter is working. Each time bartender passes the invisible contact the counter adds 1. Each time the space bar is press the counter deletes one & fires a shot glass.
But initially, it does not show all 3 ammo shots glasses. And it does not replace them as they are fired.
Oddly, if I removed counter =2 & 3 then all 3 are displayed at the begining of the frame but it still isnt removing & replacing them.
Here is a trimmed down version of the game: http://www.mediafire.com/?arccd1p8ed77sc3

PS while your looking at it, is there a more 3D way of throwing the glass?
thanks

 
n/a

Chris Burrows



Registered
  14/09/2002
Points
  2396

GOTW WINNER OCT. 2011
5th May, 2012 at 05/05/2012 01:28:40 -

You've used "Number of counter object = 3" instead of "Value of counter object = 3".

What this does is check the total number of instances of that counter object in the frame. Since you have 1 instance, this is always returning 1 and that is why only 1 of your shot glasses is displaying.

Yes, there are better ways to create the illusion of perspective but they require semi complex mathematics. If I were you, I'd save that until later in your project when you have learned a few more of the MMF ropes.

I'm not sure if you are aware, but your character fires the shot glasses at a random direction between straight up, and slightly to the left of straight up. You should make it only fire straight up.

Good luck with your project

 
n/a

jason w.



Registered
  02/05/2012 12:25:08
Points
  10
5th May, 2012 at 05/05/2012 11:20:10 -

Oh nice... Thank you for your help. Whenever I try my hand at programming I make attention to detail mistakes like that & not catch them. I have it working now.
I did notice that it was shooting in 2 directions, though. i was too lazy to go back & fix it.
I figured the perspective thing would be a big challenge. These forums & people who help, like yourself are invaluable for learning.
thanks.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click