HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Reinventing the Craft

04-30-2009, 02:32 AM#1
MindWorX
With the latest release of the Jass NewGen Pack, the latest installment of Reinventing the Craft(RtC) has been released to the public.

RtC is a big pack of natives created by SFilip and me, in an attempt to create an enhanced experience when making and playing maps. RtC includes natives such as vectors for integer arrays with no limit, events for detecting keyboard presses and mouse position/presses that wasn't previously possible, natives that returns the time of the computer being used, binary comparisons, StringPos and StringReplace that doesn't leak strings, 64bit sized integers, and wrappers for Winsock which gives you full networking control. Also being worked on is natives to give you dynamic tooltips and object names, among other things. RtC is still in active development, and we're always listening to ideas.

Here's a few examples:
MouseAPI
Collapse JASS:
scope MouseTest initializer Init
    globals
        private trigger t
    endglobals
    
    private function Actions takes nothing returns nothing
        call BJDebugMsg("(" + R2S(GetMouseTargetX()) + ", " + R2S(GetMouseTargetY()) + ")")
    endfunction
    
    private function Init takes nothing returns nothing
        set t = CreateTrigger()
        call TriggerAddAction(t, function Actions)
        call TriggerRegisterMouseEvent(t, EVENT_LMOUSEDOWN) 
    endfunction
endscope

KeyboardAPI
Collapse JASS:
scope KeyboardTest initializer Init
    globals
        private trigger t
    endglobals
    
    private function Actions takes nothing returns nothing
     local integer key = GetTriggerParam_Integer(0)
        call BJDebugMsg("Key = " + I2S(key))
    endfunction
    
    private function Init takes nothing returns nothing
        set t = CreateTrigger()
        call TriggerAddAction(t, function Actions)
        call TriggerRegisterKeyEvent(t, 1) // = Key pressed. 0 = Key released.
    endfunction
endscope

Vector
Collapse JASS:
library RtCVector
    struct vector extends array
        static method create takes integer size returns vector
            return CreateVector(size)
        endmethod
        
        method copy takes nothing returns vector
         local vector iv = vector.create(this.size)
         local integer i = 0
            loop
                exitwhen i >= this.size
                set iv[i] = this[i]
                set i = i + 1
            endloop
            return iv
        endmethod
        
        method free takes nothing returns nothing
            call DestroyVector(this)
        endmethod
        
        method clear takes nothing returns nothing
            call VectorClear(this)
        endmethod
        
        method operator size takes nothing returns integer
            return GetVectorSize(this)
        endmethod
        
        method operator size= takes integer newsize returns nothing
            call SetVectorSize(this, newsize)
        endmethod
        
        method operator [] takes integer index returns integer
            if(index >= this.size) then
          debug call BJDebugMsg("|cffff0000" + SCOPE_PREFIX + "Error: Reading out of bounds!|r")
                return 0
            endif
            return VectorGet(this, index)
        endmethod
        
        method operator []= takes integer index, integer value returns nothing
            if(index >= this.size) then
                set this.size = index + 1
            endif
            call VectorSet(this, index, value)
        endmethod
        
        method push takes integer value returns nothing
            call VectorPushBack(this, value)
        endmethod
        
        method pop takes nothing returns nothing
            call VectorPopBack(this)
        endmethod
        
        method peek takes nothing returns integer
            return VectorBack(this)
        endmethod
        
        method empty takes nothing returns boolean
            return VectorEmpty(this)
        endmethod
    endstruct
endlibrary
Collapse JASS:
library Test initializer Init requires RtCVector
    private function Init takes nothing returns nothing
     local vector iv = vector.create(0)
     local integer i = 0
     
        call BJDebugMsg("iv.size = " + I2S(iv.size))
        call iv.push(20)
        call iv.push(5)
        call iv.push(60)
        call iv.push(202)
        call BJDebugMsg("iv.size = " + I2S(iv.size))
        set i = 0
        loop
            exitwhen i >= iv.size
            
            call BJDebugMsg("iv[" + I2S(i) + "] = " + I2S(iv[i]))
            
            set i = i + 1
        endloop
        call iv.clear()
        call iv.push(5)
        set i = 0
        loop
            exitwhen i >= iv.size
            
            call BJDebugMsg("iv[" + I2S(i) + "] = " + I2S(iv[i]))
            
            set i = i + 1
        endloop
        call iv.push(20)
        call iv.push(5)
        call iv.push(60)
        call iv.push(202)
        set iv.size = 10
        loop
            exitwhen iv.empty()
            
            call BJDebugMsg("iv.peek = " + I2S(iv.peek()))
            call iv.pop()
        endloop
        
        call iv.free()
    endfunction
endlibrary

We're hoping that coming in future installments will be even more natives, that gives mappers the control they really need. As already said, we're open to suggestions. And the more people that test and use it the better. The best way to see what's available is to look at the RtC folder inside newgen, there's a file called RtCCommon.j, which in the bottom has all of our currently implemented new stuff. The two last sections are experimental and not yet fully functional, so use at your own risk.

Also, here's the beginning of a manual.
MouseAPI

Enjoy.
Attached Files
File type: ziprtc.zip (849.5 KB)
04-30-2009, 03:02 AM#2
Alevice
holy crap. believe it or not my favorite addon would be dynamic tooltips and such. i hope you can embed images somehow, like the mana cost icon and such.
04-30-2009, 11:11 AM#3
MindWorX
Well, depending on what people want the most, that's what we're going to focus on. The dynamic tooltips are still very experimental and likely buggy, but the idea worked when i tested it. You basically catch the event when wc3 looks up the tooltip, and you're able to change the tooltip to your own, instead of what it looks up, thus giving you dynamic tooltips.
04-30-2009, 01:12 PM#4
Skater
You should write a manual, even if the most natives are easy to understand.

Does this only works with 1.22 and 1.23?
04-30-2009, 01:20 PM#5
MindWorX
It only works with 1.23 right now. :) A manual is coming, but there's alot of natives to document, so it's taking a little while.
04-30-2009, 01:50 PM#6
Opossum
New natives? These sound indeed awesome but how is this even possible?
I mean wouldn't you have to basically hack wc3 and somehow inject these natives into the whole hard-coded stuff? And wouldn't that be necessary on every wc3 installation that runs a map using this?
And also: What took you so long? :D

I guess I'm not really getting this...
04-30-2009, 02:17 PM#7
Alevice
Quote:
Originally Posted by Opossum
New natives? These sound indeed awesome but how is this even possible?
I mean wouldn't you have to basically hack wc3 and somehow inject these natives into the whole hard-coded stuff?

Yes.

Quote:
Originally Posted by Opossum
And wouldn't that be necessary on every wc3 installation that runs a map using this?

Yes.

Quote:
Originally Posted by MindWorX
Well, depending on what people want the most, that's what we're going to focus on. The dynamic tooltips are still very experimental and likely buggy, but the idea worked when i tested it. You basically catch the event when wc3 looks up the tooltip, and you're able to change the tooltip to your own, instead of what it looks up, thus giving you dynamic tooltips.

Wonderful.
04-30-2009, 02:21 PM#8
PurplePoot
New natives require a hacked client, so you have to be playing either single player or with a group of people who also have said hacked client.
04-30-2009, 02:44 PM#9
MindWorX
Alright, tooltip hook is bugged it seems, addresses are all wonked up, i'll try and get it resolved asap. Fixed a bug where you couldn't hover some abilities for some reason. Going to release that fix asap too.
04-30-2009, 02:56 PM#10
Alevice
Quote:
Originally Posted by PurplePoot
New natives require a hacked client, so you have to be playing either single player or with a group of people who also have said hacked client.

damn wc3 modders, playing with modde clients was the norm for any sort of custom crap in sc, and no one complained. but doing so for wc3 seems like the bane of modding.
04-30-2009, 07:40 PM#11
Belphegor666
I blame blizz for that...

Otherwise nice hacks. Rep added.
04-30-2009, 07:56 PM#12
bboy-tiger-
Hm is there any map with this system ? Coz i didnt found any. ( I just nicely ask :) )
Anyway i wish you luck in future development with this thing, really nice.
05-01-2009, 04:01 AM#13
Av3n
Pitzermike's little mini-game that uses RtC (The laser one with ships)?

-Av3n
05-01-2009, 01:01 PM#14
MindWorX
Alright, uploaded a version that fixes the freezing problem to the first post. Documentation is being added slowly. The reason PitzerMikes demo map isn't included, is because it's outdated. But i included the FPS Demo demo map, so that should be a good display of the mouse and keyboard api. The natives for dynamic tooltips seems borked, going to see if i can get them fixed.

EDIT:
Also just added the first part of the beginning of a manual.
05-01-2009, 01:47 PM#15
Flame_Phoenix
Just to make total sure, this works work campaigns ?
Also, this only works if you open RtC first, I mean, you don't need warcraft 3 nor b.net to play this (in fact they don't support it) right?