Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, TipmyPip, VoroneTZ, Quad, 1 invisible), 688 guests, and 11 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Function for magic energy ball hitting entity? #424227
06/11/13 23:38
06/11/13 23:38
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
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.


Last edited by Ruben; 06/11/13 23:38.
Re: Function for magic energy ball hitting entity? [Re: Ruben] #424230
06/12/13 04:54
06/12/13 04:54

M
Malice
Unregistered
Malice
Unregistered
M



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.

Last edited by Malice; 06/12/13 05:19.
Re: Function for magic energy ball hitting entity? [Re: ] #424247
06/12/13 10:20
06/12/13 10:20
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Thank you Malice. It worked. :-)

Re: Function for magic energy ball hitting entity? [Re: Ruben] #424280
06/12/13 17:33
06/12/13 17:33

M
Malice
Unregistered
Malice
Unregistered
M



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

Re: Function for magic energy ball hitting entity? [Re: ] #424400
06/14/13 21:43
06/14/13 21:43
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
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?

Last edited by Ruben; 06/14/13 21:44.
Re: Function for magic energy ball hitting entity? [Re: Ruben] #424404
06/14/13 23:41
06/14/13 23:41

M
Malice
Unregistered
Malice
Unregistered
M



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


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