Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Thu 28/04/2011 19:31:53

Title: Shoot an object at player whatever his x y is..
Post by: barefoot on Thu 28/04/2011 19:31:53
Hi

I can't seem to find much for my latest scenario and I'm scratching my head trying to find a solution..

Scenario:

A Character throws a spell (object) at Main Character. If it hits Main Character then it causes an event.

If object hits something else it will ricochet off (can do objects collide).

What I would like to do is determine where the main character is and project the object in that direction..

I suppose I may be able to uses players x y to determine projection of object...

Some help with basic direction assistance would be welcomed.

cheers

barefoot


Title: Re: Shoot an object at player whatever his x y is..
Post by: WHAM on Thu 28/04/2011 19:56:46
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=43072.0

I tried something similiar in the thread I linked to. Check it out for starters, Khris pretty much had to spell it out for me, so it should be informative.
Title: Re: Shoot an object at player whatever his x y is..
Post by: barefoot on Thu 28/04/2011 20:37:54
Hi

I'll check that out

cheers

barefoot
Title: Re: Shoot an object at player whatever his x y is..
Post by: barefoot on Thu 28/04/2011 21:10:09
Hi

I was thinking along these lines:

{
if (cwizard2.x == 163 && cwizard2.y == 210) {


Say I divided the screen into 2 parts (vertically) and have above code with  >=  and   <= operators and have events for both.

Should I have this:

{
if (cwizard2.x >= 163 && cwizard2.y >= 130) {
//Do this



{
if (cwizard2.x <= 163 && cwizard2.y >= 130) {
//Do this


Perhaps from a Region if conditions are met?

I have tried this and it works ok for what it is...

Also if char collides with object event...

what would be the best way to incorporate this besides what i have in code, assuming it is ethical?

cheers

barefoot





Title: Re: Shoot an object at player whatever his x y is..
Post by: monkey0506 on Fri 29/04/2011 04:52:34
I have some basic questions..

Does the position of the spellcasting character change (does that character move)?

Does (or can) the player move after the spell has been cast? If so, is the spell supposed to follow the character, even slightly?

Does the path of the spell curve, or is it a straight line?

Why is it that people think you can't use the value of variables in function calls??

This is probably a lot simpler than you're making it..you're probably just overthinking things.
Title: Re: Shoot an object at player whatever his x y is..
Post by: barefoot on Fri 29/04/2011 08:04:49
Hi Monkey

yes, the spell character (cwizard) animates before casting spell (throws an object at main character (cwizard2) such as a fire ball).. The spell character (cwizard) does not move (walk) as such,  at the moment .

This is an eBlock action and I also check if object collides with character. I have set this up in rep exe but its not working properly at the moment.

The player character can resume moving only once the spell has finished (object thrown and after its animation) because its eblock.

The spell (object move) goes in straight lines. I have not set it up to follow the player character. Also i want to be able to make it bounce off solid items.

I have not got everything down to a fine art yet, i can make a variable but am not fully aware of all its uses yet so you'll have to excuse my ignorance and perseverance to gain further knowledge from resources as well as from experienced scripter's like yourself...

This scenario has only just begun (its the finale).. once I have one bagged then the rest will be a lot easier and will install more knowledge and skills..

As my last post stated, i have the room divided into two oarts and the objects shoots depending what part you are in ie left or right..  Of course it would be great to detect what part of the room the player is at wherever he is..  still..

Heres what I have if player walks on Region (Don't be too harsh on script presentation)


function region2_WalksOnto()
{
if (cwizard2.x >= 163 && cwizard2.y >= 130) {

 cwizard.ChangeView(37);
cwizard.Animate(0, 4);
 cwizard.ChangeView(12);
 object[6].Visible = true;
object[6].Move(181, 170, 12, eBlock);

ofire.SetView(42, 0, 0);
 ofire.Animate(0, 1, eOnce, eBlock, eBackwards);
 object[6].Visible = false;
}
else if (cwizard2.x <= 163 && cwizard2.y >= 130) {

 cwizard.ChangeView(37);

 cwizard.Animate(0, 4);
 cwizard.ChangeView(12);
object[6].Visible = true;
object[6].Move(100, 170, 12, eBlock);

 ofire.SetView(42, 0, 0);
 ofire.Animate(0, 1, eOnce, eBlock, eBackwards);
 object[6].Visible = false;

}

}


And:


function room_RepExec()
{
  if (cwizard2.IsCollidingWithObject(object[6]))
 cwizard2.Say("Ouch!!");
}


Any help/advice appreciated

cheers

barefoot