|
3 registered members (Quad, EW_bytes, ukgamer),
24,349
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Sentry
#139135
07/02/07 06:39
07/02/07 06:39
|
Joined: May 2007
Posts: 185 Netherlands
SurudoiRyu
OP
Member
|
OP
Member
Joined: May 2007
Posts: 185
Netherlands
|
Hi there,
Im in need of help again >.< I want to create a sentry gun but don't know if it is correct what i am doing.
Look at this please:
If the player is in vision-range { sentry x,y goes to players x,y slowly (i think something with *time) While the sentry looks to player x,y { Ent_create bullet towards player sound_play shoot wait(1 sec.) } }
The script must detect if player is in range at his angle, when he is, the sentry must shoot at him till player is out of range again or doesn't see the player.
Does this look right ?
Thnx in advance
-The Dragon's Eye is alway's watching you!-
|
|
|
Re: Sentry
[Re: Nems]
#139137
07/02/07 08:17
07/02/07 08:17
|
Joined: May 2006
Posts: 69 Canada
Leaf
Junior Member
|
Junior Member
Joined: May 2006
Posts: 69
Canada
|
if(my.clipped != on && vec_dist(my.x,player.x) <= 200) //200 or whatever distance
{
player.health -= 1*10 //10 damage, you can adjust wait(1000) //wait 1000m/s u ntil damage is give again }
add wahtever partical effect in there, just have it last a few frames
Hi NEMS >.<
Edit: just read about angle
Last edited by Leaf; 07/02/07 08:20.
|
|
|
Re: Sentry
[Re: Nems]
#139138
07/02/07 08:19
07/02/07 08:19
|
Joined: May 2007
Posts: 185 Netherlands
SurudoiRyu
OP
Member
|
OP
Member
Joined: May 2007
Posts: 185
Netherlands
|
Hmm ok, what this does ? vec_set (temp.x, my.x); vec_sub (temp.x, you.x); vec_to_angle (you.pan, temp.x); Is that so that de turret slowly turns facing the player ? what i have now is when im in range (even when im behind it) it faces me in <1 sec. without slowly rotating >.< very ugly  I want it to slowly face me (and when im behind it must nog detect me)
-The Dragon's Eye is alway's watching you!-
|
|
|
Re: Sentry
[Re: SurudoiRyu]
#139139
07/02/07 08:21
07/02/07 08:21
|
Joined: Mar 2007
Posts: 776 Poor village - Poland ;)
tompo
User
|
User
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
|
Use c_scan and remember to set my.enable_scan = on; not testet, but something like this: Code:
function sentry_fun { while(me) { if(c_scan(me,my.pan,vector(120,40,500),ignore_me | SCAN_ENTS) ==1) && (you == player) //if player is in range and pan { c_trace(my.x,player.x,ignore_me | ignore_passable); if(result != 0) && (you == player)//if nothing is between player and sentry { vec_set(temp,player.x); vec_sub(temp,my.x); vec_to_angle(my.pan,temp); //look at player fire(); // another function with fire, sound, particle... etc } } wait(1); } }
Last edited by tompo; 07/02/07 08:22.
Never say never.
|
|
|
Re: Sentry
[Re: SurudoiRyu]
#139140
07/02/07 08:26
07/02/07 08:26
|
Joined: May 2006
Posts: 69 Canada
Leaf
Junior Member
|
Junior Member
Joined: May 2006
Posts: 69
Canada
|
ACTION sentry_gun {
if(my.clipped != on && vec_dist(my.x,player.x) <= 200) //200 or whatever move to player distance
{ my.x == player.x+1; my.y == player.y+1; my.z == player.z+1; wait(1); } while{ if(my.clipped != on && vec_dist(my.x,player.x) <= 50)//shoot at 50 {
player.health -= 1*10 //10 damage, you can adjust wait(1000); //wait 1000m/s u ntil damage is give again } } }
Last edited by Leaf; 07/02/07 08:27.
|
|
|
Re: Sentry
[Re: Leaf]
#139141
07/02/07 08:39
07/02/07 08:39
|
Joined: Mar 2007
Posts: 776 Poor village - Poland ;)
tompo
User
|
User
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
|
to have smooth turning: 1. cut-off lines with: vec_set,vec_sub and vec_to_angle and replace with: vec_diff(temp,player.pos,my.pos); result = vec_to_angle(my_angle,temp); sentry_turnto(my_angle.PAN); 2. add function Code:
function sentry_turnto(angle) { angle = ang(angle - MY.PAN); if (angle > 10) {temp = my._speed;} else{ if(angle < -10){temp = -my._speed;} else{temp = my._speed * angle * 0.1;} } MY.PAN += temp * time_step *2; //playe with this value to turn faster/slower }
3. add at the top of script: var my_angle[3]; define _speed, skill1;
Never say never.
|
|
|
Re: Sentry
[Re: tompo]
#139142
07/02/07 08:44
07/02/07 08:44
|
Joined: May 2007
Posts: 185 Netherlands
SurudoiRyu
OP
Member
|
OP
Member
Joined: May 2007
Posts: 185
Netherlands
|
Haha cool Tompo and others ^-^ Thanks for great help  This helps me alot and learns me alot also ^=^ Im very greatfull Cheers,
-The Dragon's Eye is alway's watching you!-
|
|
|
Re: Sentry
[Re: SurudoiRyu]
#139143
07/02/07 21:26
07/02/07 21:26
|
Joined: May 2007
Posts: 185 Netherlands
SurudoiRyu
OP
Member
|
OP
Member
Joined: May 2007
Posts: 185
Netherlands
|
Hey Tompo, Im trying your code. I get no error's but also nothing happens with the sentry's >.< Can you see what im doing wrong ? Thanks allready, here is my current code: //////////////TURRET AI!!!////////////////////// var my_angle[3]; define _speed, skill1; function sentry_turnto(angle) { angle = ang(angle-my.pan); if(angle>10){temp=my._speed;} else { if(angle<-10){temp=-my._speed;} else{temp=my._speed*angle*01;} } my.pan+=temp*time_step*2; } function sentry_fire() { my.light = on; //just a thing so the function isn't empty  //sound //Shoot //Boom Particle //Player Hit //Flash Screen //Player Takes Damage or evades it } Action Sentry01 { my.ENABLE_SCAN = on; while(!player)&&(!me) { Sentrygun(); wait(1); } } function Sentrygun() { if(c_scan(me,my.pan,vector(120,40,500),ignore_me | SCAN_ENTS)==1)&&(you==player) { c_trace(my.x,player.x,ignore_me | ignore_passable); if(result != 0)&&(you==player) { vec_diff(temp,player.pos,my.pos); result = vec_to_angle(my_angle,temp); sentry_turnto(my_angle.PAN); sentry_fire(); } } wait(1); } /////////////EINDE TURRET AI!!!//////////////////
-The Dragon's Eye is alway's watching you!-
|
|
|
Re: Sentry
[Re: SurudoiRyu]
#139144
07/03/07 07:30
07/03/07 07:30
|
Joined: Mar 2007
Posts: 776 Poor village - Poland ;)
tompo
User
|
User
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
|
First, try to cut-off with "//" vec_diff, result and sentry_turnto and replace wiht the "ugly" code you've have firs, I mean vec_set, vec_sub, vec_to_angle, to check if player is detecting.
Second, have you added to player's action: my.enable_scan =on; my.enable_detect = on; and player = me; ?
Third, maybe change Action Sentry01 to while(me) { if(player ==null){wait(1);} else { here paste sentrygun function } wait(1); }
I'll try test it today and send You working and tested code later. cheers
Never say never.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|