| 05-01-2004, 12:39 AM | #1 |
Code:
Harvest Cast
Events
Unit - A unit Begins channeling an ability
Conditions
(Ability being cast) Equal to Harvest
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
InFertileSoil[(Player number of (Owner of (Casting unit)))] Equal to True
Then - Actions
For each (Integer A) from 1 to 5, do (Actions)
Loop - Actions
Custom script: set udg_HarvestPlayer = GetLocalPlayer()
Set HarvestCropPoint = (Random point in HarvestRegion[(Player number of HarvestPlayer)])
Unit - Create 1 Corn for (Player((Player number of HarvestPlayer))) at HarvestCropPoint facing Default building facing degrees
Unit Group - Add (Last created unit) to HarvestCrops[(Player number of HarvestPlayer)]
Wait 3.00 game-time seconds
For each (Integer B) from 1 to 5, do (Actions)
Loop - Actions
Custom script: set udg_HarvestPlayer = GetLocalPlayer()
Unit - Remove (Random unit from HarvestCrops[(Player number of HarvestPlayer)]) from the game
Wait 3.00 game-time seconds
Else - Actions
Game - Display to (Player group((Owner of (Casting unit)))) the text: Your crops have all...As you can see, I need to use local players so each player will get the right amount of crops created/removed and get the proper gold. (Gold & crop-types aren't in yet). But apparently Custom script: set udg_HarvestPlayer = GetLocalPlayer() desyncs. What can I do instead? |
| 05-01-2004, 12:48 AM | #2 |
You don't need GetLocalPlayer for that. Just do "For each player in (All players) do multiple actions". If you post what you're trying to do, someone should be able to help you more. |
| 05-01-2004, 12:53 AM | #3 |
Basically, if you're in "fertile soil" and you cast the spell, it creates one crop [based upon the level of the spell] every 3 seconds. After 5 crops it removes and sells them one by one, the value being based upon which crop it is. I havn't set the gold or different crop-types yet because I wanted to get it working first. I don't see another way outside of a trigger/timer for each player to keep track of this. |
| 05-01-2004, 01:42 AM | #4 |
Local Player is completely misused here (you create the crop on one computer in the game only which of course desyncs the game). What you actually want to use here is owner of casting unit I guess. |
| 05-01-2004, 01:45 AM | #5 |
I didn't test this, but I think this is the right idea. Code:
Harvest
Events
Unit - A unit Begins casting an ability
Conditions
(Ability being cast) Equal to Black Arrow
Actions
Custom script: local unit udg_HarvestUnit
Custom script: local group udg_HarvestGroup
Custom script: set udg_HarvestGroup = CreateGroup()
Set HarvestUnit = (Triggering unit)
If ((HarvestRegion[(Player number of (Owner of HarvestUnit))] contains HarvestUnit) Equal to False) then do (Skip remaining actions) else do (Do nothing)
For each (Integer A) from 1 to 5, do (Actions)
Loop - Actions
Unit - Create 1 Firebat for (Owner of HarvestUnit) at (Random point in HarvestRegion[(Player number of (Owner of HarvestUnit))]) facing (Position of (Triggering unit))
Unit Group - Add (Last created unit) to HarvestGroup
Wait 3.00 seconds
For each (Integer A) from 1 to 5, do (Actions)
Loop - Actions
Set tempUnit = (Random unit from HarvestGroup)
Unit Group - Remove tempUnit from HarvestGroup
Unit - Kill tempUnit |
