Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,791 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Make an enemy shoot #143103
07/24/07 11:07
07/24/07 11:07
Joined: Jun 2007
Posts: 63
Italy
Sonic220 Offline OP
Junior Member
Sonic220  Offline OP
Junior Member

Joined: Jun 2007
Posts: 63
Italy
How to do in c-script?
I've made this:
Code:
 Action Spawn2
{
my.push=1;
my.polygon=on;
while(my)
{

you=ent_create(bullet,vector(my.x-40,my.y,my.z),shoot_you);
you.passable=off;
wait (3);
}
wait(1);
}


Code:
Function Shoot_you
{
...
...

while(my && Player)
{
c_move(me,vector(shoot_speed*time_step,0,0),nullvector,Ignore_Push );
}

}


But tha game crash(black screen), I don't understand where the error is.
Someone can tell me what script should I use?

Something like: if player is near 200 quants to enemy, the enemy create a bullet.


~Vision Divine~
Re: Make an enemy shoot [Re: Sonic220] #143104
07/24/07 14:05
07/24/07 14:05
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
To create enemy bullet when player is come close enough :
Code:

var shoot_speed = 5;
var pushValue;

function shoot_you()
{
pushValue += 0.1; // prevent bullet hit each other
my.push = pushValue; // reset it if reached certain value
my.skill1 = 100; // bullet life
while(my.skill1 > 0)
{
c_move(my,vector(shoot_speed*time_step,0,0),nullvector,Ignore_Push);
my.skill1 -= 1 * time_step;
wait(1);
}
ent_remove(my);
}

Action Spawn2 // enemy action
{
c_setminmax(my);
while(player==NULL) {wait(1);}
while(my)
{
if (vec_dist(player.x,my.x) < 50)
{
you = ent_create(bullet,vector(my.x-40,my.y,my.z),shoot_you);
you.pan = my.pan;
}
wait(-0.5);
}
}


Just an example.

Re: Make an enemy shoot [Re: vlau] #143105
07/24/07 19:03
07/24/07 19:03
Joined: Jun 2007
Posts: 63
Italy
Sonic220 Offline OP
Junior Member
Sonic220  Offline OP
Junior Member

Joined: Jun 2007
Posts: 63
Italy
It give me an error, when player die, the engine tell me : empy poiner in Spawn2.
why?


~Vision Divine~
Re: Make an enemy shoot [Re: Sonic220] #143106
07/24/07 19:11
07/24/07 19:11
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
Try modify the following code :

Change while(my) to while(player != NULL)

EDIT
----
If it still doesn't work, please post your player codes.


Last edited by vlau; 07/24/07 19:13.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1