Frictional Games Forum (read-only)
repeating+Adding on script looks impossible?! - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: repeating+Adding on script looks impossible?! (/thread-29940.html)



repeating+Adding on script looks impossible?! - Amnesiaplayer - 05-20-2015

I tried some things, with the "cannon" Entity. (custom)
I tried to make it shoot cannonballs, each 3 seconds.
with the script:

void BallShoot(string &in asTimer)
{
PlayGuiSound("break_wood_metal", 3);
CreateEntityAtArea("Ball_+i", "cannonball.ent", "Ball_Shoot", true);
AddPropForce("Ball_+i", 0, 0, -1000000, "world");
CreateParticleSystemAtEntity("", "ps_hit_rock.ps", "Ball_Shoot", true);
AddTimer("", 3,"BallShoot");
}

So, what I want, is it creates a Ball, and do some effects.
The problem is, It is called " Ball "
And you need a name for Addpropforce, so I use " Ball " Ofcourse, but the effect is repeating, everytime it creates a new cannonball, the cannonball will have another name, since it is not possible to have 2 entities with the same name.
No, the problem is, if I open the map, It shoots the cannonball (With propforce) and does all the other effects, but after 3 seoconds, it shoots the ball, everything happen EXCEPT addpropforce, meaning the ball just fall down.
How can I make the ball use the "addpropforce" for the whole time..

Quick Explain:
I want a cannon that shoots a cannonball. (repeats after every 3 sec)

I want those things to happen:

PlayGuiSound("break_wood_metal", 3);
CreateEntityAtArea("Ball_+i", "cannonball.ent", "Ball_Shoot", true);
AddPropForce("Ball_+i", 0, 0, -1000000, "world");
CreateParticleSystemAtEntity("", "ps_hit_rock.ps", "Ball_Shoot", true);

The problem:
Let's say the entity is called "Ball" instead of Ball_+i

CreateEntityAtArea("Ball", "cannonball.ent", "Ball_Shoot", true);
AddPropForce("Ball", 0, 0, -1000000, "world");

So, at the first shot of the cannon.
What happens? It creates an entity, called "Ball".
Then, Addpropforce, will Push the heck out of "Ball".
And this needs to repeat after 3 seconds.
BUT then, it creater a "Ball" again, but it is not possible to have 2 entities with the same name, so it creates *I think* "Ball_1" Or something like that, and THEN (this is where the problem comes)
The Addpropforce will add prop force to "Ball"...
So I need to make Addpropforce work with CreateEntityAtArea....


RE: repeating+Adding on script looks impossible?! - Casotime1999 - 05-20-2015

but if you make an area with An AddEntityCollideCallback and you say at the cannon:
if the area matches with the cannon what should you do?
create the timer inside the block:
void OnStart()
{
AddEntityCollideCallback("", "cannon", "cannonshootArea", "ShootCannon", false);
}
void ShootCannon(string &in asParent, string &in asChild, int alState)
{
//inside this block you put the timerScript with a name
}
void exTimer(string &in asTimer)
{
if(asTimer=="name")
//AddPropForceScript
//Timer as the ball is turning off
if(asTimer=="name2")
{
//disable ball
//turn off the PropForce put as the coordinates as the cannon
//timer active the ball
}
if (asTimer=="Timeractiveball")
//SetEntityActive("ball", true);
//regive back the addPropForce
//reloop timer1
}
I tried to give a Hint but I think that is all you want(sorry for my bad english)


RE: repeating+Adding on script looks impossible?! - Romulator - 05-20-2015

Just a heads up;
+i works with a "For Loop".

Code:
For i = 1 < 10
Create "ball_"+i
Next

In this simple 3 line pseudocode, it creates a ball starting at one until nine, each being called ball_1, ball_2 etc. Because I have the +i and the For Loop, then we have declared what "i" should be.

Be careful as well when it comes to performance. While a cannonball is just a round, low quality object, having many of them can be pretty draining.


RE: repeating+Adding on script looks impossible?! - Daemian - 05-21-2015

Using one ball I would do like this:

PHP Code:
void BallShoot(string &in asTimer)
{
ResetProp("Ball");
PlayGuiSound("break_wood_metal"3); 
AddPropForce("Ball"00, -1000000"world");
CreateParticleSystemAtEntity("""ps_hit_rock.ps""Ball_Shoot"true);
AddTimer(""3,"BallShoot");




RE: repeating+Adding on script looks impossible?! - Amnesiaplayer - 05-21-2015

(05-21-2015, 12:47 AM)Daemian Wrote: Using one ball I would do like this:

PHP Code:
void BallShoot(string &in asTimer)
{
ResetProp("Ball");
PlayGuiSound("break_wood_metal"3); 
AddPropForce("Ball"00, -1000000"world");
CreateParticleSystemAtEntity("""ps_hit_rock.ps""Ball_Shoot"true);
AddTimer(""3,"BallShoot");


So it shoots a ball, and after 3 seconds, the ball disappear, and it will happen again???> And it will shoot again?


RE: repeating+Adding on script looks impossible?! - Mudbill - 05-21-2015






RE: repeating+Adding on script looks impossible?! - Daemian - 05-21-2015

yep. n.n


RE: repeating+Adding on script looks impossible?! - Amnesiaplayer - 05-22-2015

(05-21-2015, 05:19 PM)Mudbill Wrote:


lol xD