System Get Costs and Bounty

Jesus4Lyf

Good Idea™
Reaction score
397
JASS:
local integer id = itemTypeId-(itemTypeId/8191)*8191
            loop
                exitwhen itemTypes[id] == itemTypeId or itemTypes[id] == 0
                set id = id + 1
            endloop

C'mon mate, rip Hash off. You don't do a check in your loop for increasing over 8191, and the increment insinuates high complexity for consecutive item ids upon collision (example, using theoretical values 1, 2, 3, 4, 5 and then 8192 will loop for longer for 8192, because you do +1 instead of +90 or +53 or some other value - and consecutive item ids are common in custom items, so this is worth changing).

Aside from that, looking better! ;)

Also:
Scopes fail hard in vJass I find. I don't know if this is fixable...
JASS:
scope Units
        globals
            public integer array goldCost

I believe that exposes Units_goldCost inappropriately, right? You may want to avoid scopes in libraries, as making the scope private doesn't work off memory. (One of the bugs I can't report. :()
 

Nestharus

o-o
Reaction score
84
Ok, removing all of the cons for the next update (or most of them), meaning that you'll be able to use any player in your game and all their stuff without anything getting screwed up.

Stores previous gold and bounty, sets it to 0/1000000, then sets it back
Messes with foodcap for duration
The unit person now uses 0 food =)

playerChecker can still not be altered because other players will bug up : (, and it's just safest to use 14 ^_^.

Also will do the thing with 8191 : D.

And the scopes don't really need to be there. The variables are exposed so that you could in essence use the GetItemId and GetUnitId for multiple units and access the variable directly, but it's not really documented on =).
 

Nestharus

o-o
Reaction score
84
What else do I need to add to documentation?

Has a full description

List of functions
List of variables

The internal function isn't really meant to be used (GetItemId/GetUnitId) so it's not included in the documentation as it would be used to directly access variables within the system : ).
 

Jesus4Lyf

Good Idea™
Reaction score
397
Should ideally be encapsulated then.

I'd state how it works, any cons or things you need to be aware of, and maybe put a heading on the first post. :p

Damage type should be universal, attack type normal I think - does that hit invulnerable units?
JASS:
public function GetItemId takes integer itemTypeId returns integer
            local integer playerGold
            local integer playerWood
            local integer id = itemTypeId-(itemTypeId/8191)*8191
            loop
                exitwhen itemTypes[id] == itemTypeId or itemTypes[id] == 0
                set id = id + 35
                if id > 8191 then
                    set id = 1
                endif
            endloop
            if (itemTypes[id] == 0) then
                set playerGold = GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD)
                set playerWood = GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER)
                set itemTypes[id] = itemTypeId
                set currentItemType = itemTypeId
                set currentItemId = id
                call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD, RESOURCE_LIMIT)
                call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER, RESOURCE_LIMIT)
                call AddItemToStock(costRetriever, itemTypeId, 1, 1)
                call IssueNeutralImmediateOrderById(playerChecker, costRetriever, itemTypeId)
                set goldCost[id] = RESOURCE_LIMIT - GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD)
                set woodCost[id] = RESOURCE_LIMIT - GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER)
                call RemoveItemFromStock(costRetriever, itemTypeId)
                call EnumItemsInRect(removalArea, null, function RemoveItems)
                call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD, playerGold)
                call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER, playerWood)
            endif
            return id
        endfunction
-->
JASS:
public function GetItemId takes integer itemTypeId returns integer
            local integer playerGold
            local integer playerWood
            local integer id = itemTypeId-(itemTypeId/8191)*8191
            loop
                if (itemTypes[id] == 0) then
                    set playerGold = GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD)
                    set playerWood = GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER)
                    set itemTypes[id] = itemTypeId
                    set currentItemType = itemTypeId
                    set currentItemId = id
                    call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD, RESOURCE_LIMIT)
                    call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER, RESOURCE_LIMIT)
                    call AddItemToStock(costRetriever, itemTypeId, 1, 1)
                    call IssueNeutralImmediateOrderById(playerChecker, costRetriever, itemTypeId)
                    set goldCost[id] = RESOURCE_LIMIT - GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD)
                    set woodCost[id] = RESOURCE_LIMIT - GetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER)
                    call RemoveItemFromStock(costRetriever, itemTypeId)
                    call EnumItemsInRect(removalArea, null, function RemoveItems)
                    call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_GOLD, playerGold)
                    call SetPlayerState(playerChecker, PLAYER_STATE_RESOURCE_LUMBER, playerWood)
                endif
                exitwhen itemTypes[id] == itemTypeId // or itemTypes[id] == 0
                set id = id + 35
                if id > 8191 then
                    set id = id - 8191 // Improvement. Minimal collision chances.
                endif
            endloop
            return id
        endfunction
 

Nestharus

o-o
Reaction score
84
No cons left, I removed them all : ), but I'll explain how it works sure ^_^.

Also made things private via removing scopes : ).

Well, actually there is are 2 sort of cons left I guess.. they are in the first post : )
 

Nestharus

o-o
Reaction score
84
Updated for performance improvements and use with latest player tracking : ).

boolexprutils req was removed =).
 

Jesus4Lyf

Good Idea™
Reaction score
397
Aside from requireing graveyarded resources and having this settings area that makes no sense to anyone except Nestharus, this is looking pretty good.
JASS:
Settings:
*///===================================================================
//! textmacro Gcsn_USER_SETTINGS
    set coordX = GetRectCenterX(bj_mapInitialPlayableArea)
    set coordY = GetRectCenterY(bj_mapInitialPlayableArea)
//! endtextmacro

//! textmacro Gcsn_REGISTERED_PLAYERS
    exitwhen x == GetPlayerCount()
    set p = GetPlayer(x)
//! endtextmacro

//! textmacro Gcsn_EXTRA_PLAYERS
    //call TriggerRegisterPlayerUnitEvent(decay, Player(15), EVENT_PLAYER_UNIT_DEATH, null)
//! endtextmacro

...?
This also still doesn't implement GetDeathBounty as an event response like I mentioned in that other thread. Please steal said code. If you fix all this maybe this can be approved. :)

Oh, one more thing.
The name must be changed from "states", as this has nothing to do with states. You should know that unit states and player states exist as native stuff in WC3.

Using standard naming conventions for your library would also be greatly appreciated and give people a chance in hell of finding this (actually, the name I gave the thread does that for you).
 

Nestharus

o-o
Reaction score
84
Aside from requireing graveyarded resources and having this settings area that makes no sense to anyone except Nestharus, this is looking pretty good.

The settings are is inputted all over the code, lol. Unless you'd rather hunt thru the code to change settings? : P.

And the graveyarded resource is a utility that filters players. I'd have to write the same code in the ini of Ptn into this for ini, and because I always had to write the same lines of code over and over again, I made Ptn so I wouldn't have to ^_^. Also, Ptn has had some updates =p.


This also still doesn't implement GetDeathBounty as an event response like I mentioned in that other thread. Please steal said code. If you fix all this maybe this can be approved.

All right, i'll add it in as an optional add on =).

The name must be changed from "states", as this has nothing to do with states. You should know that unit states and player states exist as native stuff in WC3.

Actually it does have states in it. You can get total resources of a player, and you can get default item charges. I figured it was pretty appropriate, but it really does states, costs, and bounty =O.

I'll think of another name I guess if you don't approve of states, but how else do describe player states : \.

Using standard naming conventions for your library would also be greatly appreciated and give people a chance in hell of using this (actually, the name I gave the thread dose that for you).

so you mean you want me to name the library GetCostsStatesAndBounty? GetCostsAndBounty isn't accurate =).

Personally I prefer typing Gcsn as it is immeasurably shorter, but it's up to you guys =).

As for naming of the functions and vars, I followed JASS convention =).
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top