Project X Forums
http://px.worms2d.info/forum/

Sample script for new engine
http://px.worms2d.info/forum/viewtopic.php?f=5&t=3
Page 1 of 1

Author:  Entuser [ Mon Aug 17, 2009 12:39 pm ]
Post subject:  Sample script for new engine

Here is sample script of new oildrum for new scripting engine :

Code:

require default;

CNewDrum : COilDrum;      //this line declares CNewDrum class from COilDrum (explosive oil drum thingies)

CNewDrum::CNewDrum(CObject* parent, fixed x, fixed y)    //constructor of CNewDrum
{
  super(parent->Store->GetObject(25, 0), x, y, false);        //GetObject(25, 0) returns parent object for all environment objects (mines, oil drums...)
  fds = new CFireDesc;                                                  //will be used later in the script
};

void CNewDrum::Explosion()
{
   DoExplosion(1, PosX, PosY, 100, 88, 0, OwnerTeam);              //triple explosion
   DoExplosion(1, PosX, PosY - 55, 100, 80, 0, OwnerTeam); 
   DoExplosion(1, PosX, PosY - 88, 100, 75, 0, OwnerTeam); 

  fds->X = PosX;                                //flame parameters
  fds->Y = PosY;
  fds->Count = 24;
  fds->UnkB = 1;
  fds->Duration = 5000;
  fds->UpPower = 100;
  fds->Damage = 15;
  fds->OwnerTeam = OwnerTeam;
  fds->SpY = -3;
  fds->SpX = -3;
 
  local fire = new CFire(fs, fds, 0);
};

void CNewDrum::Render()           //replaces original drum render function
{
  local sn = (4 * Dmg) / 50;        //sn is the sprite index
  if (sn > 3) sn = 3;
  AddSpriteEx(16, PosX, PosY, sn + 110, GS->Tick / 50.0, 0, 1.2);  //1.2 is scale
};

void newdrum::Init()                  //newdrum is the script's name
{
  local nd = new CNewDrum(Env->Objs.Objs[0], 100, 0);               //put CNewDrum in point 100, 0
};
 


no "idk" anymore :D

Author:  Gran PC [ Fri Oct 09, 2009 5:50 pm ]
Post subject:  Re: Sample script for new engine

Entuser, I don't think "idk" would compile. :D

Author:  kellykel [ Sun Oct 11, 2009 3:15 pm ]
Post subject:  Re: Sample script for new engine

Why are you showing us the script without showing us a video? Hehe.

Author:  Gran PC [ Mon Oct 12, 2009 9:59 am ]
Post subject:  Re: Sample script for new engine

Video coming soon. It will be footage of Realtime Worms, but scripting dosen't work there yet.

Author:  kellykel [ Mon Oct 12, 2009 8:29 pm ]
Post subject:  Re: Sample script for new engine

OK do key artichoke!

Author:  diego [ Sat Jan 23, 2010 4:47 pm ]
Post subject:  Re: Sample script for new engine

Nice! I'm glad to see the new script engine is c++ based.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/