JASS if/then help.

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

owner123
Super Moderator
Posts: 1943
Joined: February 3rd, 2009, 11:28 pm

JASS if/then help.

Post by owner123 »

I'm making an EXP system, where the max you can gain per kill is 20 exp.
I have this at the end of the function.

Code: Select all

if ( not ( ExpInteger < 20 ) ) then
     set ExpInteger = 20
endif
if ( not ( ExpInteger > 0 ) ) then
     set ExpInteger = 0
endif
return Round2I(ExpInteger)

Round2I is a rounding function.

I have the (not) there because before I accidently had the signs backwards. But, it seems to be just ignoring the if. I tried it out and was gaining 27 or 28 exp sometimes.
Is there something about JASS if that I'm not getting? :\
User avatar
haxorico
Super Moderator
Posts: 3190
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

Re: JASS if/then help.

Post by haxorico »

1) If I may add my opinion on the programing syntax, variables should start with a lower-case letter, expInteger but nvm :)
2) I suggest adding the following line.

Code: Select all

call DisplayTextToPlayer(GetTriggerPlayer(),0,0,I2S(ExpInteger)) // shows the final value of ExpInteger
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,I2S(Round2I(ExpInteger))) // shows the value the function returns
// this code was written in the forum and not in jasscraft so I might have made some syntax errors, but I trust you to fix them if I did :)


Edit: My suggested code.
remove the NOT for a cleaner reading.
add a debuging message (DisplayTextToPlayer..)
add an elseif statemant to stop it from going through un-needed code (if ExpInteger>=20 it can't be <=0)

Code: Select all

if (ExpInteger>=20) then
set ExpInteger=20
elseif (ExpInteger<=0) then
set ExpInteger=0
endif

call DisplayTextToPlayer(GetTriggerPlayer(),0,0,I2S(ExpInteger)) // shows the final value of ExpInteger
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,I2S(Round2I(ExpInteger))) // shows the value the function returns

return Round2I(ExpInteger)
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?
naturesfury
Forum Spammer
Posts: 610
Joined: March 30th, 2009, 9:02 pm

Re: JASS if/then help.

Post by naturesfury »

even if that expinteger is right,
might wanna check the GUI thingie to see if the monsters give exp for killing
(if they do, then ur exp system would just add it)
owner123
Super Moderator
Posts: 1943
Joined: February 3rd, 2009, 11:28 pm

Re: JASS if/then help.

Post by owner123 »

@Hax, it's also proper naming to have both capitalized.
http://en.wikipedia.org/wiki/Pascal_cas ... rogramming
My programming teacher makes us do it that way.. so I do it that way for anything I do, as it makes no difference to me one way or the other.
I'll try the debug message. Thanks for the suggestion.
@Nature, this was a problem for a while. But I fixed it before this. All players' heroes gain 0% exp
User avatar
haxorico
Super Moderator
Posts: 3190
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

Re: JASS if/then help.

Post by haxorico »

Well if you like it use it
Is it working
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
Nuuby
Forum Staff
Posts: 519
Joined: October 18th, 2010, 8:43 am

Re: JASS if/then help.

Post by Nuuby »

I didn't have any problems while testing that though, it didn't look like there was any problems in the first place. Used this.

Code: Select all

function Exp_DEBUG takes integer ExpInteger returns nothing
if ExpInteger>20then
set ExpInteger=20
endif
if ExpInteger<0then
set ExpInteger = 0
endif
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,I2S(ExpInteger))
endfunction

With chat commands to feed it the ExpInteger.
owner123
Super Moderator
Posts: 1943
Joined: February 3rd, 2009, 11:28 pm

Re: JASS if/then help.

Post by owner123 »

It shows "20" for both values. And I got 27 exp.
I have it disabling exp gain for all players earlier.
I have

Pick every player in All Players and do action
Make (Picked Player) heroes gain 0.0% exp from future kills.

I don't understand this at all.

Edit: Just checked. Turned off my exp gain trigger, I get 9 exp from the enemy. What else could be giving exp? I have my exp triggers disabled..
naturesfury
Forum Spammer
Posts: 610
Joined: March 30th, 2009, 9:02 pm

Re: JASS if/then help.

Post by naturesfury »

make sure that trigger ran?
make sure ur picking the right thing?
try disable exp gain?

post map?
hard to help without sounding like we're making fun of you if we don't have it in front of us lol o.o
User avatar
Durge
Senior Member
Posts: 199
Joined: April 19th, 2009, 12:46 pm

Re: JASS if/then help.

Post by Durge »

Kind of a straight-forward attempt, but did you try modifying the ExpInteger amount? Try changing it to like 15 or something, you might be able to get it to give 20 exp just by making the integer smaller. (Only applies if the % exp gain for heroes and the ExpInteger are related, but from reading it seems they obviously are)
ImageImageImage
owner123
Super Moderator
Posts: 1943
Joined: February 3rd, 2009, 11:28 pm

Re: JASS if/then help.

Post by owner123 »

naturesfury wrote:make sure that trigger ran?
make sure ur picking the right thing?
try disable exp gain?

post map?
hard to help without sounding like we're making fun of you if we don't have it in front of us lol o.o

I've tried disabling exp gain in 4 different places, including a trigger that runs every 0.10 seconds.

It just seems that, for some reason, disabling experience gain isn't working.

I don't want to post the map here as it's an early beta.. I'm just making the systems right now and a few heroes.

It doesn't sound like you're making fun of me. I appreciate any response that tries to help.

Edit: I was able to fix the problem by editing the "EXP Gained" gameplay constants category. I still have no idea what could have been causing it though. Thanks to everyone who helped. I'm closing this thread.