Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
repeating+Adding on script looks impossible?!
Amnesiaplayer Offline
Senior Member

Posts: 539
Threads: 105
Joined: Jun 2014
Reputation: 0
#1
repeating+Adding on script looks impossible?!

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....
05-20-2015, 08:23 PM
Find
Casotime1999 Offline
Junior Member

Posts: 23
Threads: 6
Joined: Mar 2015
Reputation: 0
#2
RE: repeating+Adding on script looks impossible?!

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)
05-20-2015, 09:14 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#3
RE: repeating+Adding on script looks impossible?!

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

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.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 05-21-2015, 12:34 AM by Romulator.)
05-20-2015, 11:52 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#4
RE: repeating+Adding on script looks impossible?!

Using one ball I would do like this:

PHP Code: (Select All)
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");


05-21-2015, 12:47 AM
Find
Amnesiaplayer Offline
Senior Member

Posts: 539
Threads: 105
Joined: Jun 2014
Reputation: 0
#5
RE: repeating+Adding on script looks impossible?!

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

PHP Code: (Select All)
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?
(This post was last modified: 05-21-2015, 05:16 PM by Amnesiaplayer.)
05-21-2015, 05:14 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#6
RE: repeating+Adding on script looks impossible?!




(This post was last modified: 05-21-2015, 05:20 PM by Mudbill.)
05-21-2015, 05:19 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#7
RE: repeating+Adding on script looks impossible?!

yep. n.n

05-21-2015, 10:20 PM
Find
Amnesiaplayer Offline
Senior Member

Posts: 539
Threads: 105
Joined: Jun 2014
Reputation: 0
#8
RE: repeating+Adding on script looks impossible?!

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


lol xD
05-22-2015, 12:14 PM
Find




Users browsing this thread: 1 Guest(s)