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
1 registered members (TipmyPip), 18,449 guests, and 6 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
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 | 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