Vehicle Mode Demo

DCurrent

Site Owner, OpenBOR Project Leader
Staff member
As requested by White Dragon, this is a very, VERY old demo of how you could make vehicle riding modes once upon a time. It's so simple though that ugly code aside you can still make some use of it today for a straight forward ride/run/whatever mode. Keep in mind though, it IS outdated, so make sure to ask if this is the right thing for you.


The horse is nothing more than a none type entity with the galloping animation for its idle. It runs the following script on its update event. At the time the only way - and to this day an effective, albeit crude method:

C:
void main()
{
    void self = getlocalvar("self");
    void parent = getentityproperty(self, "parent");
   
   
    float x = getentityproperty(parent, "x");
    float z = getentityproperty(parent, "z");
    float a = getentityproperty(parent, "a");
    changeentityproperty(self, "position", x, z-2, 0);   
   
}

One modification you might try is to bind the Y location to parent entity's base rather than just 0. This would make it dynamically adapt to stages more where the base position isn't 0. Mid stage base changes wouldn't look great, but if things are getting that complex you're progressing beyond a quick and easy solution..

DC
 
I like the way Joe gets on the house again, pretty cool.

About the jump, you said there is another way to do this. How? Its that Sync command?
 
O Ilusionista said:
I like the way Joe gets on the house again, pretty cool.

Thanks!

About the jump, you said there is another way to do this. How? Its that Sync command?

Not exactly, I'll get into that when I have more time to type. In the meantime, just updated with better quality video.

DC
 
void main()
{
    void self = getlocalvar("self");
    void parent = getentityproperty(self, "parent");
   
   
    float x = getentityproperty(parent, "x");
    float z = getentityproperty(parent, "z");
    float a = getentityproperty(parent, "a");
    changeentityproperty(self, "position", x, z-2, 0);   
   
}

in the script it seems the player its spawning the horse
but how do you spawn the horse in the level and then set the "parent" to player

ive made this script but the npc doesn't follow the player he only follows if I spawn him in player spawn animation
name          jonpc
type          npc
subtype      follow
health        99000
nolife       1
speed        12
running       26 3.1 2.6 1 1


onspawnscript @script
void main() {
void self = getlocalvar("self");
int p = getentityproperty(self, "playerindex");
    changeentityproperty(self, "parent", p );
}
@end_script

anim spawn
loop 0
delay 150
offset 101 190
bbox 0 0 0 0
frame data/chars/3johnny/idle03.gif
 
The horse is not a follow NPC - that wouldn't and won't work for this. It's just a visual effect entity manually bound to Joe.

The dog is an NPC, and should give you an idea of how they behave. As for why your NPC won't follow, try spawning it the typical way just to see what happens. I doubt it will work then either. That's because follow behavior is controlled by Range setting in the NPC's IDLE animation. Fix those and you should be good to go.

DC
 
everything is working fine
ive done it like in the manual

jonpc has a range in its idle animation to follow the player
Code:
anim	idle
	loop	1
	delay	14
	offset	101 190
	bbox	85 96 39 91
	range	140 600
	rangez	-55 55
	frame	data/chars/3johnny/idle03.gif
	@cmd	clearL
	frame	data/chars/3johnny/idle04.gif
	frame	data/chars/3johnny/idle05.gif
	frame	data/chars/3johnny/idle04.gif

if I use custentity/spawnframe in the player.txt
jonpc follows the player when there are no enemies on screen

also if I use @cmd spawner "jonpc" 100 0 0 in the player.txt jonpc also follows the player... because the spawner script changes the VSpawn to parent

void spawner(void vName, float fX, float fY, float fZ)
{ //Spawns entity next to caller and set them as child.


void self = getlocalvar("self"); //Get calling entity.
void vSpawn; //Spawn object.

vSpawn = spawn01(vName, fX, fY, fZ); //Spawn in entity.

changeentityproperty(vSpawn, "parent", self); //Set caller as parent.
   
return vSpawn; //Return spawn.
}

I just cant seem to change the parent to player in the jonpc.txt npc ?
 
I got it working
this will make him follow the current player
anim spawn
@script
void self = getlocalvar("self");
int p1 = getplayerproperty(0, "entity");
int p2 = getplayerproperty(1, "entity");
int p3 = getplayerproperty(2, "entity");

if (frame == 1 && p1 != NULL()){
changeentityproperty(self, "parent", p1);
}
else if (frame == 1 && p2 != NULL()){
changeentityproperty(self, "parent", p2);
}
else if (frame == 1 && p3 != NULL()){
changeentityproperty(self, "parent", p3);
}
@end_script
loop 0
delay 15
offset 101 190
bbox 0 0 0 0
frame data/chars/3johnny/idle03.gif
frame data/chars/3johnny/idle03.gif
frame data/chars/3johnny/idle03.gif
frame data/chars/3johnny/idle03.gif
 
Back
Top Bottom