Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, Power_P), 1,065 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 3
A few bits of code #54610
09/10/05 14:44
09/10/05 14:44
Joined: Jul 2003
Posts: 1,300
Albury, Australia
James_Burke Offline OP
Serious User
James_Burke  Offline OP
Serious User

Joined: Jul 2003
Posts: 1,300
Albury, Australia
Hi,
Here are a few bits of code I have lying around. Some people might find useful. They're pretty simple, but some people might have some use for them.
Flickering Light
Exploding Barrel

and here's a health and armor code (ready for A5 templates, change to _health__003 and _armor__003 for template 6).

Code:

//=============================
//Health And Armor Pack Code
//---------------
//Created By: James A. Burke
//email: contact@jabigp.com
//=============================
//-----------------------------
//Defines
//-----------------------------
DEFINE _health_val, skill1; //Medical pack value
DEFINE _armor_val, skill1; //Armor pack value

//-----------------------------
//Prototype Functions
//-----------------------------
function healthPackEvent(); //Event called when player collides with a health pack entity
function armorPackEvent(); //Event called when player collides with an armor pack entity

//-----------------------------
//Functions
//-----------------------------
//---------------
//Desc: Gives the player health
//---------------
function healthPackEvent()
{
if(player._health + my._health_val > 100)
{
player._health = 100; //Don't give the player over 100 health
}
if(player._health + my._health_val <= 100)
{
player._health += my._health_val;
}
my.enable_impact = off;
my.event = null;
my.invisible = on;
my.passable = on;
wait(1);
ent_remove(my); //Remove the model
}

//---------------
//Desc: Gives the player armor
//---------------
function armorPackEvent()
{
if(player._armor + my._armor_val > 100)
{
player._armor = 100; //Don't give the player over 100 armor
}
if(player._armor + my._armor_val <= 100)
{
player._armor += my._armor_val;
}
my.enable_impact = off; //Inactive now
my.event = null;
my.invisible = on;
my.passable = on;
wait(1);
ent_remove(my); //Remove the model
}

//-----------------------------
//Actions
//-----------------------------
//---------------
//Desc: Standard health pack
//---------------
//uses: _health_val
action health_pack
{
while(player == null)
{
wait(1); //Prevent empty pointer errors
}
if(my._health_val <= 0)
{
my._health_val = 25; //Give it a default value
}
while(1)
{
if(player != null)
{
if(vec_dist(my.x, player.x) < 100)
{
player._health = 100;
ent_remove(my);
return;
}
}
my.pan += 2 * time; //Rotate the entity
wait(1);
}
}

//---------------
//Desc: Standard armor pack
//---------------
//uses: _armor_val
action armor_pack
{
if(my._armor_val <= 0)
{
my._armor_val = 25; //Give it a default value
}
my.enable_impact = on;
my.event = armorPackEvent;
}



I would also be happy to hear any suggestions for other codes
Hope this helps,
James

Re: A few bits of code [Re: James_Burke] #54611
09/11/05 09:09
09/11/05 09:09
Joined: Jul 2003
Posts: 1,300
Albury, Australia
James_Burke Offline OP
Serious User
James_Burke  Offline OP
Serious User

Joined: Jul 2003
Posts: 1,300
Albury, Australia
Here's another thing I found, a very simple action to add to anything you want physics to. When shot, the physics will be applied and it will go flying off. Note that you will need the Commercial or Professional edition as it uses Conitec's physics engine.
Code:

//=============================
//Shootable Physics Objects
//---------------
//Created By: James A. Burke
//Copyright (c) 2004 - 2005 James A. Burke
//=============================
//-----------------------------
//Variable Defines
//-----------------------------
//-----------------------------
//Prototype Functions
//-----------------------------
function moniter_event(); //Changes the moniter model and physics

//-----------------------------
//Functions
//-----------------------------
//---------------
//Desc; Adds force to the moniter9
//---------------
function moniter_event()
{
my.lightrange = 0;
my.lightred = 0;
my.lightblue = 0;
my.lightgreen = 0;
phent_enable(my, 1);
if(event_type == event_shoot)
{
phent_addforcelocal(my, vector(6000, 0, 0), target);
}
if(event_type == event_impact)
{
phent_addforcelocal(my, vector(6000, 0, 0), target);
}
}


//-----------------------------
//Actions
//-----------------------------
//---------------
//Desc: Makes the shell fall to the ground
//---------------
action moniter
{
my.shadow = on;
my._id = _spark;
phent_settype(my, PH_RIGID, PH_BOX);
phent_setmass(my, 10, PH_BOX);
phent_setfriction(my, 20);
phent_setelasticity(my, 50, 100);
phent_setdamping(my, 50, 75);
ph_setgravity(vector(0,0,-386));
my.enable_shoot = on;
my.enable_impact = on;
my.event = moniter_event;
my.lightrange = 60;
my.lightred = 20;
my.lightgreen = 128;
my.lightblue = 140;
}



Re: A few bits of code [Re: James_Burke] #54612
09/11/05 18:38
09/11/05 18:38
Joined: Sep 2004
Posts: 772
AndrewSwallow Offline
User
AndrewSwallow  Offline
User

Joined: Sep 2004
Posts: 772
any screens of anything?

im quite interested in the barrel and the light

im too busy with other stuff, to test them right now

thanks
andrewds


Northern Aspire : northernaspire.com
Re: A few bits of code [Re: AndrewSwallow] #54613
09/12/05 07:17
09/12/05 07:17
Joined: Apr 2005
Posts: 3,815
Finland
Inestical Offline
Rabbit Developer
Inestical  Offline
Rabbit Developer

Joined: Apr 2005
Posts: 3,815
Finland
nice code, but simple.. hmm I can modify 'em for my use ( *whistles* And I'm not abusing 'em now *whistles again* )


"Yesterday was once today's tomorrow."
Re: A few bits of code [Re: AndrewSwallow] #54614
09/12/05 08:57
09/12/05 08:57
Joined: Jul 2003
Posts: 1,300
Albury, Australia
James_Burke Offline OP
Serious User
James_Burke  Offline OP
Serious User

Joined: Jul 2003
Posts: 1,300
Albury, Australia
Quote:

any screens of anything?

im quite interested in the barrel and the light




Sure, here's a few screens:
Barrel



Light



Physics (not much to show really)


Re: A few bits of code [Re: Inestical] #54615
09/12/05 08:59
09/12/05 08:59
Joined: Jul 2003
Posts: 1,300
Albury, Australia
James_Burke Offline OP
Serious User
James_Burke  Offline OP
Serious User

Joined: Jul 2003
Posts: 1,300
Albury, Australia
Quote:

nice code, but simple.. hmm I can modify 'em for my use ( *whistles* And I'm not abusing 'em now *whistles again* )




Hope they are of some use to you Unfortunetly the better more advanced codes aren't free If you (or anyone) does want some specific code (for cheap) you can contact us (www.jabigp.com)


Moderated by  adoado, checkbutton, mk_1, Perro 

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