| 01-03-2004, 06:29 AM | #1 |
This trigger will show you how to create the custom spell Convert. It will allow the hero to convert a unit on a % chance basis on every successive hit. (2 trigger skill) Variables NEEDED: HeroConvertPlayer (Integer Array Size 12) HeroUnit (Unit Array Size 12) ConvertChanceNumberPart1 (Integer Array Size 12) ConvertChanceNumberPart2 (Integer Array Size 12) This trigger is required to update the level of the skill by variable. Code:
ConversionUpdate
Events
Unit - A unit owned by Player 1 (Red) Learns a skill
Unit - A unit owned by Player 2 (Blue) Learns a skill
Unit - A unit owned by Player 3 (Teal) Learns a skill
Unit - A unit owned by Player 4 (Purple) Learns a skill
Unit - A unit owned by Player 4 (Purple) Learns a skill
Unit - A unit owned by Player 5 (Yellow) Learns a skill
Unit - A unit owned by Player 6 (Orange) Learns a skill
Unit - A unit owned by Player 7 (Green) Learns a skill
Unit - A unit owned by Player 8 (Pink) Learns a skill
Unit - A unit owned by Player 9 (Gray) Learns a skill
Unit - A unit owned by Player 10 (Light Blue) Learns a skill
Unit - A unit owned by Player 11 (Dark Green) Learns a skill
Unit - A unit owned by Player 12 (Brown) Learns a skill
Conditions
(Learned Hero Skill) Equal to Conversion
Actions
Set HeroConvertPlayer[(Player number of (Owner of (Triggering unit)))] = (HeroConvertPlayer[(Player number of (Owner of (Triggering unit)))] + 1)Here's the big killer. Code:
ConversionTrigger
Events
Unit - A unit owned by Neutral Hostile (Or whatever player) Is attacked
Conditions - NONE
Actions
For each (Integer A) from 1 to 12, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Attacking unit)) Equal to Player[(Integer A)]
Then - Actions
For each (Integer B) from 1 to 30, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroConvertPlayer[(Player number of (Owner of (Attacking unit)))] Equal to (Integer B)
(Attacking unit) Equal to HeroUnit[(Player number of (Owner of (Attacking unit)))]
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroConvertPlayer[(Player number of (Owner of (Attacking unit)))] Greater than or equal to 1
HeroConvertPlayer[(Player number of (Owner of (Attacking unit)))] Less than or equal to 5
Then - Actions
Set ConvertChanceNumberPart1[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 20)
Set ConvertChanceNumberPart2[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 20)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroConvertPlayer[(Player number of (Owner of (Attacking unit)))] Greater than or equal to 6
HeroConvertPlayer[(Player number of (Owner of (Attacking unit)))] Less than or equal to 10
Then - Actions
Set ConvertChanceNumberPart1[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 17)
Set ConvertChanceNumberPart2[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 17)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroConvertPlayer[(Player number of (Owner of (Attacking unit)))] Greater than or equal to 11
HeroConvertPlayer[(Player number of (Owner of (Attacking unit)))] Less than or equal to 15
Then - Actions
Set ConvertChanceNumberPart1[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 14)
Set ConvertChanceNumberPart2[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 14)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroConvertPlayer[(Player number of (Owner of (Attacking unit)))] Greater than or equal to 16
HeroConvertPlayer[(Player number of (Owner of (Attacking unit)))] Less than or equal to 20
Then - Actions
Set ConvertChanceNumberPart1[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 13)
Set ConvertChanceNumberPart2[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 13)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroConvertPlayer[(Player number of (Owner of (Attacking unit)))] Greater than or equal to 21
HeroConvertPlayer[(Player number of (Owner of (Attacking unit)))] Less than or equal to 25
Then - Actions
Set ConvertChanceNumberPart1[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 11)
Set ConvertChanceNumberPart2[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 11)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroConvertPlayer[(Player number of (Owner of (Attacking unit)))] Greater than or equal to 26
HeroConvertPlayer[(Player number of (Owner of (Attacking unit)))] Less than or equal to 30
Then - Actions
Set ConvertChanceNumberPart1[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 10)
Set ConvertChanceNumberPart2[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 10)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
ConvertChanceNumberPart1[(Player number of (Owner of (Attacking unit)))] Equal to ConvertChanceNumberPart2[(Player number of (Owner of (Attacking unit)))]
Then - Actions
Unit - Change ownership of (Attacked unit) to (Owner of (Attacking unit)) and Change color
Else - Actions
Else - Actions
Else - ActionsExplanation and Customization Ok, this big huge trigger first of all checks for many things. The amount of levels this particular convert spell has 30. So I made every 5 levels of the skill to increase in %. Of course you can change this to whatever you want at this sections Code:
HeroConvertPlayer[(Player number of (Owner of (Attacking unit)))] Greater than or equal to X
HeroConvertPlayer[(Player number of (Owner of (Attacking unit)))] Less than or equal to XNow the harder part and the limits of this skill. Code:
Set ConvertChanceNumberPart1[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 17) Code:
Set ConvertChanceNumberPart2[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 17) 1 to 1 = 100% 1 to 2 = 50% 1 to 3 = 33% 1 to 4 = 25% 1 to 5 = 20% 1 to 6 = 17% 1 to 7 = 14% 1 to 8 = 13% 1 to 9 = 11% 1 to 10 = 10% 1 to 11 = 9% 1 to 12 = 8% 1 to 13 = 8% 1 to 14 = 7% 1 to 15 = 7% 1 to 16 = 6% 1 to 17 = 6% 1 to 18 = 6% 1 to 19 = 5% 1 to 20 = 5% 1 to 25 = 4% 1 to 33 = 3% 1 to 50 = 2% 1 to 100 = 1% |
