wc3edit.net

United Warcraft 3 map hacking!
It is currently April 27th, 2024, 1:11 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Help with abil adding
PostPosted: September 5th, 2007, 3:43 pm 
Offline
Forum Staff
User avatar

Joined: June 3rd, 2007, 8:03 pm
Posts: 1008
I'm trying to make an ability adder, but I can't seem to get it working, heres what it is rite now.
Code:
local string iabil="'"+SubString(s,9,12)+"'"

elseif SubString(s,0,8)=="-addabil"then
call UnitAddAbility(u,S2I(iabil))


Edit: the unit is succefuly gotten incase you were wondering.

_________________
Get Your Map Making Pack Here! :wink:
Good flash games website! Come join me and have fun! :O
Image


Top
 Profile  
 
PostPosted: September 5th, 2007, 4:42 pm 
Offline
Honorary wc3edit.net Traitor
User avatar

Joined: February 1st, 2007, 4:11 pm
Posts: 2513
Location: NEVADA
weirdone2 wrote:
I'm trying to make an ability adder, but I can't seem to get it working, heres what it is rite now.
Code:
local string iabil="'"+SubString(s,9,12)+"'"

elseif SubString(s,0,8)=="-addabil"then
call UnitAddAbility(u,S2I(iabil))


Edit: the unit is succefuly gotten incase you were wondering.

Lets see.

0,8 is correct for -addabil
but is 9,12 correct?


now lets see...

-addabil xxxx

that adds up to 13.

you forgot the space!

I think.... lol


Top
 Profile  
 
PostPosted: September 11th, 2007, 1:30 am 
Offline
Forum Staff
User avatar

Joined: January 28th, 2007, 8:10 pm
Posts: 830
Location: Canada
Title: JASS Programmer
Sorry for my recent lack of activity/quick response. I'm getting slammed with work and assignments that need attending. I previously investigated this myself, though not to add abilities, and have found the following to work very well. if you need clarification as to anything just ask.

Code:
globals
integer array S2RAW
endglobals

function InitS2RAW takes nothing returns nothing
set S2RAW[s2i("0")]=48
set S2RAW[s2i("1")]=49
set S2RAW[s2i("2")]=50
set S2RAW[s2i("3")]=51
set S2RAW[s2i("4")]=52
set S2RAW[s2i("5")]=53
set S2RAW[s2i("6")]=54
set S2RAW[s2i("7")]=55
set S2RAW[s2i("8")]=56
set S2RAW[s2i("9")]=57
set S2RAW[s2i("a")]=97
set S2RAW[s2i("b")]=98
set S2RAW[s2i("c")]=99
set S2RAW[s2i("d")]=100
set S2RAW[s2i("e")]=101
set S2RAW[s2i("f")]=102
set S2RAW[s2i("g")]=103
set S2RAW[s2i("h")]=104
set S2RAW[s2i("i")]=105
set S2RAW[s2i("j")]=106
set S2RAW[s2i("k")]=107
set S2RAW[s2i("l")]=108
set S2RAW[s2i("m")]=109
set S2RAW[s2i("n")]=110
set S2RAW[s2i("o")]=111
set S2RAW[s2i("p")]=112
set S2RAW[s2i("q")]=113
set S2RAW[s2i("r")]=114
set S2RAW[s2i("s")]=115
set S2RAW[s2i("t")]=116
set S2RAW[s2i("u")]=117
set S2RAW[s2i("v")]=118
set S2RAW[s2i("w")]=119
set S2RAW[s2i("x")]=120
set S2RAW[s2i("y")]=121
set S2RAW[s2i("z")]=122
set S2RAW[s2i("A")]=65
set S2RAW[s2i("B")]=66
set S2RAW[s2i("C")]=67
set S2RAW[s2i("D")]=68
set S2RAW[s2i("E")]=69
set S2RAW[s2i("F")]=70
set S2RAW[s2i("G")]=71
set S2RAW[s2i("H")]=72
set S2RAW[s2i("I")]=73
set S2RAW[s2i("J")]=74
set S2RAW[s2i("K")]=75
set S2RAW[s2i("L")]=76
set S2RAW[s2i("M")]=77
set S2RAW[s2i("N")]=78
set S2RAW[s2i("O")]=79
set S2RAW[s2i("P")]=80
set S2RAW[s2i("Q")]=81
set S2RAW[s2i("R")]=82
set S2RAW[s2i("S")]=83
set S2RAW[s2i("T")]=84
set S2RAW[s2i("U")]=85
set S2RAW[s2i("V")]=86
set S2RAW[s2i("W")]=87
set S2RAW[s2i("X")]=88
set S2RAW[s2i("Y")]=89
set S2RAW[s2i("Z")]=90
endfunction
function s2i takes string s returns integer
return s
return 0
endfunction
function Str2RAW takes string s returns integer
return S2RAW[s2i(SubString(s,0,1))]*0x1000000+S2RAW[s2i(SubString(s,1,2))]*0x10000+S2RAW[s2i(SubString(s,2,3))]*0x100+S2RAW[s2i(SubString(s,3,4))]
endfunction


Simply use Str2RAW("xxxx") and it will return the corresponding integer. This method has many more flexible uses such as password encryption... (hint)

However, for your use, there is a significantly shorter way but first I need to explain how s2i(s) works.

s2i will take any string and convert it to a 2-3 (usually) digit number which gets 'reserved' for that specific string and will never get recycled. Once s2i is used on a string, using the same string again will return the 'reserved' integer.

For example, s2i("PurpleBlurp") might return 21, and 21 will be 'remembered' as "PurpleBlurp". No other string will henceforth return 21 except for "PurpleBlurp".

So, if you had prior knowledge as to the abilities you would like to be adding, instead of using 'set S2RAW[s2i("a")]=97' ...[s2i("b)]=... ect. You could simply use:

set S2RAW[s2i("abcd")]='abcd'
set S2RAW[s2i("A000")]='A000'

(Unless of course there is significantly more abilities than 0-9, a-z, A-Z ... )

If you did this, you could eliminate 'function Str2RAW' altogether and you could do an easy loop to check for invalid ability input.

Anyhow, these are my findings -- please correct me if I'm wrong anywhere.


Top
 Profile  
 
PostPosted: September 11th, 2007, 2:29 am 
Offline
Senior Member
User avatar

Joined: June 1st, 2007, 9:05 pm
Posts: 101
Found this on another forum:

Code:
function chr takes integer i returns string
  local string abc = "abcdefghijklmnopqrstuvwxyz"
  local string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  local string digits = "0123456789"
    if i >= 65 and i <= 90 then
        return SubString(ABC, i-65,i-64)
    elseif i >= 97 and i <= 122 then
        return SubString(abc, i-97,i-96)
    elseif i >= 48 and i <= 57 then
        return SubString(digits, i-48,i-47)
    endif
    return ""
endfunction
function ID2S takes integer itemid returns string
    return chr(itemid/256/256/256) + chr(ModuloInteger(itemid/256/256, 256)) + chr(ModuloInteger(itemid/256, 256)) + chr(ModuloInteger(itemid, 256))
endfunction

ID2S would work as RawCode2String.

No idea if it works or if it's the right thing, I just found it on another forum and some guy said it was RawCode2String.

_________________
Massively Medieval RPG V 0.41 C
Join my forums!


Top
 Profile  
 
PostPosted: September 11th, 2007, 10:44 pm 
Offline
Forum Staff
User avatar

Joined: January 28th, 2007, 8:10 pm
Posts: 830
Location: Canada
Title: JASS Programmer
Optimize that code...


Top
 Profile  
 
PostPosted: September 18th, 2007, 6:30 am 
Offline
Honorary wc3edit.net Traitor
User avatar

Joined: February 1st, 2007, 4:11 pm
Posts: 2513
Location: NEVADA
Well.. Aero never ceases to amaze me, thats for sure. I think he has always known more then me ;/


Top
 Profile  
 
PostPosted: September 19th, 2007, 7:20 pm 
Offline
Forum Staff
User avatar

Joined: June 3rd, 2007, 8:03 pm
Posts: 1008
Thx for all the info, after i posted this topic my internet decided to die... I ended up finally figuring out that the encoded version couldnt be done unless I wanted to add a converter also, and it woulda been rather long since I could only figure out how to do hex to dec... Though ur converter looks kinda short lolz. I ended up just going with having to already know the unencoded digits for the abil to be able to add it.

_________________
Get Your Map Making Pack Here! :wink:
Good flash games website! Come join me and have fun! :O
Image


Top
 Profile  
 
PostPosted: September 20th, 2007, 1:27 am 
Offline
Forum Staff
User avatar

Joined: January 28th, 2007, 8:10 pm
Posts: 830
Location: Canada
Title: JASS Programmer
Yeah, I have a lot of knowledge on these sort of miscellaneous things.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 23 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

phpBB SEO


Privacy Policy Statement
Impressum (German)