Interpreting JASS

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

Lightbrand
Newcomer
Posts: 7
Joined: April 3rd, 2007, 8:09 pm

Interpreting JASS

Post by Lightbrand »

The Link to the War3map.j is
http://www.zshare.net/download/war3map-j.html

Hi I'm new to the forum, this is actually my first thread/post. Sure deprotecting map is what this forum is about. But I'm rather more fascinated on how to actually "read" JASS. And from what I can tell this Section is suppose to be for "learning purposes" but most of the registered members here are just here to request a map to be deprotected.

Anyway, I hope this section will be helping me towards my knowledge on JASS.

I learned the basic of JASS by myself, having program language of C# and ASM it's not completely "pants wetting" experience when reading JASS code.
But, there are things which I have no idea on.

Now I'm not those kind of people who like to "invent", I work with ASM so I'm more interested in "reverse engineering", here is just codes examples I got base out of a map I'm currently looking in.

Code: Select all

call TriggerRegisterPlayerChatEvent(gg_trg_cheat,Player(1),"-pwned",true)
call TriggerAddCondition(gg_trg_cheat,Condition(function Trig_cheat_Conditions))
call TriggerAddAction(gg_trg_cheat,function Trig_cheat_Actions)


What I'm guessing is:
When Player 1 say "-pwned" in chat (without quotation). The game will create a condition at "Trig_cheat_Conditions" and an action at "Trig_cheat_Actions"
and it will proceed in doing whatever it's suppose to do. If I'm not right then correct me from here.

Now assuming that's right.
My question will be:
What's going on here

Code: Select all

call TriggerRegisterPlayerChatEvent(gg_trg_Secret,Player(1),"-",false)
call TriggerAddCondition(gg_trg_Secret,Condition(function Trig_Secret_Conditions))
call TriggerAddAction(gg_trg_Secret,function Trig_Secret_Actions)


What does it mean by if player say "-" = "false"? Logically it's shown to be a double negative.
If player say "-" and it's false...Which means the player didn't say anything. And the rest of the code is a waste...I've been trying to understand that for quite a while, and many questions will follow once I get this one out of the way.

Thanks, awaiting instructions.
Last edited by Lightbrand on April 5th, 2007, 3:38 am, edited 2 times in total.
Image
User avatar
Dekar
Forum Drunk
Posts: 2907
Joined: January 17th, 2007, 4:22 pm
Location: Darmstadt, Germany
Contact:

Post by Dekar »

Code: Select all

call TriggerRegisterPlayerChatEvent(gg_trg_Secret,Player(1),"-",false)

trigger gets registered to trigger for this event
it triggers if something is typed which includes "-" anywhere (corrected)

Code: Select all

call TriggerAddCondition(gg_trg_Secret,Condition(function Trig_Secret_Character8_Conditions))

condition for the execution of the actions
have a look at Trig_Secret_Character8_Conditions

Code: Select all

call TriggerAddAction(gg_trg_Secret,function Trig_Secret_Actions)

the action function Trig_Secret_Actions triggers


greets Dekar
Last edited by Dekar on April 4th, 2007, 12:55 am, edited 1 time in total.
Don't pm me with Warcraft questions, this is a forum so just make a post!

In the world of thinking we are all immigrants. -Robert Nozick
Lightbrand
Newcomer
Posts: 7
Joined: April 3rd, 2007, 8:09 pm

Post by Lightbrand »

My mistake on

Code: Select all

 Trig_Secret_Character8_Conditions

It was suppose to be same as the others so

Code: Select all

 Trig_Secret_Conditions


Now base on what's answered, and if I understood it properly, it meant that the code will trigger something from whatever the player type in chat. As long as he doesn't just type "-"?

Will it still register if i type something like "-somethinghere"?
Image
User avatar
trb92
Senior Member
Posts: 132
Joined: February 20th, 2007, 8:40 pm
Title: Random Noob
Location: Canada!!!

Post by trb92 »

Actually, Dekar has it wrong. The false there means it does not have to be an exact match, meaning that that trigger uses substrings. The trigger will happen if any message containing "-" is said. If it was true, the trigger would only happen if exactly "-" was typed.
If you knew a woman who was pregnant, who had 8 kids already,
three who were deaf, two who were blind, one mentally retarded, and she had syphilis; would you recommend that she have an abortion?

Answer:
Spoiler:
If you said yes, you just killed Beethoven...
User avatar
Dekar
Forum Drunk
Posts: 2907
Joined: January 17th, 2007, 4:22 pm
Location: Darmstadt, Germany
Contact:

Post by Dekar »

hmmkay, my mistake :)
hmm, so this one triggers function Trig_Secret_Actions if "-" is typed and conditions return true...
as you see i'm not that skilled in jass, too... maybe aero has the best skills here in this forum :)

greets Dekar
Don't pm me with Warcraft questions, this is a forum so just make a post!

In the world of thinking we are all immigrants. -Robert Nozick
Lightbrand
Newcomer
Posts: 7
Joined: April 3rd, 2007, 8:09 pm

Post by Lightbrand »

trb92 wrote:Actually, Dekar has it wrong. The false there means it does not have to be an exact match, meaning that that trigger uses substrings. The trigger will happen if any message containing "-" is said. If it was true, the trigger would only happen if exactly "-" was typed.


Perfect. Now I understand that completely.
The second part of my question comes from the actual condition.

Code: Select all

function Trig_Secret_Conditions takes nothing returns boolean
if(not(CountUnitsInGroup(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(),'hero1'))==1))then
return false
endif
return hashstringa(GetEventPlayerChatString())
endfunction



Now

Code: Select all

function Trig_Secret_Conditions takes nothing returns boolean
if(not(CountUnitsInGroup(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(),'hero1'))==1))then
return false
endif

It meant
declare function for Trig_secret_conditions, which takes nothing and returns a true or false.
Of the unit the player is controlling isn't "hero1"
then return false
else (if it is) then it will return true.

What I don't get is

Code: Select all

return hashstringa(GetEventPlayerChatString())
endfunction

okay hashstringa is a self declared variable.
and the declaration of "hashstringa" is

Code: Select all

function hashstringa takes string s returns boolean
local integer istring=0
local integer n=0
local integer len=StringLength(s)
local location oHash=MakePair_II(0,0)
loop
exitwhen n>=len
set istring=Char2Int(SubString(s,n,n+1))
call hashblock(oHash,istring)
set n=n+1
endloop
if(First_I(oHash)==-955425320)then
if(Rest_I(oHash)==-451731975)then
call DeletePair(oHash)
set oHash=null
return true
endif
endif
call DeletePair(oHash)
set oHash=null
return false
endfunction


I have no idea what that's all about.
But the in game function of these things will result in a player typing in "-something"
and it will swap your current character with another character. It's just this "something" I'm trying to figure out.
Image
User avatar
Dekar
Forum Drunk
Posts: 2907
Joined: January 17th, 2007, 4:22 pm
Location: Darmstadt, Germany
Contact:

Post by Dekar »

OT: you failed 5 times to type "hi" or "yes" to proof you're human? OMG XD

greets Dekar
Don't pm me with Warcraft questions, this is a forum so just make a post!

In the world of thinking we are all immigrants. -Robert Nozick
User avatar
trb92
Senior Member
Posts: 132
Joined: February 20th, 2007, 8:40 pm
Title: Random Noob
Location: Canada!!!

Post by trb92 »

Dekar wrote:hmmkay, my mistake :)
hmm, so this one triggers function Trig_Secret_Actions if "-" is typed and conditions return true...
as you see i'm not that skilled in jass, too... maybe aero has the best skills here in this forum :)

greets Dekar

Actually, it triggers if anything containing "-" is typed. so "-hi" would trigger it, "-" would trigger it, and "hi, i am -bob" would trigger it. But definietly Aero would be the best to help here.
If you knew a woman who was pregnant, who had 8 kids already,
three who were deaf, two who were blind, one mentally retarded, and she had syphilis; would you recommend that she have an abortion?

Answer:
Spoiler:
If you said yes, you just killed Beethoven...
User avatar
Dekar
Forum Drunk
Posts: 2907
Joined: January 17th, 2007, 4:22 pm
Location: Darmstadt, Germany
Contact:

Post by Dekar »

i probably would remove the whole crap and add my own chat trigger
to get the char... but if you want to know it in order to use it on others
hostet games... have fun :)

edit:
post this one please: oHash
i think there is the important part of the checking mechanism.
anyway it seems to use the string length of ?s? too!

edit2:
maybe just post the whole map :)
Don't pm me with Warcraft questions, this is a forum so just make a post!

In the world of thinking we are all immigrants. -Robert Nozick
Kala-cha
Forum Addict
Posts: 405
Joined: February 17th, 2007, 9:16 pm

Post by Kala-cha »

Couldn't you just make the "-something" an exact match?
I don't know any JASS but I know a bit of GUI. Put an condition that if someone (red) typed it as a substring it wouldn't do anything? -_- I hope I did something =P
(edit) And if I didn't do anything, just completely ignore me because I suck at JASS and know nothing about it xD
Post Reply