Gamestudio Links
Zorro Links
Newest Posts
Lapsa's very own thread
by Lapsa. 06/26/24 12:45
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 833 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Mino, squik, AemStones, LucasJoshua, Baklazhan
19061 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: follow an action [Re: Xarthor] #78673
06/19/06 22:25
06/19/06 22:25
Joined: May 2005
Posts: 222
T
tek Offline OP
Member
tek  Offline OP
Member
T

Joined: May 2005
Posts: 222
This is the code I colored the important parts.

var snakemorph = 0;

Entity* snakebod;

function headhit // only do this upon impact!{my.invisible=on;}
{
my.invisible=on;
ent_morph (snakebod, "snakedead.mdl");
bestill=1;
}

action snakehead
{

// 1 is up, -1 is down
my.health=20;
my.gegner=on;
var direction = 1;
var speed = 1;
my.enable_entity=on;
my.enable_impact=on;
MY.EVENT=headhit;

while (1)
{
walk_percent=(walk_percent+5*time)%100;
ent_animate(me,"walk",walk_percent,ANM_CYCLE);

// move ball in the right direction
my.x -= direction * speed;

// change direction if obstacle is in the way

vec_set(temp,my.x);
temp.z+=direction * speed;
trace_mode = IGNORE_ME;


if (trace(my.x, temp) != 0)
{
direction *= -1;
}
wait(1);
}
}

action snakebody
{

snakebod=me; // assign entity snakebod to this models action

// 1 is up, -1 is down
my.health=20;
my.gegner=on;
var direction = 1;
var speed = 1;

while (bestill==0)
{
walk_percent=(walk_percent+5*time)%100;
ent_animate(me,"walk",walk_percent,ANM_CYCLE);

// move ball in the right direction
my.x -= direction * speed;

// change direction if obstacle is in the way

vec_set(temp,my.x);
temp.z+=direction * speed;
trace_mode = IGNORE_ME;

while (bestill==0)
{

my.enable_impact=on;
my.event=lev_2_event;
break;
}

if (trace(my.x, temp) != 0)
{
direction *= -1;
}
wait(1);
}
}



This is the image what I did was made the whole scorpion in the snake body and for the snake head I made an invisible block so when I jump on the snake head the snake body turns upside down.
btw I know it's not a snake but a scorpion, at first I started to make a snake but decided a scorpion.

Last edited by tek; 06/19/06 22:44.
Re: follow an action [Re: tek] #78674
06/19/06 22:41
06/19/06 22:41
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
I made some changes, but this code is not tested but should just work the same way as before.

Question: bestill is a defined var somewhere? Better solution would be to use a flag or a skill to do this job.
Code:

var snakemorph = 0;

Entity* snakebod;

function headhit // only do this upon impact!{my.invisible=on;}
{
my.invisible=on;
ent_morph (snakebod, "snakedead.mdl");
bestill=1;
}

action snakehead
{
// 1 is up, -1 is down
my.health=20;
my.gegner=on;
var direction = 1;
var speed = 1;
my.enable_entity=on;
my.enable_impact=on;
MY.EVENT=headhit;

while (!bestill)
{
walk_percent=(walk_percent+5*time)%100;
ent_animate(me,"walk",walk_percent,ANM_CYCLE);

my.x -= direction * speed;

vec_set(temp,my.x);
temp.z+=direction * speed;
trace_mode = IGNORE_ME;

if (trace(my.x, temp) != 0)
{
direction *= -1;
}
wait(1);
}
my.enable_entity=off;
my.enable_impact=off;
MY.EVENT=null;
}

action snakebody
{
snakebod=me; // assign entity snakebod to this models action

// 1 is up, -1 is down
my.health=20;
my.gegner=on;
var direction = 1;
var speed = 1;

my.enable_impact=on;
my.event=lev_2_event;

while(!bestill)
{
walk_percent=(walk_percent+5*time)%100;
ent_animate(me,"walk",walk_percent,ANM_CYCLE);

// move ball in the right direction
my.x -= direction * speed;

// change direction if obstacle is in the way

vec_set(temp,my.x);
temp.z+=direction * speed;
trace_mode = IGNORE_ME;

if (trace(my.x, temp) != 0)
{
direction *= -1;
}
wait(1);
}

my.enable_impact = off;
my.event = null; //MAKE THE SNAKE UNSENSIBLE FOR IMPACTS
}



Re: follow an action [Re: Xarthor] #78675
06/19/06 23:06
06/19/06 23:06
Joined: May 2005
Posts: 222
T
tek Offline OP
Member
tek  Offline OP
Member
T

Joined: May 2005
Posts: 222
cool, thanks the code worked.

Page 2 of 2 1 2

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