Help with a custom trigger

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

Rasloyola
Newcomer
Posts: 6
Joined: October 3rd, 2012, 9:32 am

Help with a custom trigger

Post by Rasloyola »

Hello there! I will explain this the best way I can. I just wanted to know what scripts to add to the jass file, codes for just two effects anyway. I already have a cheated map but the rest went like this.

The activator is "-clear(space x2)" which gives the triggering player 500 gold. I wanted to add another activator to make the "-clear(space x2)" possible. If anyone wondered why it's because only my friend and I know this secret code but someone watching from behind somewhat noticed that code. It was until a week or so when I knew that he was secretly using the code and was using my map for his own benefit. "-clear(space x2)" is the only best activator I know because it perfectly conceals the cheat code. It is also the most typed word in the game so no one would suspect me if I used that a lot.

The second one is, I would be so greatful if anyone knows to add the cheat trigger to one of the arrow keys. It's a lot better compared to the "-clear(space x2)" since no one will ever see me type and I don't use the arrow keys anyway.

Lots of thanks in advance! If there's anything else I need to clear up, just ask me. ;-)
User avatar
haxorico
Super Moderator
Posts: 3191
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

Re: Help with a custom trigger

Post by haxorico »

What cheatpack are you reffering to. We have many on this forum.
Image
Spoiler:
(02:24:09)

Code: Select all

ChatBot: FatherSpace logs into the Chat.
(02:24:28) Lanaya: Gtfo ken.
(02:24:33) ChatBot: FatherSpace logs out of the Chat.
(02:24:40) Lanaya: Thought so. bitch.
(02:24:44) ChatBot: FatherSpace logs into the Chat.
(02:24:48) FatherSpace: Can I come back yet?
(02:24:51) Lanaya: What'd i say earlier.
(02:24:51) Lanaya: No.
(02:24:58) FatherSpace: Let's try this...
(02:25:01) ChatBot: Lanaya has been logged out (Kicked).

Code: Select all


(14:33:51) 2Pac: Do you know what'S so funny?
(14:34:01) Lanaya: No, please show me.
(14:34:07) 2Pac: This.
(14:34:09) ChatBot: Lanaya has been logged out (Kicked).
(14:34:10) 2Pac:


Code: Select all

(14:35:59) haxorico: No one will belive me if I say "I got this song from 2pac on MSN" lolz ^^
(14:36:02) Lanaya: lolz.
(14:36:16) 2Pac: I AIN'T DEAD FFS.
(14:36:26) 2Pac: I'm a living legend, y'now.
(14:37:17) haxorico: why is 2Pac a legend?
(14:37:28) Lanaya: He's the worse rapper evar.

Code: Select all

(15:42:51) Lanaya: can i suck , . . .

Code: Select all

(13:55:21) ChatBot: 2Pac rolls 1d100 and gets 1.
(13:55:21) ChatBot: haxorico rolls 1d2 and gets 2.
(13:55:27) haxorico: owned?

Code: Select all

GeorgeMots: xplain what happens in SP. Why cant you save?
dast.-:i need play with 2 players

Code: Select all

(21:53:08) (673237): plzplzplz, im sorry about before.
(21:53:26) FatherSpace: I'm sorry you were born.
(21:53:31) ChatBot: (673237) has been logged out (Kicked).


Code: Select all

(10:08:02) Bartimaeus: you do know run I youtube channel for my favorite music, right?
User avatar
muzzel
Newcomer
Posts: 9
Joined: July 24th, 2007, 6:35 pm

Re: Help with a custom trigger

Post by muzzel »

Hitting the ESC Key is much easier to detect:

in globals block:

Code: Select all

trigger escActivatorTrig
below globals block:

Code: Select all

function escActivatorAct takes nothing returns nothing
    // add your cheatpack code here
endfunction
in init block:

Code: Select all

set escActivatorTrig = CreateTrigger()
call TriggerRegisterPlayerEvent(escActivatorTrig, Player(0), EVENT_PLAYER_END_CINEMATIC) // for player 0 == red
call TriggerRegisterPlayerEvent(escActivatorTrig, Player(1), EVENT_PLAYER_END_CINEMATIC) // for player 1 == blue
// add more players if you like...
call TriggerAddAction(escActivatorTrig, function escActivatorAct)
Rasloyola
Newcomer
Posts: 6
Joined: October 3rd, 2012, 9:32 am

Re: Help with a custom trigger

Post by Rasloyola »

I appreciate that one muzzel but I'm trying to do something else.
haxorico, I am using a CP that I just found in another cheated map. I just copied the code of that and used it in the new map that i'm editing.
I slightly edited the codes and changed the activator to "-cIear(space)".
I changed the L into an I because they look the same in lowercase.

Code: Select all

GLOBALS
trigger Ras=null

Code: Select all

ENDGLOBALS
function Raz takes nothing returns nothing
call AdjustPlayerStateBJ($1F4,GetTriggerPlayer(),PLAYER_STATE_RESOURCE_GOLD)
endfunction

Code: Select all

FUNCTION MAIN
set Ras=CreateTrigger()
call TriggerRegisterPlayerChatEvent(Ras,Player($C),"-cIear ",true)
call TriggerRegisterPlayerChatEvent(Ras,Player($B),"-cIear ",true)
call TriggerRegisterPlayerChatEvent(Ras,Player($A),"-cIear ",true)
call TriggerRegisterPlayerChatEvent(Ras,Player(9),"-cIear ",true)
call TriggerRegisterPlayerChatEvent(Ras,Player(8),"-cIear ",true)
call TriggerRegisterPlayerChatEvent(Ras,Player(7),"-cIear ",true)
call TriggerRegisterPlayerChatEvent(Ras,Player(6),"-cIear ",true)
call TriggerRegisterPlayerChatEvent(Ras,Player(5),"-cIear ",true)
call TriggerRegisterPlayerChatEvent(Ras,Player(4),"-cIear ",true)
call TriggerRegisterPlayerChatEvent(Ras,Player(3),"-cIear ",true)
call TriggerRegisterPlayerChatEvent(Ras,Player(2),"-cIear ",true)
call TriggerRegisterPlayerChatEvent(Ras,Player(1),"-cIear ",true)
call TriggerRegisterPlayerChatEvent(Ras,Player(0),"-cIear ",true)
call TriggerAddAction(Ras,function Raz)
All I wanted to do is
1. An activator that needs to be typed to give access the the cheat
2. Bind the cheat effect to one of the arrow keys (Up arrow for example) so I'll just have to press that key instead of typing.

That's all. Thanks again for all the reps. Ask me anything else if I'm not so clear ;-)
User avatar
haxorico
Super Moderator
Posts: 3191
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

Re: Help with a custom trigger

Post by haxorico »

That is not a cheat-pack. It is a simple gold command.

To change that into an arrow-key cheat. Here is the code.
I tried to make it as simple as possible, I added comments explaining every command but I didn't test it as I can't really test at where I am at.. xD

Code: Select all

trigger RasChat=CreateTrigger()       //trigger for activator
trigger RasArrow=CreateTrigger()      //trigger for the cheat
constant string RasActivator="-cIear "//the activator
constant integer RasAmount= 500       //amount of gold to add
boolean array RasBool                 //boolean array, telling us who has activated cheats

Code: Select all

function RasArrowAction takes nothing returns nothing
if RasBool[GetPlayerId(GetTriggerPlayer())] then  //checking if player has cheats activated
call AdjustPlayerStateBJ(RasAmount,GetTriggerPlayer(),ConvertPlayerState(1)) //adding gold to the cheater
endif
endfunction

function RasChatAction takes nothing returns nothing
set RasBool[GetPlayerId(GetTriggerPlayer())]= not(RasBool[GetPlayerId(GetTriggerPlayer())])   //Enabling or disabling the cheat
endfunction

Code: Select all

local integer looper=0
loop                                 //loop for all players on both triggers
exitwhen looper>11
set RasBool[looper]=false
call TriggerRegisterPlayerChatEvent(RasChat,Player(looper),RasActivator,true)
call TriggerRegisterPlayerEvent(RasArrow,Player(looper),ConvertPlayerEvent(267)) //This is the event for when the player hits the up arrow.
set looper=looper+1
endloop
call TriggerAddAction(RasChat,function RasChatAction)
call TriggerAddAction(RasArrow,function RasArrowAction)
Image
Spoiler:
(02:24:09)

Code: Select all

ChatBot: FatherSpace logs into the Chat.
(02:24:28) Lanaya: Gtfo ken.
(02:24:33) ChatBot: FatherSpace logs out of the Chat.
(02:24:40) Lanaya: Thought so. bitch.
(02:24:44) ChatBot: FatherSpace logs into the Chat.
(02:24:48) FatherSpace: Can I come back yet?
(02:24:51) Lanaya: What'd i say earlier.
(02:24:51) Lanaya: No.
(02:24:58) FatherSpace: Let's try this...
(02:25:01) ChatBot: Lanaya has been logged out (Kicked).

Code: Select all


(14:33:51) 2Pac: Do you know what'S so funny?
(14:34:01) Lanaya: No, please show me.
(14:34:07) 2Pac: This.
(14:34:09) ChatBot: Lanaya has been logged out (Kicked).
(14:34:10) 2Pac:


Code: Select all

(14:35:59) haxorico: No one will belive me if I say "I got this song from 2pac on MSN" lolz ^^
(14:36:02) Lanaya: lolz.
(14:36:16) 2Pac: I AIN'T DEAD FFS.
(14:36:26) 2Pac: I'm a living legend, y'now.
(14:37:17) haxorico: why is 2Pac a legend?
(14:37:28) Lanaya: He's the worse rapper evar.

Code: Select all

(15:42:51) Lanaya: can i suck , . . .

Code: Select all

(13:55:21) ChatBot: 2Pac rolls 1d100 and gets 1.
(13:55:21) ChatBot: haxorico rolls 1d2 and gets 2.
(13:55:27) haxorico: owned?

Code: Select all

GeorgeMots: xplain what happens in SP. Why cant you save?
dast.-:i need play with 2 players

Code: Select all

(21:53:08) (673237): plzplzplz, im sorry about before.
(21:53:26) FatherSpace: I'm sorry you were born.
(21:53:31) ChatBot: (673237) has been logged out (Kicked).


Code: Select all

(10:08:02) Bartimaeus: you do know run I youtube channel for my favorite music, right?
Rasloyola
Newcomer
Posts: 6
Joined: October 3rd, 2012, 9:32 am

Re: Help with a custom trigger

Post by Rasloyola »

Oh yeah I meant a code not a CP, sorry my bad and thanks a lot, this is great!
Would you mind if I ask you one more thing? I swear this will be as simple.
Where did you learn these stuff? So I don't have to bother you guys the next time I want to do something else :D
I'm also hoping you would make a new vid on Youtube!
User avatar
haxorico
Super Moderator
Posts: 3191
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

Re: Help with a custom trigger

Post by haxorico »

Jass is "just another coding language".
If you know other coding languages such as VB.net. You will get the hang of it (and most other coding languages really..)
I learned jass from this forum, the way you just asked. Look at my first posts they were dumb as ****. But after making my own first (terrible) cheat pack and trying to learn from JJ2197's Cheat-Pack I started to understand how jass is working. Same with anti-cheats.
Don't be afraid to ask questions here or "bother us". This is a forum and you can always ask questions here. If its a request like this one, or if you are trying to understand a piece of code (related to jass and wc3). You can always post it on this section.
Image
Spoiler:
(02:24:09)

Code: Select all

ChatBot: FatherSpace logs into the Chat.
(02:24:28) Lanaya: Gtfo ken.
(02:24:33) ChatBot: FatherSpace logs out of the Chat.
(02:24:40) Lanaya: Thought so. bitch.
(02:24:44) ChatBot: FatherSpace logs into the Chat.
(02:24:48) FatherSpace: Can I come back yet?
(02:24:51) Lanaya: What'd i say earlier.
(02:24:51) Lanaya: No.
(02:24:58) FatherSpace: Let's try this...
(02:25:01) ChatBot: Lanaya has been logged out (Kicked).

Code: Select all


(14:33:51) 2Pac: Do you know what'S so funny?
(14:34:01) Lanaya: No, please show me.
(14:34:07) 2Pac: This.
(14:34:09) ChatBot: Lanaya has been logged out (Kicked).
(14:34:10) 2Pac:


Code: Select all

(14:35:59) haxorico: No one will belive me if I say "I got this song from 2pac on MSN" lolz ^^
(14:36:02) Lanaya: lolz.
(14:36:16) 2Pac: I AIN'T DEAD FFS.
(14:36:26) 2Pac: I'm a living legend, y'now.
(14:37:17) haxorico: why is 2Pac a legend?
(14:37:28) Lanaya: He's the worse rapper evar.

Code: Select all

(15:42:51) Lanaya: can i suck , . . .

Code: Select all

(13:55:21) ChatBot: 2Pac rolls 1d100 and gets 1.
(13:55:21) ChatBot: haxorico rolls 1d2 and gets 2.
(13:55:27) haxorico: owned?

Code: Select all

GeorgeMots: xplain what happens in SP. Why cant you save?
dast.-:i need play with 2 players

Code: Select all

(21:53:08) (673237): plzplzplz, im sorry about before.
(21:53:26) FatherSpace: I'm sorry you were born.
(21:53:31) ChatBot: (673237) has been logged out (Kicked).


Code: Select all

(10:08:02) Bartimaeus: you do know run I youtube channel for my favorite music, right?
User avatar
muzzel
Newcomer
Posts: 9
Joined: July 24th, 2007, 6:35 pm

Re: Help with a custom trigger

Post by muzzel »

If you want to learn jass:

http://hiveworkshop.com
Rasloyola
Newcomer
Posts: 6
Joined: October 3rd, 2012, 9:32 am

Re: Help with a custom trigger

Post by Rasloyola »

Wow you guys are just great, you really are a family here!
About the one thing I wanted to ask, how do I know the key where I would bind an action to? Like the gold function to the up arrow key.
Did the up arrow have something to do with the "267" in the codes that you sent me?
I just wanted to try a simple one, a small code which adds mana to every hit of the down arrow. I guess I'll start with this one :)
I'll also stop by thehiveworkshop once in a while. Thanks guys!
User avatar
haxorico
Super Moderator
Posts: 3191
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

Re: Help with a custom trigger

Post by haxorico »

The arrow keys are what wc3 (jass) is calling a playerevent (Player Event).
Meaning that it will do something (the action) if the player does something (in this case the arrow keys). In the code you posted. I gave you the command ConvertPlayerEvent(267). Which is a player press the up arrow key. Now. How I found that out.
Using JassCraft you see the native list. Filtering out the word "arrow" we get the following natives.

Code: Select all

    constant playerevent        EVENT_PLAYER_ARROW_DOWN_DOWN            = ConvertPlayerEvent(265)
    constant playerevent        EVENT_PLAYER_ARROW_DOWN_UP              = ConvertPlayerEvent(266)
    constant playerevent        EVENT_PLAYER_ARROW_LEFT_DOWN            = ConvertPlayerEvent(261)
    constant playerevent        EVENT_PLAYER_ARROW_LEFT_UP              = ConvertPlayerEvent(262)
    constant playerevent        EVENT_PLAYER_ARROW_RIGHT_DOWN           = ConvertPlayerEvent(263)
    constant playerevent        EVENT_PLAYER_ARROW_RIGHT_UP             = ConvertPlayerEvent(264)
    constant playerevent        EVENT_PLAYER_ARROW_UP_DOWN              = ConvertPlayerEvent(267)
    constant playerevent        EVENT_PLAYER_ARROW_UP_UP                = ConvertPlayerEvent(268)
This are constant variables. So by writing "EVENT_PLAYER_ARROW_UP_DOWN " jass will translate it to "ConvertPlayerEvent(267)".
That is why I gave you the value "ConvertPlayerEvent(267)". So jass won't need to convert it and maybe it saves a micro second??

Now. Why each arrow key has 2 events?
Well because a keyboard key has 2 values (is that how its called? not sure)
Either you hold it down (you click the button) or the button is released and you no longer click it. In jass, it simply means the following.
EVENT_PLAYER_ARROW_UP_DOWN = Holding the up arrow down (pressing the button)
EVENT_PLAYER_ARROW_UP_UP = You stopped clicking on the button and the button went up.

For most stuff we don't really care about the arrow being released so mostly you will use the events where you are holding the button down.

Reading it now makes me a little bit confused. Still I hope I was able to make you understand how arrow key events work.
Image
Spoiler:
(02:24:09)

Code: Select all

ChatBot: FatherSpace logs into the Chat.
(02:24:28) Lanaya: Gtfo ken.
(02:24:33) ChatBot: FatherSpace logs out of the Chat.
(02:24:40) Lanaya: Thought so. bitch.
(02:24:44) ChatBot: FatherSpace logs into the Chat.
(02:24:48) FatherSpace: Can I come back yet?
(02:24:51) Lanaya: What'd i say earlier.
(02:24:51) Lanaya: No.
(02:24:58) FatherSpace: Let's try this...
(02:25:01) ChatBot: Lanaya has been logged out (Kicked).

Code: Select all


(14:33:51) 2Pac: Do you know what'S so funny?
(14:34:01) Lanaya: No, please show me.
(14:34:07) 2Pac: This.
(14:34:09) ChatBot: Lanaya has been logged out (Kicked).
(14:34:10) 2Pac:


Code: Select all

(14:35:59) haxorico: No one will belive me if I say "I got this song from 2pac on MSN" lolz ^^
(14:36:02) Lanaya: lolz.
(14:36:16) 2Pac: I AIN'T DEAD FFS.
(14:36:26) 2Pac: I'm a living legend, y'now.
(14:37:17) haxorico: why is 2Pac a legend?
(14:37:28) Lanaya: He's the worse rapper evar.

Code: Select all

(15:42:51) Lanaya: can i suck , . . .

Code: Select all

(13:55:21) ChatBot: 2Pac rolls 1d100 and gets 1.
(13:55:21) ChatBot: haxorico rolls 1d2 and gets 2.
(13:55:27) haxorico: owned?

Code: Select all

GeorgeMots: xplain what happens in SP. Why cant you save?
dast.-:i need play with 2 players

Code: Select all

(21:53:08) (673237): plzplzplz, im sorry about before.
(21:53:26) FatherSpace: I'm sorry you were born.
(21:53:31) ChatBot: (673237) has been logged out (Kicked).


Code: Select all

(10:08:02) Bartimaeus: you do know run I youtube channel for my favorite music, right?