• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Pregnancy for game

Status
Not open for further replies.
In a game im making (sheep farmer) which i based on another persons game which isnt very good. You farm sheep. The sheep will feed them selves (im pretty sure i can get this right) but the sheep breed on thier own. I cant figure it out exactley. In the game it uses a load and when the mana bar of it is full you get the baby, i cant figure this part out. Any ideas how to do that?
 
Level 11
Joined
Jul 12, 2005
Messages
764
Maybe picking every Sheep every x seconds that have max mana, then create a new one, and set their mana to 0.
Event - Every 1 seconds of the game
Actions-
Pick every Sheep ..blahblah
If (Mana of Picked Unit) is equal to (Max mana of Picked Unit) then
-Create a new sheep at position of picked unit
-Set mana of Picked unit to 0

Don't forget to clean the leaks!!
 
Level 2
Joined
Apr 27, 2004
Messages
28
too much resource usage checking every x seconds for an entire game.

I would start by trying something like giving the sheep a dummy spell that does nothing and set the the cool down to match thier mana regen rate, and use a "finishes casting" event for the sheep.

If thier mana is not constant then you may want to try making thier "food" a unit and run a unit dies event and setting a real variable to track thier mana. Devour would probably work for this, just make them devour the food unit.
 
Level 8
Joined
Sep 13, 2006
Messages
431
Hmmmm... I'm thinking that picking every second could get kinda laggy for those with slower comps. If I were to do it, I would probably use dummy units and casting times, not involving mana at all.

For example: Sheep get their groove on and female becomes pregnant. Create dummy to cast spell on female, with x second cast time. When the spell finally casts, you can reference the target unit of the spell (the pregnant sheep) and create a baby at the target point.

Pretty sure this would work, though it's probably not the most efficient option...
 
Level 11
Joined
Jul 12, 2005
Messages
764
Hmmmm... I'm thinking that picking every second could get kinda laggy for those with slower comps.
So? I don't have a hypercomputer neither (2 GHz, 256 Mb Ram, 64Mb video card, it is 4 years old..), and not even a 0.1 sec trigger (not too complicated of course) lagged for me. If the leaks are cleaned properly enough, i think that's the easiest way.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,207
You need to make some kind of basic trigger enhanced AI. Sheep usualy reproduce at seasons, not with a timer so maybe make them get a baby during the day and it takes 12 hours (game time) for the lamb to grow into a sheep. This is more realistic and can be easier since at the time of day you can set a boolean peramater to allow the sheep to reproduce. You can incorperate the reproduction into the automatic eating trigger. Simply 1 sheep(male) looks for a non pregnent sheep(female) and then casts a spell on it. With jass this would be easier but it is still do able with GUI.
 
Level 8
Joined
Sep 13, 2006
Messages
431
Spell 1: Impregnate
Do it however you want, but it needs to be a single target spell.
Spell 2: Pregnancy
Modified Brilliance Aura that affects only the unit that has the ability

Female sheep: No mana regen, no abilities
Male sheep: has Impregnate ability
Baby sheep: whatever

Don't have WE in front of me, but here's the basics:

Trigger 1
Events
A unit starts the effect of an ability
Conditions
Ability being cast is equal to Impregnate
Actions
IF
target unit of ability being cast is of unit type (Female Sheep)
THEN
Set target unit of ability being cast mana to 0
Give target unit of ability being cast Pregnancy //the spell described earlier
ELSE
Display to Owner of Casting Unit "I don't think it works that way..." // just in case someone decided to target a male sheep or a person,, etc. :)

Trigger 2
Events
Every 1 second of game time
Conditions
Actions
Pick every unit in playable map area matching (unit type of matching unit is equal to female sheep) and (matching unit mana is equal to 100% of max mana).
-Loop
Set mana of picked unit to 0
Create baby sheep at location of picked unit
Remove Pregnancy from picked unit


Anyway, something like that should do it. Make sure to fix leaks and all that, and good luck...
 
Status
Not open for further replies.
Top