Multiple protagonist management question?

This forum is meant for posting anything related to Adventure Maker that doesn't fit in the other forums.Please post technical questions in the Technical Support Forum!

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

Multiple protagonist management question?

Postby ZeornWarlock » Mon Feb 17, 2014 4:54 pm

Hi there, I've been continuing a few of my AM projects lately and most feature multiple protagonist a player needs to swap between different chapters or events, however I'm not too sure how to handle their inventory separately when swapping characters around. I've searched the forums with the "search" option and there doesn't seem to be anything related to this (I'm not even sure if I asked about this before!), does any of the AM gurus ever dealt with multiple inventory before, could this be possible to do to begin with? Any help or insight with this would be appreciated.

Thanks!
You have to make some to understand some.
User avatar
ZeornWarlock
Expert Member
 
Posts: 347
Joined: Tue Jun 05, 2007 12:52 am
Location: In front of the monitor.

Re: Multiple protagonist management question?

Postby Vengeance66 » Mon Feb 17, 2014 5:42 pm

Interesting question... I like to hear more from the code masters on this topic... :-)
Stay a while and listen...

Rainbow Enterainment - http://rainbowenter.com/
User avatar
Vengeance66
Administrator
 
Posts: 630
Joined: Wed Oct 13, 2010 2:17 pm
Location: Macedonia

Re: Multiple protagonist management question?

Postby reneuend » Tue Feb 18, 2014 1:36 am

Yes it's possible....and actually, you could do it with AM's built-in Inventory system.

Here is how I would do it:
NOTE: I did not test any of the code that follows. It is just to show that it is possible. Also, this is incomplete. I will try to write out an example in the future.

Variable: nCharacter integer - used to track which character's inventory is to be displayed
Variable: nPrevCharacter integer - previous character that was used
Variable: sInventory01 variant - a delimited string of the current inventory.
sInventory02 .......
sInventory03 .......
etc....................

I would use the following subroutines I created a long time ago and shared with the community in the how to area:
- GetWord()
- FindWord()

Optional (you could just use AM's file writing to save the information, but I built the following because the files are easier to use and read)
- Write2File()
- GetAllFileContents()
- GetFileContents()


When you want to display a certain character's inventory, set nCharacter for that character (nCharacter acts as an index of all the characters)
Then to get the inventory, build a subroutine that would contain a select statement.
You will need other subroutines to handle adding to the inventory, removing from the inventory, etc... because you want to keep the sInventory variable up-to-date.
Don't forget to save to the character's inventory file when user wants to quit, or savegame, etc...

Be sure to store the previous character before replacing the inventory: nPrevCharacter = nCharacter
Now set the next Character as the current character: nCharacter = 2
You would call this subroutine by just using the index: GetCharacterInventory(nCharacter)
Then you would just need to load the inventory: LoadCharacterInventory(nCharacter)


Code: Select all
Sub GetCharacterInventory(byval CharacterIdx)

  Select Case ( CharacterIdx)
    Case 1:
         sInventory01 = GetAllFileContents("Character1")
    Case 2:
         sInventory02 = GetAllFileContents("Character2")
    Case 3:
         sInventory03 = GetAllFileContents("Character3")
  End Select

 End Sub


Code: Select all
Sub LoadCharacterInventory(byval CharacterIdx)
  dim arItems()
  ClearInventory()
 
  Select Case ( CharacterIdx)
    Case 1:
         arItems = Split(sInventory01, ",")
    Case 2:
         arItems = Split(sInventory02, ",")
    Case 3:
         arItems = Split(sInventory03, ",")
  End Select

  for x = aritems.lowerbound to arItems.upperbound
    Action.AddItem arItems(x)
  next

End Sub


Code: Select all
sub ClearInventory()
  for each X in InventoryItemObject
    Action.RemoveItem x.tag
  next
End Sub
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2691
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Re: Multiple protagonist management question?

Postby ZeornWarlock » Tue Feb 18, 2014 10:39 pm

Thanks reneuend! :)

That's a good start plan, I hope I can make this work well with my limited coding skills, but it does look simple to do enough with your easy to follow and clear description.

Again, thanks a bunch I appreciated!
You have to make some to understand some.
User avatar
ZeornWarlock
Expert Member
 
Posts: 347
Joined: Tue Jun 05, 2007 12:52 am
Location: In front of the monitor.


Return to Adventure Maker General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest