RANDOMNESS

Non-platform specific questions.

RANDOMNESS

Postby BlarghNRawr » Sat Sep 27, 2008 12:34 am

how can i make an actor have a rand om animation?

and also... how can i make items randomly appear on a random part of the stage, and only when ur in a battle (not just in the menu)
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score

Re: RANDOMNESS

Postby Rux » Sat Sep 27, 2008 3:49 pm

.......... I'll give you a code for random things to happen. What it does is when ever an event happens a int variable is set and read to see what actions the game needs to perform.

Code: Select all
int n;
n = rand(*put how many different actions you want here* 2)
if(n==0)Action;//Always start with zero for 1\\
if(n==1)Action;


This will make a random action every time the event happens. :wink:
I also made a demo a while ago.
Hope this helps!
Attachments
RandomZip.zip
The Random Demo
(84.8 KiB) Downloaded 114 times
I'm not good at coming up with signatures...
User avatar
Rux
 
Posts: 645
Joined: Sun Apr 29, 2007 9:26 pm
Location: Sitting on your moniter invisable.
Score: 35 Give a positive score

Re: RANDOMNESS

Postby BlarghNRawr » Sat Sep 27, 2008 4:28 pm

what will this do?
make things appear at random, or give somethig a random animation?
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score

Re: RANDOMNESS

Postby DilloDude » Sat Sep 27, 2008 9:37 pm

For a random animation, on some event (eg create actor), use:
Code: Select all
int anim = rand(nAnims);//change nAnimns to the number of animations you want to choose from
//if you want to choose between all the anims, or just the first few, you can use this:
ChangeAnimation("Event Actr", getAnimName(anim), FORWARD);

//or if you want the last few, or a group in the middle, use this:
ChangeAnimation("Event Actr", getAnimName(anim + value), FORWARD);//change value to the frame number of the first frame you're using

//if you want to choose from a collection of animations, not all together, yuo have to do it manually:
switch(anim)
{
    case 0: ChangeAnimation("Event Actor", "someAnimation", FORWARD); break;
    case 1: ChangeAnimation("Event Actor", "someOtherAnimation", FORWARD); break;
    case 2: ChangeAnimation("Event Actor", "thisHereAnimation", STOPPED); break;
    ...
}
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: RANDOMNESS

Postby BlarghNRawr » Sat Sep 27, 2008 9:39 pm

ok thnx
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score

Re: RANDOMNESS

Postby supa-tails » Tue Oct 07, 2008 12:59 am

How do I make an animation choose randomly at the create actor? For example, right when an actor is created it randomly chooses 1 out of 10 animations and stays that way.
................................................................................................ www.freewebs.com/thebiverse .....................................................................................




c'ya on the other side
User avatar
supa-tails
 
Posts: 269
Joined: Fri Jul 27, 2007 3:03 pm
Location: In an aliens tummy... Or in cumming Georgia USA
Score: 17 Give a positive score

Re: RANDOMNESS

Postby BlarghNRawr » Tue Oct 07, 2008 1:54 am

.
Last edited by BlarghNRawr on Sat Nov 15, 2008 3:00 am, edited 1 time in total.
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score

Re: RANDOMNESS

Postby Bee-Ant » Sat Nov 15, 2008 7:51 pm

supa-tails wrote:How do I make an animation choose randomly at the create actor? For example, right when an actor is created it randomly chooses 1 out of 10 animations and stays that way.

AnyActor>CreateActor>
Code: Select all
animindex=rand(10);
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: RANDOMNESS

Postby Lexcondran » Sun Nov 16, 2008 8:32 pm

i think that thing is very weird as i said f his mom and it said yes over and over again lol
i said he is stupid and it says rux is sitting on my computer alot
then i say moo and it talks about cleaning up a puddle
http://www.mediafire.com/?e4zzycilztdm1qm =My RPG APP FILE V. 3.0 {7/15/2010}
http://www.mediafire.com/?tjjmmmkzyga =My editable demo of my Rpg for people V2.3
viewtopic.php?f=6&t=10247 =Link to my RPG's (4.0) Topic =]
User avatar
Lexcondran
 
Posts: 230
Joined: Thu Jul 31, 2008 6:09 pm
Location: Tucson, Arizona, USA
Score: 8 Give a positive score

Re: RANDOMNESS

Postby BlarghNRawr » Wed Mar 18, 2009 4:34 pm

T_T
srry i have a HUGE problem with rand...
it really doesnt like me

i know this sounds terrible, but, more depth please... ACK!
ive never had to say that in a long time
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score

Re: RANDOMNESS

Postby skydereign » Thu Mar 19, 2009 12:41 am

You could always do it like this. Didn't read much into the topic, but I believe this is what you want.
Item->CreateActor->Script Editor
Code: Select all
int random = rand(2);
switch (random)
{
    case 0:
    //ChangeAnimation to actor's first animation
    break;
    case 1:
    //ChangeAnimation to actor's second
    break;
}

The problem with animindex=rand(10) is that animindex is a read only variable. So you would need to do it manually like the switch above. If you don't get rand, it picks a random integer from 0 to 1 below your desired number.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: RANDOMNESS

Postby Diana Kennedy » Thu Mar 19, 2009 11:16 pm

I must say, I have the same Problem. I would like to make animatons happen randomly triggered by an event or so, but none of the codes above work. When you don't have any notion of scripting you don't know what exactly to copy from given codes and what not.

Okay, let's say We have two actors: One is named "Dragon" and the other "Ghost" I would like Dragon to change to a randomly choosen animation after colliding with Ghost. what would the script be, I mean entirely (and without Slash commentaries) just as We should type it into the script editor after choosing "collision" select an action?

The next step would be that Ghost reacts with his own animations depending on which animation was choosen by Dragon. Lets say: Dragon chose the animation "bite" then Ghost should change its animation to "jump".

You probably see what I want to build: fighting scenes that can't be predicted.
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Re: RANDOMNESS

Postby skydereign » Thu Mar 19, 2009 11:34 pm

Okay, I'll try my best to make this clear.
Dragon->Collide(Ghost)->Script Editor
Code: Select all
int RAND = rand(2);
switch (RAND)
{
    case 0:
    ChangeAnimation("Event Actor", "Bite", FORWARD;
    ChangeAnimation("Collide Actor", "Jump", FORWARD;
    break;
    case 1:
    ChangeAnimation("Event Actor", "Scratch", FORWARD;
    ChangeAnimation("Collide Actor", "Block", FORWARD;
    break;
}

The two, is the number of animations you want, it picks a random number, 0 or 1, in this case. Then the switch will change the animations according to the number. The dragon will bite, and the ghost will jump. And so on... I suggest commenting your code, it is meant to make it easier to read, the reason I used them in my previous example was I don't know what the ChangeAnimation will change to, as it was not my game. It is to show where the ChangeAnimation will go.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: RANDOMNESS

Postby Diana Kennedy » Fri Mar 20, 2009 10:17 pm

Thank you very much! I will try this out and then give feedback !
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Re: RANDOMNESS

Postby BlarghNRawr » Sat Mar 21, 2009 2:49 pm

thanks :)
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron