HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Trigger Based Spell - Need Help

12-30-2003, 11:20 PM#1
MysticGeneral
Ok, I'm trying to make a trigger that allows you to convert a unit that you are attacking on a % chance basis. The skill has 30 levels, and every 3 levels it gets an extra 1% chance to convert the unit. (10% chance to convert at skill level 30)

This is the first part of the trigger, all it does is update the skill.

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 TestAbilityConvert 
    Actions
        For each (Integer A) from (Player number of (Owner of (Triggering unit))) to (Player number of (Owner of (Triggering unit))), do (Actions)
            Loop - Actions
                Set DHConvertPlayer[(Integer A)] = (DHConvertPlayer[(Integer A)] + 1)

Here is the part where it should be converting it.
Code:
ConversionTrigger
    Events
        Unit - A unit owned by Neutral Hostile Is attacked
    Conditions
    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
                                        DHConvertPlayer[(Player number of (Owner of (Attacking unit)))] Equal to (Integer B)
                                    Then - Actions
                                        Set ConvertChanceNumberPart1[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and (100 / ((Integer B) / 3)))
                                        Set ConvertChanceNumberPart2[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and (100 / ((Integer B) / 3)))
                                        Game - Display to (All players) for 1.00 seconds the text: (String(ConvertChanceNumberPart1[(Player number of (Owner of (Attacking unit)))]))
                                        Game - Display to (All players) for 1.00 seconds the text: (String(ConvertChanceNumberPart2[(Player number of (Owner of (Attacking unit)))]))
                                        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 - Actions

The game - display the number action in this trigger is just to see if the trigger is working in-game. (To see if it even executes) But it doesn't.

-Just stuck an "EXECUTE" display text right before the "Set ConvertChaceNumber" triggers. It did show up, so something with that part is wrong. And I don't know what.
12-30-2003, 11:55 PM#2
linkmaster23
damn thats a headache. Let me go get sumpin to eat then ill take a better look at it. Personally, your not helping your self by trying to do all 12 people at once. brb.
12-30-2003, 11:57 PM#3
MysticGeneral
>.> I don't like to make extra triggers that aren't required when I can do it within 1-3 triggers. Plus, more triggers = adds more to the size of the map. But thx.
12-31-2003, 12:04 AM#4
linkmaster23
h/o im going to take a look.

Ok im not understanding this line

Set ConvertChanceNumberPart1[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and (100 / ((Integer B) / 3)))


explain
12-31-2003, 12:07 AM#5
MysticGeneral
Well, I changed the random integer from 1 to 100 / integer b / 3 to 1 to 2. (giving it a 50% chance to match up). Well, it worked! But now I have to figure out how to change it from 50% to 5%, incrementing to 15%. Or anything at that. Here's a list of numbers converted to chances

1 to 2 = 50% chance
1 to 3 = 33% chance
1 to 4 = 25% chance
1 to 8 = 13% chance
1 to 10 = 10% chance
1 to 16 = 6% chance
random 1 to 20 = 5% chance
I don't know anything closer than 13 without the damn editor rounding off my numbers.

Set ConvertChanceNumberPart1[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and (100 / ((Integer B) / 3)))

I have no clue what I was thinking... But uhh, I had everything right but that. Just need to find a way to make understandable chances to convert. (The freaken hero has an attack speed boost spell for a short period of time...)
12-31-2003, 12:09 AM#6
linkmaster23
so you want 15%? sigh. This is weird. So there hero recives a 15% chance of...what?
12-31-2003, 12:12 AM#7
MysticGeneral
Ok, at skill level 30, I want him to have a 15% chance to conver the unit into being his. I just need to know the right random integer numbers. Which I don't. But in any case, at level skill level 1, it should be 5%... Which would be Random integers 1 to 20. skill level 4 should be 6%. Which I have no clue what numbers they are. Skill Level 16 should be at 10% which is integers 1 to 10.
12-31-2003, 12:30 AM#8
linkmaster23
well you COULD take three 5%'s and add them up...
12-31-2003, 12:33 AM#9
MysticGeneral
Hmmm.... Yeah! Good one, thx link.
12-31-2003, 03:14 AM#10
linkmaster23
heh..really? Im genuis. BWAHAHAH the power! *walks away*
12-31-2003, 11:01 AM#11
Xinlitik
PHP Code:
ConversionUpdate
    Events
        Unit
A unit learns a skill.
    
Conditions
        
(Learned Hero SkillEqual to TestAbilityConvert 
    Actions
        Set DHConvertplayer
[(Player number of owner of triggering unit)] = DHConvertplayer[Player number of owner of triggering unit] + 


Try that for one..

For the second one... jeebus christ man. Just do something like this:

If DHConvertplayer[etc] = random integer between 1 and 100, then do..

I really cant help with the second trigger. I have no idea what the heck you're trying to do there. It looks like the tiniest chance to convert a creep...Do you realize that both of those chances are the exact same thing? 1 and 100/int b/3.. So basically, you want a 1 out of a function of how many tries it has taken to convert divided by three chance to convert.

Why not just do

For each integer b from 1 to 30 do
if chance >= random integer between 1 and 100/integer b/ 3

Edit: Everything above this point is useless.
Wait stop.. I think I understand now.

Ok, you want a skill that gives the hero a chance to convert a creep, no?

Two choices:

1) Base an ability off slow orb, make it have a chance to cast charm. Voila!

2) Unit learns a skill. Skill = yourskill Set yourskill integer = yourskill integer + 5

A unit is attacked. Unit type of attacking unit = hero[player number of owner of attacking unit] and yourskill integer => 1 ..... If yourskill integer => random integer between 1 and 100, then do change ownership.

Ok in cleaner form:


E- A unit is attacked.
C- Unit type of attacking unit = your hero[array] and yourskill integer[array] => 1
A- If yourskill integer => random integer between 1 and 100, then do change ownership of attacked unit to owner of attacking unit.


I hope that was all right and I didnt completely misinterpret it...
12-31-2003, 11:14 AM#12
RicFaith
just a not-too-short qn. I find your code a little weird, so I thought I'd ask if this solution is simpler to understand?

Firstly, with the arrival of 1.13, we don't need the learning trigger anymore, so well, I shan't ask you about that one, but it would save some time and code space:)

Next.

----
Conversion Trigger

E: Unit owned by Neutral Hostile is Attacked
C: Ability Level of (Conversion) for attacking unit > 0
A:
Set ConvAttacker = (attacking unit)
Set ConvOwner = Owner of (ConvAttacker)
Set ConvChance = 1 + (Ability Level of (Conversion) for ConvAttacker / 3)

If
(Random Number between 0 to 100) < ConvChance
Then
Change Owner of (attacked unit) to ConvOwner and change color
else
do nothing

----

explanation of variables :
ConvAttacker - unit variable
ConvOwner - player variable
ConvChance - integer variable

What it does:
creates a integer variable ConvChance to tell you the percentage (0-100) that a unit will be converted based on your Ability level for (Conversion)
Then based on a random number created from 0-100, if the random number is less than ConvChance, conversion is successful, so change owner.

----

What do you think? The formula for ConvChance can be changed easily, and I think the code is much easier to understand. Furthermore, it isn't run for all 12 players, only if the attacking unit has Conversion.