Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, 1 invisible), 1,211 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Adding my own code to templates #254863
03/06/09 00:17
03/06/09 00:17
Joined: Dec 2008
Posts: 56
B
binsky33333 Offline OP
Junior Member
binsky33333  Offline OP
Junior Member
B

Joined: Dec 2008
Posts: 56
Hi everyone,
I just have a real quick question about the template system. When i use the walkthrough project game template, can i add my own code to it? I already know that i would just copy the files over to my game directory for editing. I have already tried putting some code in, but it hasnt worked.

Re: Adding my own code to templates [Re: binsky33333] #254865
03/06/09 00:51
03/06/09 00:51
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
You can add your own code for sure!
The difficult part is to combine it with the existing code of the template and to avoid that it collides with the code of the template.

It is easier to combine a code with a code that you are familiar with, that's why many programmers tend to rely on their own code only.

Re: Adding my own code to templates [Re: Pappenheimer] #254866
03/06/09 01:09
03/06/09 01:09
Joined: Dec 2008
Posts: 56
B
binsky33333 Offline OP
Junior Member
binsky33333  Offline OP
Junior Member
B

Joined: Dec 2008
Posts: 56
Thanks a ton for your reply! What i am trying to do is setup a health and ammo system. I already have it so you can pick up a med kit and it will add X amount of health to your health... Though in the template when i add my health system code, it doesnt work. What i do is first i make a skill.

DEFINE HEALTH, skill1;

Then at the p1biped action i add
// uses:HEALTH
Then go into my WED and set the health skill to 50.
Then i setup my digits so the code is: digits (370, 200, 5, *, 1, player.health);
But then when i run the script, the digit displays 0, shouldnt it be displaying 50?


Also one more question!
Whenever i create an empty script and then add the door script, the doors never work, but they work when i add the door function to a template.


Last edited by binsky33333; 03/06/09 01:31.
Re: Adding my own code to templates [Re: binsky33333] #254870
03/06/09 02:30
03/06/09 02:30
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
search through the used scripts for skill1, to see whether it is already used for another purpose.

Most probably the door uses something from other places in the wdls of the templates: look for defines, skills flags and variables which are used in the function. Beside that the door function uses an event. An event, in this case probably a scan event, reacts when f.i. two entities come near to each other, in this case the player to the door. This means in the player action must be something like enable_scan. Look into the manual for event.
Another possibility is, that there is an id for the event to make a difference between an event where a granate explodes near the player or the player pushes a button in game or he comes near a door, because otherwise the player could loose health, because of coming near the door or such...

Re: Adding my own code to templates [Re: Pappenheimer] #254983
03/06/09 20:45
03/06/09 20:45
Joined: Dec 2008
Posts: 56
B
binsky33333 Offline OP
Junior Member
binsky33333  Offline OP
Junior Member
B

Joined: Dec 2008
Posts: 56
I have searched all through the script and havnt found that skill1 is used for another purpose. Can anyone tell me on how i can add the door template to my own movement script.

Re: Adding my own code to templates [Re: binsky33333] #255131
03/07/09 20:01
03/07/09 20:01
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
You shouldn't start a new thread for this question, and you should read my post more precisely! wink

I mentioned 'enable_scan':

my.enable_scan = on;

This probably has to be set in your moving or player script.

But, maybe not! But nobody is able to answer this without seeing the code.
You have to know that the most who are able to answer such questions are not using the templates but their own code. This means they don't know the templates - means they have to something of the code to get an idea what might be missed in their! smile

Re: Adding my own code to templates [Re: Pappenheimer] #255191
03/08/09 16:44
03/08/09 16:44
Joined: Dec 2008
Posts: 56
B
binsky33333 Offline OP
Junior Member
binsky33333  Offline OP
Junior Member
B

Joined: Dec 2008
Posts: 56
Here is all of my code:
Code:
#include <acknex.h>
#include <default.c>

var video_mode = 7;
var video_depth = 16;
var move_vec[3] = 0,0,0;
var idle_percent =0;
var walk_percent = 0;
var run_percent = 0;
var temptilt = 0;
var distance_traced;
DEFINE FALLING,skill30;
DEFINE FALL_DISTANCE,skill31;




function main()
{
	level_load("test.wmb");
	wait(2);

}


action player_move
{
	player= me;
	wait(1);
	camera.genius = player;
	shift_sense= 2;
	
	
	while(player!=NULL)
	{
		//Walking function arrow keys
		move_vec[0]= (key_cuu - key_cud)*8*time;
		move_vec[1]= (key_comma - key_period)*6*time;
		
		//Stair Climbing and falling
		vec_set(temp,my.x);
   		temp.z -= 4000;
   		trace_mode = ignore_me+ignore_sprites+IGNORE_MODELS+USE_BOX;
   		move_vec.z=(-trace(my.x,temp))*3*time;
	   player.pan -= (key_force.x)*1.5*time;
	   move_mode = IGNORE_YOU + IGNORE_PASSABLE + IGNORE_PUSH + ACTIVATE_TRIGGER + GLIDE;
  	   ent_move(move_vec,NULLVECTOR);
  	   
		var space_pressed = 0;
		if(key_space==0)
		{
			space_pressed=0;
		}
		else
		{
			space_pressed = 1;
		   my.z +=10;
		}
		
		
		
		//Running with arrow keys
		if(key_shift == 1)
		{
			move_vec[0]= (key_cuu - key_cud)*4*time;
		}
		player.pan += (key_cul - key_cur)*2*time;
		ent_move(move_vec,NULLVECTOR);
		if(move_vec[0]== 0 && move_vec[1]==0)
		{
			//Idle
		idle_percent= (idle_percent +5*time)%100;
		ent_animate(me,"stand",idle_percent,ANM_CYCLE);
	}
	else
	{
		//Running animation
		if(key_shift)
		{
			run_percent = (run_percent + sign(move_vec[0])*5*time)%100; 
			ent_animate(player,"run",run_percent,ANM_CYCLE); 
		}
		else
		{
		//Walking animation
		walk_percent = (walk_percent+ sign(move_vec[0])*5*time)%100;
		ent_animate(player,"walk",walk_percent,ANM_CYCLE);
	   }
   }
   

	   //The Camera
		vec_set(Camera.x,player.x);
		camera.z += 39;
		camera.pan = player.pan;
		temptilt += (key_pgup - key_pgdn)*4*time;
	   if(key_home){ temptilt =0;}
		if (temptilt > 75)
		{
			temptilt = 75;
			
		}
		else
		{
			if(temptilt < -75)
			{
				temptilt= -75;
			}
		}
		camera.tilt =0 +temptilt;
		wait(1);
	}
}
 


Re: Adding my own code to templates [Re: binsky33333] #255221
03/08/09 21:43
03/08/09 21:43
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Did you try what happened when you wrote the

my.enable_scan = on;

in the player's action?

What does the door action look like?

Re: Adding my own code to templates [Re: Pappenheimer] #255224
03/08/09 23:03
03/08/09 23:03
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline
Serious User
VeT  Offline
Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
try not to use digits (370, 200, 5, *, 1, player.health);
but
digits (370, 200, 5, *, 1, player_hp);

and in main loop
player_hp = player.health;

some time ago i got the similar trouble and, as i remember, that helped me wink


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: Adding my own code to templates [Re: VeT] #255701
03/12/09 00:12
03/12/09 00:12
Joined: Dec 2008
Posts: 56
B
binsky33333 Offline OP
Junior Member
binsky33333  Offline OP
Junior Member
B

Joined: Dec 2008
Posts: 56
Ok Thanks everyone for you help i got everything working... Though i have another question about adding code the walk through template.

Here is the function i have. Basically this function animates a gun when the left mouse button is clicked. Btw this code is in a different .wdl file.
Code:
var gun_percent = 0;
function run_weapons()
{
	wait(1);
	while(player!=NULL)
	{
		while(mouse_left)
		{
			while(int(gun_percent)<98)
			{
				ent_animate(gun0,"shoot",gun_percent,ANM_CYCLE);
				gun_percent=(gun_percent+10*time)%100;
				
				wait(1);
			}
			gun_percent=0;
			wait(1);
		}
		wait(1);
	}
}
 

Now i want to use this function for my player, so in the p1biped action on the first line of it i add, run_weapon();
But then when i run the game, i click and the animation doesnt happen, nor does a sound i have added which is supposed to play(its not in the code up there). What wrong? Any suggestions?

Thanks!

Last edited by binsky33333; 03/12/09 00:29.

Moderated by  HeelX, rvL_eXile 

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