Enemy Projectiles

dale_coop

Moderator
Staff member
Yeah, first, you will need to fix the ignore gravity (to make projectiles move):
http://nesmakers.com/viewtopic.php?f=35&t=1939

About the monster's projectiles... there are two kind of shooting: "shoot straight" and "shoot at player" that are 2 different action scripts
One uses the a “OBJ_MONSTER_PROJECTILE” user constant to set which object to use as projectile.
And the other one uses by default the “Effect 2” game object.
Both of your projectiles objects have to bébés set as “monster weapon”, with a speed and acceleration values, also “destroy me” on edge/solid reaction.
For the “shoot straight”, just check the “ignore collision” for the action step 0.
For the “shoot toward player”, check the “ignore gravity” AND “use aimed physics” for action step 0. (Because the behavior is different then the normal physics).
And don’t forget to define the bounding box.

Now your monster can use the actions in order to shoot. Make sure it moves before shorting (Because I think monsters are facing down at start).

PS: of course you could do some modifications to the shooting scripts
(I would suggest to use for both the same user constant, to be able to use the same object, justaube a different action step “0” for the straight and the “1” for the towards player).

The modification of the createobject part would look like that (the shoot straight):
Code:
CreateObject temp1, temp2, #OBJ_MONSTER_PROJECTILE, #$00, temp

And for shoot towards player:
Code:
CreateObject temp1, temp2, #OBJ_MONSTER_PROJECTILE, #$01, temp
 

dale_coop

Moderator
Staff member
1: In "Project Settings > User Constants" it lists YOUR game constants. Here, you will find a constant named OBJ_MONSTER_PROJECTILES. That is used by the "shoot towards player" script. You have to set the index value of the object you want to use (just count the game object, starting from 0: for example if you want to use the "Source projectile" game object, set "3").

2: Yes, too... but by default, the "shoot straight" script uses this object, the "Effect 2":
Code:
	CreateObject temp1, temp2, #$0A, #$00, temp
(I didn't write this code)
So I'd suggest to modify this script to :
Code:
	CreateObject temp1, temp2, #OBJ_MONSTER_PROJECTILES, #$01, temp

So now you can use the same unique object for your monster projecile, and just different Action Steps :
Action Step 0:
2019-02-04-13-52-21-Monster-Animation-Info.png

Action Step 1:
2019-02-04-13-52-56-Monster-Animation-Info.png


Voilà :)
 
So I was trying to set up my monster projectile and it just created my player's melee object, but it was technically working. I went into user constants and started playing around. After that, the game and I got this error:

Routines\BASIC_021019\ModuleScripts\AiScripts\ShootTowardsPlayer.asm(18):CreateObject(26): Unknown label.
demo.txt written.

I went to change the user constant back to the default setting ("1" I believe), but it is still broke and I get that error unless i just outright remove the "shoot toward player" script.
 

dale_coop

Moderator
Staff member
In the ShootTowardsPlayer script, line 18... you will see a CreateObject line ... one of the parameter is the user constant... OBJ_MONSTER_PROJECTILE (or maybe OBJ_MONSTER_PROJECTILES with an "S")
Then, in the Project Settings > Script Settings, check this user constant exists... with the same exact name. Else "Add" it with the same name as written in your script (Copy/Paste it...) and give it the id/number of the object you want to use for monster projectiles ("3" maybe ?).

2019-02-20-01-22-13-NES-MAKER-4-1-5-Version-0x159-Maim-The-Rabbit-Win-a-Prize-MST.png
 
Got it, thanks!

So for some reason under user constants, OBJ_MONSTER_PROJECTILE did exist, but it was listed as ";;;OBJ_MONSTER_PROJECTILE". No idea why there were 3 semicolons in front of it. It wasn't like that where you could type in the name yourself. So anyway, I deleted it, and then created a new one called OBJ_MONSTER_PROJECTILE, which got ride of the three semicolons, and fixed the problem :)
 

dale_coop

Moderator
Staff member
BentPawGames said:
No idea why there were 3 semicolons in front of it.

It means the constant is disabled. Just click on the "enabled" button, it will remove the semicolons.
 

Belle_Grande

New member
Yeah, first, you will need to fix the ignore gravity (to make projectiles move):

About the monster's projectiles... there are two kind of shooting: "shoot straight" and "shoot at player" that are 2 different action scripts
One uses the a “OBJ_MONSTER_PROJECTILE” user constant to set which object to use as projectile.
And the other one uses by default the “Effect 2” game object.
Both of your projectiles objects have to bébés set as “monster weapon”, with a speed and acceleration values, also “destroy me” on edge/solid reaction.
For the “shoot straight”, just check the “ignore collision” for the action step 0.
For the “shoot toward player”, check the “ignore gravity” AND “use aimed physics” for action step 0. (Because the behavior is different then the normal physics).
And don’t forget to define the bounding box.

Now your monster can use the actions in order to shoot. Make sure it moves before shorting (Because I think monsters are facing down at start).

PS: of course you could do some modifications to the shooting scripts
(I would suggest to use for both the same user constant, to be able to use the same object, justaube a different action step “0” for the straight and the “1” for the towards player).

The modification of the createobject part would look like that (the shoot straight):
Code:
CreateObject temp1, temp2, #OBJ_MONSTER_PROJECTILE, #$00, temp

And for shoot towards player:
Code:
CreateObject temp1, temp2, #OBJ_MONSTER_PROJECTILE, #$01, temp
I keep having my monster fly in opposite direction when the projectile is fired
 
Top Bottom