|
2 registered members (juanex, AndrewAMD),
988
guests, and 8
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
hidding syntax in attaching weapon...
#398993
04/09/12 23:46
04/09/12 23:46
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
While trying to correct the sword attachment in my game Tarrox, my script suddenly began to crash as I was trying to hit an entity (model) with the attached weapon.
function handle_weapon_collision()
{
VECTOR* weapon_base;
VECTOR* weapon_tip;
ENTITY* weapon_holder = you;
if(weapon_holder.attacking == 1)
{
you = NULL;
vec_for_vertex(weapon_base.x, my, 12);
vec_for_vertex(weapon_tip.x, my, 1);
result = c_trace(weapon_base.x, weapon_tip.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX | USE_POLYGON | SCAN_TEXTURE);
if(you != NULL)
{
if(you.object_typ == 1)
{
if(you.blocking == 0)
{
you.health -= my.weapon_damage;
}
else
{
if (abs(ang(my.pan - you.pan)) >= 45)
{
//block
}
else
{
you.health -= my.weapon_damage;
}
}
}
}
}
}
action attach_sword()
{
set(my, PASSABLE);
my.weapon_damage = 50;
proc_mode = PROC_LATE;
while(you.health>0)
{
vec_for_bone(my.x, you, "weapon");
ang_for_bone(my.pan, you, "weapon");
handle_weapon_collision();
wait(1);
}
}
I closed the window before I ran my game... So I couldn't undo it. I really have no idea what the problem is
Last edited by Random; 04/09/12 23:46.
|
|
|
Re: hidding syntax in attaching weapon...
[Re: Random]
#399002
04/10/12 07:17
04/10/12 07:17
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
if(weapon_holder.attacking == 1) { you = NULL;<<<---------this seems weird to me
Compulsive compiler
|
|
|
Re: hidding syntax in attaching weapon...
[Re: Wjbender]
#399015
04/10/12 10:54
04/10/12 10:54
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
Yes, but I need to set you = NULL so I can trace with the sword. And I become the same error when you = NULL is not set... So does that really mean, I can`t set vec_for_bone and ang_for_bone and I will have to use vec_for_vertex?
|
|
|
Re: hidding syntax in attaching weapon...
[Re: Random]
#399016
04/10/12 11:03
04/10/12 11:03
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
dude you=NULL makes no sense to me but this does just a example untested ENTITY* my_old=me; ENTITY* you_old=you; trace me=my_old you=you_old
function handle_weapon_collision(ENTITY* weapon,ENTITY* weapon_holder)
{
VECTOR* weapon_base;
VECTOR* weapon_tip;
ENTITY* old_me=me;-------------
me=weapon_holder;//or weapon depending on what you want to achieve---------
//////ENTITY* weapon_holder = you;----------
if(weapon_holder.attacking == 1)
{
///////////////you = NULL;------------
vec_for_vertex(weapon_base.x, my, 12);
vec_for_vertex(weapon_tip.x, my, 1);
result = c_trace(weapon_base.x, weapon_tip.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX | USE_POLYGON | SCAN_TEXTURE);
if(you != NULL)
{
if(you.object_typ == 1)
{
if(you.blocking == 0)
{
you.health -= my.weapon_damage;
}
else
{
if (abs(ang(my.pan - you.pan)) >= 45)
{
//block
}
else
{
you.health -= my.weapon_damage;
}
}
}
}
}
me=old_me;-----------------------------------
}
action attach_sword()
{
//you==player i guess
//me= weapon i guess
set(my, PASSABLE);
my.weapon_damage = 50;
proc_mode = PROC_LATE;
ENTITY* weapon=me;---------------
ENTITY* weapon_holder=you;-------------
while(weapon_holder.health>0)----------------
{
vec_for_bone(weapon.x,weapon_holder, "weapon");--------------
ang_for_bone(weapon.pan,weapon_holder, "weapon");-----------
handle_weapon_collision(weapon,weapon_holder);------------------
wait(1);
}
}
Last edited by Wjbender; 04/10/12 11:27.
Compulsive compiler
|
|
|
Re: hidding syntax in attaching weapon...
[Re: Wjbender]
#399019
04/10/12 11:24
04/10/12 11:24
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
No still doesn`t work. I thought first, because I forgot to set handle_weapon_collision ...
Last edited by Random; 04/10/12 12:42.
|
|
|
Re: hidding syntax in attaching weapon...
[Re: Random]
#399022
04/10/12 11:28
04/10/12 11:28
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
just go over it a again i made a mistake and edited it
Compulsive compiler
|
|
|
Re: hidding syntax in attaching weapon...
[Re: Wjbender]
#399027
04/10/12 12:43
04/10/12 12:43
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
I search for it. Thank you.
|
|
|
Re: hidding syntax in attaching weapon...
[Re: Random]
#399028
04/10/12 12:50
04/10/12 12:50
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
Are you guys sure there is no need for you = NULL;??? This is how it looks like now (still doesn`t work yet):
function handle_weapon_collision(ENTITY* weapon,ENTITY* weapon_holder)
{
VECTOR* weapon_base;
VECTOR* weapon_tip;
if(weapon_holder.attacking == 1)
{ //you = NULL; don`t you need me??
// Then how am I suppose to trace right?
vec_for_vertex(weapon_base.x, weapon, 12);
vec_for_vertex(weapon_tip.x, weapon, 1);
result = c_trace(weapon_base.x, weapon_tip.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX | USE_POLYGON | SCAN_TEXTURE);
//if(you != NULL)
//{
if(you.object_typ == 1)
{
if(you.blocking == 0)
{
you.health = my.weapon_damage;
}
else
{
if (abs(ang(weapon_holder.pan - you.pan)) >= 45)
{
//block
}
else
{
you.health = weapon.weapon_damage;
}
}
}
//}
}
}
action attach_sword()
{
set(my, PASSABLE);
my.weapon_damage = 50;
proc_mode = PROC_LATE;
ENTITY* weapon=me;
ENTITY* weapon_holder=you;
while(weapon_holder.health>0)
{
vec_for_bone(weapon.x,weapon_holder, "weapon");
ang_for_bone(weapon.pan,weapon_holder, "weapon");
handle_weapon_collision(weapon,weapon_holder);
wait(1);
}
}
I am a bit confused
Last edited by Random; 04/10/12 12:50.
|
|
|
Re: hidding syntax in attaching weapon...
[Re: Random]
#399071
04/10/12 21:23
04/10/12 21:23
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
hows this for confusing
function handle_weapon_collision(ENTITY* weapon,ENTITY* weapon_holder)
{
VECTOR* weapon_base;
VECTOR* weapon_tip;
//now ,when you trace ME needs to get ignored because c_trace(...IGNORE_ME...)
//but ME can change during other functions SO i saved it into weapon right?
//i now need to tell the engine that the ME that needs to get ignored during
//the trace is the weapon right?
//im saving the current ME why? because im assigning the weapon to ME on the next line
ENTITY* old_me=me;
me=weapon;
//why? because you cant say c_trace(IGNORE_WEAPON) only c_trace(IGNORE_ME)
//so ME needs to be weapon
//but we need to save the ME pointer and later restore it again
//because it could be realy any other entity by now
if(weapon_holder.attacking == 1)
{
//YOU is of no importance here untill c_trace hits another entity
//only if you use IGNORE_YOU will you matter
//after tracing
//YOU then gets modified to point to that other entity that got struck/hit !!!
//you cant say you=NULL because you could be ANY entity right now
//you = NULL; don`t you need me?? no i dont
//Then how am I suppose to trace right? only with ME
vec_for_vertex(weapon_base.x, weapon, 12);
vec_for_vertex(weapon_tip.x, weapon, 1);
//you see you need the me entity here IGNORE_ME
result = c_trace(weapon_base.x, weapon_tip.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX | USE_POLYGON | SCAN_TEXTURE);
//now c_trace checks and if it hits a entity YOU becomes that entity
//YOU and ME are global pointers they could be any entity
if(you != NULL)
{
if(you.object_typ == 1)
{
if(you.blocking == 0)
{
you.health = my.weapon_damage;
}
else
{
if (abs(ang(weapon_holder.pan - you.pan)) >= 45)
{
//block
}
else
{
you.health = weapon.weapon_damage;
}
}
}
}
}
//now i need to restore ME back to its orignal state because i changed it to equal
//the weapon remember? so:
me=old_me;
}
//you=is the pointer to the creating entity
//me=Pointer to the entity that the current function is executed from or assigned to
//so if this action is assigned to a weapon then the weapon=me
//weapon_holder is the entity which yealds the sword/weapon
//if thats the player: weapon_holder=player or whichever ,weapon_holder=john_doe
//but remember if using player ,player needs to be assigned
//to a entity which is the player(hero) before this
action attach_sword()
{
set(my, PASSABLE);
my.weapon_damage = 50;
proc_mode = PROC_LATE;
//im saving the ME entity to a tempory placeholder
//because ME is global and CAN change so im saving it here into weapon
//the same reason for temporarly saving the PLAYER or weapon yielding entity
//into weapon_holder
//im sorry with the you thingy placed here earlier i confused myself
//but if you is the valid entity holding the sword somehow then yes weapon_holder=you
//assuming this is the weapon calling this action then
ENTITY* weapon=me;
//assuming player exist then
ENTITY* weapon_holder=player;
while(weapon_holder.health>0)
{
vec_for_bone(weapon.x,weapon_holder, "weapon");
ang_for_bone(weapon.pan,weapon_holder, "weapon");
handle_weapon_collision(weapon,weapon_holder);
wait(1);
}
}
Compulsive compiler
|
|
|
|