Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/06/23 11:29
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
7 registered members (fairtrader, Quad, miwok, Martin_HH, AndrewAMD, alibaba, dpn), 581 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Help me to modify a Script #276694
07/06/09 02:05
07/06/09 02:05
Joined: Mar 2009
Posts: 207
E
Erick_Castro Offline OP
Member
Erick_Castro  Offline OP
Member
E

Joined: Mar 2009
Posts: 207
Hey Guys.

In the AUM 57 the WorkShop 32 is excellent, because the enemy follow the player and find the player using the function C_CONTENT to verify if the area front the enemy is empty and modify the pan if its not.

With that function the enemy can rotate and avoid the obstacle and continue to follow the player.

But the problem is if the player go to a second floor
the enemy can NOT climb the steps.

That is the only one problem that have this excellent script.

But i dont know how to modify it.

Can somebody help me?


The next is the code of the Action



action my_enemy // attach this action to your enemies
{
var idle_percentage = 0;
var run_percentage = 0;
var death_percentage = 0;
var content_right; // tracks the content in front of the player
var content_left; // tracks the content in front of the player
my.polygon = on; // use accurate collision detection
my.health = 100;
my.enable_impact = on; // the enemy is sensitive to impact with player's bullets
my.event = got_shot; // and runs this function when it is hit
my.status = idle; // that's the same thing with my.skill1 = 1; (really!)
while (my.status != dead) // this loop will run for as long as my.skill1 isn't equal to 3
{
if (my.status == idle) // hanging around?
{
ent_animate(my, "stand", idle_percentage, anm_cycle); // play the "stand" aka idle animation
idle_percentage += 3 * time; // "3" controls the animation speed
if (vec_dist (player.x, my.x) < 1000) // the player has come too close?
{
// scanned in the direction of the pan angle and detected the player?
if ((c_scan(my.x, my.pan, vector(120, 60, 1000), ignore_me) > 0) && (you == player))
{
my.status = attacking; // then attack the player even if it hasn't fired at the enemy yet
}
}
}
if (my.status == attacking) // shooting at the player?
{
// the road is clear? then rotate the enemy towards the player
if (c_content (content_right.x, 0) + c_content (content_left.x, 0) == 2)
{
vec_set(temp, player.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan, temp); // turn the enemy towards the player
}
if (vec_dist (player.x, my.x) > 500)
{
vec_set(content_right, vector(50, -20, -15));
vec_rotate(content_right, my.pan);
vec_add(content_right.x, my.x);
if (c_content (content_right.x, 0) != 1) // this area isn't clear?
{
my.pan += 5 * time; // then rotate the enemy, allowing it to avoid the obstacle
}
vec_set(content_left, vector(50, 20, -15));
vec_rotate(content_left, my.pan);
vec_add(content_left.x, my.x);
if (c_content (content_left.x, 0) != 1) // this area isn't clear?
{
my.pan -= 5 * time; // then rotate the enemy, allowing it to avoid the obstacle
}
c_move (my, vector(10 * time, 0, 0), nullvector, glide);
ent_animate(my, "run", run_percentage, anm_cycle); // play the "run" animation
run_percentage += 6 * time; // "6" controls the animation speed
}
else
{
ent_animate(my, "alert", 100, null); // use the last frame from the "alert" animation here
}
if ((total_frames % 80) == 1) // fire a bullet each second
{
vec_for_vertex (temp, my, 8);
// create the bullet at enemy's position and attach it the "move_enemy_bullets" function
ent_create (bullet_mdl, temp, move_enemy_bullets);
}
if (vec_dist (player.x, my.x) > 1500) // the player has moved far away from the enemy?
{
my.status = idle; // then switch to "idle"
}
}
wait (1);
}
while (death_percentage < 100) // the loop runs until the "death" animation percentage reaches 100%
{
ent_animate(my, "deatha", death_percentage, null); // play the "die" animation only once
death_percentage += 3 * time; // "3" controls the animation speed
wait (1);
}
my.passable = on; // allow the player to pass through the corpse now
}


Re: Help me to modify a Script [Re: Erick_Castro] #276729
07/06/09 08:30
07/06/09 08:30
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
Take a look at this:

c_move (my, vector(10 * time, 0, 0), nullvector, glide);

This is from your script. As you see, no vertical force is applied.
To do this, use c_trace as follows:

Insert this at the beginning of the action:

var gravity; // place this below the other "var"s.

Now, above the c_move:

gravity = -c_trace(my.x,vector(my.x,my.y,my.z-4000),IGNORE_ME | USE_BOX)*0.3;

gravity = min(gravity,30);
gravity = max(gravity,-30);

c_move (my, vector(10 * time, 0,gravity), nullvector, glide);


This is very simple gravity, but it makes your enemy climb the stairs.

Re: Help me to modify a Script [Re: the_clown] #276792
07/06/09 13:10
07/06/09 13:10
Joined: Mar 2009
Posts: 207
E
Erick_Castro Offline OP
Member
Erick_Castro  Offline OP
Member
E

Joined: Mar 2009
Posts: 207
The_clown, friend, thanks!
I am testing it and , by now, its works very good!

Re: Help me to modify a Script [Re: Erick_Castro] #276817
07/06/09 16:04
07/06/09 16:04
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
You're welcome.

Re: Help me to modify a Script [Re: the_clown] #276880
07/06/09 21:45
07/06/09 21:45
Joined: Feb 2009
Posts: 2,154
Damocles_ Offline
Expert
Damocles_  Offline
Expert

Joined: Feb 2009
Posts: 2,154
I have seen many movecodes, they often had problems with
getting stuck at "bumbs" in the floor, or problems to
jump / slide on steep surfaces.


Those movecodes treat the player as a "collision box" covering the whole body, and try to move the player with one single move per frame.
This is like moving a stiff clothes-drawer with a single push.
It will get stuck easily.
Treat the legs of the player as a flexible part (which they are in humans)

Dont move your player with just one move, but rather with
3 to 4 seperate movements:

1-Move the player up (at about half the body hight) whenever the
player is standing on the ground. If not skip this.

2-move the player forward (with the current "forward-speed")

3-Move the player down (half the body hight again, skip if
also skipped 1)

4-move the player down by the curretn gravitational
accelerated speed.

This way the player will smoothly move over obstacles
on the ground, and still have the gravitational force.

Jumping is like applying a negative force to gravitation,
that fades, and should only be possible when the player
is on the ground at the time of jump.

Re: Help me to modify a Script [Re: Damocles_] #276897
07/06/09 23:05
07/06/09 23:05
Joined: Mar 2009
Posts: 207
E
Erick_Castro Offline OP
Member
Erick_Castro  Offline OP
Member
E

Joined: Mar 2009
Posts: 207
Damocles. Thank you for your words.
Do you have an example that move the enemy and climb the stairs in four Steps?

Thank you

Re: Help me to modify a Script [Re: Erick_Castro] #276898
07/06/09 23:09
07/06/09 23:09
Joined: Mar 2009
Posts: 207
E
Erick_Castro Offline OP
Member
Erick_Castro  Offline OP
Member
E

Joined: Mar 2009
Posts: 207
The Clown

my friend, the code works good but the feet looks "buried" in the floor.

frown

Re: Help me to modify a Script [Re: Erick_Castro] #276905
07/07/09 00:09
07/07/09 00:09
Joined: Feb 2009
Posts: 2,154
Damocles_ Offline
Expert
Damocles_  Offline
Expert

Joined: Feb 2009
Posts: 2,154
look up my player-movecode in the "companion ai" thread.
Its using a movecode like this.

Re: Help me to modify a Script [Re: Damocles_] #276962
07/07/09 09:28
07/07/09 09:28
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
To remove the sinking feet, change the c_move:

c_move (my, vector(10 * time, 0,gravity+20), nullvector, glide);


Tweak the red number until it fits your needs.


Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | 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