Mirage Source
http://www.miragesource.net/forums/

My first step into Mirage
http://www.miragesource.net/forums/viewtopic.php?f=201&t=1002
Page 1 of 51

Author:  Stomach Pulser [ Sun Dec 31, 2006 2:45 am ]
Post subject:  My first step into Mirage

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 :D or is it messed up to an evil extent :twisted: ?

Author:  Lea [ Sun Dec 31, 2006 3:06 am ]
Post subject: 

Does it work? If it does, then it's fine. It looks like it works to me :)

Author:  Misunderstood [ Sun Dec 31, 2006 3:09 am ]
Post subject: 

I think you could use a little less comments :P 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?

Author:  Stomach Pulser [ Sun Dec 31, 2006 4:19 am ]
Post subject:  It works

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 :D

Author:  grimsk8ter11 [ Sun Dec 31, 2006 5:30 am ]
Post subject: 

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

Author:  Stomach Pulser [ Sun Dec 31, 2006 3:40 pm ]
Post subject: 

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

Author:  Tony [ Sun Dec 31, 2006 11:03 pm ]
Post subject: 

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

:: Pando

Author:  Robin [ Sun Dec 31, 2006 11:09 pm ]
Post subject: 

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.

Author:  funkynut [ Mon Jan 01, 2007 12:47 am ]
Post subject: 

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)

Author:  Misunderstood [ Mon Jan 01, 2007 1:34 am ]
Post subject: 

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 :P

Author:  funkynut [ Mon Jan 01, 2007 2:19 am ]
Post subject: 

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

Author:  Stomach Pulser [ Mon Jan 01, 2007 3:50 am ]
Post subject: 

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!

Author:  Obsidian [ Mon Jan 01, 2007 5:05 am ]
Post subject: 

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.

Author:  Lea [ Mon Jan 01, 2007 5:17 am ]
Post subject: 

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...

Author:  Stomach Pulser [ Mon Jan 01, 2007 5:30 am ]
Post subject: 

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.

Author:  Misunderstood [ Mon Jan 01, 2007 8:05 pm ]
Post subject: 

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.

Author:  Stomach Pulser [ Tue Jan 02, 2007 3:41 pm ]
Post subject: 

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

Author:  wanai [ Sun Jan 23, 2022 1:19 am ]
Post subject:  Re: My first step into Mirage

wwwa

Author:  wanai [ Sun Jan 23, 2022 1:20 am ]
Post subject:  Re: My first step into Mirage

162.8

Author:  wanai [ Sun Jan 23, 2022 1:21 am ]
Post subject:  Re: My first step into Mirage

Bett

Author:  wanai [ Sun Jan 23, 2022 1:22 am ]
Post subject:  Re: My first step into Mirage

Bett

Author:  wanai [ Sun Jan 23, 2022 1:23 am ]
Post subject:  Re: My first step into Mirage

Gabr

Author:  wanai [ Sun Jan 23, 2022 1:24 am ]
Post subject:  Re: My first step into Mirage

Zara

Author:  wanai [ Sun Jan 23, 2022 1:26 am ]
Post subject:  Re: My first step into Mirage

Soun

Author:  wanai [ Sun Jan 23, 2022 1:27 am ]
Post subject:  Re: My first step into Mirage

Akir

Page 1 of 51 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/