![]() |
|
Adding Weight To An Item - 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: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49) +---- Thread: Adding Weight To An Item (/showthread.php?tid=1485) Pages:
1
2
|
Adding Weight To An Item - Stomach Pulser - 02-01-2008 The feature of adding weight to your items was brought on by James and John's Fabulatra. I figured why not add it. But, as it turns out, since I'm still new, it took me awhile to get it done! Currently all it does is check to see when to add or subtract from the player's weight. Whenever you get/give an item from the ground/shop, it should update your current weight and tell you when you are carrying too much. I leave it up to anyone who wants to use to decide what happens when you are carrying too much weight. Without further ado, let's begin. Difficulty 3/5 – Comprehension (I tried to not make it a C + P, but I fail at making things hard ^_^) Client Side Start off in ModTypes. Add this into ItemRec, at the bottom Code: Weight As DoubleInside PlayerRec, just under the inventory category, add this: Code: CurWeight As LongNow go into ModGameLogic. Add the following functions/subs somewhere in there (preferably at the bottom): Code: Function GetPlayerCurWeight(ByVal Index As Long) As DoubleNow, find the sub “ItemEditorInit†without the quotes of course. Add this in before the first if statement: Code: frmItemEditor.txtWeight.Text = Item(EditorIndex).WeightNow find the sub “ItemEditorOKâ€. Add this before the first if statement: Code: Item(EditorIndex).Weight = frmItemEditor.txtWeight.TextNow find the sub “ClearPlayer†Add this line right before the armor statements (after the inventory clear): Code: Player(Index).CurWeight = 0Now find the sub “ClearItemâ€. Add this line at the end: Code: Item(Index).Weight = 0Moving on to ModClientTCP Find the sub “SendSaveItemâ€. Inside the packet part, remove the END_CHAR and add this: Code: & .Weight & END_CHARGo to ModHandleData Find the “Edit item packet†Add this at the end of the “ 'Update the Item†block of code Code: Item(n).Weight = Val(Parse(8))Find the “Update item packet†Add this right before it says exit sub Code: Item(n).Weight = Val(Parse(5))Now, go into frmItemEditor Add a text box and a label. Text Box.Name = txtWeight Label.Name = lblWeight Lablel.Caption = Weight That is all you have to do client side, now onto... Server Side Start off in ModTypes again Add the same variables as you did in the Client Go to ModGameLogic and add these in there Code: Function GetPlayerCurWeight(ByVal Index As Long) As DoubleNow find the sub “TakeItemâ€. Add the top of the sub add a boolean called curtake. Find “ ' Is what we are trying to take away more then what they have? If so just set it to zero†and replace that and the lines below it (until “ ' Check to see if its any sort of ArmorSlot/WeaponSlotâ€) with this: Code: ' Is what we are trying to take away more then what they have? If so just set it to zeroFind the sub “GiveItemâ€. Add this before the SendInventoryUpdate Code: Call SetPlayerCurWeight(Index, (GetPlayerCurWeight(Index) + (Item(GetPlayerInvItemNum(Index, i)).Weight * GetPlayerInvItemValue(Index, i))))Find the Sub “PlayerMapGetItemâ€. Replace the if statement Code: If n 0Code: If n 0 ThenFind the Sub “PlayerDropMapItemâ€. Replace the if statement Code: If Item(GetPlayerInvItemNum(Index, InvNum)).Type = ITEM_TYPE_CURRENCY Then[code]If Item(GetPlayerInvItemNum(Index, InvNum)).Type = ITEM_TYPE_CURRENCY Then ' Check if its more then they have and if so drop it all If Ammount >= GetPlayerInvItemValue(Index, InvNum) Then MapItem(GetPlayerMap(Index), i).Value = GetPlayerInvItemValue(Index, InvNum) Call MapMsg(GetPlayerMap(Index), GetPlayerName(Index) & " drops " & GetPlayerInvItemValue(Index, InvNum) & " " & Trim(Item(GetPlayerInvItemNum(Index, InvNum)).Name) & ".", Yellow) Call SetPlayerInvItemNum(Index, InvNum, 0) Call SetPlayerInvItemValue(Index, InvNum, 0) Call SetPlayerInvItemDur(Index, InvNum, 0) Else MapItem(GetPlayerMap(Index), i).Value = Ammount Call MapMsg(GetPlayerMap(Index), GetPlayerName(Index) & " drops " & Ammount & " " & Trim(Item(GetPlayerInvItemNum(Index, InvNum)).Name) & ".", Yellow) Call SetPlayerInvItemValue(Index, InvNum, GetPlayerInvItemValue(Index, InvNum) - Ammount) End If Call SetPlayerCurWeight(Index, (GetPlayerCurWeight(Index) - (Item(GetPlayerInvItemNum(Index, InvNum)).Weight * GetPlayerInvItemValue(Index, InvNum)))) Else ' Its not a currency object so this is easy MapItem(GetPlayerMap(Index), i).Value = 0 If Item(GetPlayerInvItemNum(Index, InvNum)).Type >= ITEM_TYPE_WEAPON And Item(GetPlayerInvItemNum(Index, InvNum)).Type Re: Adding Weight To An Item - Rezeyu - 02-01-2008 I prefer slots as opposed to weight. That's what I used in GS, and when you equipped a backpack, it added more slots. Re: Adding Weight To An Item - Stomach Pulser - 02-01-2008 In my game you have 15 inventory slots and you can get up to 10 more through packs/pouches. I'm not sure if I'm having this weight system. Just made it for the hell of it. Re: Adding Weight To An Item - William - 06-01-2008 I prefer movable slots like most good games have. This is a pretty cool idea though. Re: Adding Weight To An Item - Matt2 - 10-01-2008 I want to point something out. You defined Weight as a Double. Too big. Single should be fine. Unless you're planning to have each player be a super character. I'm pretty sure the average human can't lift more than 120 pounds... Single can cover that. ![]() I'm from the US, I regret not knowing the metric system as well as the rest of the world. >.< Also, CurWeight and MaxWeight, why are they Longs? Longs can't handle floating point numbers. So, if you have a limit of 3kg, and your item is 2.6 kg, if you use Fix(), your cur becomes 2[I'm assuming that's how you did it] instead of .4. I'm editing this as i read the tut, so, I'll post when I've read this all the way through. Other than what I mentioned, it's fine. I love weight, as opposed to slots. Makes games more realistic. Though, Pokemon doesn't call for it. Everything is a capsule, lol. So, yeah, good tut. And I'm done. xD Re: Adding Weight To An Item - Stomach Pulser - 10-01-2008 CurWeight As Long was a mistake...I changed that to double later, after I finished the first part of the tutorial. MaxWeight As Long is not a mistake though. Since I like your max weight to be a solid number, I made it a long. And yes, it is somewhat of a waste to use a double, but I figured if someone wanted to have uber1337 extreme values, they could... Re: Adding Weight To An Item - Matt2 - 11-01-2008 Just giving you my input. Btw, I dunno when you've come but I've been seeing you alot. Welcome. And nice tut. And yeah, super uber weapons. Didn't consider that. Thinking as a player, not a developer.
Re: Adding Weight To An Item - Stomach Pulser - 11-01-2008 Matt Wrote:Btw, I dunno when you've come but I've been seeing you alot. If you're referring to me, I have been around for a little over a year and got more active when I decided to start up a project, Portal To Bakaria. I came from playerworlds... Re: Adding Weight To An Item - Matt2 - 12-01-2008 Stomach Pulser Wrote:Matt Wrote:Btw, I dunno when you've come but I've been seeing you alot. Sweet. Welcome. Have fun!
Re: Adding Weight To An Item - Stomach Pulser - 13-01-2008 Welcoming me when I joined over a year ago. Me no understand explode logic brain gah! Re: Adding Weight To An Item - Robin - 13-01-2008 Matt.. wtf? Re: Adding Weight To An Item - Matt2 - 14-01-2008 Robin Wrote:Matt.. wtf? I was indeed thinking the same thing... I hadn't realized what I was doing. xD It's this stupid programming class. Lights are dimmed, and I go to sleep alot. xD Re: Adding Weight To An Item - laxika - 06-02-2008 I found a bug. If my max Weight 80, and my cur weight 79, but i want to pick an item when have 10 weight, i can... It says curr weight 89/ max weight 80... This is only in my source or the tutorial buggy? :roll: Re: Adding Weight To An Item - Stomach Pulser - 06-02-2008 Does it output that you have to much weight? So far, the code let's you pick up as much weight as you want without penalties, but it should say that you are overencumbered. Re: Adding Weight To An Item - Rian - 07-02-2008 Code: If GetPlayerCurWeight(Index) > GetPlayerMaxWeight(Index) Then Call PlayerMsg(Index, "You are over encumbered!", White)Thats a key line of code for this system. If you want being over encumbered to carry penalties, that's pretty much how you would do it. I would probably take the above line of code and use it to determine whether a player can walk or not. Putting this in the appropriate sub would work: Code: If GetPlayerCurWeight(Index) > GetPlayerMaxWeight(Index) Then CanMove = FalseRe: Adding Weight To An Item - laxika - 07-02-2008 Sonire Wrote: Ty this is nice, works good... my players can't walk if over encumbered... funny :twisted: I now need another litle help. :roll: I make a label(lblWeight) and a shape(shpWeight) to the inventory. I use this code: Private Sub Label24_Click() 'Weight lblWeight.Caption = GetPlayerMaxWeight & " / " & GetPlayerCurWeight shpWeight.Width = (((GetPlayerMaxWeight / lblWeight.Width) / GetPlayerCurWeight / lblWeight.Width) * lblWeight.Width) End Sub But if i want to make my project, is says: Argument not optional! lblWeight.Caption = GetPlayerMaxWeight & " / " & GetPlayerCurWeight Any tip :?: :roll: Re: Adding Weight To An Item - laxika - 07-02-2008 Dave Wrote:GetPlayerMaxWeight(MyIndex) & " / " & GetPlayerCurWeight(MyIndex) lblWeight.Caption = GetPlayerMaxWeight(MyIndex) & " / " & Variable not defined. :roll: Re: Adding Weight To An Item - Matt2 - 07-02-2008 laxika Wrote:Dave Wrote:GetPlayerMaxWeight(MyIndex) & " / " & GetPlayerCurWeight(MyIndex) Define it, or use one that's defined. Noob. It's common sense... -.- Re: Adding Weight To An Item - Anthony - 07-02-2008 Use Index instead of MyIndex. Re: Adding Weight To An Item - laxika - 07-02-2008 Vegeta Wrote:Use Index instead of MyIndex. K this works thanks to you and Matt!
Re: Adding Weight To An Item - Reece - 08-02-2008 laxika Wrote:Vegeta Wrote:Use Index instead of MyIndex. All he done was call you a noob.. Re: Adding Weight To An Item - Robin - 08-02-2008 Someone has a fucked up source. Re: Adding Weight To An Item - Matt2 - 08-02-2008 Lol. Re: Adding Weight To An Item - Stomach Pulser - 09-02-2008 Now, I have a fucked up source! Wheeeee....
Re: Adding Weight To An Item - Robin - 09-02-2008 Stop changing your font colour. Makes you look noobish. |