Print Page | Close Window

Doubling max everything

Printed From: Mirage Source
Category: Tutorials
Forum Name: Submitted Tutorials
Forum Discription: Tutorial submissions for MSE are posted here, waiting for approval
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=497
Printed Date: 20 December 2006 at 6:05pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Doubling max everything
Posted By: Ozzy
Subject: Doubling max everything
Date Posted: 17 March 2006 at 11:34am
Theory-only.
Made By Joost
Disclaimer : This tut, and/or any edits from this tuts (like the actual code) can ONLY be posted on MS/ES/EB. Don't post anywhere else without permission.

In this entire tut, we'll be talking about integers. I'll use the example "NPC_HP", which normally should be around 32k (An integer).

As we all know (I assume) an integer is a number between -32k and +32k. For easier calculating, we'll pretend an integer is a number between -10 and 10, in this tutorial.

So normally, if the NPC_HP is dimmed as integer, the max is 10, correct? Cause an NPC can't have less than 0 hp, as soon as it goes under 0 after being hit, it's dead. We want to use the -10~10 part as well. So what do we do? We don't have to edit the 0~10 part, leave that alone.

We start with making the scroll for NPC_HP longer by 10. "OMG, then the max is twenty!?" Correct. Now for the saving.
If the scollbar is set on a number HIGHER THAN 10 (otherwise, do normal) do it - 10 * -1 and save it.. For example, if you set the scroll bar to 15, the NPC_HP will be saved as 15 - 10 = 5.    5 * -1 =  -5.   So we'll be using the extra room we weren't capable of using before.

Same goes for converting the < 0 number back to the > 10 number. If the NPC gets hit, before adding the damage check if his HP < 0, and if so, do it * -1 and + 10. So, if his hp = -5, his hp will turn out to be -5 * -1 = 5 + 10 = 15. Then remove the damage dealt to the npc. If it's less than 0, consider it dead, and if it's still greater than 10, convert back to -.

So, the max_hp from the npc went from 10 to 20, without using any more memory. Wow, that super. The same thing works formax_hp (MAX_HP will go from 32k to 64k) AND anything else dimmed as integer in the source.


EDIT

Im a stupid idiot. You can replace the "* -1 and + 10" sh*t with "+ 20", and the "* -1 and - 10" sh*t with "- 20"



Replies:
Posted By: Sonire
Date Posted: 17 March 2006 at 4:43pm
I'm going to post an example of what Ozzy has explained. My example simple: Changing the max items from 255 to 500.

Changes to be made:
modTypes ~ Server Side
modConstants ~ Server Side
modTypes ~ Client Side
modConstants ~ Client Side

Lets start with the the Server side work.
Firstly, modTypes:

Find
Type PlayerInvRec
    Num As Byte
    Value As Long
    Dur As Integer
End Type


Then change
Num As Byte

to
Num As Integer



Now find
Type MapItemRec
    Num As Byte
    Value As Long
    Dur As Integer


And change
Num As Byte

to
Num As Integer


Now, still working with the server side code, lets move to modConstants.

Find
Public Const MAX_ITEMS = 255

And change it to
Public Const MAX_ITEMS As Integer = 500


AND WE HAVE FINISHED THE SERVER SIDE STUFF

Now, let go to the client workstation.
First, lets open modconstants and get the easy stuff over with.

In modConstants, find
Public Const MAX_ITEMS = 255

And change it to
Public Const MAX_ITEMS As Integer = 500


Now find
Type PlayerInvRec
    Num As Byte
    Value As Long
    Dur As Integer
End Type

And lets change
Num As Byte

to
Num As Integer


Now find
Type MapItemRec
    Num As Byte
    Value As Long
    Dur As Integer

And then change
Num As Byte

to
Num As Integer


Also, if you haven't already done so, open up frmItemEditor, and change the scrollbar that calculates the selected item so that it's max is 500 rather than 255.

If you want, you can change 500 to an even higher number. This code technically supports up to 65534 items, becuase an interger = -32,767 through 32,767. Like Ozzy said, roughly 32k.

-------------
I grant permission for anyone to alter a tutorial previously posted by me for use in a tutorial submission for MSE, so long as "Originally Coded By Sonire" is credited at the top of the tutorial.



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info