I am not too clear what you mean, so apologies if this is way off.
If the character is attacking a monster, then you might determine the outcome like this:
<!--Saved by Quest 5.2.4515.34846-->
<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="attack">
<gameid>94174176-4256-46bf-a867-fd8d14eab408</gameid>
<version>1.0</version>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<to_hit_bonus type="int">2</to_hit_bonus>
<damage_die type="int">12</damage_die>
</object>
<object name="monster">
<inherit name="editor_object" />
<hit_points type="int">30</hit_points>
<defensive_bonus type="int">12</defensive_bonus>
<attack type="script"><![CDATA[
if (player.to_hit_bonus + GetRandomInt (1, 20) > this.defensive_bonus) {
damage = GetRandomInt (1, player.damage_die)
msg ("You hit for " + damage + " points of damage.")
this.hit_points = this.hit_points - damage
if (0 > this.hit_points) {
msg ("It is dead!")
}
}
else {
msg ("You attack, but miss.")
}
]]></attack>
<displayverbs>Look at; Attack</displayverbs>
</object>
</object>
<verb>
<property>attack</property>
<pattern>attack</pattern>
<defaultexpression>"You can't attack " + object.article + "."</defaultexpression>
</verb>
</asl>
For a proper game, you would be better creating a monster type, and attaching the script to that, by the way.