- Joined
- Aug 13, 2007
- Messages
- 309
I want to create an ability that does nothing but casts itself at intervals every x seconds. Everything else in this post is irrelevant and is just here to show you what I'd be doing with said ability if I had it.
I'd be using it as a timer to make units check for potential mates every once in awhile & auto-mate if there's a female that is not pregnant in the vicinity. That would be scripted based on the event.
i.e.
Edit 2: I also need an ability that can be toggled on or off and does nothing at all, but for my stamina system.
I'd be using it as a timer to make units check for potential mates every once in awhile & auto-mate if there's a female that is not pregnant in the vicinity. That would be scripted based on the event.
i.e.
-
Auto-mate
-
Events
- Unit - Any Unit uses Action - Mate at Generic6 - Complete stage (Ignore shared abilities)
-
Local Variables
- u = No Unit <Unit>
- u 2 = No Unit <Unit>
- cv = 0 <Integer>
- cv 2 = 0 <Integer>
- ug = (Empty unit group) <Unit Group>
- ut = No Game Link <Game Link - Unit>
- pt = No Point <Point>
- r = No Region <Region>
- gender = false <Boolean>
- ------- Constants
- radius = 15.0 <Real (Constant)>
- uf = Required: Biological; Excluded: Missile, Dead, Hidden <Unit Filter>
- Conditions
-
Actions
- General - Custom Script: lv_u = EventUnit();...
-
Events
JASS:
lv_u = EventUnit();
lv_cv = FixedToInt(UnitGetCustomValue(lv_u, gv_CVS));
if (!gv_mature[lv_cv]) {
return true;
}
lv_ut = UnitGetType(lv_u);
lv_pt = UnitGetPosition(lv_u);
lv_r = RegionCircle(lv_pt, lv_radius);
lv_ug = UnitGroup(null, c_playerAny, lv_r, lv_uf, 0);
UnitGroupLoopBegin(lv_ug);
while (!UnitGroupLoopDone()) {
lv_u2 = UnitGroupLoopCurrent();
lv_cv2 = FixedToInt(UnitGetCustomValue(lv_u2, gv_CVS));
if (UnitGetType(lv_u2) == lv_ut) {
if (gv_mature[lv_cv2]) {
if (gv_gender[lv_cv] != gv_gender[lv_cv2]) {
if ((!gv_pregnant[lv_cv]) && (!gv_pregnant[lv_cv2])) { // The other 'pregnancy' check actually checks the males fertility.
UnitIssueOrder(lv_u, OrderTargetingUnit(AbilityCommand("Mate", 0), lv_u2), c_orderQueueAddToEnd);
if (!gv_gender[lv_cv]) {
UnitGroupLoopEnd();
}
}
}
}
}
UnitGroupLoopStep();
}
UnitGroupLoopEnd();
UnitIssueOrder(lv_u, Order(AbilityCommand("stop", 0)), c_orderQueueAddToEnd);
Last edited: