Mirage Source
My first step into Mirage - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17)
+---- Thread: My first step into Mirage (/showthread.php?tid=558)



My first step into Mirage - Stomach Pulser - 31-12-2006

Hello, I have been browsing the forums the past few days, looking for interesting things. I found Magnus's tutorial on carrying over EXP after a player levels up. It is my first time coding in Mirage, so here goes (I re-made my levelup sub)

Code:
Sub CheckPlayerLevelUp(ByVal Index As Long)
'**S*O*U*R*C*E***E*D*I*T****************************************************************
'* Deathlycat -                                                                        *
'*      Revamped entire levelup system to have EXP carry over after a player levels up *
'* 12/30/06                                                                            *
'***************************************************************************************
    Do While GetPlayerExp(Index) >= GetPlayerNextLevel(Index)
        ' When a player has more EXP than the TNL states, give them the EXP that they have left after they level up
        Call SetPlayerExp(Index, (GetPlayerExp(Index)) - (GetPlayerNextLevel(Index)))
        Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
        ' Gives the player stat points based on their current level divided by 10
        Call SetPlayerPOINTS(Index, (GetPlayerPOINTS(Index)) + (GetPlayerLevel(Index) / 10) + 1)
        ' Tells everyone that that player leveled up
        Call GlobalMsg(GetPlayerName(Index) & " has gained a level!", Brown)
        Call PlayerMsg(Index, "You have gained a level!  You now have " & GetPlayerPOINTS(Index) & " stat points to distribute.", BrightBlue)
    Loop

    
End Sub

Is this good Big Grin or is it messed up to an evil extent :twisted: ?


- Misunderstood - 31-12-2006

I think you could use a little less comments Tongue 1 every other line is a little excessive. Oh and the entire do loop(including do and loop should be indented more, nothing else(except some dim statements) should line up with the sub and end sub. Hopefully you don't take this as an insult or bad criticism, just trying to point out things you might want to fix in the future.

I'm not sure if the code works or not, did you test it?


It works - Stomach Pulser - 31-12-2006

I tested the code and it works fine, giving me the EXP that I rightfully deserve. Thanks for feedback, I wanted to make sure it wouldn't totally screw up my game before I put it into action Big Grin


- grimsk8ter11 - 31-12-2006

Code:
'****************************************************************
'* Deathlycat -
'*      Revamped entire levelup system to have EXP carry over after a player levels up
'* 12/30/06
'****************************************************************
Sub CheckPlayerLevelUp(ByVal Index As Long)

     ' If a player has enough EXP to level up, level them up
     Do While GetPlayerExp(Index) >= GetPlayerNextLevel(Index)

         ' When a player has more EXP than the TNL states, give them the EXP that they have left
         Call SetPlayerExp(Index, (GetPlayerExp(Index)) - (GetPlayerNextLevel(Index)))
         ' Levels the player up
         Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
         ' Gives the player stat points based on their current level divided by 10
         Call SetPlayerPOINTS(Index, (GetPlayerPOINTS(Index)) + (GetPlayerLevel(Index) / 10))
         ' Tells everyone that that player leveled up
         Call GlobalMsg(GetPlayerName(Index) & " has gained a level!", Brown)
         ' Tells the player that they leveled up and how much stat points they have
         Call PlayerMsg(Index, "You have gained a level!  You now have " & GetPlayerPOINTS(Index) & " stat points to distribute.", BrightBlue)

     Loop
  
End Sub

ther' we go


- Stomach Pulser - 31-12-2006

Thanks! I got it indented in my source code now.


- Tony - 31-12-2006

I hate commenting my code. Its annoying to see it :o But welcome!

:: Pando


- Robin - 31-12-2006

Pando Wrote:I hate commenting my code. Its annoying to see it :o But welcome!

:: Pando

Good luck having a few people working on the same piece.


- funkynut - 01-01-2007

I always make pattens with my comments, I hate seeing text that doesn't match the patten of the surrounding code (You know, how you sometimes have repeating if statements, or perhaps setting a group of variables or yada yada)


- Misunderstood - 01-01-2007

funkynut Wrote:I always make pattens with my comments, I hate seeing text that doesn't match the patten of the surrounding code (You know, how you sometimes have repeating if statements, or perhaps setting a group of variables or yada yada)

No, I guess I'm just not OCD like you Tongue


- funkynut - 01-01-2007

pffft, ocd my butt, kinda hard to explain while I'm in the celebration state of mind.

Basically, It just makes it easier on my eyes to look through my code


- Stomach Pulser - 01-01-2007

OK, I implemented characters changing their direction without moving...but I have 2 questions for this.

1.) How can I implement key coding (i.e. Pressing alt + up arrow at same time) to have direction changes, because right now I just have a single key for each direction.

2.) When I am moving one direction, holding down the right arrow for say, if I also hold down my change direction key, after I start moving, My char will change directions for that split second during movement when you aren't moving. It will instantly change back after that second, so you will barely see the change, but it is noticeable. Any known fix, or will it simply be solved when I implement question 1?

[EDIT]
OK, on a different note, I found out how to increase the number of NPCs you can have on a map through experimenting and analyzing code! It is the first thing that I have implemented solely by me! I am starting to get the hang of things now!

Happy new Year!


- Obsidian - 01-01-2007

to my knowledge, alt can't be used. i tried to find a way to use it a while ago (although i didn't look very hard), and couldn't find one.


- Stomach Pulser - 01-01-2007

Dave Wrote:You could use a low level keyboard hook to keep track of the state of the alt key... then if it's down when the arrow key is pressed...
What is a low level keyboard hook? Anyways, alt was just an example.


- Misunderstood - 01-01-2007

google it or look on pscode. It lets you capture key presses(even from other apps) and decide whether to pass them on or not.


- Stomach Pulser - 02-01-2007

Would you have to use keyboard hooks to combine controls (i.e Ctrl + 4), or could you use a different methods.