* *
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 24, 2017, 12:41:04 AM

Login with username, password and session length

@cmd projectile

  • 9 Replies
  • 765 Views
*

Offline nsw25

  • Hero Member
  • *****
  • 1746
    • Thatcher Productions
@cmd projectile
« on: October 31, 2015, 07:08:30 AM »
Hi just wanted to know a bit more about @cmd   

here is one that I use projectile 1 "zap" 4 1 55 1 5

I really want to know what each number does. (at the moment I just fiddle around until I get the desired effect)

example

@cmd   projectile 1 "zap" a b c d e

a= ?
b= how deep the attack box is ?
c= height
d= ?
e= ?
« Last Edit: October 31, 2015, 07:17:24 AM by nsw25 »
Bad ass babes
http://store.steampowered.com/app/529000/

see more of my games and projects at
www.thatcherproductions.org

*

Offline Piccolo

  • Hero Member
  • *****
  • 502
    • Le repaire du DaimaĆ“
Re: @cmd projectile
« Reply #1 on: October 31, 2015, 08:13:31 AM »
Projectile function is a bit particular.

It can take 8 or 9 parameters, which are :

relative, name, x, z, y, direction, ptype, type and map

If you don't use an integer as first parameter, then relative will not be used and be implicitly set to 0.

x, z, y are the spawn position of the projectile.

type is for the projectile trajectory I think (knife VS bomb)

ptype is not really important. I think it is for choosing between knife/shot entities or something.


On a side note, your question is not about @cmd but about the hardcoded projectile function. @cmd is just how you use this function, but actually you can use it without @cmd.

*

Offline bWWd

  • Hero Member
  • *****
  • 1298
Re: @cmd projectile
« Reply #2 on: November 13, 2015, 11:24:14 AM »

//entity * projectile([0/1], char *name, float x, float z, float a, int direction, int pytype, int type, int map);

*

Offline O Ilusionista

  • Global Moderator
  • Hero Member
  • *****
  • 4980
  • >> I WILL BE AWAY FOR SOME TIME <<
    • BMT - Brazil Mugen Team
Re: @cmd projectile
« Reply #3 on: September 12, 2017, 09:02:45 AM »
I would like to bump this topic because I want to document the projectile function.
Following the tips from Piccolo and bWWd, I was able to find info at the source code, but I need help to document it.

1-DEFINITION=================================================
Code: [Select]
projectile {relative} {name} {x} {z} {y} {direction} {ptype} {type} {map}//entity * projectile([0/1], char *name, float x, float z, float a, int direction, int pytype, int type, int map);

{relative} - Seams to control all other settings, but I need help with this.

For example, if relative is "1",
Code: [Select]
x = 0;else
Code: [Select]
x = self->position.x;
This means that if relative is 0, the position will count from the edge of the screen, while if 1, it will use the parent x position as a it's x value?

The same for 'direction'
Code: [Select]
    else if(relative)
    {
        direction  = DIRECTION_RIGHT;
    }
    else
    {
        direction = self->direction;

{name} - name of the spawned position, from models.txt
{x} - X spawn position, defaults to 0. Accept decimals.
{z} - Z spawn position, defaults to 0. Accept decimals.
{y} - Y spawn position, defaults to 0. Accept decimals.
{direction} - direction of the spawn. According to the source, defaults to DIRECTION_LEFT
{ptype} - What this does? defaults to 0
{type} - "0" - will use "knife' behaviour. "1" will use "bomb" behaviour (and ignores the ptype above). defaults to 0
{map} - map of the spawned entity, defaults to 0

2- USAGE=======================================================
Will this works if we use without @cmd?

3- QUESTIONS =================================================
The source says there is an ANI_THROWATTACK animation. What it does?

Also, the source says
Quote
   struct entity *owner; // Added for "hitenemy" flag so projectile recognizes its owner
How we set this?

Any help is appreciated.
« Last Edit: September 12, 2017, 09:05:16 AM by O Ilusionista »

*

Offline Damon Caskey

  • Administrator
  • Hero Member
  • *****
  • 1786
    • DC Current
Re: @cmd projectile
« Reply #4 on: September 12, 2017, 10:37:05 AM »
{ptype} - What this does? defaults to 0

If it has any value other than 0, the projectile is given a default name of "shot" and a model index of -1 as opposed to the parent model's predefined knife or pshot index. What that does in the long term I can't tell you because it will require quite a bit of code tracing.

Quote
...This means that if relative is 0, the position will count from the edge of the screen, while if 1, it will use the parent x position as a it's x value?

Yes.

Quote
The same for 'direction'

Also correct.

Quote
Will this works if we use without @cmd?

You have that a bit backward. @cmd is just a shortcut for executing user or engine defined script methods (functions) on a given animation frame. They all work the same either way.

Quote
The source says there is an ANI_THROWATTACK animation. What it does?

Once upon a time and well before myself or SX were coders, there was a weird, non-abstracted weapon system coded in specifically for gun and other projectile type weapons. I imagine ANI_THROWATTACK is a remnant. It's best left ignored.

Quote
Also, the source says
Quote
   struct entity *owner; // Added for "hitenemy" flag so projectile recognizes its owner
How we set this?

Setting a projectile's owner to self is hard coded into the projectile method. However, you can still set a different owner with a little extra code. Owner is available as a property, and projectile method returns the handle of the entity it spawns.

Code: [Select]
void projectile_ent;

// Spawn and throw projectile.
projectile_ent = projectile(...);

// Set projectile owner.
setentityproperty(projectile_ent, "owner", {your new owner entity});
« Last Edit: September 12, 2017, 10:45:59 AM by Damon Caskey »
Projects in progress are now available here: https://github.com/DCurrent

*

Offline O Ilusionista

  • Global Moderator
  • Hero Member
  • *****
  • 4980
  • >> I WILL BE AWAY FOR SOME TIME <<
    • BMT - Brazil Mugen Team
Re: @cmd projectile
« Reply #5 on: September 12, 2017, 11:00:44 AM »
Thanks for the explantions, DC.
About the "owner", won't it make sense the entity who spawns it be automatically its owner or parent?

And can I use the "owner" on a doattack script to control what the entity will hit, to simulate a better versus game?

*Edit by DC* I accidentally edited your post instead of quoting it. Restored manually. My bad.
« Last Edit: September 12, 2017, 11:16:51 AM by Damon Caskey »

*

Offline Damon Caskey

  • Administrator
  • Hero Member
  • *****
  • 1786
    • DC Current
Re: @cmd projectile
« Reply #6 on: September 12, 2017, 11:18:47 AM »
Thanks for the explantions, DC.
About the "owner", won't it make sense the entity who spawns it be automatically its owner or parent?

Yes it would - and that's exactly what it does. The example code I gave was just in case you'd want to make it someone else.

Quote
And can I use the "owner" on a doattack script to control what the entity will hit, to simulate a better versus game?

You can do that, but not with Owner. Owner doesn't have anything to do with what a projectile can hit. That's controlled by candamage, which by default is the same as the entity that threw the projectile. Owner is just a way to know who the projectile belongs to.

Let's say you're Ryu, and you throw a Hadouken. The Haoduken hits Ken. When processing Ken's hit reaction, damage, and such, OpenBOR will see it was a projectile that hit Ken, and so check the projectile for an owner. Presumably it finds the entity handle for Ryu. So now it knows to give Ryu points for the hit, a tick on the combo meter, and display Ken's HP gauge under Ryu's.
Projects in progress are now available here: https://github.com/DCurrent

*

Offline O Ilusionista

  • Global Moderator
  • Hero Member
  • *****
  • 4980
  • >> I WILL BE AWAY FOR SOME TIME <<
    • BMT - Brazil Mugen Team
Re: @cmd projectile
« Reply #7 on: September 12, 2017, 11:24:29 AM »
Quote
Yes it would - and that's exactly what it does. That's what I was telling you above.
Sorry, language barrier. I mean it won't make more sense if I don't had to set the owner manually?

Quote
OpenBOR will see it was a projectile that hit Ken, and so check the projectile for an owner...
Yeah, but my point is: if you spawn an entity (not by native projectile function, but with a scripted function like your "spawn01") with a CANDAMAGE PLAYER, it will hurt the entity who spawns it too.

I remember WD said he made a Versus code, but he said its a nightmare to implement.

*

Offline Damon Caskey

  • Administrator
  • Hero Member
  • *****
  • 1786
    • DC Current
Re: @cmd projectile
« Reply #8 on: September 12, 2017, 11:51:16 AM »
Quote
Yes it would - and that's exactly what it does. That's what I was telling you above.
Sorry, language barrier. I mean it won't make more sense if I don't had to set the owner manually?

999 out of 1000 times, you want the owner to be self. In the few cases which you want to a different owner, the ability is there and it's easy to do with just two lines. So from an engineering perspective, it makes a lot more sense to have a default behavior instead of yet another function argument. We need less of those, not more.

Quote
Yeah, but my point is: if you spawn an entity (not by native projectile function, but with a scripted function like your "spawn01") with a CANDAMAGE PLAYER, it will hurt the entity who spawns it too.

This isn't a projectile issue or even a programming bug. The engine is doing exactly what it is meant to. When a projectile capable of damaging player types is launched, obviously it's going to hit the player that threw it because their collision boxes will be overlapping as the projectile spawns into play.

The problem is one of too much data compression. It harkens back to the original BOR. Roel loved to pack tons of data into as few variables as possible - that's one of the reasons why his games are so darn optimal. Downside, it makes granular separation very difficult. There is WAY too much that depends on entity type.

The permanent solution is a numerated "faction" system which is in planning stages and will remove a ton of difficulties for VS. and RPG style games. Therefore hard coding a separate anti-collision system would be pretty wasteful at this point. But like always, there is a manual solution, in this case doattack. In your doattack event, identity the owner, and if it's self, then turn off the hitflag. Done - Ryu is now immune to his own player vs. player Hadoukens and won't hit himself in the face every time he throws one.  ;D

DC
Projects in progress are now available here: https://github.com/DCurrent

*

Offline O Ilusionista

  • Global Moderator
  • Hero Member
  • *****
  • 4980
  • >> I WILL BE AWAY FOR SOME TIME <<
    • BMT - Brazil Mugen Team
Re: @cmd projectile
« Reply #9 on: September 12, 2017, 12:04:36 PM »
Thanks again, I will make some tests.
That faction system seams to be pretty useful

 

Recent

Members
  • Total Members: 6634
  • Latest: dre10g
Stats
  • Total Posts: 47092
  • Total Topics: 3229
  • Online Today: 25
  • Online Ever: 316
  • (January 04, 2013, 09:43:02 AM)
Users Online
Users: 0
Guests: 20
Total: 20