Open Surge Forum

A fun 2D retro platformer inspired by Sonic games and a game creation system

You are not logged in.

Announcement

Our community has moved to Discord! https://discord.gg/w8JqM7m

#1 2010-12-23 06:05:28

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,270
Website

Game AI: Follow the Leader

Follow the Leader

(needs 0.2.0, bleeding edge 373 or greater)

I wanted to try out some of the new commands of the scripting engine, so I came out with this.

Download: http://upload.surgeswarehouse.com/uploa … leader.zip

s070.png

// ------------------------------------------------------------
// Follow the Leader
// This object needs Open Surge 0.2.0 revision 373 or greater
// http://opensnc.sourceforge.net
// ------------------------------------------------------------

> 1 Changelog

Version 1.0 by Alexandre (2010-12-22): initial release

If you're able to improve this object, please share
you improvements with the community!
http://opensnc.sourceforge.net/forum


> 2 Description

This object makes the non-active characters follow the leader. The AI is a simple
finite state machine. This is an interesting object for wide-open levels, but
it may not be appropriate for levels with too many obstacles (unless someone
makes this AI more accurate ;-)


> 3 How to use it

Spawn an ***UNIQUE*** instance of ".Follow_The_Leader" in your level. An easy way to do
this is to add .Follow_The_Leader to the startup list. Open your .lev file with a text
editor and locate a line starting with startup. Replace it by:

startup ".default_startup" ".Follow_The_Leader"

If no such line exists, please add it.


> 4 Advanced scripting

If you wish to disable the Follow the Leader mode during your level, you must
destroy the object. To do it, make some object run the following command:

change_closest_object_state ".Follow_The_Leader" "destroy"

Needlessly to say, you can enable/disable the Follow the Leader mode whenever you
want via scripting.


> 5 How does it work

We make an assumption: there is always three characters in your level: Surge,
Neon and Charge.

.Follow_The_Player spawns three other objects: a master and two slaves. The master
will get attached to the leading character and will share important data like
the position of the active player via global variables. On the other hand, the
two slaves will get attached to the other two characters and will perform some logic
in order to make it follow the leading character.

Offline

#2 2010-12-23 07:06:35

jobromedia
Member
From: Stockholm, Sweden
Registered: 2009-11-01
Posts: 1,072
Website

Re: Game AI: Follow the Leader

Very impressive!

Offline

#3 2010-12-23 14:10:33

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

Re: Game AI: Follow the Leader

RPG style smile i like it


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#4 2010-12-23 15:55:34

SilverstepP
Member
From: North Carolina
Registered: 2009-07-31
Posts: 1,545

Re: Game AI: Follow the Leader

o.o

I like this.

But... I don't like how the other characters get hurt spontaneously and lose every ring. Can we just say something like 'half their rings get lost' or something?

Offline

#5 2010-12-23 16:19:26

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,270
Website

Re: Game AI: Follow the Leader

SilverstepP wrote:

Can we just say something like 'half their rings get lost' or something?

No. At least, not via the approach we're using: controlling the players with simulate_button_down.

edit: hmm, wait.

1) store the current amount of rings
2) on_player_hit => jump to state recovery
3) state recovery => set rings to the half of the previous amount

...though a lot of rings would still be created

Last edited by Alexandre (2010-12-23 16:21:46)

Offline

#6 2010-12-23 19:05:09

Race the Hedgehog
Member
From: Sao Bernardo do Campo, Brazil
Registered: 2010-12-16
Posts: 163
Website

Re: Game AI: Follow the Leader

Very Coll! smile big_smile lol
Sonic Heores style!! cool


PunBB bbcode test
Creating and Editing Sprites.

Offline

#7 2011-01-04 21:52:53

J0nnJ0nes
Member
Registered: 2010-05-19
Posts: 180

Re: Game AI: Follow the Leader

SWEET! big_smile Oh, I wish I had the time to learn the engine inside and out (and the time for so many things, in fact)... patience is a virtue, and a really portable computer is a godsend due soon!

This opens up so many doors... roll

Offline

#8 2020-05-30 00:11:37

CrazyPencilDawg
Member
From: Kingston, ON
Registered: 2018-10-12
Posts: 47

Re: Game AI: Follow the Leader

Can you copy-paste the code and put it in a post?


I'm making a game about a blue cartoon rat. I must have made some terrible life choices.
icon-medallion.gif

Offline

#9 2020-05-30 01:21:10

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,270
Website

Re: Game AI: Follow the Leader

This post is very old now. At this point, it's better to recreate it in SurgeScript.

Offline

#10 2021-07-13 00:07:07

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,270
Website

Re: Game AI: Follow the Leader

I have found this script among old files. I'm reuploading it for historical purposes.

Download script

This is from 2010 - long before SurgeScript came into being - and no longer works with new versions of Open Surge. It's still useful as inspiration. Experiment it with early builds of Open Surge 0.2.0.

Offline

Board footer

Powered by FluxBB  hosted by tuxfamily.org