Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO] Tile made by item


Mikekan13
 Share

Recommended Posts

So I have made a "Plant" system that works similar to the resource system but has several stages of growing and different amounts of items given based on its "growth state" There is also items called "seeds" that when used turn the tile a player is on into a "plant" tile type. The problem is: If I plant say two seeds then go into the map editor only 1 plant will show up and if I plant 3 then only 2 show up. It is always one less then the actual amount planted. I have noticed that the resources do something very similar. was there a bug like this in the resources?

Edit: here is the code when the Tile is made:
```
Case ITEM_TYPE_SEED
                Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Type = TILE_TYPE_PLANT
                Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data1 = Item(GetPlayerInvItemNum(Index, InvNum)).Data1
                PlayerMsg Index, Trim$(Item(GetPlayerInvItemNum(Index, InvNum)).Name) & " planted.", BrightGreen

                Call SaveMap(GetPlayerMap(Index))
                Call CachePlants(GetPlayerMap(Index))
                Call TakeInvItem(Index, GetPlayerInvItemNum(Index, InvNum), 0)
                For I = 0 To PlantCache(GetPlayerMap(Index)).Plant_Count
                    SendPlantCacheToMap Index, I
                Next
```

Edit2: Ok so I got it working by Warping the Players like it does when it saves a map, but everything blinks when a seed is planted. What is vital in the warp code that I can use by itself so it does not blink all the items and stuff.
Link to comment
Share on other sites

I have one more question regarding this system. I have it on a timer based on each plants growth time. Basicaly every X amount of minutes the plant gains a point that corresponds to how many resources is in the plant (up to its maximum). However I dont want the timer to reset every time I recache the plants. currently my code :
```
PlantCache(GetPlayerMap(Index)).PlantData(i).PlantTimer = GetTickCount
```this is done in my plantcache sub so every time a player "plants a seed" it resets the timer for all the plants. Since Some things will take hours maybe even days to grow things this wont work. Have any ideas on how to just update the timer individually This is my use seed code:
```
Case ITEM_TYPE_SEED
                Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Type = TILE_TYPE_PLANT
                Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data1 = Item(GetPlayerInvItemNum(Index, InvNum)).Data1
                PlayerMsg Index, Trim$(Item(GetPlayerInvItemNum(Index, InvNum)).Name) & " planted.", BrightGreen
                Call SaveMap(GetPlayerMap(Index))
                Call MapCache_Create(GetPlayerMap(Index))

                ' Refresh map for everyone online
                For i = 1 To MAX_PLAYERS
                    If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(Index) Then
                        Call SendMap(i, GetPlayerMap(Index))
                    End If
                Next i

                Call TakeInvItem(Index, GetPlayerInvItemNum(Index, InvNum), 0)
                Call CachePlants(GetPlayerMap(Index))
                For i = 0 To PlantCache(GetPlayerMap(Index)).Plant_Count
                    SendPlantCacheToMap Index, i
                Next
```
I can't think of a way to just tell it to change the time on the one being planted. Plus I would have to do the same if the plants were changed in the map editor.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...