Jump to content


Photo

Script to move any unit


  • Please log in to reply
1 reply to this topic

#1 Ap0C552

Ap0C552
  • Members
  • 84 posts

Posted 11 December 2009 - 11:03 PM

Sorry if I spam these forums with questions over the next little while. When I come up with a great new gameplay idea and I am in the early concept stage, I need to discover ways to make the core mechanics work. That involves doing things I have never done, and things I can't do. Anyways.......

Two things.

I am trying to create a simpler way to move large amounts of spawned enemies around the map.

I have not had much success.

Basically I thought I would create a conveyor belt kind of system.

Instead of say "spawn unit named X" and "Spawn unit named y" etc etc and then "move unit X to here" and "Move unit Y to here" I could just eliminate the naming all together. I could do this by just creating an area with a waypoint in it. All units spawn on waypoint and then I have a script along the lines of "Any unit in area X move to waypoint y"

That way I don't have to name every single spawned unit to later tell the game to moved named unit. I could just spawn mass amounts of enemies in an area and tell them game "Any unit inside this area move here".

The problem being there is no selection for <Any Object> just like there is <any player>. I was hoping I could creata a script that said

If <any object> is in area X

move <any object> to waypoint.


So you guys have any idea if there is another way I could do this. I would just be so simple to move tha mass amounts of spawned enemy waves with less lines of scripting.


ALSO


I want to have players have to enter an area to recharge their science power, particularily "heal". So "if player is in area X , set science availability to available". But here is the thing, once they cast that power, I don't want them to be able to use it again until they re enter this special area. So I need to find a way to have the power set to unavailble once the power is executed. Only problem is there is no script that I can do this with. I can do this with a Hero power. There is a script that "when player starts using special (hero) power......" but there is not script for "When player starts using Science power".

Essentially what I need is "when player uses science power X, set science availability to unavaible"

If I can not manage to make this happen some way, my whole awesome gameplay idea will be completely messed, and I might cry.....possibly. :p If you have any work arounds, I would be incredibly grateful!!!!!!



EDIT: SOLUTION

If someone is dumb enough as me to make the same mistake, here is a solution for you.

The script that I thought only reffered to hero's powers also referred to science powers as well, and it worked successfully.

*** IF ***
	Player Player 'Player_1' starts using Special power 'SpellBookHeal'.
*** THEN ***
  Null operation. (Does nothing.)
   Player 'Player_1' set Science 'SCIENCE_Heal' availability to Science availability 'Disabled'.

Edited by Ap0C552, 11 December 2009 - 11:58 PM.


#2 Puzzler33

Puzzler33
  • Members
  • 226 posts

Posted 12 December 2009 - 04:21 PM

(There is no need for 'null operation' actions if there are in fact actions but whatever...)

These problems are relatively simple and hopefully I can address them all.

For the first problem you have to use (sub)teams go into edit > edit teams... then in the window you will see all the players on the left and in the main window each team will have the subteam as '(default team)'. It would help to know a bit more about the concept of the map in order to give relevant advice but I gather you may be doing something similar to a hero vs waves map.

So anyway first of all add a new (sub)team to the player you want to control the subteam (I will assume it is PlyrCreeps) and give it a relevant name. This subteam should be sufficient as it is but you may want to put in ATTACK_TEAM as behaviour and set stance to Aggressive and so on. You do not need to create units on this subteam.

The rule with the way I think is best to spawn troops (as I will explain) is that the number of subteams you need is at minimum the number of groups of units which will exist with separate orders (different paths to follow). Generally this means that if you have 3 different paths (a, b and c) and you spawn each wave in two parts (part i and ii, where ii always comes 15 seconds after ii) then you will need 6 subteams for that wave. Going back to the general rule, it is only ever necessary to have at least 4 subteams where you will only ever have 4 groups of units with different orders to each other. You may have more, for example, if you have 4 paths but you only ever use 3 paths in any one wave and there are no waves split into parts, because you would want to keep it clear which subteam is spawning and following which path. Hopefully you understand this.

To spawn one wave of creeps following one path (where the wave is not segmented) then you will need 1 subteam. I will call this subteam Path A (as it will follow path A).

IF:
(Wave Trigger example:
Counter 'Wave Number' is equal to 1)

THEN:
(Wave example:
Spawn unit of type 'GoblinWarriorHorde' at waypoint 'spawn A' on team 'TeamPlyrCreeps/Path A'
Spawn unit of type 'GoblinWarriorHorde' at waypoint 'spawn A' on team 'TeamPlyrCreeps/Path A'
Spawn unit of type 'GoblinWarriorHorde' at waypoint 'spawn A' on team 'TeamPlyrCreeps/Path A'
Spawn unit of type 'GoblinCaveTroll' at waypoint 'spawn A' on team 'TeamPlyrCreeps/Path A'
Set timer 'wave move' to expire in 2 seconds)

IF:
'wave move' has expired
*AND*
Counter 'Wave Number' is equal to 1

THEN:
(Attack)Move team 'TeamPlyrCreeps/Path A' along waypoint path 'Path A'

The subteam the troops are on means you don't need to name them.

This method is good because you can copy the spawning of a unit for identical units, edit the last one to make a different unit and then copy that (etc.).
The problem with this is that (as far as I am aware) you can not give these units upgrades and it is harder to give them experience.

The other way you can do it is to set up the waves you want within the teams place rather than leaving it empty (note that you will need at least as many teams as you have unique groups of units, so you can only use a subteam once this way unless you use identical waves), where you can easily edit the properties of the spawning units and their numbers are decided by a number rather than a copied action. Once you have this prepared wave, instead of spawning units you can spawn the subteam as a reinforcement team (note the team has to have the two options at the bottom – which are similar to 'AI can build' and 'Reinforce wherever possible') so the script action would be something like
Spawn team 'TeamPlyrCreeps/Wave1A' at waypoint 'Path A'
(Where 1A means the first wave following path A)

Just to inform you about a really annoying aspect of worldbuilder scripting, there is no link between the trigger and consequence of a script, which means you always have to specifically reference which unit(s) the trigger and action apply/applies to, which makes 'move <any object> to waypoint' utterly impossible (because you have to make reference to the unit).

The thing about the heal you will find is that you can't make the recharge time much quicker without an ini file or loads of indestructible signal fires (belonging to specific players) and they probably won't recharge unless the power is enabled. Despite this, try using player (action)>special power>Special Power 'SCIENCE_Heal' set recharge timer to 5 seconds, if you can do something like that.
Posted Image




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users