2 registered members (AndrewAMD, 1 invisible),
1,211
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
binsky33333
OP
Junior Member
|
OP
Junior Member
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
Senior Expert
|
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: binsky33333]
#255131
03/07/09 20:01
03/07/09 20:01
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
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! 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!
|
|
|
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
binsky33333
OP
Junior Member
|
OP
Junior Member
Joined: Dec 2008
Posts: 56
|
Here is all of my 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: Pappenheimer]
#255224
03/08/09 23:03
03/08/09 23:03
|
Joined: Aug 2004
Posts: 1,345 Kyiv, Ukraine
VeT
Serious User
|
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
|
|
|
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
binsky33333
OP
Junior Member
|
OP
Junior Member
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.
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.
|
|
|
|