HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Here I go again!

05-31-2006, 07:04 PM#1
James59281
I have another problem now.
Those of you who answered my previous post will probably be a little more familiar with my idea.

Here's my code:
Trigger:
Collapse Events
Time - Every 0.01 seconds of game time

Collapse Actions
Collapse Unit Group - Pick every unit in (Units in (Entire map) matching (((Unit-type of (Matching unit)) Equal to Bullet)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Collapse Then - Actions
Unit - Move (Picked unit) instantly to ((Position of (Picked unit)) offset by 8.00 towards (Facing of (Picked unit)) degrees)
Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) + 8.00)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Mana of (Picked unit)) Greater than or equal to 2000.00
Collapse Then - Actions
Unit - Kill (Picked unit)
Else - Actions
Else - Actions
Collapse Unit Group - Pick every unit in (Units in (Entire map) matching (((Unit-type of (Matching unit)) Equal to Bullet)
Collapse Loop - Actions
Set PickedUnit = (Picked unit)
Collapse Unit Group - Pick every unit in (Units within 60.00 of (Position of PickedUnit)) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Mana of PickedUnit) Greater than 60.00
((Picked unit) is dead) Equal to False
(PickedUnit is dead) Equal to False
(Level of 100% Evasion for (Picked unit)) Equal to 0
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Picked unit) has an item of type bullet deflector 1 Equal to False
((Picked unit) has an item of type bullet deflector 2 Equal to False
Collapse Then - Actions
Unit - Cause PickedUnit to damage (Picked unit), dealing 1000000000.00 damage of attack type Normal and damage type Normal
Else - Actions
-------- ****** BULLET DEFLECTION ****** --------
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Collapse Or - Any (Conditions) are true
Collapse Conditions
((Picked unit) has an item of type bullet deflector 1 Equal to True
((Picked unit) has an item of type bullet deflector 2 Equal to True
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Facing of PickedUnit) Less than 180.00
Collapse Then - Actions
Unit - Move PickedUnit instantly to ((Position of PickedUnit) offset by 0 towards ((Facing of PickedUnit) + 180.00) degrees), facing ((Facing of PickedUnit) + 180.00) degrees
Collapse Else - Actions
Unit - Move PickedUnit instantly to ((Position of PickedUnit) offset by 0 towards ((Facing of PickedUnit) - 180.00) degrees), facing ((Facing of PickedUnit) - 180.00) degrees
Else - Actions
Else - Actions


Basically, i'm trying to make a custom bullet move such that if it gets too close to another unit then it damages it. But if the unit has a bullet deflector, the bullet reverses direction.
Some notes:
The current mana of the unit is used to track how far it has travelled.
Picked unit and PickedUnit are different units. The former is the unit that will be damaged, and the latter is the bullet itself.

My problem: the bullet doesn't reverse direction but gets a little stuck on a unit with a bullet deflector. It takes a while for it to get unstuck, jiggles around a bit and then flies off back towards the direction it came from but not directly in the opposite direction.

It works fine on units without a bullet deflector.

Also, any suggestions for reducing lag or leaking?
05-31-2006, 08:54 PM#2
The_AwaKening
OUch, I would probably find another way of doing this. Selecting a unitgroup every .01 seconds of game is gonna lag no matter what you do with this.

You should only need to group once instead of twice and just throw the bottom set of actions at the bottom of your first group.

On your if/then/else in the second group, you'll notice that you are setting new if/then/else when you could be throwing them in the else section above it. The whole thing confuses me since picked unit is different variables. It also looks like the condition you set for the last action is checking the unit facing. Shouldn't you be checking for the range?
05-31-2006, 08:55 PM#3
James59281
Thanks for your reply. i wasn't sure if anyone would actually answer! LOL

The lag issue wasn't really my primary concern - i need to figure out why my bullet is following such a weird trajectory. I can't understand why it doesn't just reverse direction.

Thanks for the suggestion about putting it in one unit group selection action, but i can't see how it would work. I know it's confusing, but it's because the first one picks units of type bullet, the second one picks units of type not equal to bullet, but only close to the bullet to keep lag to a minimum. There's only going to be a few bullets at any time so i'm hoping the lag won't be *that* bad.

I have noticed though, that lag gets pretty bad after about 6 or more bullets have been fired. It's as if th bullets still exist even after i killed them.
Weird? Is this what is called leaking?
How can i fix it?

(This is a sub-question to my original question)



EDIT : sorry, i see what you mean about the unit groups now - there's one too many.
06-01-2006, 09:51 AM#4
Captain Griffen
Trigger:
Collapse Events
Time - Every 0.01 seconds of game time

Collapse Actions
Set TempGroup = Pick every unit in (Units in (Entire map) matching (((Unit-type of (Matching unit)) Equal to Bullet)
Collapse Unit Group - Pick every unit in TempGroup and do actions
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
//WHAT conditions?
Collapse Then - Actions
Custom Script: call SetUnitPosition(GetEnumUnit(), GetUnitX(GetEnumUnit()) + 8 * Cos(GetUnitFacing(GetEnumUnit()) * bj_DEGTORAD), GetUnitX(GetEnumUnit()) + 8 * Sin(GetUnitFacing(GetEnumUnit()) * bj_DEGTORAD))
Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) + 8.00)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Mana of (Picked unit)) Greater than or equal to 2000.00
Collapse Then - Actions
Unit - Kill (Picked unit)
Else - Actions
Else - Actions
Set PickedUnit = (Picked unit)
Set DamagedGroup = Pick every unit in (Units within 60.00 of (Position of PickedUnit))
Collapse Unit Group - Pick every unit in DamagedGroup and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Mana of PickedUnit) Greater than 60.00
((Picked unit) is dead) Equal to False
(PickedUnit is dead) Equal to False
(Level of 100% Evasion for (Picked unit)) Equal to 0
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Picked unit) has an item of type bullet deflector 1 Equal to False
((Picked unit) has an item of type bullet deflector 2 Equal to False
Collapse Then - Actions
Unit - Cause PickedUnit to damage (Picked unit), dealing 10000.00 damage of attack type Normal and damage type Normal
Collapse -------- ****** BULLET DEFLECTION ****** --------
//Why do you need ANOTHER identicle if/then/else?
Collapse Else - Actions
Collapse // If/then/else here also unneeded. 450 = 90.
Custom Script: SetUnitFacing(udg_PickedUnit, GetUnitFacing(udg_PickedUnit) + 180)
Custom Script: call SetUnitPosition(udg_PickedUnit, GetUnitX(udg_PickedUnit) + 8 * Cos(GetUnitFacing(udg_PickedUnit) * bj_DEGTORAD), GetUnitX(udg_PickedUnit) + 8 * Sin(GetUnitFacing(udg_PickedUnit) * bj_DEGTORAD))
Else - Actions
Custom Script: call DestroyGroup(udg_DamagedGroup)
Custom Script: call DestroyGroup(udg_TempGroup)

Hasn't quite lined everything up, but you can work it out. Anyway, I would very much suggest having a unit group permamently which you add and remove them from.
06-01-2006, 11:44 AM#5
blu_da_noob
I thought nesting ForGroup's didn't work, or did they change that?