Function for magic energy ball hitting entity?

Posted By: Ruben

Function for magic energy ball hitting entity? - 06/11/13 23:38

Does anyone know of a function that determines whether an object like a magic energy ball fired by a wizard hits an entity (true or false, 1 or 0) like the player entity?

And if the magic energy ball does hit an entity (true or 1), that entity's health score goes down by a certain amount.

Posted By: Anonymous

Re: Function for magic energy ball hitting entity? - 06/12/13 04:54

Your posting in the wrong section. Look below.

Code:
action mball_action()
{
you = player;  // not needed
vec_set(my.pan,you.pan);

while(my)
{
c_move(my,vector(20*time_step,0,0),nullvector,IGNORE_YOU | IGNORE_PASSABLE | ACTIVATE_SHOOT);
if(event_type == EVENT_SHOOT)
{
wait(1);
ent_remove(my);
}
wait(1);
}
}


function mball_damage()
{
if(event_type == EVENT_SHOOT)
my.HEALTH -= 10;
}

action enemy_action()
{
my.emask |= ENABLE_SHOOT;
my.event = mball_damage;
// more code here  ///
}

action player_code()
{
VECTOR vec_mball;


// your code here ///

if(mouse_left && !mlock)
{
mlock = 1;
vec_set(vec_mball,vector(50,0,0));
vec_add(vec_mball,my.x)
vec_rotate(vec_mball,my.pan);
ent_create("mball.mdl",vec_mball,mball_action);
}
if(!mouse_left)
mlock =0;


// more code here //
}



EDIT change a little... I did it from the player and mouse fire but you should get the idea

event_type == EVENT_SHOOT is your true/false

EDIT2 also look at c_move and this
Quote:
hit.flags The HIT_TARGET macro is nonzero when something was hit.
Posted By: Ruben

Re: Function for magic energy ball hitting entity? - 06/12/13 10:20

Thank you Malice. It worked. :-)
Posted By: Anonymous

Re: Function for magic energy ball hitting entity? - 06/12/13 17:33

Your welcome - Glad I could be of some little help. Please mind the section you post in because sometime people (like me) only look in certain sections. While I'm still active on the forum feel free to ask me for anything in a post or pm and I will solve it 'IF I CAN'.

Mal
Posted By: Ruben

Re: Function for magic energy ball hitting entity? - 06/14/13 21:43

Originally Posted By: Malice
Your welcome - Glad I could be of some little help. Please mind the section you post in because sometime people (like me) only look in certain sections. While I'm still active on the forum feel free to ask me for anything in a post or pm and I will solve it 'IF I CAN'.

Mal

Which section should I have posted this thread in?
Posted By: Anonymous

Re: Function for magic energy ball hitting entity? - 06/14/13 23:41

Code questions should go in Lite-C Programming and are often posted in Starting with GameStudios. This section is for questions about the editors.
© 2024 lite-C Forums