HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

revive normal unit and keep the variable?

01-14-2003, 01:53 PM#1
SilentSpyder
So here's my problem. I got a map with a town, that consist of about 70 villagers. Each villager has a varriable (array to be exact).

Now if a unit is killed, what easy way is there to revive it, without losing the variable. I tried replacing the unit, but the variable gets lost. I know one way to do it, but it requires 70 "If/then else".

So is there an easier way. To be more detailed, when a unit dies, its suppose to revive after a minute, in a random part of the map. So that it'll look like a new villager has entered the map, and not actually revived.
01-14-2003, 02:51 PM#2
Guest
Events :
A Unit owned by neutral passive dies

Conditions :
Dying unit is in (town region)
Dying unit (of type) equal to male 1 or dying unit of type equal to male 2 or dying unit of type equal to kid or dying *blah blah blah you get the point

Events :
Wait 60.00 seconds
Instantly Revive (Dying Unit) at random position in (Town Region) - Hide revival graphics
01-14-2003, 02:59 PM#3
DraX
Add a wait for 60 seconds and a condition for the unit types allowed.
01-15-2003, 12:56 AM#4
SilentSpyder
That doesn't work on normal units. Does anyone know?
01-15-2003, 04:06 PM#5
Guest
hmm, seems we have to ust the unit-moovement hight for the 3.th time, now as speed:)

VillagerNumber Real, default 160 (normal speed - a bit to make them not too fast), it's important to set it default to a start number to aquire a normal Speed!


Trigger:
Map initialtzation
Action:
For each integer A from 1-70 do action (run trigger createVillager)

CreateVillager:
Action:
Create a Villager at desired point (you should have this)
Unit Set Movement Speed (last created unit) to VillagerNumber
Set Variable VillagerNumber=VillagerNumber+1

Villager dies:
Triggers:
Think you have them
Actions:
Wait 60s
Create a Villager at desired point (you should have this)
Unit Set Movement Speed (last created unit) to (unit - current movement Speed (triggering unit))


To get the VillagerNumber out of a Villager:
VillagerNumber=unit current Movement Speed of desired Villager - 160


Should work fine, if you find a way to do it with max mana (should be possible) it's the same thing. But the change of Speed is so marginal that it should not even be noticed.

If it does not work, e.g. because the unit movement Speed of the 60secs dead Villager cant be remembered, post, then I'll have to think again. It's a pitty you can't use variable or a array as cache to store the movement speed cause the trigger can rum several times at the same time (because of the 60sec wait-timer), and the variable can be changed from outside (sucking global Variables!) by the other ones. :////

Edit:
Default movement spped ---> Current Movement Speed
Edited VillagerNumber + Create Villager
01-15-2003, 10:30 PM#6
Unindel
what is the variable on each unit exactly? if u mean that theres a unit array with each unit being placed in the array, try this:

event: unit owned by neutral passive dies
condition: unit type of (dying unit) equal to *whatever unit type u want*
action:
replace (dying unit) with a (unit-type of (dying unit)) using (The new unit's default) life and mana
for every integer a from 1 to 70 (or whatever starting/ending point they had in the array (0-69 21-90) do (If (unit[integer a] equal to No unit) then do (Set unit[integer a] = (Last Created unit) else do (Do nothing).

that'll replace the unit and check through the array for a spot with a missing unit, and have that spot point to the unit that was just replaced.
01-15-2003, 10:45 PM#7
dataangel
Easiest way:

Event
Unit dies
Condition
Unit is owned by blah....
Action
set temp = 0 (make this new var in the var editor)

For each integer A from 1 to 70 if (Dying unit) is equal to Villagers[IntegerA] then set temp = Integer A

if Villagers[temp] does not equal No Unit, then Do nothing else Skip Remaining Actions

Unit create new peasant at random location

Set Villagers[temp] = Last Created Unit

Hide Unit

Wait 60 seconds

Unhide unit


Test it to make sure it works -- the Wait 60 seconds may cause it never to unhide (wait is buggy).
01-16-2003, 05:51 AM#8
SilentSpyder
Thanks, the trigger with the "temp" variable seems to work.