Grouped action specials in DECORATE

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Grouped action specials in DECORATE

Re: Grouped action specials in DECORATE

by jmickle » Mon Jan 12, 2015 4:24 am

Glad to see this come in! Thanks a bunch Randi :)

Re: Grouped action specials in DECORATE

by NeuralStunner » Sun Jan 11, 2015 8:42 pm

Gez wrote:A_Jump jumps if the random number between 0 and 255 is under the value you give it. 255 is not less than 255, so if you used 255, there is one chance in 256 that it will not jump.
Also of note: If you only need one possible jump destination, it's better to use A_JumpIf and provide your own formula. "Random(1,10) == 1" is a much clearer way to express "1 in 10 chance".

Usually I avoid using A_Jump, unless I need a "virtual goto" for inheritance's sake.

Re: Grouped action specials in DECORATE

by Major Cooke » Sun Jan 11, 2015 2:05 pm

Oh, wait. I was looking at the wrong piece of code. Yes, fishy, you're right, it does require braces.

Re: Grouped action specials in DECORATE

by Dark-Assassin » Sun Jan 11, 2015 1:59 pm

Ah, that makes sense. Thanks for clearing that up.

Thought it was Less or Equal as A_JumpIfInventory and similar jump if Greater or Equal, not just Greater.

Re: Grouped action specials in DECORATE

by Gez » Sun Jan 11, 2015 1:55 pm

A_Jump jumps if the random number between 0 and 255 is under the value you give it. 255 is not less than 255, so if you used 255, there is one chance in 256 that it will not jump.

You can use any number greater than 255. So 256, or more.

Re: Grouped action specials in DECORATE

by Dark-Assassin » Sun Jan 11, 2015 1:53 pm

I always thought 255 as it's technically the 256'th number.

Re: Grouped action specials in DECORATE

by Graf Zahl » Sun Jan 11, 2015 1:51 pm

dark-slayer-201 wrote:s before an A_Jump(255,"State"); (Obvious)

Obviously you should use 256 instead of 255. :P

Re: Grouped action specials in DECORATE

by Dark-Assassin » Sun Jan 11, 2015 1:45 pm

I feel that any A_Jump should Terminate/Return when successful.
Instead just use If/Else statements with random(0,255) > whatever and additional actions before an A_Jump(255,"State"); (Obvious)

Re: Grouped action specials in DECORATE

by Fishytza » Sun Jan 11, 2015 1:41 pm

Graf Zahl wrote:I never said that. The way this is implemented they are just regular functions.
Hmm. Guess I misunderstood this bit:
Graf Zahl wrote:The scripting language won't allow a goto, it also won't allow A_Jump constructs, but real script syntax instead.
But nevermind that, I've got another question regarding A_Jump*:

Code: Select all

SARG A 5
{
	A_Jump(50, "Roar"); //If A_Jump decides to 'jump', will the rest below still run?
	A_Jump(20, "Snort");
	A_ActiveSound;
	A_Jump(100, "StandForAMoment");
	A_Jump(10, "Fart");
}

Re: Grouped action specials in DECORATE

by Dark-Assassin » Sun Jan 11, 2015 1:23 pm

Code: Select all

BOSS A 0 
{
   A_Jump(256, "AngryMissile") if ( health < 250 ) and random(0,100) <= 75;
   A_Jump(256, "SuperMegaUltimateMissile") unless random(0,100) >= 10 or ( health < 100 );
   A_Jump(256, "Missile");
}
Just throwing it out there. More of a Perl like alternative 1 liner If syntax. And can be &&, Or can be ||
But, maybe just ignore me. Especially since it's not C like. But I find it better than the non bracketed, new lined C like If/Else system;

Re: Grouped action specials in DECORATE

by Graf Zahl » Sun Jan 11, 2015 1:16 pm

I never said that. The way this is implemented they are just regular functions.

Re: Grouped action specials in DECORATE

by Fishytza » Sun Jan 11, 2015 12:55 pm

Major Cooke wrote:So you could do this:

Code: Select all

POSS G 3
{
   if (health > 1)
      A_Jump(256,"Alive") //Or perhaps Goto Alive could work?
   else
      A_Jump(256,"Dead") //Or perhaps Goto Dead could work?
}
I don't think so. Didn't Randi say that braces for if statements are absolutely mandatory?

EDIT: Quick question. Are A_Jump* functions (when used in "grouped action functions") still going to work?
IE will something like this work?


EDIT2: Meh. I just remembered Graf saying that A_Jump and co. aren't allowed.

Re: Grouped action specials in DECORATE

by NeuralStunner » Sun Jan 11, 2015 11:45 am

Since Goto is not a frame action, I don't see a reason for it to work as part of a frame.

Re: Grouped action specials in DECORATE

by Major Cooke » Sun Jan 11, 2015 11:21 am

Also, fellas, it appears for a single action it doesn't need braces.

Code: Select all

    // If it's not a '{', then it should be a single action. 
    // Otherwise, it's a sequence of actions.
    if (!sc.Compare("{"))
    {
        tcall->Code = ParseAction(sc, state, statestring, bag);
        return;
    }
So you could do this:

Code: Select all

POSS G 3
{
	if (health > 1)
		A_Jump(256,"Alive") //Or perhaps Goto Alive could work?
	else
		A_Jump(256,"Dead") //Or perhaps Goto Dead could work?
}
Except I dont know if gotos are allowed like that. Randi, does that seem like something which would work?

Oh man I'm excited to see this put into the main branch. :D

Re: Grouped action specials in DECORATE

by Major Cooke » Sat Jan 10, 2015 3:15 pm

Thank god for that, that's one thing I never enjoyed when programming within ZDooM's source code.

Top