Page 1 of 1

collide with "any enemy" cause 20 "global damage" (grouping)

PostPosted: Mon Mar 17, 2008 2:07 am
by stevenp
i have a situation that i have been avoiding for 2 months, causing "global damage" instead of "individual damage"

this is how my game is CURRENTLY set up

// when shock bolt colides with enemy1... enemy1's health goes down 20
// when shock bolt colides with enemy2... enemy2's health goes down 20
// when shock bolt colides with enemy3... enemy3's health goes down 20.....
//.... when shock bolt colides with enemy125... enemy125's health goes down 20

you can see my point and how inefficiant this is, and how it will take much time in the long run

what i would like to know how to do is this

// when shock bolt collides with "any enemy" cause 20 "damage" to that enemy

so i need to know how would you create a "group" called "enemy group" and "global damage" so when ANY enemy gets hit by the shock bolt, his health goes down by 20

is this possible?

i appreciate any help :D[list=][/list]

Re: collide with "any enemy" cause 20 "global damage" (grouping)

PostPosted: Mon Mar 17, 2008 5:04 am
by DilloDude
I use a stats actor variable, and set individual bits up as properties (see here). I'd have a stat for either damageable or damages (and some other properties that may take effect). Then do a collision with any actor. For example, on a bullet type of thing, it might be
Code: Select all
if (collide.stats & bDAble)
{
    collide.health --;
    DestroyActor("Event Actor");
}
else if (collide.stats & bSolid)
{
    DestroyActor("Event Actor");
}


In my current project, I'm doing it the other way around. On the object that gets hit, collision with any actor, something like this:
Code: Select all
if (collide.stats & bDamages)
{
    //check other stats about attack type
    health -= collide.strength;
    if (collide.stats & bForces)//another property, whether a colliding actor should bounce away
    {
        //whatever bounce effect
    }
    collide.signal ++;//a variable to store when the actor has hit something. The shot checks this on draw actor and destroys itself if necessary
}

Re: collide with "any enemy" cause 20 "global damage" (grouping)

PostPosted: Thu May 22, 2008 12:11 am
by stevenp
ok, for some reason it is giving me an error, ILLEAL STRUCTURE OPERATION even tho i followed fuzzy's steps..

i dont understand why this is the case

Re: collide with "any enemy" cause 20 "global damage" (grouping)

PostPosted: Thu May 22, 2008 12:18 am
by makslane
The code Stick.Traits = something will works only if Traits was a Actor variable, not a global variable

Re: collide with "any enemy" cause 20 "global damage" (grouping)

PostPosted: Thu May 22, 2008 7:41 pm
by stevenp
ok that actor variable thing you said worked fine, this mehtod has 1 last step to it,

but i must be missing something...

when the green actor collides on one actor, it plays both sounds

it shouldent do that, what am i doing wrong?

Re: collide with "any enemy" cause 20 "global damage" (grouping)

PostPosted: Fri May 23, 2008 12:43 am
by pyrometal
A solution, a lot less work than other methods: The code are centralized within every projectiles instead, and it does all the work.

Damage programing.zip
Simple and effective
(208.14 KiB) Downloaded 145 times


Drag the projectile actor into the enemy actors and see the behavior!

Re: collide with "any enemy" cause 20 "global damage" (grouping)

PostPosted: Fri May 23, 2008 12:46 am
by stevenp
thank you!

eternal legacy v2 can now continue development!

+1

Re: collide with "any enemy" cause 20 "global damage" (grouping)

PostPosted: Sat Nov 15, 2008 2:10 am
by Lexcondran
YAY i get olve someones problem again like i i with Animetanks Lost Marien. :D :lol: :D
lol so yeah i did a bit with this problem of hp and added a few text if you dont understand the scripts. :D :shock: :D
Also i redid leech animation and added blood--Enemy animations and added a Castlevania 4 Midi :D 8) :D