Code analysis, how to prevent variables from getting the same unit

  • Thread starter Thread starter ThE-eNiGmA
  • Start date Start date
T

ThE-eNiGmA

Guest
Posting yet again, but here is my revised, second version of bombing run, with pseudo AoE damage. It isn't balanced, but works fine except for one potential glaring flaw. It is possible for 2+ variables to have the same unit...which means that the unit, unfairly, gets (2+)x damage. Can anybody suggest a way to avoid that pitfall, or simply refine my code (without resorting to JASS if possible) LoL, I wouldnt mind knowing how to actually make the unit dive...which would be a reverse of a jump ability I know i have seen somewhere...

Bombing Run Copy
Events
Unit - A unit Begins casting an ability
Conditions
(Ability being cast) Equal to Bombing Run
Actions
Unit - Set (Casting unit) movement speed to 400.00
Unit - Order (Casting unit) to Move To (Target point of ability being cast)
For each (Integer A) from 1 to 8, do (Actions)
Loop - Actions
Wait (Random real number between 0.05 and 0.50) game-time seconds
Set BombDrop[0] = (Random point in (Region centered at (Position of (Casting unit)) with size (400.00, 400.00)))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Region centered at BombDrop[0] with size (200.00, 200.00)) contains (Matching unit)) Equal to True
Then - Actions
Set BombedUnit[0] = (Random unit from (Units in (Region centered at (BombDrop[0] offset by (0.00, 0.00)) with size (400.00, 400.00)) matching (((((Unit-type of (Matching unit)) is A structure) Equal to True) or (((Unit-type of (Matching unit)) is A ground unit) Equal to True)) a
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Region centered at BombDrop[1] with size (200.00, 200.00)) contains (Matching unit)) Equal to True
Then - Actions
Set BombedUnit[1] = (Random unit from (Units in (Region centered at (BombDrop[0] offset by (0.00, 0.00)) with size (400.00, 400.00)) matching (((((Unit-type of (Matching unit)) is A structure) Equal to True) or (((Unit-type of (Matching unit)) is A ground unit) Equal to True)) a
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Region centered at BombDrop[2] with size (200.00, 200.00)) contains (Matching unit)) Equal to True
Then - Actions
Set BombedUnit[2] = (Random unit from (Units in (Region centered at (BombDrop[0] offset by (0.00, 0.00)) with size (400.00, 400.00)) matching (((((Unit-type of (Matching unit)) is A structure) Equal to True) or (((Unit-type of (Matching unit)) is A ground unit) Equal to True)) a
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Region centered at BombDrop[3] with size (200.00, 200.00)) contains (Matching unit)) Equal to True
Then - Actions
Set BombedUnit[3] = (Random unit from (Units in (Region centered at (BombDrop[0] offset by (0.00, 0.00)) with size (400.00, 400.00)) matching (((((Unit-type of (Matching unit)) is A structure) Equal to True) or (((Unit-type of (Matching unit)) is A ground unit) Equal to True)) a
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Region centered at BombDrop[4] with size (200.00, 200.00)) contains (Matching unit)) Equal to True
Then - Actions
Set BombedUnit[4] = (Random unit from (Units in (Region centered at (BombDrop[0] offset by (0.00, 0.00)) with size (400.00, 400.00)) matching (((((Unit-type of (Matching unit)) is A structure) Equal to True) or (((Unit-type of (Matching unit)) is A ground unit) Equal to True)) a
Else - Actions
Special Effect - Create a special effect at BombDrop[0] using Objects\Spawnmodels\Human\SmallFlameSpawn\SmallFlameSpawn.mdl
Unit - Order (Casting unit) to damage BombedUnit[0] for 100.00 using attack type Siege and damage type Demolition.
Unit - Order (Casting unit) to damage BombedUnit[1] for 100.00 using attack type Siege and damage type Demolition.
Unit - Order (Casting unit) to damage BombedUnit[2] for 100.00 using attack type Siege and damage type Demolition.
Unit - Order (Casting unit) to damage BombedUnit[3] for 100.00 using attack type Siege and damage type Demolition.
Unit - Order (Casting unit) to damage BombedUnit[4] for 100.00 using attack type Siege and damage type Demolition.
Unit - Set (Casting unit) movement speed to (Default movement speed of (Casting unit))
 
add another condition to make it so that trigger can only happen for the same unit once but again once the cooldown is down.

or instead of the trigger being started from the start of the casting have it start at the end maybe?
 
1. Yes, they can get picked twice.
2. That will happen A LOT because 8 random points in a region thats only 400x400.
3. You may as well damage all units IN the 400x400.
4. Why the wait? Your bombing them at the end anyway. No need.
5. Here is a revised copy. You need a UNIT GROUP variable called Bombed Units.

Code:
Bombing Run Copy
Events
Unit - A unit Begins casting an ability
Conditions
(Ability being cast) Equal to Bombing Run
Actions
Unit - Set (Casting unit) movement speed to 400.00
Unit - Order (Casting unit) to Move To (Target point of ability being cast)
For each (Integer A) from 1 to 8, do (Actions)
  Loop - Actions
  Unit Group - Pick every unit in (Units in (Region centered at (Random point in (Region centered at (Position of (Casting unit)) with size (400.00, 400.00))) with size (200.00, 200.00))) and do (Unit Group - Add (Picked unit) to Bombed_Units)
Unit Group - Pick every unit in Bombed_Units and do (Actions)
  Loop - Actions
    Special Effect - Create a special effect at (Picked unit) using Objects\Spawnmodels\Human\SmallFlameSpawn\SmallFlameSpawn.mdl
    Unit - Order (Casting unit) to damage (Picked unit) for 100.00 using attack type Siege and damage type Demolition.
Unit - Set (Casting unit) movement speed to (Default movement speed of (Casting unit))
 
Or that could work, its better and faster.
 
lol, i never thought of the unit group. why the wait? It is a bombing run. you dont have bombs appearing all at once. I spread it out a bit. They are not ALL getting bombed in the end. By the time the bomber moves to the end of its run, it should be hitting a different set of units. Plus, the "8" is not 8 points in the same region...the unit is moving during the process. its is actually 1 point, but 5 units. It just gets repeated and updated once it loops. Note- the first working version of the trigger was set up so that the effect appeared on the unit itself. What i was trying to do was stimulate the randomness of an actual bombing run. Its all splash. I'm glad you told me about the unit group...that is a variable I have never used so far. Hmm...just realized something. You may be right, i haven't forced the unit to move in a line, just to move to where the ability is cast. Which means you can just squat there if you aim right near you. Not good. I'm gonna have to work on that.
(edit) Oh, speaking of which, after working on something like this over the weekend(and giving up, i might add), do you know how to get a unit to move in a straight, predefined distance in the direction of a target point? I came close, but too many things just werent working.
 
It is supposed to simulate a bombing run...that is... the bomber moves in a straight line and drops bombs. The effect is where the bomb is, and there is splash damage to ground units around the bomb. What i should do is set the integer to a random number, to add more randomness. BTW, i tried the unit group variable, modified it, and it didn't work. Ill have to look at it again later.
 
Heh i was bored so i decided to try this...
Ya, it was HARD i gave up :D but i got this far...

1-made unit ability
2-made trigger
3-tested
4-hits both air and ground (i was 2 lazy)
5-only goes one way... thats north
6-can control when bombing... but dmg is still dealt in a line
7-4 explosions
... its ok i guess in my standard, maybe you can adjust it to your needs?(i think you will need multiple triggers for different general degrees the unit is facing)
 

Attachments

I modified it, over and over. Added a few more effects, like sound, and simplified the code. What I feel would be the real trick is to get it to go a defined distance IN THE DIRECTION of the point. What I originally tried to do was make the point the half-way mark in the bombing run. The unit would fly to the point, and then keep on going....no such luck. Back then the code was much different, anyway. Maybe what I should do is make the unit unselectable (if only i could do this with triggers, maybe i should replace the bomber with a copy with locust), have the unit go to a spot that is offset from the point a certain distance, then have the unit go TO the point, and then the run is over. I know it is possible, but thinking of all the relationships involved could be tricky.

I also made another interesting thing for my map...Three whirling tornadoes that also have lightning strikes nearby that do damage. The only problem is, even though I gave them fly, they dont wander very far...and i need a more randomized movement.
I added a trigger that randomizes their speed, from 100 to 300, but dunno how much good that does.
 
Iv been lost in this thread as I really am not good with triggers. But, here is what I have been able to come up with:

Dive Down, Opposite of Jump: perhaps you could use a variation of conans jump ability (search the forums a bit) and give it a negative trajectory; you would likely have to scrap your entire trigger right now though, probably not the best idea

Unselectable: what do you mean, you cant make it unselectable?! There are a few actions that can remove the unit from the players selection; you could make the plane neutral victim and unselect it and then just reselect it when it is through.
Alternately, you could just unselect for player x, and then loop that every .1 seconds or something.

Cant help with more, hope this aids you, lol :D

Edit- the tornadoes will be big right :D perhaps you could even make it a seasonal thing, like weather, if you plan on making variable weather as well
 
I worked on it earlier this morning (I am at school now) and added some stuff ...ohhhhh...now i know why my trigger stopped working. Lol, it came to me as I was typing this. I replaced the bomber unit with a bomber with locust, making it unselectabe, unattackable. I tried to add some lines detailing the flight path, but all it does is go in the opposite direction from what i wanted. Not only that, but the bombs stopped falling. I just figured out that my bomb-loop trigger needs to be edited a bit...here is a question, can you set the unit doing damage = no unit and still have it work? I think it should...

Thanks shadow, I heard a reference to the jump trigger somewhere but never really searched for it all that hard (the one time I tried, i stumbled on the evolution thread...)
(edit) Yes, the tornadoes are big...and it is funny to see a ship being up in the air.
Doesn't do much damage though.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Real users can't really disable Javascript anymore these days.
  • Ghan Ghan:
    The internet is broken without it.
  • Ghan Ghan:
    Bot readable, not human usable.
  • The Helper The Helper:
    got it
  • The Helper The Helper:
    Happy Thursday!
  • The Helper The Helper:
    Check out the new Featured Content feature we apparently got with the forum software upgrade! https://www.thehelper.net/featured/
  • The Helper The Helper:
    Also on the bottom right side bar we now have a Trending Content Box!
    +1
  • The Helper The Helper:
    Not on the Headline News page just on the Forums page can we get that Featured and Trending on the home page?
  • Ghan Ghan:
    Since the home page is technically a forum, it now shows on all forum views. Still in the sidebar.
    +1
  • The Helper The Helper:
    Happy Friday! Hope everyone has a fantastic day and an even better weekend!
  • The Helper The Helper:
    Happy Sunday!
  • The Helper The Helper:
    I lovc that I can post webp and X links now! :)
  • The Helper The Helper:
    Happy Thursday!
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    we were down for a minute - think a log file or something got too big
    +1
  • Ghan Ghan:
    The alerts say it was down for a while unfortunately.
  • Ghan Ghan:
    Didn't know what was going on while I was at work.
  • Ghan Ghan:
    Disk filled up with logs. Fixed now.
    +1
  • The Helper The Helper:
    not a problem at all thanks for getting us back up
  • The Helper The Helper:
    I think the bots are finding a way to get through the anubis
  • The Helper The Helper:
    Happy Wednesday Everyone! Hope everyone has a Fantastic Day!
    +1
  • The Helper The Helper:
    Yeah, stats are showing big bot influx like 12k page views.
  • Wizard Wizard:
    :wave:
    +1
  • Ghan Ghan:
    TH changed his avatar again. 6 more weeks of summer.
    +3
  • Wizard Wizard:
    lol
    +1

The Helper Discord

Members online

No members online now.

Affiliates

Hive Workshop NUON Dome World Editor Tutorials
Back
Top