4 random triggers,and a pawn as a pickup .

Topics regarding Scripting with Reality Factory
Post Reply
Veleran
Posts: 891
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

4 random triggers,and a pawn as a pickup .

Post by Veleran » Sun Aug 17, 2008 4:23 pm

1.Lets say you have a chest and when it opens it sets a trigger on before fading out.
It chooses randomly one from four triggers.
example:Trigger1 is fireball,2 for treasure,3 for health potion,4 is for dart trap.

I have the chest script but i dont know what to add in for the triggers event.

The "Open" order is the part in which i want to add the 4 random triggers instead of the
SetEventState command.

{
Spawn[ ()
{
Console(false);
BoxWidth(44); // set bounding box width/depth
AttributeOrder("health", 20, "Open");
} ]

Wait[ ()
{
PlaySound("");
} ]

Open[ ()
{
AnimateStop("Open","2","creak1.wav");
SetEventState("Chest1Trigger", true);
SetNoCollision();
FadeOut(1,0);
Remove(true);
} ]

}


2. And i would like to ask if you want a pawn to spawn an attribute item next to it when it gets destroyed:
I guess there is no way to spawn the attribute entity near the point each pawn was killed.

So the way must be propably a pawn that will act as the gold,which will be positioned next to the dying pawn some texels up on the air-with gravity on,to seem like it has fallen from the pawn.


I will not use this script yet,but i wanted to know if its going to work anyway.
Few years ago i had trouble switching between high and lowlevel orders,as i often got messages in the debug console like-
Unknown method:lowlevel..etc.

----Monsters Gold script----

{
Spawn[ ()
{
Console(false);
BoxWidth(44); // set bounding box width/depth
Gravity("true");
LowLevel("Position");

} ]

Position[ ()
{
PositionToPawn("Grunt_44", 0, 0, 12, false);
HighLevel("Wait");
} ]

Wait[ ()
{
AddCollisionOrder("Givegold");
PlayAnimation("Rotate", "false", "");
RestartOrder();
} ]

Givegold[ ()
{
ModifyAttribute("gold", 100, "Player");
DelCollisionOrder();
Remove(true);
} ]

}

A detail:Is there a way to loop the animation of the wait order without using restart order?
And,do i have to use DelCollisionOrder at the end?

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: 4 random triggers,and a pawn as a pickup .

Post by Juutis » Wed Aug 20, 2008 9:22 am

1.)

Code: Select all

Open[ ()
{
AnimateStop("Open","2","creak1.wav");

switch(random(0,4))
{
case 0
{
SetEventState("trigger1",true);
}
case 1
{
SetEventState("trigger2",true);
}
case 2
{
SetEventState("trigger3",true);
}
case 3
{
SetEventState("trigger4",true);
}
case 4
{
SetEventState("trigger1",true);
}
}

SetNoCollision();
FadeOut(1,0);
Remove(true);
} ]

2.) Using a different pawn for the gold would basically double the amount of pawns you have. And that's not something you want to do. I'd use an effect like spray or actorspray for the visuals and use the enemy script to give the gold to the player. So after dying the enemy pawn would go to a state something like in your gold script checking if the player is near enough and then giving the gold.
Pain is only psychological.

Post Reply