Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
deepthought

enemies spawning projectiles?

Recommended Posts

I'm trying to create a starwars mod, and i want the zombiemen, who i've turned to stormtroopers to fire blaster bolts. in the DECORATE lump of my wadfile i've entered


actor stormtrooper:Zombieman replaces Zombieman
{
states
{
Missile:
POSS D 0 A_SpawnItemEx("blasterbolt",0,0,8,0,20,0,0,0)
stop
}
}

all they do when they should fire is turn into my blasterbolt actor and go flying. Quite hilarious, really!

How should i make my enemy fire blaster bolts?

Thanks in advance!!

Share this post


Link to post

Replace the "stop" at the end of the missile state with a "goto See" and it should propably work!
However, your missile state looks a little odd anyway (only one frame is called and that with a duration of 0 tics), I'd suggest to examine other peoples DECORATE or take a look at the wiki.

Share this post


Link to post
deepthought said:

actor stormtrooper:Zombieman replaces Zombieman
{
states
{
Missile:
POSS D 0 A_SpawnItemEx("blasterbolt",0,0,8,0,20,0,0,0)
stop
}
}

all they do when they should fire is turn into my blasterbolt actor and go flying. Quite hilarious, really!

See that "stop" keyword here? It means that the actor stops existing. They don't turn into blasterbolts, they shoot blasterbolts and disappear.

Share this post


Link to post

OK i replaced stop with Goto see. they don't disappear, but they are like real storm troopers, which is to say, wildly inaccurate. i need them to shoot at me, not sideways.

Share this post


Link to post

You really should look at the many many many examples of standard actors on the ZDoom wiki. You'll see how they're made. For example, I don't see a call to A_FaceTarget, so they will not even aim at their target before firing...

Share this post


Link to post

You're right reading does help! i replaces A_SpawnItemEx with A_missile attack, and used A_FACE TARGET. they are accurate now. Now, how can i achieve a shotgun effect for the zombie seargeant?

for my shotgun i used SHTG AAAAAAA 0 A_FireCustomMissile("blasterbolt",0,false,random(-10,10),8,0)

How can i do that for a monster? A_FireCustomMissile doesn't work with monsters. if you try it gives you an invalid state parameter error.

Thanks in advance!!

Share this post


Link to post

Yeah, A_CustomMissile, A_CustomMeleeAttack, A_CustomComboAttack, A_CustomRailgun and A_CustomBulletAttack are the functions you'll want to use most often for monster attacks.

Missile: throws a projectile
Melee: inflicts damage directly to target in range
Combo: either missile or melee depending on range
Railgun: railgun effect
Bullet: hitscan effect (like shotgun or chaingun for example)

Also A_MonsterRefire to create refiring loops (like arachnotrons or chaingunners).

You can find them here.

Share this post


Link to post

speaking of A_CustomRailgun, how would you reccomend that i create 2 parallel railgun blasts at the same time (think force lightning)?

Share this post


Link to post

BLAH A 6 A_FaceTarget
BLAH A 0 A_CustomRailgun(params)
BLAH A 8 A_CustomRailgun(params)
Goto See

Both railguns will be fired at the same time.

Use the parameters to give them different offsets so that they're parallel instead of being fused.

The durations I used (6 for A_FaceTarget and 8 for A_CustomRailgun) are just examples of reasonable values. You can use different ones. If you want several actions to take place at the same time, use several states that have all a length of zero tics, except the last one that has a normal length. (Actions are executed when the actor enters the new state, so with BLAH A 8 A_CustomRailgun, it fires the rail gun then waits 8 tics before going to the next state.)

Share this post


Link to post

OK. How can i get the guy to fire continously? I want him to blast you for about 5 seconds, walk around, blast you again, etc.

Share this post


Link to post

Instead of Goto See, add another state where it calls A_MonsterRefire and then after that use Loop. The monster will continually refire (because of the loop) unless it loses line of sight (then A_MonsterRefire will put it back in the See state).

If you want to have a limited time, you can do something like this pseudocode:

Missile:
A_SetArg(4, 0)
MissileLoop:
A_FaceTarget
A_CustomRailgun
etc.
A_SetArg(4, args[4]+1)
A_JumpIf(args[4] > 50, "See")
A_MonsterRefire
Loop
Here you use the monster's args[4] value to keep track of how many times the monster went through its attack sequence. (See how it's initialized to 0 first, then increased by one at the end of each loop.) When that variable gets above a certain value (50 in the example, but adjust as appropriate depending on the total length of the attack sequence and how long you want them to stay in the loop, knowing that a second is made up of 35 tics), the monster is forcefully yanked to its See state. Otherwise, A_MonsterRefire is called to check the usual stuff (so that the monster will not keep firing if it loses line of sight). And then the state loop (going back to the last label, that is to say, MissileLoop), so that it fires again.

Share this post


Link to post

Don't just copy that code directly, that's pseudo code, just to show the logic. It lacks sprite names, frames, durations, etc.

Share this post


Link to post

Are you using Skulltag? Or an old (pre-2.4.0) version of ZDoom?

Share this post


Link to post

Well, then, forget about using A_SetArg with ST. ST doesn't have that function yet.

(On the ZDoom wiki, when a function, flag or other feature is marked with a "New", it means that ST does not have it. If it has an SVN tag, it means that the latest official version of ZDoom (2.4.1 at the moment) does not have it either.)

Share this post


Link to post

Ok i got the powerup working. i also modded the wings of wrath to become a jetpack. only problem is that the icon for the powerup covers up the player mugshot. Also when iselect it, the mugshot is totally replaced with the icon. How do i prevent that?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×