Jump to content


Photo

Elegant scripting


  • Please log in to reply
1 reply to this topic

#1 RoccoTheStiff

RoccoTheStiff
  • Members
  • 48 posts

Posted 05 January 2018 - 02:34 AM

Hey hey, so, since i'm noob i need help :p

 

I have a 5v2 map, to play with my coworker at work and i've added some base defenses, namely unit spawn if P1 or P2 is in area X and i've given all four AI's the fort's that shoot, ie, Mordor fireball, Isen lightning etc etc...

 

Current script i have checks if a particular unit is in area X and then fires mighty catapult at the nearest unity of that type. The problem is, it sometimes fires out of area, which looks horrid, ie enemy soldiers surrounding half the fort, which is loosing health rapidly and it's shooting over the hill to try to hit reinforcements. Kinda lame. Is there a minimum range on fort "capital" weapons?

 

Is there any other, better, more elegant way? For example it's a sheer load of scripts for 4 players (the fifth is a ragged clan of wildmen hiding in the forests and hills with no fort) and to cover almost all the units us two human players have. If i want to edit it it's 15 mins of work just running through the menus.

 

So i was thinking along the lines of, if infantry is in area X, shoot on closest infantry in area X? Is that doable?

 

Thanks for any answers.  :D



#2 Jokuc

Jokuc

    Hardcore Procrastinator

  • Members
  • 187 posts
  • Location:Sweden
  •  Mapper

Posted 16 January 2018 - 12:12 AM

1. I don't know if there's a minimum range or if it's just the fact that the fort won't let it target itself, but either way it's not something you can fix in worldbuilder and you'd have to make a map.ini for this. But isn't it kind of pointless for them to use fireball on their own buildings? I mean what you could do is make the lightning and fireball only damage units and not buildings.. which can be done in two different ways I believe, one of which is changing the armor for their fortress and the damage type for the fireball, but then you've got yourself even more ini stuff to learn.

 

What you can do in worldbuilder is having them fire rain of fire or something on the units when they are around the fort. My suggestion is making two areas. One that covers everything your current area does, except for a small area around their fortress, and another that covers only that small area around the fort. Then, I'd do something else to those units if they are inside that fort area. Like using oil on the Mordor fortress... or possibly spawning orcs next to it.

 

2. 

Current script i have checks if a particular unit is in area X and then fires mighty catapult at the nearest unity of that type

So i was thinking along the lines of, if infantry is in area X, shoot on closest infantry in area X? Is that doable?

 

I'm guessing you have a bunch of named units which spawn on your map and you're using the names of those to check whether they are in the area or not? Like this:

**IF** Unit 'UnluckyUnit01' is inside area 'X'
**OR** Unit 'UnluckyUnit02' is inside area 'X'

? In that case, you can reduce the amount of scripts and make it easier to add/change units by using unit types instead: (You can find this under Player instead of Unit)

**IF** 'Player_1' has Greater Than or Equal To 1 unit with KIND OF 'CAVALRY' in area 'X'
**OR** 'Player_1' has Greater Than or Equal To 1 unit with KIND OF 'INFANTRY' in area 'X'
**OR** 'Player_2' has Greater Than or Equal To 1 unit with KIND OF 'CAVALRY' in area 'X'
**OR** 'Player_2' has Greater Than or Equal To 1 unit with KIND OF 'INFANTRY' in area 'X'

Alternatively, you can use Teams, which also can be very useful. Go to Edit Teams, then to one of the human players. Player_1 for example, if that's the case for you. Add a new team and change its name to something easy to remember... "UnitSpawnP1" for example. Do the same for Player_2.

 

When you make the unit spawn scripts, pick the UnitSpawn team for the unit you're spawning like so:

Spawn 'UnluckyUnit01' of type 'ElvenLorienArcherHorde' on Team 'Player_1/UnitSpawnP1' at Waypoint 'X'

Then for the area scripts you check if the team is inside it rather than a specific unit:

**IF** Team 'Player_1/UnitSpawnP1' has one or more units in area 'X' (Surfaces Allowed:GROUND)

However, that'd mean you'll have to do all your unit spawn scripts all over again so the first option is probably better for you.

 

Alternative 3 which is the fastest and easiest, would be to just do a "If player 1 has units in area X", but that's not the smartest move to do if you have builders on your map, as the script will activate by both builders, buildings and even stuff like elven wood when you use it inside area X.


Edited by Jokuc, 16 January 2018 - 12:33 AM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users