PDA

View Full Version : crowds and Maxscript


eagle4
15-06-2005, 02:08 AM
hi, i am making a space battle, and i started using pflow, but i have now moved onto crowds and a bit of maxscript, and i seem to be geting further. ok what i want to happen is when a ship of another team gets within a certain distance then this ship chasses after it. i can set it up between 2 deligates, but i cant set it up so that it checks the closest enemy to chase if there are more than just 1 on each team. also how can i check the speed of an object, because i also want to also stick in a simple check to see if the enemy's speed is less than its own speed, then chase, because this way i can change the outcome of the whole animation by just altering the speed of a few deligates. But i cant work out how to set a speed and how to check it using maxscript.

when the chaser gets close enough to the one getting chased i want him to shoot, so i figure i need to set up a particle system and get maxscript to check the distance and then somehow fire a particle from that ship, do i need a particle system for each ship? and if it hits then i want the ship that got hit to blow up and dissapear, blow up shouldnt be too hard, just use particles to do that, but getting it to dissapear and then tell the chasser to find another target is my next problem. does anyone have any ideas?

i am new to maxscript, i have used visual basic so i have a basic understanding of programming.

any tips would be appreciated, weather you solve my whole problem, or just 1 thing, it would be great.



eagle4

MaggieQue
16-06-2005, 11:38 PM
Do u know how to write Pseudocode or drawing Flow Chart?

If u can show ur logic with either of it, then I will try my best to give u the maxscript.

eagle4
17-06-2005, 02:05 AM
thanks maggie, i will try to write it in pseudocode, so hopefully you can help.




eagle4

eagle4
17-06-2005, 02:23 AM
2 teams of deligates, blue and red are to be attacking each other
what i cant think a way to program is for this code to work for 1 team to search out the other team individually by each deligate. this can be worked to work with red1 shooting at blue1 and blue 2 shooting at red2 etc etc, but i want it to be a bit more procedural than that, i want it to randomly find a member of the other team, this way i can make red win or blue win the battle by just changing their start speed. wander and seek are both crowd behaviours that i hope can be called upon.

ok here's waht happens in my pseudocode. the variable 'distance' is initalised (worked out reguluarly) and it just wanders randomly arround. It then checks if the distance is close enough, to 'see' them and it makes sure the speed of the enemy is less than themselves then it chases after them and if it gets close enough to shoot it shoots, then it checks if the particle (missle, bullet or whatever) hits, if not it keeps shooting until the enemy is dead, or he himself is dead.

This is for the blue team.



Distance = blue position – red position

wander

IF Distance <= 200 and red.speed < blue.speed THEN
seek
IF Distance <= 50 THEN
Shoot
Blue.speed = Blue.speed + 10
go back to the begining
ENDIF
ENDIF


“Shoot”
LOOP
Pflow emit 1 particle from blue deligate
IF particle collides with red deligate THEN
Red explode
ENDIF
ENDLOOP




i hope this helped



eagle4