How to make a simple fishing system?

Sevion

The DIY Ninja
Reaction score
413
All you have to do is a terrain check and then an animation set with a timer that runs and on ending that timer, it does a chance check, if it hits, then you give him a fish.
 

.Itap

New Member
Reaction score
0
Is possible you made a demo map?

Is possible made a demo simple fishing system demo map for me ?
 

Sevion

The DIY Ninja
Reaction score
413
Here, try this code.

I just decided to make it.

How to use it:

1. Make a trigger named Fish
2. Convert it to Custom Text (Edit -> Convert To Custom Text)
3. Paste this in there
4. Create a trigger that fires on map initialization.
5. In that trigger, make custom scripts that add your item types.
6. Example:
Trigger:
  • Custom Script: call Fish.addFish('afac')

7. To find your itemtype id's, go to the object editor and do Control + D to display raw data.
8. The itemtype id is the 4 character code on the left of the item's name.
9. To make a unit fish, simply make a custom script like so:
Trigger:
  • Custom Script: call Fish.start(UNIT,CHANCE,TIME,ANIMATION,BOOLEAN)

(Check the documentation for more info)

OR

1. Download the UI files located here: View attachment 1279311703.
2. Extract them to your Warcraft III Directory.
3. Add items to the fish stack via the GUI action:
Trigger:
  • Unit - Add fish

4. Start fishing with units via the GUI action:
Trigger:
  • Unit - Start fish


JASS:
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~ Fish ~~ By Sevion ~~ Version 1.0.0.0 ~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//  What is Fish?
//          -Fish is an easy way to make units "fish" for items.
//
//  API:
//          -struct Fish extends array
//              -real chance
//                  The chance to "fish" an item.
//
//              -real time
//                  The duration of the "fishing".
//
//              -animation
//                  The animation to play while "fishing".
//
//              - static method start takes unit whichUnit, real chance, real time, string animation, boolean checkOnTick returns thistype
//                  Creates a fishing instance.
//
//              - static method stop takes unit whichUnit returns nothing
//                  Stops a fishing instance.
//
//              - method destroy takes nothing returns nothing
//                  Stop a fishing instance.
//
//              - static method addFish takes integer id returns nothing
//                  Add a fish to the stack.
//
//              - static method removeFish takes integer id returns nothing
//                  Remove a fish from the stack.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
native UnitAlive takes unit whichUnit returns boolean
library Fish
    globals
        private constant real PERIOD = 0.0325
    endglobals
    
    private struct FishArray extends array
        public static integer instanceCount = 0
        private static integer array recycle
        private static integer recycleCount = 0
        public thistype next
        public thistype prev
        public integer type
        
        public static method create takes nothing returns thistype
            local thistype this
            
            if ( recycleCount != 0 ) then
                set recycleCount = recycleCount - 1
                set this = recycle[recycleCount]
            else
                set instanceCount = instanceCount + 1
                set this = instanceCount
            endif
            
            set thistype(0).next.prev = this
            set this.next = thistype(0).next
            set thistype(0).next = this
            set this.prev = thistype(0)
            
            return this
        endmethod
        
        public method destroy takes nothing returns nothing
            set recycle[recycleCount] = this
            set recycleCount = recycleCount + 1
            set this.next.prev = this.prev
            set this.prev.next = this.next
        endmethod
    endstruct
    
    struct Fish extends array
        private static integer instanceCount = 0
        private static integer array recycle
        private static integer recycleCount = 0
        private static timer timer = CreateTimer()
        private static hashtable hash
        private thistype next
        private thistype prev
        private unit unit
        private real chanceX
        private real timeX
        private real increment
        private real tick
        private string animX
        private boolean bool
        
        private static method periodic takes nothing returns nothing
            local thistype this = thistype(0).next
            
            if ( this == 0 ) then
                call PauseTimer(thistype.timer)
                return
            endif
            
            loop
                exitwhen this == 0
                if ( not UnitAlive(this.unit) ) then
                    call this.destroy()
                endif
                set this.tick = this.tick + PERIOD
                call SetUnitAnimation(this.unit, this.animX)
                if ( this.bool ) then
                    if ( GetRandomReal(0, 1.00) <= this.chanceX ) then
                        call UnitAddItem(this.unit, CreateItem(FishArray(GetRandomInt(1, FishArray.instanceCount)).type, GetUnitX(this.unit), GetUnitY(this.unit)))
                    endif
                elseif ( this.tick >= this.timeX ) then
                    if ( GetRandomReal(0, 1.00) <= this.chanceX ) then
                        call UnitAddItem(this.unit, CreateItem(FishArray(GetRandomInt(1, FishArray.instanceCount)).type, GetUnitX(this.unit), GetUnitY(this.unit)))
                    endif
                endif
                if ( this.tick > this.timeX ) then
                    call this.destroy()
                endif
                set this = this.next
            endloop
        endmethod
        
        public method operator chance takes nothing returns real
            return this.chanceX
        endmethod
        
        public method operator time takes nothing returns real
            return this.timeX
        endmethod
        
        public method operator animation takes nothing returns string
            return this.animX
        endmethod
        
        public method operator chance= takes real chance returns nothing
            set this.chanceX = chance
        endmethod
        
        public method operator time= takes real time returns nothing
            set this.timeX = time
        endmethod
        
        public method operator animation= takes string animation returns nothing
            set this.animX = animation
        endmethod
        
        public static method start takes unit whichUnit, real chance, real time, string animation, boolean checkOnTick returns thistype
            local thistype this
            
            debug if ( FishArray(0).next == 0 ) then
                debug call BJDebugMsg("Error (Fish): No fish in the stack!")
                debug return 0
            debug endif
            debug if ( not UnitAlive(whichUnit) ) then
                debug call BJDebugMsg("Error (Fish): Specified unit is dead!")
                debug return 0
            debug endif
            debug if ( GetUnitAbilityLevel(whichUnit, 'Apak') < 1 and GetUnitAbilityLevel(whichUnit, 'AInv') < 1 and GetUnitAbilityLevel(whichUnit, 'Aien') < 1 and GetUnitAbilityLevel(whichUnit, 'Aion') < 1 and GetUnitAbilityLevel(whichUnit, 'Aihn') < 1 and GetUnitAbilityLevel(whichUnit, 'Aiun') < 1 ) then
                debug call BJDebugMsg("Error (Fish): Unit has no inventory!")
                debug return 0
            debug endif
            
            if ( recycleCount != 0 ) then
                set recycleCount = recycleCount - 1
                set this = recycle[recycleCount]
            else
                set instanceCount = instanceCount + 1
                set this = instanceCount
            endif
            
            set thistype(0).next.prev = this
            set this.next = thistype(0).next
            set thistype(0).next = this
            set this.prev = thistype(0)
            
            call SaveInteger(thistype.hash, GetHandleId(whichUnit), 0, this)
            
            set this.unit = whichUnit
            set this.chanceX = chance
            set this.timeX = time
            set this.tick = 0
            set this.animX = animation
            set this.bool = checkOnTick
            
            call ResumeTimer(thistype.timer)
            
            return this
        endmethod
        
        public static method stop takes unit whichUnit returns nothing
            debug if ( whichUnit == null ) then
                debug call BJDebugMsg("Error (Fish): Specified unit doesn't exist!")
                debug return
            debug endif
            
            call thistype(LoadInteger(thistype.hash, GetHandleId(whichUnit), 0)).destroy()
        endmethod
        
        public method destroy takes nothing returns nothing
            call SetUnitAnimation(this.unit, "stand")
            set recycle[recycleCount] = this
            set recycleCount = recycleCount + 1
            set this.next.prev = this.prev
            set this.prev.next = this.next
        endmethod
        
        public static method addFish takes integer id returns nothing
            local FishArray this = FishArray.create()
            set this.type = id
            call SaveInteger(thistype.hash, id, 1, this)
        endmethod
        
        public static method removeFish takes integer id returns nothing
            call FishArray(LoadInteger(thistype.hash, id, 1)).destroy()
        endmethod
        
        private static method onInit takes nothing returns nothing
            call TimerStart(thistype.timer, PERIOD, true, function thistype.periodic)
            set thistype.hash = InitHashtable()
        endmethod
    endstruct
endlibrary
 

.Itap

New Member
Reaction score
0
Make a simple fishing system in GUI or MUI?

I'm Not Jass...

Make a simple fishing system in GUI or MUI please?

Sorry My English :(
 

Smilis

TH.net Regular
Reaction score
7
I'm Not Jass...

Make a simple fishing system in GUI or MUI please?

Sorry My English :(

or MUI? MUI and GUI isn't the same thing...

well, can try to make one for you :)

will edit this post with a map in a few hours :)
 

mapguy

New Member
Reaction score
46
try this:

BEWARE, HAND MADE:
Code:
A unit starts the effect of an ability

Ability beeing cast equal to fishing.

Set random_fish = random number between 1 and 3
If random_fish equal to 1 then add red fish to triggering unit inventory.
If random_fish equal to 2 then add blue fish to triggering unit inventory.
If random_fish equal to 3 then add yellow fish to triggering unit inventory.
Change the terrain type underwater to an unique type of terrain:
Code:
A unit beguins casting an ability

ability beeing cast equal to fishing

set X = target point of ability beeing cast.
If terrain type at X not equal to (YOUR TERRAIN) then do actions.
------Pause triggering unit
------Order triggering unit to stop
------Unpause triggering unit.

This is the most simple system I can think...Of course this is shit. But this is simple.
 

Sevion

The DIY Ninja
Reaction score
413
I'm Not Jass...

Make a simple fishing system in GUI or MUI please?

You don't need to know JASS to use this. Just use the functions I showed you. Here, let me quick make a GUI api for it...

Okay, just unzip UI.zip to your WC3 directory and wallah. You have a GUI api for Fish.

It's at the very bottom of the Actions list.

Add your items to the list and then start fishing.

NOTE: ONLY ADD ITEMS TO THE LIST ONCE!
 

Attachments

  • UI.zip
    168.2 KB · Views: 215

Sevion

The DIY Ninja
Reaction score
413
I think is you... :rolleyes:

also that work like EGUI, right? :p I love what you do things like that for gui users x)

Minutes' work o_o'

Not really a whole lot.

(Working on a tool to make it from minutes to seconds <3)
 

.Itap

New Member
Reaction score
0
Fishing System GUI!

Quote : Minutes' work o_o'

Not really a whole lot.

(Working on a tool to make it from minutes to seconds )


GUI MAP ????? SIMPLE FISHING SYSTEM PLEASE !!!
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • 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

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top